diff --git a/assets/api/writer-generator/typescript/profile-helpers.ts b/assets/api/writer-generator/typescript/profile-helpers.ts index 91cfb01f..5eec2ea3 100644 --- a/assets/api/writer-generator/typescript/profile-helpers.ts +++ b/assets/api/writer-generator/typescript/profile-helpers.ts @@ -1,8 +1,8 @@ /** - * Runtime helpers for generated FHIR profile classes. + * Runtime helpers for generated FHIR types and profile classes. * * This file is copied verbatim into every generated TypeScript output and - * imported by profile modules. It provides: + * imported by profile and binding modules. It provides: * * - **Slice helpers** – match, get, set, and default-fill array slices * defined by a FHIR StructureDefinition. @@ -12,6 +12,8 @@ * profile classes can expose a flat API. * - **Validation helpers** – lightweight structural checks that profile * classes call from their `validate()` method. + * - **Parse helpers** – validate / enrich values coming from external + * sources (CSV, HTTP form, untyped JSON) into typed FHIR values. * - **Misc utilities** – deep-match, deep-merge, path navigation. */ @@ -447,3 +449,92 @@ export const validateReference = (res: object, profileName: string, field: strin ? [] : [`${profileName}: field '${field}' references '${refType}' but only ${allowed.join(", ")} are allowed`]; }; + +// --------------------------------------------------------------------------- +// Parse helpers +// +// Each `parse*` validates an untyped value (typically string from CSV or HTTP +// form input) and returns a value of the typed FHIR shape. All throw an +// `Error` on failure; the message includes `fieldName` when provided so the +// call site can be located in stack traces. +// --------------------------------------------------------------------------- + +/** + * Validate that `input` is one of the literal values in `allowed`, returning + * it as the narrowed type. Throws when `input` is not in the set. + * + * @example + * parseLiteral(row.gender, ["male", "female", "other", "unknown"], "Patient.gender") + */ +export const parseLiteral = (input: unknown, allowed: readonly T[], fieldName?: string): T => { + if (typeof input === "string" && (allowed as readonly string[]).includes(input)) return input as T; + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid value ${JSON.stringify(input)}. Expected one of: ${allowed.join(", ")}`); +}; + +/** + * Look up `input` in a code → `{system, code, display}` table and return the + * corresponding FHIR Coding. Throws when the code is not in the table. + * + * Generated per-binding helpers wrap this with the binding's lookup table so + * callers only need to supply the code string. + * + * @example + * parseCoding(row.raceCode, USCoreOmbRaceCategoriesCodes, "Race.ombCategory") + */ +export const parseCoding = ( + input: unknown, + lookup: Readonly>, + fieldName?: string, +): { system?: string; code: T; display?: string } => { + if (typeof input === "string" && Object.hasOwn(lookup, input)) { + const concept = lookup[input]; + if (concept) return concept; + } + const where = fieldName ? `${fieldName}: ` : ""; + const allowed = Object.keys(lookup).join(", "); + throw new Error(`${where}invalid code ${JSON.stringify(input)}. Expected one of: ${allowed}`); +}; + +/** + * Coerce `input` into a boolean. Accepts `true`/`false`, `"true"`/`"false"`, + * `"1"`/`"0"` (case-insensitive). Throws on anything else. + */ +export const parseBoolean = (input: unknown, fieldName?: string): boolean => { + if (typeof input === "boolean") return input; + if (typeof input === "string") { + const v = input.trim().toLowerCase(); + if (v === "true" || v === "1") return true; + if (v === "false" || v === "0") return false; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid boolean ${JSON.stringify(input)}`); +}; + +/** + * Coerce `input` into a finite number. Accepts numbers and numeric strings. + * Throws on `NaN`, `Infinity`, or non-numeric input. + */ +export const parseNumber = (input: unknown, fieldName?: string): number => { + if (typeof input === "number" && Number.isFinite(input)) return input; + if (typeof input === "string" && input.trim() !== "") { + const n = Number(input); + if (Number.isFinite(n)) return n; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid number ${JSON.stringify(input)}`); +}; + +/** + * Validate that `input` is a FHIR `instant` string (ISO 8601 with timezone). + * Returns the original string on success; throws on malformed input. + */ +export const parseInstant = (input: unknown, fieldName?: string): string => { + if (typeof input === "string") { + // FHIR instant: YYYY-MM-DDTHH:MM:SS(.sss)?(Z|[+-]HH:MM) + const re = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/; + if (re.test(input) && !Number.isNaN(Date.parse(input))) return input; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid instant ${JSON.stringify(input)}`); +}; diff --git a/examples/typescript-r4/bindings.test.ts b/examples/typescript-r4/bindings.test.ts new file mode 100644 index 00000000..112a4b3d --- /dev/null +++ b/examples/typescript-r4/bindings.test.ts @@ -0,0 +1,68 @@ +/** + * Demo: parse helpers for coded fields. + * + * Generated `bindings.ts` exports a `parse` for each ValueSet-bound + * field. These parsers replace the unsafe `as Patient["gender"]` cast by + * validating the input string at runtime and throwing on unknown values. + * `parseCoding` additionally fills in `system` and `display` from the + * binding's lookup table, so callers can supply just the code. + */ + +import { describe, expect, test } from "bun:test"; +import { + AdministrativeGenderCodes, + AdministrativeGenderConcepts, + parseAdministrativeGender, + parseAdministrativeGenderCoding, +} from "./fhir-types/hl7-fhir-r4-core/bindings"; +import type { Patient } from "./fhir-types/hl7-fhir-r4-core/Patient"; + +describe("demo: typed Patient.gender via parseAdministrativeGender", () => { + test("CSV-like row goes through the parser, not an `as` cast", () => { + const row = { gender: "female", birthDate: "1990-04-15" }; + + const patient: Patient = { + resourceType: "Patient", + gender: parseAdministrativeGender(row.gender, "Patient.gender"), + birthDate: row.birthDate, + }; + + expect(patient.gender).toBe("female"); + }); + + test("parser throws on values outside the binding", () => { + expect(() => parseAdministrativeGender("FEMALE", "Patient.gender")).toThrow( + /Patient.gender: invalid value "FEMALE"/, + ); + }); + + test("Codes tuple is the literal union source-of-truth", () => { + expect(AdministrativeGenderCodes).toEqual(["male", "female", "other", "unknown"]); + }); +}); + +describe("demo: ValueSet-bound Coding via parseAdministrativeGenderCoding", () => { + test("supplying only the code fills in system and display", () => { + const coding = parseAdministrativeGenderCoding("male"); + + expect(coding).toEqual({ + system: "http://hl7.org/fhir/administrative-gender", + code: "male", + display: "Male", + }); + }); + + test("lookup table is exposed for direct access", () => { + expect(AdministrativeGenderConcepts.unknown).toEqual({ + system: "http://hl7.org/fhir/administrative-gender", + code: "unknown", + display: "Unknown", + }); + }); + + test("parser throws on values outside the binding", () => { + expect(() => parseAdministrativeGenderCoding("XX", "Patient.coding")).toThrow( + /Patient.coding: invalid code "XX"/, + ); + }); +}); diff --git a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/bindings.ts b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/bindings.ts new file mode 100644 index 00000000..b17d3f10 --- /dev/null +++ b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/bindings.ts @@ -0,0 +1,869 @@ +// WARNING: This file is autogenerated by @atomic-ehr/codegen. +// GitHub: https://github.com/atomic-ehr/codegen +// Any manual changes made to this file may be overwritten. + +import { parseLiteral, parseCoding } from "../profile-helpers"; + +// AddressType (required — http://hl7.org/fhir/ValueSet/address-type) +export const AddressTypeCodes = ["postal", "physical", "both"] as const; +export type AddressType = (typeof AddressTypeCodes)[number]; +export const AddressTypeConcepts: Readonly> = { + postal: { system: "http://hl7.org/fhir/address-type", code: "postal", display: "Postal" }, + physical: { system: "http://hl7.org/fhir/address-type", code: "physical", display: "Physical" }, + both: { system: "http://hl7.org/fhir/address-type", code: "both", display: "Postal & Physical" }, +} as const; +export const parseAddressType = (input: unknown, fieldName?: string): AddressType => { + return parseLiteral(input, AddressTypeCodes, fieldName); +} +export const parseAddressTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, AddressTypeConcepts, fieldName); +} + +// AddressUse (required — http://hl7.org/fhir/ValueSet/address-use) +export const AddressUseCodes = ["home", "work", "temp", "old", "billing"] as const; +export type AddressUse = (typeof AddressUseCodes)[number]; +export const AddressUseConcepts: Readonly> = { + home: { system: "http://hl7.org/fhir/address-use", code: "home", display: "Home" }, + work: { system: "http://hl7.org/fhir/address-use", code: "work", display: "Work" }, + temp: { system: "http://hl7.org/fhir/address-use", code: "temp", display: "Temporary" }, + old: { system: "http://hl7.org/fhir/address-use", code: "old", display: "Old / Incorrect" }, + billing: { system: "http://hl7.org/fhir/address-use", code: "billing", display: "Billing" }, +} as const; +export const parseAddressUse = (input: unknown, fieldName?: string): AddressUse => { + return parseLiteral(input, AddressUseCodes, fieldName); +} +export const parseAddressUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, AddressUseConcepts, fieldName); +} + +// AdministrativeGender (required — http://hl7.org/fhir/ValueSet/administrative-gender) +export const AdministrativeGenderCodes = ["male", "female", "other", "unknown"] as const; +export type AdministrativeGender = (typeof AdministrativeGenderCodes)[number]; +export const AdministrativeGenderConcepts: Readonly> = { + male: { system: "http://hl7.org/fhir/administrative-gender", code: "male", display: "Male" }, + female: { system: "http://hl7.org/fhir/administrative-gender", code: "female", display: "Female" }, + other: { system: "http://hl7.org/fhir/administrative-gender", code: "other", display: "Other" }, + unknown: { system: "http://hl7.org/fhir/administrative-gender", code: "unknown", display: "Unknown" }, +} as const; +export const parseAdministrativeGender = (input: unknown, fieldName?: string): AdministrativeGender => { + return parseLiteral(input, AdministrativeGenderCodes, fieldName); +} +export const parseAdministrativeGenderCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, AdministrativeGenderConcepts, fieldName); +} + +// BundleType (required — http://hl7.org/fhir/ValueSet/bundle-type) +export const BundleTypeCodes = ["document", "message", "transaction", "transaction-response", "batch", "batch-response", "history", "searchset", "collection"] as const; +export type BundleType = (typeof BundleTypeCodes)[number]; +export const BundleTypeConcepts: Readonly> = { + document: { system: "http://hl7.org/fhir/bundle-type", code: "document", display: "Document" }, + message: { system: "http://hl7.org/fhir/bundle-type", code: "message", display: "Message" }, + transaction: { system: "http://hl7.org/fhir/bundle-type", code: "transaction", display: "Transaction" }, + "transaction-response": { system: "http://hl7.org/fhir/bundle-type", code: "transaction-response", display: "Transaction Response" }, + batch: { system: "http://hl7.org/fhir/bundle-type", code: "batch", display: "Batch" }, + "batch-response": { system: "http://hl7.org/fhir/bundle-type", code: "batch-response", display: "Batch Response" }, + history: { system: "http://hl7.org/fhir/bundle-type", code: "history", display: "History List" }, + searchset: { system: "http://hl7.org/fhir/bundle-type", code: "searchset", display: "Search Results" }, + collection: { system: "http://hl7.org/fhir/bundle-type", code: "collection", display: "Collection" }, +} as const; +export const parseBundleType = (input: unknown, fieldName?: string): BundleType => { + return parseLiteral(input, BundleTypeCodes, fieldName); +} +export const parseBundleTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, BundleTypeConcepts, fieldName); +} + +// ContactPointSystem (required — http://hl7.org/fhir/ValueSet/contact-point-system) +export const ContactPointSystemCodes = ["phone", "fax", "email", "pager", "url", "sms", "other"] as const; +export type ContactPointSystem = (typeof ContactPointSystemCodes)[number]; +export const ContactPointSystemConcepts: Readonly> = { + phone: { system: "http://hl7.org/fhir/contact-point-system", code: "phone", display: "Phone" }, + fax: { system: "http://hl7.org/fhir/contact-point-system", code: "fax", display: "Fax" }, + email: { system: "http://hl7.org/fhir/contact-point-system", code: "email", display: "Email" }, + pager: { system: "http://hl7.org/fhir/contact-point-system", code: "pager", display: "Pager" }, + url: { system: "http://hl7.org/fhir/contact-point-system", code: "url", display: "URL" }, + sms: { system: "http://hl7.org/fhir/contact-point-system", code: "sms", display: "SMS" }, + other: { system: "http://hl7.org/fhir/contact-point-system", code: "other", display: "Other" }, +} as const; +export const parseContactPointSystem = (input: unknown, fieldName?: string): ContactPointSystem => { + return parseLiteral(input, ContactPointSystemCodes, fieldName); +} +export const parseContactPointSystemCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ContactPointSystemConcepts, fieldName); +} + +// ContactPointUse (required — http://hl7.org/fhir/ValueSet/contact-point-use) +export const ContactPointUseCodes = ["home", "work", "temp", "old", "mobile"] as const; +export type ContactPointUse = (typeof ContactPointUseCodes)[number]; +export const ContactPointUseConcepts: Readonly> = { + home: { system: "http://hl7.org/fhir/contact-point-use", code: "home", display: "Home" }, + work: { system: "http://hl7.org/fhir/contact-point-use", code: "work", display: "Work" }, + temp: { system: "http://hl7.org/fhir/contact-point-use", code: "temp", display: "Temp" }, + old: { system: "http://hl7.org/fhir/contact-point-use", code: "old", display: "Old" }, + mobile: { system: "http://hl7.org/fhir/contact-point-use", code: "mobile", display: "Mobile" }, +} as const; +export const parseContactPointUse = (input: unknown, fieldName?: string): ContactPointUse => { + return parseLiteral(input, ContactPointUseCodes, fieldName); +} +export const parseContactPointUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ContactPointUseConcepts, fieldName); +} + +// ContributorType (required — http://hl7.org/fhir/ValueSet/contributor-type) +export const ContributorTypeCodes = ["author", "editor", "reviewer", "endorser"] as const; +export type ContributorType = (typeof ContributorTypeCodes)[number]; +export const ContributorTypeConcepts: Readonly> = { + author: { system: "http://hl7.org/fhir/contributor-type", code: "author", display: "Author" }, + editor: { system: "http://hl7.org/fhir/contributor-type", code: "editor", display: "Editor" }, + reviewer: { system: "http://hl7.org/fhir/contributor-type", code: "reviewer", display: "Reviewer" }, + endorser: { system: "http://hl7.org/fhir/contributor-type", code: "endorser", display: "Endorser" }, +} as const; +export const parseContributorType = (input: unknown, fieldName?: string): ContributorType => { + return parseLiteral(input, ContributorTypeCodes, fieldName); +} +export const parseContributorTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ContributorTypeConcepts, fieldName); +} + +// DayOfWeek (required — http://hl7.org/fhir/ValueSet/days-of-week) +export const DayOfWeekCodes = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] as const; +export type DayOfWeek = (typeof DayOfWeekCodes)[number]; +export const DayOfWeekConcepts: Readonly> = { + mon: { system: "http://hl7.org/fhir/days-of-week", code: "mon", display: "Monday" }, + tue: { system: "http://hl7.org/fhir/days-of-week", code: "tue", display: "Tuesday" }, + wed: { system: "http://hl7.org/fhir/days-of-week", code: "wed", display: "Wednesday" }, + thu: { system: "http://hl7.org/fhir/days-of-week", code: "thu", display: "Thursday" }, + fri: { system: "http://hl7.org/fhir/days-of-week", code: "fri", display: "Friday" }, + sat: { system: "http://hl7.org/fhir/days-of-week", code: "sat", display: "Saturday" }, + sun: { system: "http://hl7.org/fhir/days-of-week", code: "sun", display: "Sunday" }, +} as const; +export const parseDayOfWeek = (input: unknown, fieldName?: string): DayOfWeek => { + return parseLiteral(input, DayOfWeekCodes, fieldName); +} +export const parseDayOfWeekCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, DayOfWeekConcepts, fieldName); +} + +// EventTiming (required — http://hl7.org/fhir/ValueSet/event-timing) +export const EventTimingCodes = ["MORN", "MORN.early", "MORN.late", "NOON", "AFT", "AFT.early", "AFT.late", "EVE", "EVE.early", "EVE.late", "NIGHT", "PHS", "HS", "WAKE", "C", "CM", "CD", "CV", "AC", "ACM", "ACD", "ACV", "PC", "PCM", "PCD", "PCV"] as const; +export type EventTiming = (typeof EventTimingCodes)[number]; +export const EventTimingConcepts: Readonly> = { + MORN: { system: "http://hl7.org/fhir/event-timing", code: "MORN", display: "Morning" }, + "MORN.early": { system: "http://hl7.org/fhir/event-timing", code: "MORN.early", display: "Early Morning" }, + "MORN.late": { system: "http://hl7.org/fhir/event-timing", code: "MORN.late", display: "Late Morning" }, + NOON: { system: "http://hl7.org/fhir/event-timing", code: "NOON", display: "Noon" }, + AFT: { system: "http://hl7.org/fhir/event-timing", code: "AFT", display: "Afternoon" }, + "AFT.early": { system: "http://hl7.org/fhir/event-timing", code: "AFT.early", display: "Early Afternoon" }, + "AFT.late": { system: "http://hl7.org/fhir/event-timing", code: "AFT.late", display: "Late Afternoon" }, + EVE: { system: "http://hl7.org/fhir/event-timing", code: "EVE", display: "Evening" }, + "EVE.early": { system: "http://hl7.org/fhir/event-timing", code: "EVE.early", display: "Early Evening" }, + "EVE.late": { system: "http://hl7.org/fhir/event-timing", code: "EVE.late", display: "Late Evening" }, + NIGHT: { system: "http://hl7.org/fhir/event-timing", code: "NIGHT", display: "Night" }, + PHS: { system: "http://hl7.org/fhir/event-timing", code: "PHS", display: "After Sleep" }, + HS: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "HS" }, + WAKE: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "WAKE" }, + C: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "C" }, + CM: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "CM" }, + CD: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "CD" }, + CV: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "CV" }, + AC: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "AC" }, + ACM: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "ACM" }, + ACD: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "ACD" }, + ACV: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "ACV" }, + PC: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PC" }, + PCM: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PCM" }, + PCD: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PCD" }, + PCV: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PCV" }, +} as const; +export const parseEventTiming = (input: unknown, fieldName?: string): EventTiming => { + return parseLiteral(input, EventTimingCodes, fieldName); +} +export const parseEventTimingCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, EventTimingConcepts, fieldName); +} + +// ExpressionLanguage (extensible — http://hl7.org/fhir/ValueSet/expression-language) +export const ExpressionLanguageCodes = ["text/cql", "text/fhirpath", "application/x-fhir-query"] as const; +export type ExpressionLanguage = (typeof ExpressionLanguageCodes)[number]; +export const ExpressionLanguageConcepts: Readonly> = { + "text/cql": { system: "http://hl7.org/fhir/expression-language", code: "text/cql", display: "CQL" }, + "text/fhirpath": { system: "http://hl7.org/fhir/expression-language", code: "text/fhirpath", display: "FHIRPath" }, + "application/x-fhir-query": { system: "http://hl7.org/fhir/expression-language", code: "application/x-fhir-query", display: "FHIR Query" }, +} as const; +export const parseExpressionLanguage = (input: unknown, fieldName?: string): ExpressionLanguage => { + return parseLiteral(input, ExpressionLanguageCodes, fieldName); +} +export const parseExpressionLanguageCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ExpressionLanguageConcepts, fieldName); +} + +// HTTPVerb (required — http://hl7.org/fhir/ValueSet/http-verb) +export const HTTPVerbCodes = ["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"] as const; +export type HTTPVerb = (typeof HTTPVerbCodes)[number]; +export const HTTPVerbConcepts: Readonly> = { + GET: { system: "http://hl7.org/fhir/http-verb", code: "GET", display: "GET" }, + HEAD: { system: "http://hl7.org/fhir/http-verb", code: "HEAD", display: "HEAD" }, + POST: { system: "http://hl7.org/fhir/http-verb", code: "POST", display: "POST" }, + PUT: { system: "http://hl7.org/fhir/http-verb", code: "PUT", display: "PUT" }, + DELETE: { system: "http://hl7.org/fhir/http-verb", code: "DELETE", display: "DELETE" }, + PATCH: { system: "http://hl7.org/fhir/http-verb", code: "PATCH", display: "PATCH" }, +} as const; +export const parseHTTPVerb = (input: unknown, fieldName?: string): HTTPVerb => { + return parseLiteral(input, HTTPVerbCodes, fieldName); +} +export const parseHTTPVerbCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, HTTPVerbConcepts, fieldName); +} + +// IdentifierType (extensible — http://hl7.org/fhir/ValueSet/identifier-type) +export const IdentifierTypeCodes = ["DL", "PPN", "BRN", "MR", "MCN", "EN", "TAX", "NIIP", "PRN", "MD", "DR", "ACSN", "UDI", "SNO", "SB", "PLAC", "FILL", "JHN"] as const; +export type IdentifierType = (typeof IdentifierTypeCodes)[number]; +export const IdentifierTypeConcepts: Readonly> = { + DL: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "DL" }, + PPN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "PPN" }, + BRN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "BRN" }, + MR: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR" }, + MCN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MCN" }, + EN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "EN" }, + TAX: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "TAX" }, + NIIP: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "NIIP" }, + PRN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "PRN" }, + MD: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MD" }, + DR: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "DR" }, + ACSN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "ACSN" }, + UDI: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "UDI" }, + SNO: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "SNO" }, + SB: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "SB" }, + PLAC: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "PLAC" }, + FILL: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "FILL" }, + JHN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "JHN" }, +} as const; +export const parseIdentifierType = (input: unknown, fieldName?: string): IdentifierType => { + return parseLiteral(input, IdentifierTypeCodes, fieldName); +} +export const parseIdentifierTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, IdentifierTypeConcepts, fieldName); +} + +// IdentifierUse (required — http://hl7.org/fhir/ValueSet/identifier-use) +export const IdentifierUseCodes = ["usual", "official", "temp", "secondary", "old"] as const; +export type IdentifierUse = (typeof IdentifierUseCodes)[number]; +export const IdentifierUseConcepts: Readonly> = { + usual: { system: "http://hl7.org/fhir/identifier-use", code: "usual", display: "Usual" }, + official: { system: "http://hl7.org/fhir/identifier-use", code: "official", display: "Official" }, + temp: { system: "http://hl7.org/fhir/identifier-use", code: "temp", display: "Temp" }, + secondary: { system: "http://hl7.org/fhir/identifier-use", code: "secondary", display: "Secondary" }, + old: { system: "http://hl7.org/fhir/identifier-use", code: "old", display: "Old" }, +} as const; +export const parseIdentifierUse = (input: unknown, fieldName?: string): IdentifierUse => { + return parseLiteral(input, IdentifierUseCodes, fieldName); +} +export const parseIdentifierUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, IdentifierUseConcepts, fieldName); +} + +// IssueSeverity (required — http://hl7.org/fhir/ValueSet/issue-severity) +export const IssueSeverityCodes = ["fatal", "error", "warning", "information"] as const; +export type IssueSeverity = (typeof IssueSeverityCodes)[number]; +export const IssueSeverityConcepts: Readonly> = { + fatal: { system: "http://hl7.org/fhir/issue-severity", code: "fatal", display: "Fatal" }, + error: { system: "http://hl7.org/fhir/issue-severity", code: "error", display: "Error" }, + warning: { system: "http://hl7.org/fhir/issue-severity", code: "warning", display: "Warning" }, + information: { system: "http://hl7.org/fhir/issue-severity", code: "information", display: "Information" }, +} as const; +export const parseIssueSeverity = (input: unknown, fieldName?: string): IssueSeverity => { + return parseLiteral(input, IssueSeverityCodes, fieldName); +} +export const parseIssueSeverityCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, IssueSeverityConcepts, fieldName); +} + +// IssueType (required — http://hl7.org/fhir/ValueSet/issue-type) +export const IssueTypeCodes = ["invalid", "structure", "required", "value", "invariant", "security", "login", "unknown", "expired", "forbidden", "suppressed", "processing", "not-supported", "duplicate", "multiple-matches", "not-found", "deleted", "too-long", "code-invalid", "extension", "too-costly", "business-rule", "conflict", "transient", "lock-error", "no-store", "exception", "timeout", "incomplete", "throttled", "informational"] as const; +export type IssueType = (typeof IssueTypeCodes)[number]; +export const IssueTypeConcepts: Readonly> = { + invalid: { system: "http://hl7.org/fhir/issue-type", code: "invalid", display: "Invalid Content" }, + structure: { system: "http://hl7.org/fhir/issue-type", code: "structure", display: "Structural Issue" }, + required: { system: "http://hl7.org/fhir/issue-type", code: "required", display: "Required element missing" }, + value: { system: "http://hl7.org/fhir/issue-type", code: "value", display: "Element value invalid" }, + invariant: { system: "http://hl7.org/fhir/issue-type", code: "invariant", display: "Validation rule failed" }, + security: { system: "http://hl7.org/fhir/issue-type", code: "security", display: "Security Problem" }, + login: { system: "http://hl7.org/fhir/issue-type", code: "login", display: "Login Required" }, + unknown: { system: "http://hl7.org/fhir/issue-type", code: "unknown", display: "Unknown User" }, + expired: { system: "http://hl7.org/fhir/issue-type", code: "expired", display: "Session Expired" }, + forbidden: { system: "http://hl7.org/fhir/issue-type", code: "forbidden", display: "Forbidden" }, + suppressed: { system: "http://hl7.org/fhir/issue-type", code: "suppressed", display: "Information Suppressed" }, + processing: { system: "http://hl7.org/fhir/issue-type", code: "processing", display: "Processing Failure" }, + "not-supported": { system: "http://hl7.org/fhir/issue-type", code: "not-supported", display: "Content not supported" }, + duplicate: { system: "http://hl7.org/fhir/issue-type", code: "duplicate", display: "Duplicate" }, + "multiple-matches": { system: "http://hl7.org/fhir/issue-type", code: "multiple-matches", display: "Multiple Matches" }, + "not-found": { system: "http://hl7.org/fhir/issue-type", code: "not-found", display: "Not Found" }, + deleted: { system: "http://hl7.org/fhir/issue-type", code: "deleted", display: "Deleted" }, + "too-long": { system: "http://hl7.org/fhir/issue-type", code: "too-long", display: "Content Too Long" }, + "code-invalid": { system: "http://hl7.org/fhir/issue-type", code: "code-invalid", display: "Invalid Code" }, + extension: { system: "http://hl7.org/fhir/issue-type", code: "extension", display: "Unacceptable Extension" }, + "too-costly": { system: "http://hl7.org/fhir/issue-type", code: "too-costly", display: "Operation Too Costly" }, + "business-rule": { system: "http://hl7.org/fhir/issue-type", code: "business-rule", display: "Business Rule Violation" }, + conflict: { system: "http://hl7.org/fhir/issue-type", code: "conflict", display: "Edit Version Conflict" }, + transient: { system: "http://hl7.org/fhir/issue-type", code: "transient", display: "Transient Issue" }, + "lock-error": { system: "http://hl7.org/fhir/issue-type", code: "lock-error", display: "Lock Error" }, + "no-store": { system: "http://hl7.org/fhir/issue-type", code: "no-store", display: "No Store Available" }, + exception: { system: "http://hl7.org/fhir/issue-type", code: "exception", display: "Exception" }, + timeout: { system: "http://hl7.org/fhir/issue-type", code: "timeout", display: "Timeout" }, + incomplete: { system: "http://hl7.org/fhir/issue-type", code: "incomplete", display: "Incomplete Results" }, + throttled: { system: "http://hl7.org/fhir/issue-type", code: "throttled", display: "Throttled" }, + informational: { system: "http://hl7.org/fhir/issue-type", code: "informational", display: "Informational Note" }, +} as const; +export const parseIssueType = (input: unknown, fieldName?: string): IssueType => { + return parseLiteral(input, IssueTypeCodes, fieldName); +} +export const parseIssueTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, IssueTypeConcepts, fieldName); +} + +// Language (preferred — http://hl7.org/fhir/ValueSet/languages) +export const LanguageCodes = ["ar", "bn", "cs", "da", "de", "de-AT", "de-CH", "de-DE", "el", "en", "en-AU", "en-CA", "en-GB", "en-IN", "en-NZ", "en-SG", "en-US", "es", "es-AR", "es-ES", "es-UY", "fi", "fr", "fr-BE", "fr-CH", "fr-FR", "fy", "fy-NL", "hi", "hr", "it", "it-CH", "it-IT", "ja", "ko", "nl", "nl-BE", "nl-NL", "no", "no-NO", "pa", "pl", "pt", "pt-BR", "ru", "ru-RU", "sr", "sr-RS", "sv", "sv-SE", "te", "zh", "zh-CN", "zh-HK", "zh-SG", "zh-TW"] as const; +export type Language = (typeof LanguageCodes)[number]; +export const LanguageConcepts: Readonly> = { + ar: { system: "urn:ietf:bcp:47", code: "ar", display: "Arabic" }, + bn: { system: "urn:ietf:bcp:47", code: "bn", display: "Bengali" }, + cs: { system: "urn:ietf:bcp:47", code: "cs", display: "Czech" }, + da: { system: "urn:ietf:bcp:47", code: "da", display: "Danish" }, + de: { system: "urn:ietf:bcp:47", code: "de", display: "German" }, + "de-AT": { system: "urn:ietf:bcp:47", code: "de-AT", display: "German (Austria)" }, + "de-CH": { system: "urn:ietf:bcp:47", code: "de-CH", display: "German (Switzerland)" }, + "de-DE": { system: "urn:ietf:bcp:47", code: "de-DE", display: "German (Germany)" }, + el: { system: "urn:ietf:bcp:47", code: "el", display: "Greek" }, + en: { system: "urn:ietf:bcp:47", code: "en", display: "English" }, + "en-AU": { system: "urn:ietf:bcp:47", code: "en-AU", display: "English (Australia)" }, + "en-CA": { system: "urn:ietf:bcp:47", code: "en-CA", display: "English (Canada)" }, + "en-GB": { system: "urn:ietf:bcp:47", code: "en-GB", display: "English (Great Britain)" }, + "en-IN": { system: "urn:ietf:bcp:47", code: "en-IN", display: "English (India)" }, + "en-NZ": { system: "urn:ietf:bcp:47", code: "en-NZ", display: "English (New Zeland)" }, + "en-SG": { system: "urn:ietf:bcp:47", code: "en-SG", display: "English (Singapore)" }, + "en-US": { system: "urn:ietf:bcp:47", code: "en-US", display: "English (United States)" }, + es: { system: "urn:ietf:bcp:47", code: "es", display: "Spanish" }, + "es-AR": { system: "urn:ietf:bcp:47", code: "es-AR", display: "Spanish (Argentina)" }, + "es-ES": { system: "urn:ietf:bcp:47", code: "es-ES", display: "Spanish (Spain)" }, + "es-UY": { system: "urn:ietf:bcp:47", code: "es-UY", display: "Spanish (Uruguay)" }, + fi: { system: "urn:ietf:bcp:47", code: "fi", display: "Finnish" }, + fr: { system: "urn:ietf:bcp:47", code: "fr", display: "French" }, + "fr-BE": { system: "urn:ietf:bcp:47", code: "fr-BE", display: "French (Belgium)" }, + "fr-CH": { system: "urn:ietf:bcp:47", code: "fr-CH", display: "French (Switzerland)" }, + "fr-FR": { system: "urn:ietf:bcp:47", code: "fr-FR", display: "French (France)" }, + fy: { system: "urn:ietf:bcp:47", code: "fy", display: "Frysian" }, + "fy-NL": { system: "urn:ietf:bcp:47", code: "fy-NL", display: "Frysian (Netherlands)" }, + hi: { system: "urn:ietf:bcp:47", code: "hi", display: "Hindi" }, + hr: { system: "urn:ietf:bcp:47", code: "hr", display: "Croatian" }, + it: { system: "urn:ietf:bcp:47", code: "it", display: "Italian" }, + "it-CH": { system: "urn:ietf:bcp:47", code: "it-CH", display: "Italian (Switzerland)" }, + "it-IT": { system: "urn:ietf:bcp:47", code: "it-IT", display: "Italian (Italy)" }, + ja: { system: "urn:ietf:bcp:47", code: "ja", display: "Japanese" }, + ko: { system: "urn:ietf:bcp:47", code: "ko", display: "Korean" }, + nl: { system: "urn:ietf:bcp:47", code: "nl", display: "Dutch" }, + "nl-BE": { system: "urn:ietf:bcp:47", code: "nl-BE", display: "Dutch (Belgium)" }, + "nl-NL": { system: "urn:ietf:bcp:47", code: "nl-NL", display: "Dutch (Netherlands)" }, + no: { system: "urn:ietf:bcp:47", code: "no", display: "Norwegian" }, + "no-NO": { system: "urn:ietf:bcp:47", code: "no-NO", display: "Norwegian (Norway)" }, + pa: { system: "urn:ietf:bcp:47", code: "pa", display: "Punjabi" }, + pl: { system: "urn:ietf:bcp:47", code: "pl", display: "Polish" }, + pt: { system: "urn:ietf:bcp:47", code: "pt", display: "Portuguese" }, + "pt-BR": { system: "urn:ietf:bcp:47", code: "pt-BR", display: "Portuguese (Brazil)" }, + ru: { system: "urn:ietf:bcp:47", code: "ru", display: "Russian" }, + "ru-RU": { system: "urn:ietf:bcp:47", code: "ru-RU", display: "Russian (Russia)" }, + sr: { system: "urn:ietf:bcp:47", code: "sr", display: "Serbian" }, + "sr-RS": { system: "urn:ietf:bcp:47", code: "sr-RS", display: "Serbian (Serbia)" }, + sv: { system: "urn:ietf:bcp:47", code: "sv", display: "Swedish" }, + "sv-SE": { system: "urn:ietf:bcp:47", code: "sv-SE", display: "Swedish (Sweden)" }, + te: { system: "urn:ietf:bcp:47", code: "te", display: "Telegu" }, + zh: { system: "urn:ietf:bcp:47", code: "zh", display: "Chinese" }, + "zh-CN": { system: "urn:ietf:bcp:47", code: "zh-CN", display: "Chinese (China)" }, + "zh-HK": { system: "urn:ietf:bcp:47", code: "zh-HK", display: "Chinese (Hong Kong)" }, + "zh-SG": { system: "urn:ietf:bcp:47", code: "zh-SG", display: "Chinese (Singapore)" }, + "zh-TW": { system: "urn:ietf:bcp:47", code: "zh-TW", display: "Chinese (Taiwan)" }, +} as const; +export const parseLanguage = (input: unknown, fieldName?: string): Language => { + return parseLiteral(input, LanguageCodes, fieldName); +} +export const parseLanguageCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, LanguageConcepts, fieldName); +} + +// LinkType (required — http://hl7.org/fhir/ValueSet/link-type) +export const LinkTypeCodes = ["replaced-by", "replaces", "refer", "seealso"] as const; +export type LinkType = (typeof LinkTypeCodes)[number]; +export const LinkTypeConcepts: Readonly> = { + "replaced-by": { system: "http://hl7.org/fhir/link-type", code: "replaced-by", display: "Replaced-by" }, + replaces: { system: "http://hl7.org/fhir/link-type", code: "replaces", display: "Replaces" }, + refer: { system: "http://hl7.org/fhir/link-type", code: "refer", display: "Refer" }, + seealso: { system: "http://hl7.org/fhir/link-type", code: "seealso", display: "See also" }, +} as const; +export const parseLinkType = (input: unknown, fieldName?: string): LinkType => { + return parseLiteral(input, LinkTypeCodes, fieldName); +} +export const parseLinkTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, LinkTypeConcepts, fieldName); +} + +// MaritalStatus (extensible — http://hl7.org/fhir/ValueSet/marital-status) +export const MaritalStatusCodes = ["A", "D", "I", "L", "M", "P", "S", "T", "U", "W", "UNK"] as const; +export type MaritalStatus = (typeof MaritalStatusCodes)[number]; +export const MaritalStatusConcepts: Readonly> = { + A: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "A", display: "Annulled" }, + D: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "D", display: "Divorced" }, + I: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "I", display: "Interlocutory" }, + L: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "L", display: "Legally Separated" }, + M: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "M", display: "Married" }, + P: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "P", display: "Polygamous" }, + S: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "S", display: "Never Married" }, + T: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "T", display: "Domestic partner" }, + U: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "U", display: "unmarried" }, + W: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "W", display: "Widowed" }, + UNK: { system: "http://terminology.hl7.org/CodeSystem/v3-NullFlavor", code: "UNK" }, +} as const; +export const parseMaritalStatus = (input: unknown, fieldName?: string): MaritalStatus => { + return parseLiteral(input, MaritalStatusCodes, fieldName); +} +export const parseMaritalStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, MaritalStatusConcepts, fieldName); +} + +// NameUse (required — http://hl7.org/fhir/ValueSet/name-use) +export const NameUseCodes = ["usual", "official", "temp", "nickname", "anonymous", "old", "maiden"] as const; +export type NameUse = (typeof NameUseCodes)[number]; +export const NameUseConcepts: Readonly> = { + usual: { system: "http://hl7.org/fhir/name-use", code: "usual", display: "Usual" }, + official: { system: "http://hl7.org/fhir/name-use", code: "official", display: "Official" }, + temp: { system: "http://hl7.org/fhir/name-use", code: "temp", display: "Temp" }, + nickname: { system: "http://hl7.org/fhir/name-use", code: "nickname", display: "Nickname" }, + anonymous: { system: "http://hl7.org/fhir/name-use", code: "anonymous", display: "Anonymous" }, + old: { system: "http://hl7.org/fhir/name-use", code: "old", display: "Old" }, + maiden: { system: "http://hl7.org/fhir/name-use", code: "maiden", display: "Name changed for Marriage" }, +} as const; +export const parseNameUse = (input: unknown, fieldName?: string): NameUse => { + return parseLiteral(input, NameUseCodes, fieldName); +} +export const parseNameUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, NameUseConcepts, fieldName); +} + +// NarrativeStatus (required — http://hl7.org/fhir/ValueSet/narrative-status) +export const NarrativeStatusCodes = ["generated", "extensions", "additional", "empty"] as const; +export type NarrativeStatus = (typeof NarrativeStatusCodes)[number]; +export const NarrativeStatusConcepts: Readonly> = { + generated: { system: "http://hl7.org/fhir/narrative-status", code: "generated", display: "Generated" }, + extensions: { system: "http://hl7.org/fhir/narrative-status", code: "extensions", display: "Extensions" }, + additional: { system: "http://hl7.org/fhir/narrative-status", code: "additional", display: "Additional" }, + empty: { system: "http://hl7.org/fhir/narrative-status", code: "empty", display: "Empty" }, +} as const; +export const parseNarrativeStatus = (input: unknown, fieldName?: string): NarrativeStatus => { + return parseLiteral(input, NarrativeStatusCodes, fieldName); +} +export const parseNarrativeStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, NarrativeStatusConcepts, fieldName); +} + +// ObservationCategory (preferred — http://hl7.org/fhir/ValueSet/observation-category) +export const ObservationCategoryCodes = ["social-history", "vital-signs", "imaging", "laboratory", "procedure", "survey", "exam", "therapy", "activity"] as const; +export type ObservationCategory = (typeof ObservationCategoryCodes)[number]; +export const ObservationCategoryConcepts: Readonly> = { + "social-history": { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "social-history", display: "Social History" }, + "vital-signs": { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "vital-signs", display: "Vital Signs" }, + imaging: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "imaging", display: "Imaging" }, + laboratory: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "laboratory", display: "Laboratory" }, + procedure: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "procedure", display: "Procedure" }, + survey: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "survey", display: "Survey" }, + exam: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "exam", display: "Exam" }, + therapy: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "therapy", display: "Therapy" }, + activity: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "activity", display: "Activity" }, +} as const; +export const parseObservationCategory = (input: unknown, fieldName?: string): ObservationCategory => { + return parseLiteral(input, ObservationCategoryCodes, fieldName); +} +export const parseObservationCategoryCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationCategoryConcepts, fieldName); +} + +// ObservationInterpretation (extensible — http://hl7.org/fhir/ValueSet/observation-interpretation) +export const ObservationInterpretationCodes = ["_GeneticObservationInterpretation", "CAR", "Carrier", "_ObservationInterpretationChange", "B", "D", "U", "W", "_ObservationInterpretationExceptions", "<", ">", "AC", "IE", "QCF", "TOX", "_ObservationInterpretationNormality", "A", "AA", "HH", "LL", "H", "H>", "HU", "L", "L<", "LU", "N", "_ObservationInterpretationSusceptibility", "I", "MS", "NCL", "NS", "R", "SYN-R", "S", "SDD", "SYN-S", "VS", "EX", "HX", "LX", "HM", "ObservationInterpretationDetection", "IND", "E", "NEG", "ND", "POS", "DET", "ObservationInterpretationExpectation", "EXP", "UNE", "OBX", "ReactivityObservationInterpretation", "NR", "RR", "WR"] as const; +export type ObservationInterpretation = (typeof ObservationInterpretationCodes)[number]; +export const ObservationInterpretationConcepts: Readonly> = { + _GeneticObservationInterpretation: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_GeneticObservationInterpretation", display: "GeneticObservationInterpretation" }, + CAR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "CAR", display: "Carrier" }, + Carrier: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "Carrier", display: "Carrier" }, + _ObservationInterpretationChange: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationChange", display: "ObservationInterpretationChange" }, + B: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "B", display: "Better" }, + D: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "D", display: "Significant change down" }, + U: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "U", display: "Significant change up" }, + W: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "W", display: "Worse" }, + _ObservationInterpretationExceptions: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationExceptions", display: "ObservationInterpretationExceptions" }, + "<": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "<", display: "Off scale low" }, + ">": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: ">", display: "Off scale high" }, + AC: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "AC", display: "Anti-complementary substances present" }, + IE: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "IE", display: "Insufficient evidence" }, + QCF: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "QCF", display: "Quality control failure" }, + TOX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "TOX", display: "Cytotoxic substance present" }, + _ObservationInterpretationNormality: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationNormality", display: "ObservationInterpretationNormality" }, + A: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "A", display: "Abnormal" }, + AA: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "AA", display: "Critical abnormal" }, + HH: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HH", display: "Critical high" }, + LL: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "LL", display: "Critical low" }, + H: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "H", display: "High" }, + "H>": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "H>", display: "Significantly high" }, + HU: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HU", display: "Significantly high" }, + L: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "L", display: "Low" }, + "L<": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "L<", display: "Significantly low" }, + LU: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "LU", display: "Significantly low" }, + N: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "N", display: "Normal" }, + _ObservationInterpretationSusceptibility: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationSusceptibility", display: "ObservationInterpretationSusceptibility" }, + I: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "I", display: "Intermediate" }, + MS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "MS", display: "moderately susceptible" }, + NCL: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NCL", display: "No CLSI defined breakpoint" }, + NS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NS", display: "Non-susceptible" }, + R: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "R", display: "Resistant" }, + "SYN-R": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "SYN-R", display: "Synergy - resistant" }, + S: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "S", display: "Susceptible" }, + SDD: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "SDD", display: "Susceptible-dose dependent" }, + "SYN-S": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "SYN-S", display: "Synergy - susceptible" }, + VS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "VS", display: "very susceptible" }, + EX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "EX", display: "outside threshold" }, + HX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HX", display: "above high threshold" }, + LX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "LX", display: "below low threshold" }, + HM: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HM", display: "Hold for Medical Review" }, + ObservationInterpretationDetection: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ObservationInterpretationDetection", display: "ObservationInterpretationDetection" }, + IND: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "IND", display: "Indeterminate" }, + E: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "E", display: "Equivocal" }, + NEG: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NEG", display: "Negative" }, + ND: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ND", display: "Not detected" }, + POS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "POS", display: "Positive" }, + DET: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "DET", display: "Detected" }, + ObservationInterpretationExpectation: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ObservationInterpretationExpectation", display: "ObservationInterpretationExpectation" }, + EXP: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "EXP", display: "Expected" }, + UNE: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "UNE", display: "Unexpected" }, + OBX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "OBX", display: "Interpretation qualifiers in separate OBX segments" }, + ReactivityObservationInterpretation: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ReactivityObservationInterpretation", display: "ReactivityObservationInterpretation" }, + NR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NR", display: "Non-reactive" }, + RR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "RR", display: "Reactive" }, + WR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "WR", display: "Weakly reactive" }, +} as const; +export const parseObservationInterpretation = (input: unknown, fieldName?: string): ObservationInterpretation => { + return parseLiteral(input, ObservationInterpretationCodes, fieldName); +} +export const parseObservationInterpretationCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationInterpretationConcepts, fieldName); +} + +// ObservationRangeMeaning (preferred — http://hl7.org/fhir/ValueSet/referencerange-meaning) +export const ObservationRangeMeaningCodes = ["type", "normal", "recommended", "treatment", "therapeutic", "pre", "post", "endocrine", "pre-puberty", "follicular", "midcycle", "luteal", "postmenopausal"] as const; +export type ObservationRangeMeaning = (typeof ObservationRangeMeaningCodes)[number]; +export const ObservationRangeMeaningConcepts: Readonly> = { + type: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "type", display: "Type" }, + normal: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "normal", display: "Normal Range" }, + recommended: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "recommended", display: "Recommended Range" }, + treatment: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "treatment", display: "Treatment Range" }, + therapeutic: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "therapeutic", display: "Therapeutic Desired Level" }, + pre: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "pre", display: "Pre Therapeutic Desired Level" }, + post: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "post", display: "Post Therapeutic Desired Level" }, + endocrine: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "endocrine", display: "Endocrine" }, + "pre-puberty": { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "pre-puberty", display: "Pre-Puberty" }, + follicular: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "follicular", display: "Follicular Stage" }, + midcycle: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "midcycle", display: "MidCycle" }, + luteal: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "luteal", display: "Luteal" }, + postmenopausal: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "postmenopausal", display: "Post-Menopause" }, +} as const; +export const parseObservationRangeMeaning = (input: unknown, fieldName?: string): ObservationRangeMeaning => { + return parseLiteral(input, ObservationRangeMeaningCodes, fieldName); +} +export const parseObservationRangeMeaningCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationRangeMeaningConcepts, fieldName); +} + +// ObservationStatus (required — http://hl7.org/fhir/ValueSet/observation-status) +export const ObservationStatusCodes = ["registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown"] as const; +export type ObservationStatus = (typeof ObservationStatusCodes)[number]; +export const ObservationStatusConcepts: Readonly> = { + registered: { system: "http://hl7.org/fhir/observation-status", code: "registered", display: "Registered" }, + preliminary: { system: "http://hl7.org/fhir/observation-status", code: "preliminary", display: "Preliminary" }, + final: { system: "http://hl7.org/fhir/observation-status", code: "final", display: "Final" }, + amended: { system: "http://hl7.org/fhir/observation-status", code: "amended", display: "Amended" }, + corrected: { system: "http://hl7.org/fhir/observation-status", code: "corrected", display: "Corrected" }, + cancelled: { system: "http://hl7.org/fhir/observation-status", code: "cancelled", display: "Cancelled" }, + "entered-in-error": { system: "http://hl7.org/fhir/observation-status", code: "entered-in-error", display: "Entered in Error" }, + unknown: { system: "http://hl7.org/fhir/observation-status", code: "unknown", display: "Unknown" }, +} as const; +export const parseObservationStatus = (input: unknown, fieldName?: string): ObservationStatus => { + return parseLiteral(input, ObservationStatusCodes, fieldName); +} +export const parseObservationStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationStatusConcepts, fieldName); +} + +// ObservationValueAbsentReason (extensible — http://hl7.org/fhir/ValueSet/data-absent-reason) +export const ObservationValueAbsentReasonCodes = ["unknown", "asked-unknown", "temp-unknown", "not-asked", "asked-declined", "masked", "not-applicable", "unsupported", "as-text", "error", "not-a-number", "negative-infinity", "positive-infinity", "not-performed", "not-permitted"] as const; +export type ObservationValueAbsentReason = (typeof ObservationValueAbsentReasonCodes)[number]; +export const ObservationValueAbsentReasonConcepts: Readonly> = { + unknown: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "unknown", display: "Unknown" }, + "asked-unknown": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "asked-unknown", display: "Asked But Unknown" }, + "temp-unknown": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "temp-unknown", display: "Temporarily Unknown" }, + "not-asked": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-asked", display: "Not Asked" }, + "asked-declined": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "asked-declined", display: "Asked But Declined" }, + masked: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "masked", display: "Masked" }, + "not-applicable": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-applicable", display: "Not Applicable" }, + unsupported: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "unsupported", display: "Unsupported" }, + "as-text": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "as-text", display: "As Text" }, + error: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "error", display: "Error" }, + "not-a-number": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-a-number", display: "Not a Number (NaN)" }, + "negative-infinity": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "negative-infinity", display: "Negative Infinity (NINF)" }, + "positive-infinity": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "positive-infinity", display: "Positive Infinity (PINF)" }, + "not-performed": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-performed", display: "Not Performed" }, + "not-permitted": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-permitted", display: "Not Permitted" }, +} as const; +export const parseObservationValueAbsentReason = (input: unknown, fieldName?: string): ObservationValueAbsentReason => { + return parseLiteral(input, ObservationValueAbsentReasonCodes, fieldName); +} +export const parseObservationValueAbsentReasonCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationValueAbsentReasonConcepts, fieldName); +} + +// ParameterUse (required — http://hl7.org/fhir/ValueSet/operation-parameter-use) +export const ParameterUseCodes = ["in", "out"] as const; +export type ParameterUse = (typeof ParameterUseCodes)[number]; +export const ParameterUseConcepts: Readonly> = { + in: { system: "http://hl7.org/fhir/operation-parameter-use", code: "in", display: "In" }, + out: { system: "http://hl7.org/fhir/operation-parameter-use", code: "out", display: "Out" }, +} as const; +export const parseParameterUse = (input: unknown, fieldName?: string): ParameterUse => { + return parseLiteral(input, ParameterUseCodes, fieldName); +} +export const parseParameterUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ParameterUseConcepts, fieldName); +} + +// QuantityComparator (required — http://hl7.org/fhir/ValueSet/quantity-comparator) +export const QuantityComparatorCodes = ["<", "<=", ">=", ">"] as const; +export type QuantityComparator = (typeof QuantityComparatorCodes)[number]; +export const QuantityComparatorConcepts: Readonly> = { + "<": { system: "http://hl7.org/fhir/quantity-comparator", code: "<", display: "Less than" }, + "<=": { system: "http://hl7.org/fhir/quantity-comparator", code: "<=", display: "Less or Equal to" }, + ">=": { system: "http://hl7.org/fhir/quantity-comparator", code: ">=", display: "Greater or Equal to" }, + ">": { system: "http://hl7.org/fhir/quantity-comparator", code: ">", display: "Greater than" }, +} as const; +export const parseQuantityComparator = (input: unknown, fieldName?: string): QuantityComparator => { + return parseLiteral(input, QuantityComparatorCodes, fieldName); +} +export const parseQuantityComparatorCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, QuantityComparatorConcepts, fieldName); +} + +// RelatedArtifactType (required — http://hl7.org/fhir/ValueSet/related-artifact-type) +export const RelatedArtifactTypeCodes = ["documentation", "justification", "citation", "predecessor", "successor", "derived-from", "depends-on", "composed-of"] as const; +export type RelatedArtifactType = (typeof RelatedArtifactTypeCodes)[number]; +export const RelatedArtifactTypeConcepts: Readonly> = { + documentation: { system: "http://hl7.org/fhir/related-artifact-type", code: "documentation", display: "Documentation" }, + justification: { system: "http://hl7.org/fhir/related-artifact-type", code: "justification", display: "Justification" }, + citation: { system: "http://hl7.org/fhir/related-artifact-type", code: "citation", display: "Citation" }, + predecessor: { system: "http://hl7.org/fhir/related-artifact-type", code: "predecessor", display: "Predecessor" }, + successor: { system: "http://hl7.org/fhir/related-artifact-type", code: "successor", display: "Successor" }, + "derived-from": { system: "http://hl7.org/fhir/related-artifact-type", code: "derived-from", display: "Derived From" }, + "depends-on": { system: "http://hl7.org/fhir/related-artifact-type", code: "depends-on", display: "Depends On" }, + "composed-of": { system: "http://hl7.org/fhir/related-artifact-type", code: "composed-of", display: "Composed Of" }, +} as const; +export const parseRelatedArtifactType = (input: unknown, fieldName?: string): RelatedArtifactType => { + return parseLiteral(input, RelatedArtifactTypeCodes, fieldName); +} +export const parseRelatedArtifactTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, RelatedArtifactTypeConcepts, fieldName); +} + +// SearchEntryMode (required — http://hl7.org/fhir/ValueSet/search-entry-mode) +export const SearchEntryModeCodes = ["match", "include", "outcome"] as const; +export type SearchEntryMode = (typeof SearchEntryModeCodes)[number]; +export const SearchEntryModeConcepts: Readonly> = { + match: { system: "http://hl7.org/fhir/search-entry-mode", code: "match", display: "Match" }, + include: { system: "http://hl7.org/fhir/search-entry-mode", code: "include", display: "Include" }, + outcome: { system: "http://hl7.org/fhir/search-entry-mode", code: "outcome", display: "Outcome" }, +} as const; +export const parseSearchEntryMode = (input: unknown, fieldName?: string): SearchEntryMode => { + return parseLiteral(input, SearchEntryModeCodes, fieldName); +} +export const parseSearchEntryModeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, SearchEntryModeConcepts, fieldName); +} + +// SignatureType (preferred — http://hl7.org/fhir/ValueSet/signature-type) +export const SignatureTypeCodes = ["1.2.840.10065.1.12.1.1", "1.2.840.10065.1.12.1.2", "1.2.840.10065.1.12.1.3", "1.2.840.10065.1.12.1.4", "1.2.840.10065.1.12.1.5", "1.2.840.10065.1.12.1.6", "1.2.840.10065.1.12.1.7", "1.2.840.10065.1.12.1.8", "1.2.840.10065.1.12.1.9", "1.2.840.10065.1.12.1.10", "1.2.840.10065.1.12.1.11", "1.2.840.10065.1.12.1.12", "1.2.840.10065.1.12.1.13", "1.2.840.10065.1.12.1.14", "1.2.840.10065.1.12.1.15", "1.2.840.10065.1.12.1.16", "1.2.840.10065.1.12.1.17", "1.2.840.10065.1.12.1.18"] as const; +export type SignatureType = (typeof SignatureTypeCodes)[number]; +export const SignatureTypeConcepts: Readonly> = { + "1.2.840.10065.1.12.1.1": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.1", display: "Author's Signature" }, + "1.2.840.10065.1.12.1.2": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.2", display: "Coauthor's Signature" }, + "1.2.840.10065.1.12.1.3": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.3", display: "Co-participant's Signature" }, + "1.2.840.10065.1.12.1.4": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.4", display: "Transcriptionist/Recorder Signature" }, + "1.2.840.10065.1.12.1.5": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.5", display: "Verification Signature" }, + "1.2.840.10065.1.12.1.6": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.6", display: "Validation Signature" }, + "1.2.840.10065.1.12.1.7": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.7", display: "Consent Signature" }, + "1.2.840.10065.1.12.1.8": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.8", display: "Signature Witness Signature" }, + "1.2.840.10065.1.12.1.9": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.9", display: "Event Witness Signature" }, + "1.2.840.10065.1.12.1.10": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.10", display: "Identity Witness Signature" }, + "1.2.840.10065.1.12.1.11": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.11", display: "Consent Witness Signature" }, + "1.2.840.10065.1.12.1.12": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.12", display: "Interpreter Signature" }, + "1.2.840.10065.1.12.1.13": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.13", display: "Review Signature" }, + "1.2.840.10065.1.12.1.14": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.14", display: "Source Signature" }, + "1.2.840.10065.1.12.1.15": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.15", display: "Addendum Signature" }, + "1.2.840.10065.1.12.1.16": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.16", display: "Modification Signature" }, + "1.2.840.10065.1.12.1.17": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.17", display: "Administrative (Error/Edit) Signature" }, + "1.2.840.10065.1.12.1.18": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.18", display: "Timestamp Signature" }, +} as const; +export const parseSignatureType = (input: unknown, fieldName?: string): SignatureType => { + return parseLiteral(input, SignatureTypeCodes, fieldName); +} +export const parseSignatureTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, SignatureTypeConcepts, fieldName); +} + +// SortDirection (required — http://hl7.org/fhir/ValueSet/sort-direction) +export const SortDirectionCodes = ["ascending", "descending"] as const; +export type SortDirection = (typeof SortDirectionCodes)[number]; +export const SortDirectionConcepts: Readonly> = { + ascending: { system: "http://hl7.org/fhir/sort-direction", code: "ascending", display: "Ascending" }, + descending: { system: "http://hl7.org/fhir/sort-direction", code: "descending", display: "Descending" }, +} as const; +export const parseSortDirection = (input: unknown, fieldName?: string): SortDirection => { + return parseLiteral(input, SortDirectionCodes, fieldName); +} +export const parseSortDirectionCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, SortDirectionConcepts, fieldName); +} + +// Status (required — http://hl7.org/fhir/ValueSet/observation-status) +export const StatusCodes = ["registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown"] as const; +export type Status = (typeof StatusCodes)[number]; +export const StatusConcepts: Readonly> = { + registered: { system: "http://hl7.org/fhir/observation-status", code: "registered", display: "Registered" }, + preliminary: { system: "http://hl7.org/fhir/observation-status", code: "preliminary", display: "Preliminary" }, + final: { system: "http://hl7.org/fhir/observation-status", code: "final", display: "Final" }, + amended: { system: "http://hl7.org/fhir/observation-status", code: "amended", display: "Amended" }, + corrected: { system: "http://hl7.org/fhir/observation-status", code: "corrected", display: "Corrected" }, + cancelled: { system: "http://hl7.org/fhir/observation-status", code: "cancelled", display: "Cancelled" }, + "entered-in-error": { system: "http://hl7.org/fhir/observation-status", code: "entered-in-error", display: "Entered in Error" }, + unknown: { system: "http://hl7.org/fhir/observation-status", code: "unknown", display: "Unknown" }, +} as const; +export const parseStatus = (input: unknown, fieldName?: string): Status => { + return parseLiteral(input, StatusCodes, fieldName); +} +export const parseStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, StatusConcepts, fieldName); +} + +// TimingAbbreviation (preferred — http://hl7.org/fhir/ValueSet/timing-abbreviation) +export const TimingAbbreviationCodes = ["BID", "TID", "QID", "AM", "PM", "QD", "QOD", "Q1H", "Q2H", "Q3H", "Q4H", "Q6H", "Q8H", "BED", "WK", "MO"] as const; +export type TimingAbbreviation = (typeof TimingAbbreviationCodes)[number]; +export const TimingAbbreviationConcepts: Readonly> = { + BID: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "BID", display: "BID" }, + TID: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "TID", display: "TID" }, + QID: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "QID", display: "QID" }, + AM: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "AM", display: "AM" }, + PM: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "PM", display: "PM" }, + QD: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "QD", display: "QD" }, + QOD: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "QOD", display: "QOD" }, + Q1H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q1H", display: "every hour" }, + Q2H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q2H", display: "every 2 hours" }, + Q3H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q3H", display: "every 3 hours" }, + Q4H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q4H", display: "Q4H" }, + Q6H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q6H", display: "Q6H" }, + Q8H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q8H", display: "every 8 hours" }, + BED: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "BED", display: "at bedtime" }, + WK: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "WK", display: "weekly" }, + MO: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "MO", display: "monthly" }, +} as const; +export const parseTimingAbbreviation = (input: unknown, fieldName?: string): TimingAbbreviation => { + return parseLiteral(input, TimingAbbreviationCodes, fieldName); +} +export const parseTimingAbbreviationCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, TimingAbbreviationConcepts, fieldName); +} + +// TriggerType (required — http://hl7.org/fhir/ValueSet/trigger-type) +export const TriggerTypeCodes = ["named-event", "periodic", "data-changed", "data-added", "data-modified", "data-removed", "data-accessed", "data-access-ended"] as const; +export type TriggerType = (typeof TriggerTypeCodes)[number]; +export const TriggerTypeConcepts: Readonly> = { + "named-event": { system: "http://hl7.org/fhir/trigger-type", code: "named-event", display: "Named Event" }, + periodic: { system: "http://hl7.org/fhir/trigger-type", code: "periodic", display: "Periodic" }, + "data-changed": { system: "http://hl7.org/fhir/trigger-type", code: "data-changed", display: "Data Changed" }, + "data-added": { system: "http://hl7.org/fhir/trigger-type", code: "data-added", display: "Data Added" }, + "data-modified": { system: "http://hl7.org/fhir/trigger-type", code: "data-modified", display: "Data Updated" }, + "data-removed": { system: "http://hl7.org/fhir/trigger-type", code: "data-removed", display: "Data Removed" }, + "data-accessed": { system: "http://hl7.org/fhir/trigger-type", code: "data-accessed", display: "Data Accessed" }, + "data-access-ended": { system: "http://hl7.org/fhir/trigger-type", code: "data-access-ended", display: "Data Access Ended" }, +} as const; +export const parseTriggerType = (input: unknown, fieldName?: string): TriggerType => { + return parseLiteral(input, TriggerTypeCodes, fieldName); +} +export const parseTriggerTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, TriggerTypeConcepts, fieldName); +} + +// UnitsOfTime (required — http://hl7.org/fhir/ValueSet/units-of-time) +export const UnitsOfTimeCodes = ["s", "min", "h", "d", "wk", "mo", "a"] as const; +export type UnitsOfTime = (typeof UnitsOfTimeCodes)[number]; +export const UnitsOfTimeConcepts: Readonly> = { + s: { system: "http://unitsofmeasure.org", code: "s", display: "second" }, + min: { system: "http://unitsofmeasure.org", code: "min", display: "minute" }, + h: { system: "http://unitsofmeasure.org", code: "h", display: "hour" }, + d: { system: "http://unitsofmeasure.org", code: "d", display: "day" }, + wk: { system: "http://unitsofmeasure.org", code: "wk", display: "week" }, + mo: { system: "http://unitsofmeasure.org", code: "mo", display: "month" }, + a: { system: "http://unitsofmeasure.org", code: "a", display: "year" }, +} as const; +export const parseUnitsOfTime = (input: unknown, fieldName?: string): UnitsOfTime => { + return parseLiteral(input, UnitsOfTimeCodes, fieldName); +} +export const parseUnitsOfTimeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, UnitsOfTimeConcepts, fieldName); +} + +// UsageContextType (extensible — http://hl7.org/fhir/ValueSet/usage-context-type) +export const UsageContextTypeCodes = ["gender", "age", "focus", "user", "workflow", "task", "venue", "species", "program"] as const; +export type UsageContextType = (typeof UsageContextTypeCodes)[number]; +export const UsageContextTypeConcepts: Readonly> = { + gender: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "gender", display: "Gender" }, + age: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "age", display: "Age Range" }, + focus: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "focus", display: "Clinical Focus" }, + user: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "user", display: "User Type" }, + workflow: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "workflow", display: "Workflow Setting" }, + task: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "task", display: "Workflow Task" }, + venue: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "venue", display: "Clinical Venue" }, + species: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "species", display: "Species" }, + program: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "program", display: "Program" }, +} as const; +export const parseUsageContextType = (input: unknown, fieldName?: string): UsageContextType => { + return parseLiteral(input, UsageContextTypeCodes, fieldName); +} +export const parseUsageContextTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, UsageContextTypeConcepts, fieldName); +} + +// VitalSigns (extensible — http://hl7.org/fhir/ValueSet/observation-vitalsignresult) +export const VitalSignsCodes = ["85353-1", "9279-1", "8867-4", "2708-6", "8310-5", "8302-2", "9843-4", "29463-7", "39156-5", "85354-9", "8480-6", "8462-4", "8478-0"] as const; +export type VitalSigns = (typeof VitalSignsCodes)[number]; +export const VitalSignsConcepts: Readonly> = { + "85353-1": { system: "http://loinc.org", code: "85353-1" }, + "9279-1": { system: "http://loinc.org", code: "9279-1" }, + "8867-4": { system: "http://loinc.org", code: "8867-4" }, + "2708-6": { system: "http://loinc.org", code: "2708-6" }, + "8310-5": { system: "http://loinc.org", code: "8310-5" }, + "8302-2": { system: "http://loinc.org", code: "8302-2" }, + "9843-4": { system: "http://loinc.org", code: "9843-4" }, + "29463-7": { system: "http://loinc.org", code: "29463-7" }, + "39156-5": { system: "http://loinc.org", code: "39156-5" }, + "85354-9": { system: "http://loinc.org", code: "85354-9" }, + "8480-6": { system: "http://loinc.org", code: "8480-6" }, + "8462-4": { system: "http://loinc.org", code: "8462-4" }, + "8478-0": { system: "http://loinc.org", code: "8478-0" }, +} as const; +export const parseVitalSigns = (input: unknown, fieldName?: string): VitalSigns => { + return parseLiteral(input, VitalSignsCodes, fieldName); +} +export const parseVitalSignsCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, VitalSignsConcepts, fieldName); +} + diff --git a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/index.ts b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/index.ts index 691e9603..40e474ba 100644 --- a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/index.ts +++ b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/index.ts @@ -1,4 +1,5 @@ export * from "./profiles"; +export * from "./bindings"; export type { Address } from "./Address"; export type { Age } from "./Age"; export type { Annotation } from "./Annotation"; diff --git a/examples/typescript-r4/fhir-types/profile-helpers.ts b/examples/typescript-r4/fhir-types/profile-helpers.ts index 91cfb01f..5eec2ea3 100644 --- a/examples/typescript-r4/fhir-types/profile-helpers.ts +++ b/examples/typescript-r4/fhir-types/profile-helpers.ts @@ -1,8 +1,8 @@ /** - * Runtime helpers for generated FHIR profile classes. + * Runtime helpers for generated FHIR types and profile classes. * * This file is copied verbatim into every generated TypeScript output and - * imported by profile modules. It provides: + * imported by profile and binding modules. It provides: * * - **Slice helpers** – match, get, set, and default-fill array slices * defined by a FHIR StructureDefinition. @@ -12,6 +12,8 @@ * profile classes can expose a flat API. * - **Validation helpers** – lightweight structural checks that profile * classes call from their `validate()` method. + * - **Parse helpers** – validate / enrich values coming from external + * sources (CSV, HTTP form, untyped JSON) into typed FHIR values. * - **Misc utilities** – deep-match, deep-merge, path navigation. */ @@ -447,3 +449,92 @@ export const validateReference = (res: object, profileName: string, field: strin ? [] : [`${profileName}: field '${field}' references '${refType}' but only ${allowed.join(", ")} are allowed`]; }; + +// --------------------------------------------------------------------------- +// Parse helpers +// +// Each `parse*` validates an untyped value (typically string from CSV or HTTP +// form input) and returns a value of the typed FHIR shape. All throw an +// `Error` on failure; the message includes `fieldName` when provided so the +// call site can be located in stack traces. +// --------------------------------------------------------------------------- + +/** + * Validate that `input` is one of the literal values in `allowed`, returning + * it as the narrowed type. Throws when `input` is not in the set. + * + * @example + * parseLiteral(row.gender, ["male", "female", "other", "unknown"], "Patient.gender") + */ +export const parseLiteral = (input: unknown, allowed: readonly T[], fieldName?: string): T => { + if (typeof input === "string" && (allowed as readonly string[]).includes(input)) return input as T; + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid value ${JSON.stringify(input)}. Expected one of: ${allowed.join(", ")}`); +}; + +/** + * Look up `input` in a code → `{system, code, display}` table and return the + * corresponding FHIR Coding. Throws when the code is not in the table. + * + * Generated per-binding helpers wrap this with the binding's lookup table so + * callers only need to supply the code string. + * + * @example + * parseCoding(row.raceCode, USCoreOmbRaceCategoriesCodes, "Race.ombCategory") + */ +export const parseCoding = ( + input: unknown, + lookup: Readonly>, + fieldName?: string, +): { system?: string; code: T; display?: string } => { + if (typeof input === "string" && Object.hasOwn(lookup, input)) { + const concept = lookup[input]; + if (concept) return concept; + } + const where = fieldName ? `${fieldName}: ` : ""; + const allowed = Object.keys(lookup).join(", "); + throw new Error(`${where}invalid code ${JSON.stringify(input)}. Expected one of: ${allowed}`); +}; + +/** + * Coerce `input` into a boolean. Accepts `true`/`false`, `"true"`/`"false"`, + * `"1"`/`"0"` (case-insensitive). Throws on anything else. + */ +export const parseBoolean = (input: unknown, fieldName?: string): boolean => { + if (typeof input === "boolean") return input; + if (typeof input === "string") { + const v = input.trim().toLowerCase(); + if (v === "true" || v === "1") return true; + if (v === "false" || v === "0") return false; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid boolean ${JSON.stringify(input)}`); +}; + +/** + * Coerce `input` into a finite number. Accepts numbers and numeric strings. + * Throws on `NaN`, `Infinity`, or non-numeric input. + */ +export const parseNumber = (input: unknown, fieldName?: string): number => { + if (typeof input === "number" && Number.isFinite(input)) return input; + if (typeof input === "string" && input.trim() !== "") { + const n = Number(input); + if (Number.isFinite(n)) return n; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid number ${JSON.stringify(input)}`); +}; + +/** + * Validate that `input` is a FHIR `instant` string (ISO 8601 with timezone). + * Returns the original string on success; throws on malformed input. + */ +export const parseInstant = (input: unknown, fieldName?: string): string => { + if (typeof input === "string") { + // FHIR instant: YYYY-MM-DDTHH:MM:SS(.sss)?(Z|[+-]HH:MM) + const re = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/; + if (re.test(input) && !Number.isNaN(Date.parse(input))) return input; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid instant ${JSON.stringify(input)}`); +}; diff --git a/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/bindings.ts b/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/bindings.ts new file mode 100644 index 00000000..485dcccd --- /dev/null +++ b/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/bindings.ts @@ -0,0 +1,756 @@ +// WARNING: This file is autogenerated by @atomic-ehr/codegen. +// GitHub: https://github.com/atomic-ehr/codegen +// Any manual changes made to this file may be overwritten. + +import { parseLiteral, parseCoding } from "../profile-helpers"; + +// AddressType (required — http://hl7.org/fhir/ValueSet/address-type) +export const AddressTypeCodes = ["postal", "physical", "both"] as const; +export type AddressType = (typeof AddressTypeCodes)[number]; +export const AddressTypeConcepts: Readonly> = { + postal: { system: "http://hl7.org/fhir/address-type", code: "postal", display: "Postal" }, + physical: { system: "http://hl7.org/fhir/address-type", code: "physical", display: "Physical" }, + both: { system: "http://hl7.org/fhir/address-type", code: "both", display: "Postal & Physical" }, +} as const; +export const parseAddressType = (input: unknown, fieldName?: string): AddressType => { + return parseLiteral(input, AddressTypeCodes, fieldName); +} +export const parseAddressTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, AddressTypeConcepts, fieldName); +} + +// AddressUse (required — http://hl7.org/fhir/ValueSet/address-use) +export const AddressUseCodes = ["home", "work", "temp", "old", "billing"] as const; +export type AddressUse = (typeof AddressUseCodes)[number]; +export const AddressUseConcepts: Readonly> = { + home: { system: "http://hl7.org/fhir/address-use", code: "home", display: "Home" }, + work: { system: "http://hl7.org/fhir/address-use", code: "work", display: "Work" }, + temp: { system: "http://hl7.org/fhir/address-use", code: "temp", display: "Temporary" }, + old: { system: "http://hl7.org/fhir/address-use", code: "old", display: "Old / Incorrect" }, + billing: { system: "http://hl7.org/fhir/address-use", code: "billing", display: "Billing" }, +} as const; +export const parseAddressUse = (input: unknown, fieldName?: string): AddressUse => { + return parseLiteral(input, AddressUseCodes, fieldName); +} +export const parseAddressUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, AddressUseConcepts, fieldName); +} + +// AdministrativeGender (required — http://hl7.org/fhir/ValueSet/administrative-gender) +export const AdministrativeGenderCodes = ["male", "female", "other", "unknown"] as const; +export type AdministrativeGender = (typeof AdministrativeGenderCodes)[number]; +export const AdministrativeGenderConcepts: Readonly> = { + male: { system: "http://hl7.org/fhir/administrative-gender", code: "male", display: "Male" }, + female: { system: "http://hl7.org/fhir/administrative-gender", code: "female", display: "Female" }, + other: { system: "http://hl7.org/fhir/administrative-gender", code: "other", display: "Other" }, + unknown: { system: "http://hl7.org/fhir/administrative-gender", code: "unknown", display: "Unknown" }, +} as const; +export const parseAdministrativeGender = (input: unknown, fieldName?: string): AdministrativeGender => { + return parseLiteral(input, AdministrativeGenderCodes, fieldName); +} +export const parseAdministrativeGenderCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, AdministrativeGenderConcepts, fieldName); +} + +// ContactPointSystem (required — http://hl7.org/fhir/ValueSet/contact-point-system) +export const ContactPointSystemCodes = ["phone", "fax", "email", "pager", "url", "sms", "other"] as const; +export type ContactPointSystem = (typeof ContactPointSystemCodes)[number]; +export const ContactPointSystemConcepts: Readonly> = { + phone: { system: "http://hl7.org/fhir/contact-point-system", code: "phone", display: "Phone" }, + fax: { system: "http://hl7.org/fhir/contact-point-system", code: "fax", display: "Fax" }, + email: { system: "http://hl7.org/fhir/contact-point-system", code: "email", display: "Email" }, + pager: { system: "http://hl7.org/fhir/contact-point-system", code: "pager", display: "Pager" }, + url: { system: "http://hl7.org/fhir/contact-point-system", code: "url", display: "URL" }, + sms: { system: "http://hl7.org/fhir/contact-point-system", code: "sms", display: "SMS" }, + other: { system: "http://hl7.org/fhir/contact-point-system", code: "other", display: "Other" }, +} as const; +export const parseContactPointSystem = (input: unknown, fieldName?: string): ContactPointSystem => { + return parseLiteral(input, ContactPointSystemCodes, fieldName); +} +export const parseContactPointSystemCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ContactPointSystemConcepts, fieldName); +} + +// ContactPointUse (required — http://hl7.org/fhir/ValueSet/contact-point-use) +export const ContactPointUseCodes = ["home", "work", "temp", "old", "mobile"] as const; +export type ContactPointUse = (typeof ContactPointUseCodes)[number]; +export const ContactPointUseConcepts: Readonly> = { + home: { system: "http://hl7.org/fhir/contact-point-use", code: "home", display: "Home" }, + work: { system: "http://hl7.org/fhir/contact-point-use", code: "work", display: "Work" }, + temp: { system: "http://hl7.org/fhir/contact-point-use", code: "temp", display: "Temp" }, + old: { system: "http://hl7.org/fhir/contact-point-use", code: "old", display: "Old" }, + mobile: { system: "http://hl7.org/fhir/contact-point-use", code: "mobile", display: "Mobile" }, +} as const; +export const parseContactPointUse = (input: unknown, fieldName?: string): ContactPointUse => { + return parseLiteral(input, ContactPointUseCodes, fieldName); +} +export const parseContactPointUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ContactPointUseConcepts, fieldName); +} + +// ContributorType (required — http://hl7.org/fhir/ValueSet/contributor-type) +export const ContributorTypeCodes = ["author", "editor", "reviewer", "endorser"] as const; +export type ContributorType = (typeof ContributorTypeCodes)[number]; +export const ContributorTypeConcepts: Readonly> = { + author: { system: "http://hl7.org/fhir/contributor-type", code: "author", display: "Author" }, + editor: { system: "http://hl7.org/fhir/contributor-type", code: "editor", display: "Editor" }, + reviewer: { system: "http://hl7.org/fhir/contributor-type", code: "reviewer", display: "Reviewer" }, + endorser: { system: "http://hl7.org/fhir/contributor-type", code: "endorser", display: "Endorser" }, +} as const; +export const parseContributorType = (input: unknown, fieldName?: string): ContributorType => { + return parseLiteral(input, ContributorTypeCodes, fieldName); +} +export const parseContributorTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ContributorTypeConcepts, fieldName); +} + +// DayOfWeek (required — http://hl7.org/fhir/ValueSet/days-of-week) +export const DayOfWeekCodes = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] as const; +export type DayOfWeek = (typeof DayOfWeekCodes)[number]; +export const DayOfWeekConcepts: Readonly> = { + mon: { system: "http://hl7.org/fhir/days-of-week", code: "mon", display: "Monday" }, + tue: { system: "http://hl7.org/fhir/days-of-week", code: "tue", display: "Tuesday" }, + wed: { system: "http://hl7.org/fhir/days-of-week", code: "wed", display: "Wednesday" }, + thu: { system: "http://hl7.org/fhir/days-of-week", code: "thu", display: "Thursday" }, + fri: { system: "http://hl7.org/fhir/days-of-week", code: "fri", display: "Friday" }, + sat: { system: "http://hl7.org/fhir/days-of-week", code: "sat", display: "Saturday" }, + sun: { system: "http://hl7.org/fhir/days-of-week", code: "sun", display: "Sunday" }, +} as const; +export const parseDayOfWeek = (input: unknown, fieldName?: string): DayOfWeek => { + return parseLiteral(input, DayOfWeekCodes, fieldName); +} +export const parseDayOfWeekCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, DayOfWeekConcepts, fieldName); +} + +// EventTiming (required — http://hl7.org/fhir/ValueSet/event-timing) +export const EventTimingCodes = ["MORN", "MORN.early", "MORN.late", "NOON", "AFT", "AFT.early", "AFT.late", "EVE", "EVE.early", "EVE.late", "NIGHT", "PHS", "HS", "WAKE", "C", "CM", "CD", "CV", "AC", "ACM", "ACD", "ACV", "PC", "PCM", "PCD", "PCV"] as const; +export type EventTiming = (typeof EventTimingCodes)[number]; +export const EventTimingConcepts: Readonly> = { + MORN: { system: "http://hl7.org/fhir/event-timing", code: "MORN", display: "Morning" }, + "MORN.early": { system: "http://hl7.org/fhir/event-timing", code: "MORN.early", display: "Early Morning" }, + "MORN.late": { system: "http://hl7.org/fhir/event-timing", code: "MORN.late", display: "Late Morning" }, + NOON: { system: "http://hl7.org/fhir/event-timing", code: "NOON", display: "Noon" }, + AFT: { system: "http://hl7.org/fhir/event-timing", code: "AFT", display: "Afternoon" }, + "AFT.early": { system: "http://hl7.org/fhir/event-timing", code: "AFT.early", display: "Early Afternoon" }, + "AFT.late": { system: "http://hl7.org/fhir/event-timing", code: "AFT.late", display: "Late Afternoon" }, + EVE: { system: "http://hl7.org/fhir/event-timing", code: "EVE", display: "Evening" }, + "EVE.early": { system: "http://hl7.org/fhir/event-timing", code: "EVE.early", display: "Early Evening" }, + "EVE.late": { system: "http://hl7.org/fhir/event-timing", code: "EVE.late", display: "Late Evening" }, + NIGHT: { system: "http://hl7.org/fhir/event-timing", code: "NIGHT", display: "Night" }, + PHS: { system: "http://hl7.org/fhir/event-timing", code: "PHS", display: "After Sleep" }, + HS: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "HS" }, + WAKE: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "WAKE" }, + C: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "C" }, + CM: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "CM" }, + CD: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "CD" }, + CV: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "CV" }, + AC: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "AC" }, + ACM: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "ACM" }, + ACD: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "ACD" }, + ACV: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "ACV" }, + PC: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PC" }, + PCM: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PCM" }, + PCD: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PCD" }, + PCV: { system: "http://terminology.hl7.org/CodeSystem/v3-TimingEvent", code: "PCV" }, +} as const; +export const parseEventTiming = (input: unknown, fieldName?: string): EventTiming => { + return parseLiteral(input, EventTimingCodes, fieldName); +} +export const parseEventTimingCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, EventTimingConcepts, fieldName); +} + +// ExpressionLanguage (extensible — http://hl7.org/fhir/ValueSet/expression-language) +export const ExpressionLanguageCodes = ["text/cql", "text/fhirpath", "application/x-fhir-query"] as const; +export type ExpressionLanguage = (typeof ExpressionLanguageCodes)[number]; +export const ExpressionLanguageConcepts: Readonly> = { + "text/cql": { system: "http://hl7.org/fhir/expression-language", code: "text/cql", display: "CQL" }, + "text/fhirpath": { system: "http://hl7.org/fhir/expression-language", code: "text/fhirpath", display: "FHIRPath" }, + "application/x-fhir-query": { system: "http://hl7.org/fhir/expression-language", code: "application/x-fhir-query", display: "FHIR Query" }, +} as const; +export const parseExpressionLanguage = (input: unknown, fieldName?: string): ExpressionLanguage => { + return parseLiteral(input, ExpressionLanguageCodes, fieldName); +} +export const parseExpressionLanguageCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ExpressionLanguageConcepts, fieldName); +} + +// IdentifierType (extensible — http://hl7.org/fhir/ValueSet/identifier-type) +export const IdentifierTypeCodes = ["DL", "PPN", "BRN", "MR", "MCN", "EN", "TAX", "NIIP", "PRN", "MD", "DR", "ACSN", "UDI", "SNO", "SB", "PLAC", "FILL", "JHN"] as const; +export type IdentifierType = (typeof IdentifierTypeCodes)[number]; +export const IdentifierTypeConcepts: Readonly> = { + DL: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "DL" }, + PPN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "PPN" }, + BRN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "BRN" }, + MR: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR" }, + MCN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MCN" }, + EN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "EN" }, + TAX: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "TAX" }, + NIIP: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "NIIP" }, + PRN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "PRN" }, + MD: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MD" }, + DR: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "DR" }, + ACSN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "ACSN" }, + UDI: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "UDI" }, + SNO: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "SNO" }, + SB: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "SB" }, + PLAC: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "PLAC" }, + FILL: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "FILL" }, + JHN: { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "JHN" }, +} as const; +export const parseIdentifierType = (input: unknown, fieldName?: string): IdentifierType => { + return parseLiteral(input, IdentifierTypeCodes, fieldName); +} +export const parseIdentifierTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, IdentifierTypeConcepts, fieldName); +} + +// IdentifierUse (required — http://hl7.org/fhir/ValueSet/identifier-use) +export const IdentifierUseCodes = ["usual", "official", "temp", "secondary", "old"] as const; +export type IdentifierUse = (typeof IdentifierUseCodes)[number]; +export const IdentifierUseConcepts: Readonly> = { + usual: { system: "http://hl7.org/fhir/identifier-use", code: "usual", display: "Usual" }, + official: { system: "http://hl7.org/fhir/identifier-use", code: "official", display: "Official" }, + temp: { system: "http://hl7.org/fhir/identifier-use", code: "temp", display: "Temp" }, + secondary: { system: "http://hl7.org/fhir/identifier-use", code: "secondary", display: "Secondary" }, + old: { system: "http://hl7.org/fhir/identifier-use", code: "old", display: "Old" }, +} as const; +export const parseIdentifierUse = (input: unknown, fieldName?: string): IdentifierUse => { + return parseLiteral(input, IdentifierUseCodes, fieldName); +} +export const parseIdentifierUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, IdentifierUseConcepts, fieldName); +} + +// Language (preferred — http://hl7.org/fhir/ValueSet/languages) +export const LanguageCodes = ["ar", "bn", "cs", "da", "de", "de-AT", "de-CH", "de-DE", "el", "en", "en-AU", "en-CA", "en-GB", "en-IN", "en-NZ", "en-SG", "en-US", "es", "es-AR", "es-ES", "es-UY", "fi", "fr", "fr-BE", "fr-CH", "fr-FR", "fy", "fy-NL", "hi", "hr", "it", "it-CH", "it-IT", "ja", "ko", "nl", "nl-BE", "nl-NL", "no", "no-NO", "pa", "pl", "pt", "pt-BR", "ru", "ru-RU", "sr", "sr-RS", "sv", "sv-SE", "te", "zh", "zh-CN", "zh-HK", "zh-SG", "zh-TW"] as const; +export type Language = (typeof LanguageCodes)[number]; +export const LanguageConcepts: Readonly> = { + ar: { system: "urn:ietf:bcp:47", code: "ar", display: "Arabic" }, + bn: { system: "urn:ietf:bcp:47", code: "bn", display: "Bengali" }, + cs: { system: "urn:ietf:bcp:47", code: "cs", display: "Czech" }, + da: { system: "urn:ietf:bcp:47", code: "da", display: "Danish" }, + de: { system: "urn:ietf:bcp:47", code: "de", display: "German" }, + "de-AT": { system: "urn:ietf:bcp:47", code: "de-AT", display: "German (Austria)" }, + "de-CH": { system: "urn:ietf:bcp:47", code: "de-CH", display: "German (Switzerland)" }, + "de-DE": { system: "urn:ietf:bcp:47", code: "de-DE", display: "German (Germany)" }, + el: { system: "urn:ietf:bcp:47", code: "el", display: "Greek" }, + en: { system: "urn:ietf:bcp:47", code: "en", display: "English" }, + "en-AU": { system: "urn:ietf:bcp:47", code: "en-AU", display: "English (Australia)" }, + "en-CA": { system: "urn:ietf:bcp:47", code: "en-CA", display: "English (Canada)" }, + "en-GB": { system: "urn:ietf:bcp:47", code: "en-GB", display: "English (Great Britain)" }, + "en-IN": { system: "urn:ietf:bcp:47", code: "en-IN", display: "English (India)" }, + "en-NZ": { system: "urn:ietf:bcp:47", code: "en-NZ", display: "English (New Zeland)" }, + "en-SG": { system: "urn:ietf:bcp:47", code: "en-SG", display: "English (Singapore)" }, + "en-US": { system: "urn:ietf:bcp:47", code: "en-US", display: "English (United States)" }, + es: { system: "urn:ietf:bcp:47", code: "es", display: "Spanish" }, + "es-AR": { system: "urn:ietf:bcp:47", code: "es-AR", display: "Spanish (Argentina)" }, + "es-ES": { system: "urn:ietf:bcp:47", code: "es-ES", display: "Spanish (Spain)" }, + "es-UY": { system: "urn:ietf:bcp:47", code: "es-UY", display: "Spanish (Uruguay)" }, + fi: { system: "urn:ietf:bcp:47", code: "fi", display: "Finnish" }, + fr: { system: "urn:ietf:bcp:47", code: "fr", display: "French" }, + "fr-BE": { system: "urn:ietf:bcp:47", code: "fr-BE", display: "French (Belgium)" }, + "fr-CH": { system: "urn:ietf:bcp:47", code: "fr-CH", display: "French (Switzerland)" }, + "fr-FR": { system: "urn:ietf:bcp:47", code: "fr-FR", display: "French (France)" }, + fy: { system: "urn:ietf:bcp:47", code: "fy", display: "Frysian" }, + "fy-NL": { system: "urn:ietf:bcp:47", code: "fy-NL", display: "Frysian (Netherlands)" }, + hi: { system: "urn:ietf:bcp:47", code: "hi", display: "Hindi" }, + hr: { system: "urn:ietf:bcp:47", code: "hr", display: "Croatian" }, + it: { system: "urn:ietf:bcp:47", code: "it", display: "Italian" }, + "it-CH": { system: "urn:ietf:bcp:47", code: "it-CH", display: "Italian (Switzerland)" }, + "it-IT": { system: "urn:ietf:bcp:47", code: "it-IT", display: "Italian (Italy)" }, + ja: { system: "urn:ietf:bcp:47", code: "ja", display: "Japanese" }, + ko: { system: "urn:ietf:bcp:47", code: "ko", display: "Korean" }, + nl: { system: "urn:ietf:bcp:47", code: "nl", display: "Dutch" }, + "nl-BE": { system: "urn:ietf:bcp:47", code: "nl-BE", display: "Dutch (Belgium)" }, + "nl-NL": { system: "urn:ietf:bcp:47", code: "nl-NL", display: "Dutch (Netherlands)" }, + no: { system: "urn:ietf:bcp:47", code: "no", display: "Norwegian" }, + "no-NO": { system: "urn:ietf:bcp:47", code: "no-NO", display: "Norwegian (Norway)" }, + pa: { system: "urn:ietf:bcp:47", code: "pa", display: "Punjabi" }, + pl: { system: "urn:ietf:bcp:47", code: "pl", display: "Polish" }, + pt: { system: "urn:ietf:bcp:47", code: "pt", display: "Portuguese" }, + "pt-BR": { system: "urn:ietf:bcp:47", code: "pt-BR", display: "Portuguese (Brazil)" }, + ru: { system: "urn:ietf:bcp:47", code: "ru", display: "Russian" }, + "ru-RU": { system: "urn:ietf:bcp:47", code: "ru-RU", display: "Russian (Russia)" }, + sr: { system: "urn:ietf:bcp:47", code: "sr", display: "Serbian" }, + "sr-RS": { system: "urn:ietf:bcp:47", code: "sr-RS", display: "Serbian (Serbia)" }, + sv: { system: "urn:ietf:bcp:47", code: "sv", display: "Swedish" }, + "sv-SE": { system: "urn:ietf:bcp:47", code: "sv-SE", display: "Swedish (Sweden)" }, + te: { system: "urn:ietf:bcp:47", code: "te", display: "Telegu" }, + zh: { system: "urn:ietf:bcp:47", code: "zh", display: "Chinese" }, + "zh-CN": { system: "urn:ietf:bcp:47", code: "zh-CN", display: "Chinese (China)" }, + "zh-HK": { system: "urn:ietf:bcp:47", code: "zh-HK", display: "Chinese (Hong Kong)" }, + "zh-SG": { system: "urn:ietf:bcp:47", code: "zh-SG", display: "Chinese (Singapore)" }, + "zh-TW": { system: "urn:ietf:bcp:47", code: "zh-TW", display: "Chinese (Taiwan)" }, +} as const; +export const parseLanguage = (input: unknown, fieldName?: string): Language => { + return parseLiteral(input, LanguageCodes, fieldName); +} +export const parseLanguageCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, LanguageConcepts, fieldName); +} + +// LinkType (required — http://hl7.org/fhir/ValueSet/link-type) +export const LinkTypeCodes = ["replaced-by", "replaces", "refer", "seealso"] as const; +export type LinkType = (typeof LinkTypeCodes)[number]; +export const LinkTypeConcepts: Readonly> = { + "replaced-by": { system: "http://hl7.org/fhir/link-type", code: "replaced-by", display: "Replaced-by" }, + replaces: { system: "http://hl7.org/fhir/link-type", code: "replaces", display: "Replaces" }, + refer: { system: "http://hl7.org/fhir/link-type", code: "refer", display: "Refer" }, + seealso: { system: "http://hl7.org/fhir/link-type", code: "seealso", display: "See also" }, +} as const; +export const parseLinkType = (input: unknown, fieldName?: string): LinkType => { + return parseLiteral(input, LinkTypeCodes, fieldName); +} +export const parseLinkTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, LinkTypeConcepts, fieldName); +} + +// MaritalStatus (extensible — http://hl7.org/fhir/ValueSet/marital-status) +export const MaritalStatusCodes = ["A", "D", "I", "L", "M", "P", "S", "T", "U", "W", "UNK"] as const; +export type MaritalStatus = (typeof MaritalStatusCodes)[number]; +export const MaritalStatusConcepts: Readonly> = { + A: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "A", display: "Annulled" }, + D: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "D", display: "Divorced" }, + I: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "I", display: "Interlocutory" }, + L: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "L", display: "Legally Separated" }, + M: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "M", display: "Married" }, + P: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "P", display: "Polygamous" }, + S: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "S", display: "Never Married" }, + T: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "T", display: "Domestic partner" }, + U: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "U", display: "unmarried" }, + W: { system: "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", code: "W", display: "Widowed" }, + UNK: { system: "http://terminology.hl7.org/CodeSystem/v3-NullFlavor", code: "UNK" }, +} as const; +export const parseMaritalStatus = (input: unknown, fieldName?: string): MaritalStatus => { + return parseLiteral(input, MaritalStatusCodes, fieldName); +} +export const parseMaritalStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, MaritalStatusConcepts, fieldName); +} + +// NameUse (required — http://hl7.org/fhir/ValueSet/name-use) +export const NameUseCodes = ["usual", "official", "temp", "nickname", "anonymous", "old", "maiden"] as const; +export type NameUse = (typeof NameUseCodes)[number]; +export const NameUseConcepts: Readonly> = { + usual: { system: "http://hl7.org/fhir/name-use", code: "usual", display: "Usual" }, + official: { system: "http://hl7.org/fhir/name-use", code: "official", display: "Official" }, + temp: { system: "http://hl7.org/fhir/name-use", code: "temp", display: "Temp" }, + nickname: { system: "http://hl7.org/fhir/name-use", code: "nickname", display: "Nickname" }, + anonymous: { system: "http://hl7.org/fhir/name-use", code: "anonymous", display: "Anonymous" }, + old: { system: "http://hl7.org/fhir/name-use", code: "old", display: "Old" }, + maiden: { system: "http://hl7.org/fhir/name-use", code: "maiden", display: "Name changed for Marriage" }, +} as const; +export const parseNameUse = (input: unknown, fieldName?: string): NameUse => { + return parseLiteral(input, NameUseCodes, fieldName); +} +export const parseNameUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, NameUseConcepts, fieldName); +} + +// NarrativeStatus (required — http://hl7.org/fhir/ValueSet/narrative-status) +export const NarrativeStatusCodes = ["generated", "extensions", "additional", "empty"] as const; +export type NarrativeStatus = (typeof NarrativeStatusCodes)[number]; +export const NarrativeStatusConcepts: Readonly> = { + generated: { system: "http://hl7.org/fhir/narrative-status", code: "generated", display: "Generated" }, + extensions: { system: "http://hl7.org/fhir/narrative-status", code: "extensions", display: "Extensions" }, + additional: { system: "http://hl7.org/fhir/narrative-status", code: "additional", display: "Additional" }, + empty: { system: "http://hl7.org/fhir/narrative-status", code: "empty", display: "Empty" }, +} as const; +export const parseNarrativeStatus = (input: unknown, fieldName?: string): NarrativeStatus => { + return parseLiteral(input, NarrativeStatusCodes, fieldName); +} +export const parseNarrativeStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, NarrativeStatusConcepts, fieldName); +} + +// ObservationCategory (preferred — http://hl7.org/fhir/ValueSet/observation-category) +export const ObservationCategoryCodes = ["social-history", "vital-signs", "imaging", "laboratory", "procedure", "survey", "exam", "therapy", "activity"] as const; +export type ObservationCategory = (typeof ObservationCategoryCodes)[number]; +export const ObservationCategoryConcepts: Readonly> = { + "social-history": { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "social-history", display: "Social History" }, + "vital-signs": { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "vital-signs", display: "Vital Signs" }, + imaging: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "imaging", display: "Imaging" }, + laboratory: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "laboratory", display: "Laboratory" }, + procedure: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "procedure", display: "Procedure" }, + survey: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "survey", display: "Survey" }, + exam: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "exam", display: "Exam" }, + therapy: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "therapy", display: "Therapy" }, + activity: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "activity", display: "Activity" }, +} as const; +export const parseObservationCategory = (input: unknown, fieldName?: string): ObservationCategory => { + return parseLiteral(input, ObservationCategoryCodes, fieldName); +} +export const parseObservationCategoryCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationCategoryConcepts, fieldName); +} + +// ObservationInterpretation (extensible — http://hl7.org/fhir/ValueSet/observation-interpretation) +export const ObservationInterpretationCodes = ["_GeneticObservationInterpretation", "CAR", "Carrier", "_ObservationInterpretationChange", "B", "D", "U", "W", "_ObservationInterpretationExceptions", "<", ">", "AC", "IE", "QCF", "TOX", "_ObservationInterpretationNormality", "A", "AA", "HH", "LL", "H", "H>", "HU", "L", "L<", "LU", "N", "_ObservationInterpretationSusceptibility", "I", "MS", "NCL", "NS", "R", "SYN-R", "S", "SDD", "SYN-S", "VS", "EX", "HX", "LX", "HM", "ObservationInterpretationDetection", "IND", "E", "NEG", "ND", "POS", "DET", "ObservationInterpretationExpectation", "EXP", "UNE", "OBX", "ReactivityObservationInterpretation", "NR", "RR", "WR"] as const; +export type ObservationInterpretation = (typeof ObservationInterpretationCodes)[number]; +export const ObservationInterpretationConcepts: Readonly> = { + _GeneticObservationInterpretation: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_GeneticObservationInterpretation", display: "GeneticObservationInterpretation" }, + CAR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "CAR", display: "Carrier" }, + Carrier: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "Carrier", display: "Carrier" }, + _ObservationInterpretationChange: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationChange", display: "ObservationInterpretationChange" }, + B: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "B", display: "Better" }, + D: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "D", display: "Significant change down" }, + U: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "U", display: "Significant change up" }, + W: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "W", display: "Worse" }, + _ObservationInterpretationExceptions: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationExceptions", display: "ObservationInterpretationExceptions" }, + "<": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "<", display: "Off scale low" }, + ">": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: ">", display: "Off scale high" }, + AC: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "AC", display: "Anti-complementary substances present" }, + IE: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "IE", display: "Insufficient evidence" }, + QCF: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "QCF", display: "Quality control failure" }, + TOX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "TOX", display: "Cytotoxic substance present" }, + _ObservationInterpretationNormality: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationNormality", display: "ObservationInterpretationNormality" }, + A: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "A", display: "Abnormal" }, + AA: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "AA", display: "Critical abnormal" }, + HH: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HH", display: "Critical high" }, + LL: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "LL", display: "Critical low" }, + H: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "H", display: "High" }, + "H>": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "H>", display: "Significantly high" }, + HU: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HU", display: "Significantly high" }, + L: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "L", display: "Low" }, + "L<": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "L<", display: "Significantly low" }, + LU: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "LU", display: "Significantly low" }, + N: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "N", display: "Normal" }, + _ObservationInterpretationSusceptibility: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "_ObservationInterpretationSusceptibility", display: "ObservationInterpretationSusceptibility" }, + I: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "I", display: "Intermediate" }, + MS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "MS", display: "moderately susceptible" }, + NCL: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NCL", display: "No CLSI defined breakpoint" }, + NS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NS", display: "Non-susceptible" }, + R: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "R", display: "Resistant" }, + "SYN-R": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "SYN-R", display: "Synergy - resistant" }, + S: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "S", display: "Susceptible" }, + SDD: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "SDD", display: "Susceptible-dose dependent" }, + "SYN-S": { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "SYN-S", display: "Synergy - susceptible" }, + VS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "VS", display: "very susceptible" }, + EX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "EX", display: "outside threshold" }, + HX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HX", display: "above high threshold" }, + LX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "LX", display: "below low threshold" }, + HM: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "HM", display: "Hold for Medical Review" }, + ObservationInterpretationDetection: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ObservationInterpretationDetection", display: "ObservationInterpretationDetection" }, + IND: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "IND", display: "Indeterminate" }, + E: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "E", display: "Equivocal" }, + NEG: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NEG", display: "Negative" }, + ND: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ND", display: "Not detected" }, + POS: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "POS", display: "Positive" }, + DET: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "DET", display: "Detected" }, + ObservationInterpretationExpectation: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ObservationInterpretationExpectation", display: "ObservationInterpretationExpectation" }, + EXP: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "EXP", display: "Expected" }, + UNE: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "UNE", display: "Unexpected" }, + OBX: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "OBX", display: "Interpretation qualifiers in separate OBX segments" }, + ReactivityObservationInterpretation: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "ReactivityObservationInterpretation", display: "ReactivityObservationInterpretation" }, + NR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "NR", display: "Non-reactive" }, + RR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "RR", display: "Reactive" }, + WR: { system: "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", code: "WR", display: "Weakly reactive" }, +} as const; +export const parseObservationInterpretation = (input: unknown, fieldName?: string): ObservationInterpretation => { + return parseLiteral(input, ObservationInterpretationCodes, fieldName); +} +export const parseObservationInterpretationCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationInterpretationConcepts, fieldName); +} + +// ObservationRangeMeaning (preferred — http://hl7.org/fhir/ValueSet/referencerange-meaning) +export const ObservationRangeMeaningCodes = ["type", "normal", "recommended", "treatment", "therapeutic", "pre", "post", "endocrine", "pre-puberty", "follicular", "midcycle", "luteal", "postmenopausal"] as const; +export type ObservationRangeMeaning = (typeof ObservationRangeMeaningCodes)[number]; +export const ObservationRangeMeaningConcepts: Readonly> = { + type: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "type", display: "Type" }, + normal: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "normal", display: "Normal Range" }, + recommended: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "recommended", display: "Recommended Range" }, + treatment: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "treatment", display: "Treatment Range" }, + therapeutic: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "therapeutic", display: "Therapeutic Desired Level" }, + pre: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "pre", display: "Pre Therapeutic Desired Level" }, + post: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "post", display: "Post Therapeutic Desired Level" }, + endocrine: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "endocrine", display: "Endocrine" }, + "pre-puberty": { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "pre-puberty", display: "Pre-Puberty" }, + follicular: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "follicular", display: "Follicular Stage" }, + midcycle: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "midcycle", display: "MidCycle" }, + luteal: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "luteal", display: "Luteal" }, + postmenopausal: { system: "http://terminology.hl7.org/CodeSystem/referencerange-meaning", code: "postmenopausal", display: "Post-Menopause" }, +} as const; +export const parseObservationRangeMeaning = (input: unknown, fieldName?: string): ObservationRangeMeaning => { + return parseLiteral(input, ObservationRangeMeaningCodes, fieldName); +} +export const parseObservationRangeMeaningCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationRangeMeaningConcepts, fieldName); +} + +// ObservationStatus (required — http://hl7.org/fhir/ValueSet/observation-status) +export const ObservationStatusCodes = ["registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown"] as const; +export type ObservationStatus = (typeof ObservationStatusCodes)[number]; +export const ObservationStatusConcepts: Readonly> = { + registered: { system: "http://hl7.org/fhir/observation-status", code: "registered", display: "Registered" }, + preliminary: { system: "http://hl7.org/fhir/observation-status", code: "preliminary", display: "Preliminary" }, + final: { system: "http://hl7.org/fhir/observation-status", code: "final", display: "Final" }, + amended: { system: "http://hl7.org/fhir/observation-status", code: "amended", display: "Amended" }, + corrected: { system: "http://hl7.org/fhir/observation-status", code: "corrected", display: "Corrected" }, + cancelled: { system: "http://hl7.org/fhir/observation-status", code: "cancelled", display: "Cancelled" }, + "entered-in-error": { system: "http://hl7.org/fhir/observation-status", code: "entered-in-error", display: "Entered in Error" }, + unknown: { system: "http://hl7.org/fhir/observation-status", code: "unknown", display: "Unknown" }, +} as const; +export const parseObservationStatus = (input: unknown, fieldName?: string): ObservationStatus => { + return parseLiteral(input, ObservationStatusCodes, fieldName); +} +export const parseObservationStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationStatusConcepts, fieldName); +} + +// ObservationValueAbsentReason (extensible — http://hl7.org/fhir/ValueSet/data-absent-reason) +export const ObservationValueAbsentReasonCodes = ["unknown", "asked-unknown", "temp-unknown", "not-asked", "asked-declined", "masked", "not-applicable", "unsupported", "as-text", "error", "not-a-number", "negative-infinity", "positive-infinity", "not-performed", "not-permitted"] as const; +export type ObservationValueAbsentReason = (typeof ObservationValueAbsentReasonCodes)[number]; +export const ObservationValueAbsentReasonConcepts: Readonly> = { + unknown: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "unknown", display: "Unknown" }, + "asked-unknown": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "asked-unknown", display: "Asked But Unknown" }, + "temp-unknown": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "temp-unknown", display: "Temporarily Unknown" }, + "not-asked": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-asked", display: "Not Asked" }, + "asked-declined": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "asked-declined", display: "Asked But Declined" }, + masked: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "masked", display: "Masked" }, + "not-applicable": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-applicable", display: "Not Applicable" }, + unsupported: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "unsupported", display: "Unsupported" }, + "as-text": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "as-text", display: "As Text" }, + error: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "error", display: "Error" }, + "not-a-number": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-a-number", display: "Not a Number (NaN)" }, + "negative-infinity": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "negative-infinity", display: "Negative Infinity (NINF)" }, + "positive-infinity": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "positive-infinity", display: "Positive Infinity (PINF)" }, + "not-performed": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-performed", display: "Not Performed" }, + "not-permitted": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-permitted", display: "Not Permitted" }, +} as const; +export const parseObservationValueAbsentReason = (input: unknown, fieldName?: string): ObservationValueAbsentReason => { + return parseLiteral(input, ObservationValueAbsentReasonCodes, fieldName); +} +export const parseObservationValueAbsentReasonCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationValueAbsentReasonConcepts, fieldName); +} + +// ParameterUse (required — http://hl7.org/fhir/ValueSet/operation-parameter-use) +export const ParameterUseCodes = ["in", "out"] as const; +export type ParameterUse = (typeof ParameterUseCodes)[number]; +export const ParameterUseConcepts: Readonly> = { + in: { system: "http://hl7.org/fhir/operation-parameter-use", code: "in", display: "In" }, + out: { system: "http://hl7.org/fhir/operation-parameter-use", code: "out", display: "Out" }, +} as const; +export const parseParameterUse = (input: unknown, fieldName?: string): ParameterUse => { + return parseLiteral(input, ParameterUseCodes, fieldName); +} +export const parseParameterUseCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ParameterUseConcepts, fieldName); +} + +// QuantityComparator (required — http://hl7.org/fhir/ValueSet/quantity-comparator) +export const QuantityComparatorCodes = ["<", "<=", ">=", ">"] as const; +export type QuantityComparator = (typeof QuantityComparatorCodes)[number]; +export const QuantityComparatorConcepts: Readonly> = { + "<": { system: "http://hl7.org/fhir/quantity-comparator", code: "<", display: "Less than" }, + "<=": { system: "http://hl7.org/fhir/quantity-comparator", code: "<=", display: "Less or Equal to" }, + ">=": { system: "http://hl7.org/fhir/quantity-comparator", code: ">=", display: "Greater or Equal to" }, + ">": { system: "http://hl7.org/fhir/quantity-comparator", code: ">", display: "Greater than" }, +} as const; +export const parseQuantityComparator = (input: unknown, fieldName?: string): QuantityComparator => { + return parseLiteral(input, QuantityComparatorCodes, fieldName); +} +export const parseQuantityComparatorCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, QuantityComparatorConcepts, fieldName); +} + +// RelatedArtifactType (required — http://hl7.org/fhir/ValueSet/related-artifact-type) +export const RelatedArtifactTypeCodes = ["documentation", "justification", "citation", "predecessor", "successor", "derived-from", "depends-on", "composed-of"] as const; +export type RelatedArtifactType = (typeof RelatedArtifactTypeCodes)[number]; +export const RelatedArtifactTypeConcepts: Readonly> = { + documentation: { system: "http://hl7.org/fhir/related-artifact-type", code: "documentation", display: "Documentation" }, + justification: { system: "http://hl7.org/fhir/related-artifact-type", code: "justification", display: "Justification" }, + citation: { system: "http://hl7.org/fhir/related-artifact-type", code: "citation", display: "Citation" }, + predecessor: { system: "http://hl7.org/fhir/related-artifact-type", code: "predecessor", display: "Predecessor" }, + successor: { system: "http://hl7.org/fhir/related-artifact-type", code: "successor", display: "Successor" }, + "derived-from": { system: "http://hl7.org/fhir/related-artifact-type", code: "derived-from", display: "Derived From" }, + "depends-on": { system: "http://hl7.org/fhir/related-artifact-type", code: "depends-on", display: "Depends On" }, + "composed-of": { system: "http://hl7.org/fhir/related-artifact-type", code: "composed-of", display: "Composed Of" }, +} as const; +export const parseRelatedArtifactType = (input: unknown, fieldName?: string): RelatedArtifactType => { + return parseLiteral(input, RelatedArtifactTypeCodes, fieldName); +} +export const parseRelatedArtifactTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, RelatedArtifactTypeConcepts, fieldName); +} + +// SignatureType (preferred — http://hl7.org/fhir/ValueSet/signature-type) +export const SignatureTypeCodes = ["1.2.840.10065.1.12.1.1", "1.2.840.10065.1.12.1.2", "1.2.840.10065.1.12.1.3", "1.2.840.10065.1.12.1.4", "1.2.840.10065.1.12.1.5", "1.2.840.10065.1.12.1.6", "1.2.840.10065.1.12.1.7", "1.2.840.10065.1.12.1.8", "1.2.840.10065.1.12.1.9", "1.2.840.10065.1.12.1.10", "1.2.840.10065.1.12.1.11", "1.2.840.10065.1.12.1.12", "1.2.840.10065.1.12.1.13", "1.2.840.10065.1.12.1.14", "1.2.840.10065.1.12.1.15", "1.2.840.10065.1.12.1.16", "1.2.840.10065.1.12.1.17", "1.2.840.10065.1.12.1.18"] as const; +export type SignatureType = (typeof SignatureTypeCodes)[number]; +export const SignatureTypeConcepts: Readonly> = { + "1.2.840.10065.1.12.1.1": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.1", display: "Author's Signature" }, + "1.2.840.10065.1.12.1.2": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.2", display: "Coauthor's Signature" }, + "1.2.840.10065.1.12.1.3": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.3", display: "Co-participant's Signature" }, + "1.2.840.10065.1.12.1.4": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.4", display: "Transcriptionist/Recorder Signature" }, + "1.2.840.10065.1.12.1.5": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.5", display: "Verification Signature" }, + "1.2.840.10065.1.12.1.6": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.6", display: "Validation Signature" }, + "1.2.840.10065.1.12.1.7": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.7", display: "Consent Signature" }, + "1.2.840.10065.1.12.1.8": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.8", display: "Signature Witness Signature" }, + "1.2.840.10065.1.12.1.9": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.9", display: "Event Witness Signature" }, + "1.2.840.10065.1.12.1.10": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.10", display: "Identity Witness Signature" }, + "1.2.840.10065.1.12.1.11": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.11", display: "Consent Witness Signature" }, + "1.2.840.10065.1.12.1.12": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.12", display: "Interpreter Signature" }, + "1.2.840.10065.1.12.1.13": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.13", display: "Review Signature" }, + "1.2.840.10065.1.12.1.14": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.14", display: "Source Signature" }, + "1.2.840.10065.1.12.1.15": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.15", display: "Addendum Signature" }, + "1.2.840.10065.1.12.1.16": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.16", display: "Modification Signature" }, + "1.2.840.10065.1.12.1.17": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.17", display: "Administrative (Error/Edit) Signature" }, + "1.2.840.10065.1.12.1.18": { system: "urn:iso-astm:E1762-95:2013", code: "1.2.840.10065.1.12.1.18", display: "Timestamp Signature" }, +} as const; +export const parseSignatureType = (input: unknown, fieldName?: string): SignatureType => { + return parseLiteral(input, SignatureTypeCodes, fieldName); +} +export const parseSignatureTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, SignatureTypeConcepts, fieldName); +} + +// SortDirection (required — http://hl7.org/fhir/ValueSet/sort-direction) +export const SortDirectionCodes = ["ascending", "descending"] as const; +export type SortDirection = (typeof SortDirectionCodes)[number]; +export const SortDirectionConcepts: Readonly> = { + ascending: { system: "http://hl7.org/fhir/sort-direction", code: "ascending", display: "Ascending" }, + descending: { system: "http://hl7.org/fhir/sort-direction", code: "descending", display: "Descending" }, +} as const; +export const parseSortDirection = (input: unknown, fieldName?: string): SortDirection => { + return parseLiteral(input, SortDirectionCodes, fieldName); +} +export const parseSortDirectionCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, SortDirectionConcepts, fieldName); +} + +// Status (required — http://hl7.org/fhir/ValueSet/observation-status) +export const StatusCodes = ["registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown"] as const; +export type Status = (typeof StatusCodes)[number]; +export const StatusConcepts: Readonly> = { + registered: { system: "http://hl7.org/fhir/observation-status", code: "registered", display: "Registered" }, + preliminary: { system: "http://hl7.org/fhir/observation-status", code: "preliminary", display: "Preliminary" }, + final: { system: "http://hl7.org/fhir/observation-status", code: "final", display: "Final" }, + amended: { system: "http://hl7.org/fhir/observation-status", code: "amended", display: "Amended" }, + corrected: { system: "http://hl7.org/fhir/observation-status", code: "corrected", display: "Corrected" }, + cancelled: { system: "http://hl7.org/fhir/observation-status", code: "cancelled", display: "Cancelled" }, + "entered-in-error": { system: "http://hl7.org/fhir/observation-status", code: "entered-in-error", display: "Entered in Error" }, + unknown: { system: "http://hl7.org/fhir/observation-status", code: "unknown", display: "Unknown" }, +} as const; +export const parseStatus = (input: unknown, fieldName?: string): Status => { + return parseLiteral(input, StatusCodes, fieldName); +} +export const parseStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, StatusConcepts, fieldName); +} + +// TimingAbbreviation (preferred — http://hl7.org/fhir/ValueSet/timing-abbreviation) +export const TimingAbbreviationCodes = ["BID", "TID", "QID", "AM", "PM", "QD", "QOD", "Q1H", "Q2H", "Q3H", "Q4H", "Q6H", "Q8H", "BED", "WK", "MO"] as const; +export type TimingAbbreviation = (typeof TimingAbbreviationCodes)[number]; +export const TimingAbbreviationConcepts: Readonly> = { + BID: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "BID", display: "BID" }, + TID: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "TID", display: "TID" }, + QID: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "QID", display: "QID" }, + AM: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "AM", display: "AM" }, + PM: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "PM", display: "PM" }, + QD: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "QD", display: "QD" }, + QOD: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "QOD", display: "QOD" }, + Q1H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q1H", display: "every hour" }, + Q2H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q2H", display: "every 2 hours" }, + Q3H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q3H", display: "every 3 hours" }, + Q4H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q4H", display: "Q4H" }, + Q6H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q6H", display: "Q6H" }, + Q8H: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "Q8H", display: "every 8 hours" }, + BED: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "BED", display: "at bedtime" }, + WK: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "WK", display: "weekly" }, + MO: { system: "http://terminology.hl7.org/CodeSystem/v3-GTSAbbreviation", code: "MO", display: "monthly" }, +} as const; +export const parseTimingAbbreviation = (input: unknown, fieldName?: string): TimingAbbreviation => { + return parseLiteral(input, TimingAbbreviationCodes, fieldName); +} +export const parseTimingAbbreviationCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, TimingAbbreviationConcepts, fieldName); +} + +// TriggerType (required — http://hl7.org/fhir/ValueSet/trigger-type) +export const TriggerTypeCodes = ["named-event", "periodic", "data-changed", "data-added", "data-modified", "data-removed", "data-accessed", "data-access-ended"] as const; +export type TriggerType = (typeof TriggerTypeCodes)[number]; +export const TriggerTypeConcepts: Readonly> = { + "named-event": { system: "http://hl7.org/fhir/trigger-type", code: "named-event", display: "Named Event" }, + periodic: { system: "http://hl7.org/fhir/trigger-type", code: "periodic", display: "Periodic" }, + "data-changed": { system: "http://hl7.org/fhir/trigger-type", code: "data-changed", display: "Data Changed" }, + "data-added": { system: "http://hl7.org/fhir/trigger-type", code: "data-added", display: "Data Added" }, + "data-modified": { system: "http://hl7.org/fhir/trigger-type", code: "data-modified", display: "Data Updated" }, + "data-removed": { system: "http://hl7.org/fhir/trigger-type", code: "data-removed", display: "Data Removed" }, + "data-accessed": { system: "http://hl7.org/fhir/trigger-type", code: "data-accessed", display: "Data Accessed" }, + "data-access-ended": { system: "http://hl7.org/fhir/trigger-type", code: "data-access-ended", display: "Data Access Ended" }, +} as const; +export const parseTriggerType = (input: unknown, fieldName?: string): TriggerType => { + return parseLiteral(input, TriggerTypeCodes, fieldName); +} +export const parseTriggerTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, TriggerTypeConcepts, fieldName); +} + +// UnitsOfTime (required — http://hl7.org/fhir/ValueSet/units-of-time) +export const UnitsOfTimeCodes = ["s", "min", "h", "d", "wk", "mo", "a"] as const; +export type UnitsOfTime = (typeof UnitsOfTimeCodes)[number]; +export const UnitsOfTimeConcepts: Readonly> = { + s: { system: "http://unitsofmeasure.org", code: "s", display: "second" }, + min: { system: "http://unitsofmeasure.org", code: "min", display: "minute" }, + h: { system: "http://unitsofmeasure.org", code: "h", display: "hour" }, + d: { system: "http://unitsofmeasure.org", code: "d", display: "day" }, + wk: { system: "http://unitsofmeasure.org", code: "wk", display: "week" }, + mo: { system: "http://unitsofmeasure.org", code: "mo", display: "month" }, + a: { system: "http://unitsofmeasure.org", code: "a", display: "year" }, +} as const; +export const parseUnitsOfTime = (input: unknown, fieldName?: string): UnitsOfTime => { + return parseLiteral(input, UnitsOfTimeCodes, fieldName); +} +export const parseUnitsOfTimeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, UnitsOfTimeConcepts, fieldName); +} + +// UsageContextType (extensible — http://hl7.org/fhir/ValueSet/usage-context-type) +export const UsageContextTypeCodes = ["gender", "age", "focus", "user", "workflow", "task", "venue", "species", "program"] as const; +export type UsageContextType = (typeof UsageContextTypeCodes)[number]; +export const UsageContextTypeConcepts: Readonly> = { + gender: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "gender", display: "Gender" }, + age: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "age", display: "Age Range" }, + focus: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "focus", display: "Clinical Focus" }, + user: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "user", display: "User Type" }, + workflow: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "workflow", display: "Workflow Setting" }, + task: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "task", display: "Workflow Task" }, + venue: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "venue", display: "Clinical Venue" }, + species: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "species", display: "Species" }, + program: { system: "http://terminology.hl7.org/CodeSystem/usage-context-type", code: "program", display: "Program" }, +} as const; +export const parseUsageContextType = (input: unknown, fieldName?: string): UsageContextType => { + return parseLiteral(input, UsageContextTypeCodes, fieldName); +} +export const parseUsageContextTypeCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, UsageContextTypeConcepts, fieldName); +} + +// VitalSigns (extensible — http://hl7.org/fhir/ValueSet/observation-vitalsignresult) +export const VitalSignsCodes = ["85353-1", "9279-1", "8867-4", "2708-6", "8310-5", "8302-2", "9843-4", "29463-7", "39156-5", "85354-9", "8480-6", "8462-4", "8478-0"] as const; +export type VitalSigns = (typeof VitalSignsCodes)[number]; +export const VitalSignsConcepts: Readonly> = { + "85353-1": { system: "http://loinc.org", code: "85353-1" }, + "9279-1": { system: "http://loinc.org", code: "9279-1" }, + "8867-4": { system: "http://loinc.org", code: "8867-4" }, + "2708-6": { system: "http://loinc.org", code: "2708-6" }, + "8310-5": { system: "http://loinc.org", code: "8310-5" }, + "8302-2": { system: "http://loinc.org", code: "8302-2" }, + "9843-4": { system: "http://loinc.org", code: "9843-4" }, + "29463-7": { system: "http://loinc.org", code: "29463-7" }, + "39156-5": { system: "http://loinc.org", code: "39156-5" }, + "85354-9": { system: "http://loinc.org", code: "85354-9" }, + "8480-6": { system: "http://loinc.org", code: "8480-6" }, + "8462-4": { system: "http://loinc.org", code: "8462-4" }, + "8478-0": { system: "http://loinc.org", code: "8478-0" }, +} as const; +export const parseVitalSigns = (input: unknown, fieldName?: string): VitalSigns => { + return parseLiteral(input, VitalSignsCodes, fieldName); +} +export const parseVitalSignsCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, VitalSignsConcepts, fieldName); +} + diff --git a/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/index.ts b/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/index.ts index 82c1509a..6505b3c4 100644 --- a/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/index.ts +++ b/examples/typescript-us-core/fhir-types/hl7-fhir-r4-core/index.ts @@ -1,4 +1,5 @@ export * from "./profiles"; +export * from "./bindings"; export type { Address } from "./Address"; export type { Age } from "./Age"; export type { Annotation } from "./Annotation"; diff --git a/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/bindings.ts b/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/bindings.ts new file mode 100644 index 00000000..a30b730d --- /dev/null +++ b/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/bindings.ts @@ -0,0 +1,173 @@ +// WARNING: This file is autogenerated by @atomic-ehr/codegen. +// GitHub: https://github.com/atomic-ehr/codegen +// Any manual changes made to this file may be overwritten. + +import { parseLiteral, parseCoding } from "../profile-helpers"; + +// ObservationCategory (preferred — http://hl7.org/fhir/ValueSet/observation-category) +export const ObservationCategoryCodes = ["social-history", "vital-signs", "imaging", "laboratory", "procedure", "survey", "exam", "therapy", "activity"] as const; +export type ObservationCategory = (typeof ObservationCategoryCodes)[number]; +export const ObservationCategoryConcepts: Readonly> = { + "social-history": { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "social-history", display: "Social History" }, + "vital-signs": { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "vital-signs", display: "Vital Signs" }, + imaging: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "imaging", display: "Imaging" }, + laboratory: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "laboratory", display: "Laboratory" }, + procedure: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "procedure", display: "Procedure" }, + survey: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "survey", display: "Survey" }, + exam: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "exam", display: "Exam" }, + therapy: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "therapy", display: "Therapy" }, + activity: { system: "http://terminology.hl7.org/CodeSystem/observation-category", code: "activity", display: "Activity" }, +} as const; +export const parseObservationCategory = (input: unknown, fieldName?: string): ObservationCategory => { + return parseLiteral(input, ObservationCategoryCodes, fieldName); +} +export const parseObservationCategoryCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationCategoryConcepts, fieldName); +} + +// ObservationValueAbsentReason (extensible — http://hl7.org/fhir/ValueSet/data-absent-reason) +export const ObservationValueAbsentReasonCodes = ["unknown", "asked-unknown", "temp-unknown", "not-asked", "asked-declined", "masked", "not-applicable", "unsupported", "as-text", "error", "not-a-number", "negative-infinity", "positive-infinity", "not-performed", "not-permitted"] as const; +export type ObservationValueAbsentReason = (typeof ObservationValueAbsentReasonCodes)[number]; +export const ObservationValueAbsentReasonConcepts: Readonly> = { + unknown: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "unknown", display: "Unknown" }, + "asked-unknown": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "asked-unknown", display: "Asked But Unknown" }, + "temp-unknown": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "temp-unknown", display: "Temporarily Unknown" }, + "not-asked": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-asked", display: "Not Asked" }, + "asked-declined": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "asked-declined", display: "Asked But Declined" }, + masked: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "masked", display: "Masked" }, + "not-applicable": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-applicable", display: "Not Applicable" }, + unsupported: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "unsupported", display: "Unsupported" }, + "as-text": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "as-text", display: "As Text" }, + error: { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "error", display: "Error" }, + "not-a-number": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-a-number", display: "Not a Number (NaN)" }, + "negative-infinity": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "negative-infinity", display: "Negative Infinity (NINF)" }, + "positive-infinity": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "positive-infinity", display: "Positive Infinity (PINF)" }, + "not-performed": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-performed", display: "Not Performed" }, + "not-permitted": { system: "http://terminology.hl7.org/CodeSystem/data-absent-reason", code: "not-permitted", display: "Not Permitted" }, +} as const; +export const parseObservationValueAbsentReason = (input: unknown, fieldName?: string): ObservationValueAbsentReason => { + return parseLiteral(input, ObservationValueAbsentReasonCodes, fieldName); +} +export const parseObservationValueAbsentReasonCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, ObservationValueAbsentReasonConcepts, fieldName); +} + +// Status (required — http://hl7.org/fhir/ValueSet/observation-status) +export const StatusCodes = ["registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown"] as const; +export type Status = (typeof StatusCodes)[number]; +export const StatusConcepts: Readonly> = { + registered: { system: "http://hl7.org/fhir/observation-status", code: "registered", display: "Registered" }, + preliminary: { system: "http://hl7.org/fhir/observation-status", code: "preliminary", display: "Preliminary" }, + final: { system: "http://hl7.org/fhir/observation-status", code: "final", display: "Final" }, + amended: { system: "http://hl7.org/fhir/observation-status", code: "amended", display: "Amended" }, + corrected: { system: "http://hl7.org/fhir/observation-status", code: "corrected", display: "Corrected" }, + cancelled: { system: "http://hl7.org/fhir/observation-status", code: "cancelled", display: "Cancelled" }, + "entered-in-error": { system: "http://hl7.org/fhir/observation-status", code: "entered-in-error", display: "Entered in Error" }, + unknown: { system: "http://hl7.org/fhir/observation-status", code: "unknown", display: "Unknown" }, +} as const; +export const parseStatus = (input: unknown, fieldName?: string): Status => { + return parseLiteral(input, StatusCodes, fieldName); +} +export const parseStatusCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, StatusConcepts, fieldName); +} + +// USCoreBloodPressureProfile_code_binding (extensible — http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.62) +export const USCoreBloodPressureProfile_code_bindingCodes = ["2708-6", "29463-7", "3140-1", "3150-0", "3151-8", "39156-5", "59408-5", "59575-1", "59576-9", "77606-2", "8287-5", "8289-1", "8302-2", "8306-3", "8310-5", "8462-4", "8478-0", "8480-6", "8867-4", "9279-1", "9843-4"] as const; +export type USCoreBloodPressureProfile_code_binding = (typeof USCoreBloodPressureProfile_code_bindingCodes)[number]; +export const USCoreBloodPressureProfile_code_bindingConcepts: Readonly> = { + "2708-6": { system: "http://loinc.org", code: "2708-6", display: "Oxygen saturation in Arterial blood" }, + "29463-7": { system: "http://loinc.org", code: "29463-7", display: "Body weight" }, + "3140-1": { system: "http://loinc.org", code: "3140-1", display: "Body surface area Derived from formula" }, + "3150-0": { system: "http://loinc.org", code: "3150-0", display: "Inhaled oxygen concentration" }, + "3151-8": { system: "http://loinc.org", code: "3151-8", display: "Inhaled oxygen flow rate" }, + "39156-5": { system: "http://loinc.org", code: "39156-5", display: "Body mass index (BMI) [Ratio]" }, + "59408-5": { system: "http://loinc.org", code: "59408-5", display: "Oxygen saturation in Arterial blood by Pulse oximetry" }, + "59575-1": { system: "http://loinc.org", code: "59575-1", display: "Body mass index (BMI) [Percentile] Per age" }, + "59576-9": { system: "http://loinc.org", code: "59576-9", display: "Body mass index (BMI) [Percentile] Per age and sex" }, + "77606-2": { system: "http://loinc.org", code: "77606-2", display: "Weight-for-length Per age and sex" }, + "8287-5": { system: "http://loinc.org", code: "8287-5", display: "Head Occipital-frontal circumference by Tape measure" }, + "8289-1": { system: "http://loinc.org", code: "8289-1", display: "Head Occipital-frontal circumference Percentile" }, + "8302-2": { system: "http://loinc.org", code: "8302-2", display: "Body height" }, + "8306-3": { system: "http://loinc.org", code: "8306-3", display: "Body height --lying" }, + "8310-5": { system: "http://loinc.org", code: "8310-5", display: "Body temperature" }, + "8462-4": { system: "http://loinc.org", code: "8462-4", display: "Diastolic blood pressure" }, + "8478-0": { system: "http://loinc.org", code: "8478-0", display: "Mean blood pressure" }, + "8480-6": { system: "http://loinc.org", code: "8480-6", display: "Systolic blood pressure" }, + "8867-4": { system: "http://loinc.org", code: "8867-4", display: "Heart rate" }, + "9279-1": { system: "http://loinc.org", code: "9279-1", display: "Respiratory rate" }, + "9843-4": { system: "http://loinc.org", code: "9843-4", display: "Head Occipital-frontal circumference" }, +} as const; +export const parseUSCoreBloodPressureProfile_code_binding = (input: unknown, fieldName?: string): USCoreBloodPressureProfile_code_binding => { + return parseLiteral(input, USCoreBloodPressureProfile_code_bindingCodes, fieldName); +} +export const parseUSCoreBloodPressureProfile_code_bindingCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, USCoreBloodPressureProfile_code_bindingConcepts, fieldName); +} + +// USCoreBodyWeightProfile_code_binding (extensible — http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.62) +export const USCoreBodyWeightProfile_code_bindingCodes = ["2708-6", "29463-7", "3140-1", "3150-0", "3151-8", "39156-5", "59408-5", "59575-1", "59576-9", "77606-2", "8287-5", "8289-1", "8302-2", "8306-3", "8310-5", "8462-4", "8478-0", "8480-6", "8867-4", "9279-1", "9843-4"] as const; +export type USCoreBodyWeightProfile_code_binding = (typeof USCoreBodyWeightProfile_code_bindingCodes)[number]; +export const USCoreBodyWeightProfile_code_bindingConcepts: Readonly> = { + "2708-6": { system: "http://loinc.org", code: "2708-6", display: "Oxygen saturation in Arterial blood" }, + "29463-7": { system: "http://loinc.org", code: "29463-7", display: "Body weight" }, + "3140-1": { system: "http://loinc.org", code: "3140-1", display: "Body surface area Derived from formula" }, + "3150-0": { system: "http://loinc.org", code: "3150-0", display: "Inhaled oxygen concentration" }, + "3151-8": { system: "http://loinc.org", code: "3151-8", display: "Inhaled oxygen flow rate" }, + "39156-5": { system: "http://loinc.org", code: "39156-5", display: "Body mass index (BMI) [Ratio]" }, + "59408-5": { system: "http://loinc.org", code: "59408-5", display: "Oxygen saturation in Arterial blood by Pulse oximetry" }, + "59575-1": { system: "http://loinc.org", code: "59575-1", display: "Body mass index (BMI) [Percentile] Per age" }, + "59576-9": { system: "http://loinc.org", code: "59576-9", display: "Body mass index (BMI) [Percentile] Per age and sex" }, + "77606-2": { system: "http://loinc.org", code: "77606-2", display: "Weight-for-length Per age and sex" }, + "8287-5": { system: "http://loinc.org", code: "8287-5", display: "Head Occipital-frontal circumference by Tape measure" }, + "8289-1": { system: "http://loinc.org", code: "8289-1", display: "Head Occipital-frontal circumference Percentile" }, + "8302-2": { system: "http://loinc.org", code: "8302-2", display: "Body height" }, + "8306-3": { system: "http://loinc.org", code: "8306-3", display: "Body height --lying" }, + "8310-5": { system: "http://loinc.org", code: "8310-5", display: "Body temperature" }, + "8462-4": { system: "http://loinc.org", code: "8462-4", display: "Diastolic blood pressure" }, + "8478-0": { system: "http://loinc.org", code: "8478-0", display: "Mean blood pressure" }, + "8480-6": { system: "http://loinc.org", code: "8480-6", display: "Systolic blood pressure" }, + "8867-4": { system: "http://loinc.org", code: "8867-4", display: "Heart rate" }, + "9279-1": { system: "http://loinc.org", code: "9279-1", display: "Respiratory rate" }, + "9843-4": { system: "http://loinc.org", code: "9843-4", display: "Head Occipital-frontal circumference" }, +} as const; +export const parseUSCoreBodyWeightProfile_code_binding = (input: unknown, fieldName?: string): USCoreBodyWeightProfile_code_binding => { + return parseLiteral(input, USCoreBodyWeightProfile_code_bindingCodes, fieldName); +} +export const parseUSCoreBodyWeightProfile_code_bindingCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, USCoreBodyWeightProfile_code_bindingConcepts, fieldName); +} + +// USCoreVitalSignsProfile_code_binding (extensible — http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.62) +export const USCoreVitalSignsProfile_code_bindingCodes = ["2708-6", "29463-7", "3140-1", "3150-0", "3151-8", "39156-5", "59408-5", "59575-1", "59576-9", "77606-2", "8287-5", "8289-1", "8302-2", "8306-3", "8310-5", "8462-4", "8478-0", "8480-6", "8867-4", "9279-1", "9843-4"] as const; +export type USCoreVitalSignsProfile_code_binding = (typeof USCoreVitalSignsProfile_code_bindingCodes)[number]; +export const USCoreVitalSignsProfile_code_bindingConcepts: Readonly> = { + "2708-6": { system: "http://loinc.org", code: "2708-6", display: "Oxygen saturation in Arterial blood" }, + "29463-7": { system: "http://loinc.org", code: "29463-7", display: "Body weight" }, + "3140-1": { system: "http://loinc.org", code: "3140-1", display: "Body surface area Derived from formula" }, + "3150-0": { system: "http://loinc.org", code: "3150-0", display: "Inhaled oxygen concentration" }, + "3151-8": { system: "http://loinc.org", code: "3151-8", display: "Inhaled oxygen flow rate" }, + "39156-5": { system: "http://loinc.org", code: "39156-5", display: "Body mass index (BMI) [Ratio]" }, + "59408-5": { system: "http://loinc.org", code: "59408-5", display: "Oxygen saturation in Arterial blood by Pulse oximetry" }, + "59575-1": { system: "http://loinc.org", code: "59575-1", display: "Body mass index (BMI) [Percentile] Per age" }, + "59576-9": { system: "http://loinc.org", code: "59576-9", display: "Body mass index (BMI) [Percentile] Per age and sex" }, + "77606-2": { system: "http://loinc.org", code: "77606-2", display: "Weight-for-length Per age and sex" }, + "8287-5": { system: "http://loinc.org", code: "8287-5", display: "Head Occipital-frontal circumference by Tape measure" }, + "8289-1": { system: "http://loinc.org", code: "8289-1", display: "Head Occipital-frontal circumference Percentile" }, + "8302-2": { system: "http://loinc.org", code: "8302-2", display: "Body height" }, + "8306-3": { system: "http://loinc.org", code: "8306-3", display: "Body height --lying" }, + "8310-5": { system: "http://loinc.org", code: "8310-5", display: "Body temperature" }, + "8462-4": { system: "http://loinc.org", code: "8462-4", display: "Diastolic blood pressure" }, + "8478-0": { system: "http://loinc.org", code: "8478-0", display: "Mean blood pressure" }, + "8480-6": { system: "http://loinc.org", code: "8480-6", display: "Systolic blood pressure" }, + "8867-4": { system: "http://loinc.org", code: "8867-4", display: "Heart rate" }, + "9279-1": { system: "http://loinc.org", code: "9279-1", display: "Respiratory rate" }, + "9843-4": { system: "http://loinc.org", code: "9843-4", display: "Head Occipital-frontal circumference" }, +} as const; +export const parseUSCoreVitalSignsProfile_code_binding = (input: unknown, fieldName?: string): USCoreVitalSignsProfile_code_binding => { + return parseLiteral(input, USCoreVitalSignsProfile_code_bindingCodes, fieldName); +} +export const parseUSCoreVitalSignsProfile_code_bindingCoding = (input: unknown, fieldName?: string) => { + return parseCoding(input, USCoreVitalSignsProfile_code_bindingConcepts, fieldName); +} + diff --git a/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/index.ts b/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/index.ts index 09303f50..29ba7f57 100644 --- a/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/index.ts +++ b/examples/typescript-us-core/fhir-types/hl7-fhir-us-core/index.ts @@ -1 +1,2 @@ export * from "./profiles"; +export * from "./bindings"; diff --git a/examples/typescript-us-core/fhir-types/profile-helpers.ts b/examples/typescript-us-core/fhir-types/profile-helpers.ts index 91cfb01f..5eec2ea3 100644 --- a/examples/typescript-us-core/fhir-types/profile-helpers.ts +++ b/examples/typescript-us-core/fhir-types/profile-helpers.ts @@ -1,8 +1,8 @@ /** - * Runtime helpers for generated FHIR profile classes. + * Runtime helpers for generated FHIR types and profile classes. * * This file is copied verbatim into every generated TypeScript output and - * imported by profile modules. It provides: + * imported by profile and binding modules. It provides: * * - **Slice helpers** – match, get, set, and default-fill array slices * defined by a FHIR StructureDefinition. @@ -12,6 +12,8 @@ * profile classes can expose a flat API. * - **Validation helpers** – lightweight structural checks that profile * classes call from their `validate()` method. + * - **Parse helpers** – validate / enrich values coming from external + * sources (CSV, HTTP form, untyped JSON) into typed FHIR values. * - **Misc utilities** – deep-match, deep-merge, path navigation. */ @@ -447,3 +449,92 @@ export const validateReference = (res: object, profileName: string, field: strin ? [] : [`${profileName}: field '${field}' references '${refType}' but only ${allowed.join(", ")} are allowed`]; }; + +// --------------------------------------------------------------------------- +// Parse helpers +// +// Each `parse*` validates an untyped value (typically string from CSV or HTTP +// form input) and returns a value of the typed FHIR shape. All throw an +// `Error` on failure; the message includes `fieldName` when provided so the +// call site can be located in stack traces. +// --------------------------------------------------------------------------- + +/** + * Validate that `input` is one of the literal values in `allowed`, returning + * it as the narrowed type. Throws when `input` is not in the set. + * + * @example + * parseLiteral(row.gender, ["male", "female", "other", "unknown"], "Patient.gender") + */ +export const parseLiteral = (input: unknown, allowed: readonly T[], fieldName?: string): T => { + if (typeof input === "string" && (allowed as readonly string[]).includes(input)) return input as T; + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid value ${JSON.stringify(input)}. Expected one of: ${allowed.join(", ")}`); +}; + +/** + * Look up `input` in a code → `{system, code, display}` table and return the + * corresponding FHIR Coding. Throws when the code is not in the table. + * + * Generated per-binding helpers wrap this with the binding's lookup table so + * callers only need to supply the code string. + * + * @example + * parseCoding(row.raceCode, USCoreOmbRaceCategoriesCodes, "Race.ombCategory") + */ +export const parseCoding = ( + input: unknown, + lookup: Readonly>, + fieldName?: string, +): { system?: string; code: T; display?: string } => { + if (typeof input === "string" && Object.hasOwn(lookup, input)) { + const concept = lookup[input]; + if (concept) return concept; + } + const where = fieldName ? `${fieldName}: ` : ""; + const allowed = Object.keys(lookup).join(", "); + throw new Error(`${where}invalid code ${JSON.stringify(input)}. Expected one of: ${allowed}`); +}; + +/** + * Coerce `input` into a boolean. Accepts `true`/`false`, `"true"`/`"false"`, + * `"1"`/`"0"` (case-insensitive). Throws on anything else. + */ +export const parseBoolean = (input: unknown, fieldName?: string): boolean => { + if (typeof input === "boolean") return input; + if (typeof input === "string") { + const v = input.trim().toLowerCase(); + if (v === "true" || v === "1") return true; + if (v === "false" || v === "0") return false; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid boolean ${JSON.stringify(input)}`); +}; + +/** + * Coerce `input` into a finite number. Accepts numbers and numeric strings. + * Throws on `NaN`, `Infinity`, or non-numeric input. + */ +export const parseNumber = (input: unknown, fieldName?: string): number => { + if (typeof input === "number" && Number.isFinite(input)) return input; + if (typeof input === "string" && input.trim() !== "") { + const n = Number(input); + if (Number.isFinite(n)) return n; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid number ${JSON.stringify(input)}`); +}; + +/** + * Validate that `input` is a FHIR `instant` string (ISO 8601 with timezone). + * Returns the original string on success; throws on malformed input. + */ +export const parseInstant = (input: unknown, fieldName?: string): string => { + if (typeof input === "string") { + // FHIR instant: YYYY-MM-DDTHH:MM:SS(.sss)?(Z|[+-]HH:MM) + const re = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/; + if (re.test(input) && !Number.isNaN(Date.parse(input))) return input; + } + const where = fieldName ? `${fieldName}: ` : ""; + throw new Error(`${where}invalid instant ${JSON.stringify(input)}`); +}; diff --git a/src/api/writer-generator/typescript/bindings.ts b/src/api/writer-generator/typescript/bindings.ts new file mode 100644 index 00000000..4c1b4afc --- /dev/null +++ b/src/api/writer-generator/typescript/bindings.ts @@ -0,0 +1,120 @@ +import { + type BindingTypeSchema, + isBindingSchema, + isChoiceDeclarationField, + isProfileTypeSchema, + type SpecializationTypeSchema, + type TypeSchema, +} from "@root/typeschema/types"; +import type { TypeSchemaIndex } from "@root/typeschema/utils"; +import { tsBindingName } from "./name"; +import type { TypeScript } from "./writer"; + +const collectBindingUrls = (schemas: TypeSchema[]): Set => { + const urls = new Set(); + const visit = (schema: { fields?: Record } | undefined) => { + if (!schema?.fields) return; + for (const field of Object.values(schema.fields)) { + if (!field || typeof field !== "object") continue; + if (isChoiceDeclarationField(field as never)) continue; + const f = field as { binding?: { url: string } }; + if (f.binding) urls.add(f.binding.url); + } + }; + for (const schema of schemas) { + if (isProfileTypeSchema(schema)) { + visit(schema); + } else { + const s = schema as SpecializationTypeSchema; + visit(s); + if (s.nested) for (const n of s.nested) visit(n); + } + } + return urls; +}; + +/** Bindings used by the given package's schemas, with concepts available. */ +export const collectBindingsForPackage = ( + tsIndex: TypeSchemaIndex, + packageSchemas: TypeSchema[], +): BindingTypeSchema[] => { + const usedUrls = collectBindingUrls(packageSchemas); + const allBindings = tsIndex.schemas.filter(isBindingSchema); + return allBindings + .filter((b) => usedUrls.has(b.identifier.url) && b.concepts && b.concepts.length > 0) + .sort((a, b) => a.identifier.name.localeCompare(b.identifier.name)); +}; + +const emitConceptsLookup = ( + w: TypeScript, + name: string, + type: string, + concepts: NonNullable, +) => { + const seen = new Set(); + w.curlyBlock([ + "export", + "const", + `${name}Concepts:`, + `Readonly>`, + "=", + ], () => { + for (const concept of concepts) { + if (seen.has(concept.code)) continue; + seen.add(concept.code); + const parts: string[] = []; + if (concept.system) parts.push(`system: ${JSON.stringify(concept.system)}`); + parts.push(`code: ${JSON.stringify(concept.code)}`); + if (concept.display) parts.push(`display: ${JSON.stringify(concept.display)}`); + const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(concept.code) ? concept.code : JSON.stringify(concept.code); + w.line(`${key}: { ${parts.join(", ")} },`); + } + }, [" as const;"]); +}; + +const emitBinding = (w: TypeScript, binding: BindingTypeSchema) => { + const name = tsBindingName(binding.identifier); + const concepts = binding.concepts; + if (!concepts || concepts.length === 0) return; + + // Deduplicate codes preserving first occurrence. + const seen = new Set(); + const codes: string[] = []; + for (const c of concepts) { + if (seen.has(c.code)) continue; + seen.add(c.code); + codes.push(c.code); + } + const valueSetUrl = binding.valueset?.url; + const strength = binding.strength; + const headerParts = [strength, valueSetUrl].filter(Boolean).join(" — "); + if (headerParts) w.comment(`${name}${headerParts ? ` (${headerParts})` : ""}`); + + // Codes array + literal type + w.lineSM(`export const ${name}Codes = [${codes.map((c) => JSON.stringify(c)).join(", ")}] as const`); + w.lineSM(`export type ${name} = (typeof ${name}Codes)[number]`); + + // Concepts lookup table + emitConceptsLookup(w, name, name, concepts); + + // Parse helpers + w.curlyBlock(["export", "const", `parse${name}`, "=", `(input: unknown, fieldName?: string): ${name} =>`], () => { + w.lineSM(`return parseLiteral(input, ${name}Codes, fieldName)`); + }); + + w.curlyBlock(["export", "const", `parse${name}Coding`, "=", "(input: unknown, fieldName?: string) =>"], () => { + w.lineSM(`return parseCoding(input, ${name}Concepts, fieldName)`); + }); + w.line(); +}; + +export const generateBindingsModule = (w: TypeScript, bindings: BindingTypeSchema[], helpersImportPath: string) => { + w.cat("bindings.ts", () => { + w.generateDisclaimer(); + w.tsImport(helpersImportPath, "parseLiteral", "parseCoding"); + w.line(); + for (const binding of bindings) { + emitBinding(w, binding); + } + }); +}; diff --git a/src/api/writer-generator/typescript/name.ts b/src/api/writer-generator/typescript/name.ts index 82661edb..d38b9e2d 100644 --- a/src/api/writer-generator/typescript/name.ts +++ b/src/api/writer-generator/typescript/name.ts @@ -107,3 +107,5 @@ export const tsExtensionFlatTypeName = (profileName: string, extensionName: stri export const tsSliceStaticName = (name: string): string => name.replace(/\[x\]/g, "").replace(/[^a-zA-Z0-9_$]/g, "_"); export const tsValueFieldName = (id: TypeIdentifier): string => `value${uppercaseFirstLetter(id.name)}`; + +export const tsBindingName = (id: TypeIdentifier): string => normalizeTsName(id.name); diff --git a/src/api/writer-generator/typescript/writer.ts b/src/api/writer-generator/typescript/writer.ts index 885d4c92..193a2543 100644 --- a/src/api/writer-generator/typescript/writer.ts +++ b/src/api/writer-generator/typescript/writer.ts @@ -19,6 +19,7 @@ import { type TypeSchema, } from "@root/typeschema/types"; import { groupByPackages, type TypeSchemaIndex } from "@root/typeschema/utils"; +import { collectBindingsForPackage, generateBindingsModule } from "./bindings"; import { tsFieldName, tsModuleFileName, @@ -102,12 +103,15 @@ export class TypeScript extends Writer { } } - generateFhirPackageIndexFile(schemas: TypeSchema[]) { + generateFhirPackageIndexFile(schemas: TypeSchema[], withBindings = false) { this.cat("index.ts", () => { const profiles = schemas.filter(isProfileTypeSchema); if (profiles.length > 0) { this.lineSM(`export * from "./profiles"`); } + if (withBindings) { + this.lineSM(`export * from "./bindings"`); + } let exports = schemas .flatMap((schema) => { @@ -385,9 +389,15 @@ export class TypeScript extends Writer { const grouped = groupByPackages(typesToGenerate); const hasProfiles = this.opts.generateProfile && typesToGenerate.some(isProfileTypeSchema); + const bindingsByPackage: Record> = {}; + for (const [pkg, schemas] of Object.entries(grouped)) { + const bindings = collectBindingsForPackage(tsIndex, schemas); + if (bindings.length > 0) bindingsByPackage[pkg] = bindings; + } + const hasBindings = Object.keys(bindingsByPackage).length > 0; this.cd("/", () => { - if (hasProfiles) { + if (hasProfiles || hasBindings) { this.cp("profile-helpers.ts", "profile-helpers.ts"); } @@ -398,7 +408,11 @@ export class TypeScript extends Writer { this.generateResourceModule(tsIndex, schema); } generateProfileIndexFile(this, tsIndex, packageSchemas.filter(isProfileTypeSchema)); - this.generateFhirPackageIndexFile(packageSchemas); + const packageBindings = bindingsByPackage[packageName]; + if (packageBindings) { + generateBindingsModule(this, packageBindings, "../profile-helpers"); + } + this.generateFhirPackageIndexFile(packageSchemas, packageBindings !== undefined); }); } }); diff --git a/src/typeschema/core/binding.ts b/src/typeschema/core/binding.ts index 2e120779..b4220a85 100644 --- a/src/typeschema/core/binding.ts +++ b/src/typeschema/core/binding.ts @@ -162,12 +162,21 @@ function generateBindingSchema( ); const enumResult = buildEnum(register, fhirSchema, element, logger); + const concepts = enumResult + ? extractValueSetConceptsByUrl( + register, + fhirSchema.package_meta, + element.binding.valueSet as CanonicalUrl, + logger, + )?.filter((c) => enumResult.values.includes(c.code)) + : undefined; return { identifier, valueset: valueSetIdentifier, strength: element.binding.strength, enum: enumResult, + concepts: concepts && concepts.length > 0 ? concepts : undefined, dependencies: [valueSetIdentifier], }; } diff --git a/src/typeschema/types.ts b/src/typeschema/types.ts index ea99121d..0b0e9cc7 100644 --- a/src/typeschema/types.ts +++ b/src/typeschema/types.ts @@ -397,6 +397,7 @@ export interface BindingTypeSchema { description?: string; strength?: string; enum?: EnumDefinition; + concepts?: Concept[]; valueset?: ValueSetIdentifier; dependencies?: TypeIdentifier[]; } diff --git a/test/api/write-generator/__snapshots__/introspection.test.ts.snap b/test/api/write-generator/__snapshots__/introspection.test.ts.snap index bacdd839..d8c18293 100644 --- a/test/api/write-generator/__snapshots__/introspection.test.ts.snap +++ b/test/api/write-generator/__snapshots__/introspection.test.ts.snap @@ -2603,8 +2603,8 @@ exports[`IntrospectionWriter - TypeSchema output Check all introspection data in {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},"description":"Base StructureDefinition for code type: A string which has at least one character and no leading or trailing whitespace and where there is no whitespace other than single spaces in the contents","base":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},"dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},"description":"Base StructureDefinition for string Type: A sequence of Unicode characters","base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} {"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IssueDetails","url":"urn:fhir:binding:IssueDetails"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"OperationOutcome","url":"http://hl7.org/fhir/ValueSet/operation-outcome"},"strength":"example","dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"OperationOutcome","url":"http://hl7.org/fhir/ValueSet/operation-outcome"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IssueSeverity","url":"urn:fhir:binding:IssueSeverity"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueSeverity","url":"http://hl7.org/fhir/ValueSet/issue-severity"},"strength":"required","enum":{"isOpen":false,"values":["fatal","error","warning","information"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueSeverity","url":"http://hl7.org/fhir/ValueSet/issue-severity"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IssueType","url":"urn:fhir:binding:IssueType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueType","url":"http://hl7.org/fhir/ValueSet/issue-type"},"strength":"required","enum":{"isOpen":false,"values":["invalid","structure","required","value","invariant","security","login","unknown","expired","forbidden","suppressed","processing","not-supported","duplicate","multiple-matches","not-found","deleted","too-long","code-invalid","extension","too-costly","business-rule","conflict","transient","lock-error","no-store","exception","timeout","incomplete","throttled","informational"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueType","url":"http://hl7.org/fhir/ValueSet/issue-type"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IssueSeverity","url":"urn:fhir:binding:IssueSeverity"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueSeverity","url":"http://hl7.org/fhir/ValueSet/issue-severity"},"strength":"required","enum":{"isOpen":false,"values":["fatal","error","warning","information"]},"concepts":[{"system":"http://hl7.org/fhir/issue-severity","code":"fatal","display":"Fatal"},{"system":"http://hl7.org/fhir/issue-severity","code":"error","display":"Error"},{"system":"http://hl7.org/fhir/issue-severity","code":"warning","display":"Warning"},{"system":"http://hl7.org/fhir/issue-severity","code":"information","display":"Information"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueSeverity","url":"http://hl7.org/fhir/ValueSet/issue-severity"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IssueType","url":"urn:fhir:binding:IssueType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueType","url":"http://hl7.org/fhir/ValueSet/issue-type"},"strength":"required","enum":{"isOpen":false,"values":["invalid","structure","required","value","invariant","security","login","unknown","expired","forbidden","suppressed","processing","not-supported","duplicate","multiple-matches","not-found","deleted","too-long","code-invalid","extension","too-costly","business-rule","conflict","transient","lock-error","no-store","exception","timeout","incomplete","throttled","informational"]},"concepts":[{"system":"http://hl7.org/fhir/issue-type","code":"invalid","display":"Invalid Content"},{"system":"http://hl7.org/fhir/issue-type","code":"structure","display":"Structural Issue"},{"system":"http://hl7.org/fhir/issue-type","code":"required","display":"Required element missing"},{"system":"http://hl7.org/fhir/issue-type","code":"value","display":"Element value invalid"},{"system":"http://hl7.org/fhir/issue-type","code":"invariant","display":"Validation rule failed"},{"system":"http://hl7.org/fhir/issue-type","code":"security","display":"Security Problem"},{"system":"http://hl7.org/fhir/issue-type","code":"login","display":"Login Required"},{"system":"http://hl7.org/fhir/issue-type","code":"unknown","display":"Unknown User"},{"system":"http://hl7.org/fhir/issue-type","code":"expired","display":"Session Expired"},{"system":"http://hl7.org/fhir/issue-type","code":"forbidden","display":"Forbidden"},{"system":"http://hl7.org/fhir/issue-type","code":"suppressed","display":"Information Suppressed"},{"system":"http://hl7.org/fhir/issue-type","code":"processing","display":"Processing Failure"},{"system":"http://hl7.org/fhir/issue-type","code":"not-supported","display":"Content not supported"},{"system":"http://hl7.org/fhir/issue-type","code":"duplicate","display":"Duplicate"},{"system":"http://hl7.org/fhir/issue-type","code":"multiple-matches","display":"Multiple Matches"},{"system":"http://hl7.org/fhir/issue-type","code":"not-found","display":"Not Found"},{"system":"http://hl7.org/fhir/issue-type","code":"deleted","display":"Deleted"},{"system":"http://hl7.org/fhir/issue-type","code":"too-long","display":"Content Too Long"},{"system":"http://hl7.org/fhir/issue-type","code":"code-invalid","display":"Invalid Code"},{"system":"http://hl7.org/fhir/issue-type","code":"extension","display":"Unacceptable Extension"},{"system":"http://hl7.org/fhir/issue-type","code":"too-costly","display":"Operation Too Costly"},{"system":"http://hl7.org/fhir/issue-type","code":"business-rule","display":"Business Rule Violation"},{"system":"http://hl7.org/fhir/issue-type","code":"conflict","display":"Edit Version Conflict"},{"system":"http://hl7.org/fhir/issue-type","code":"transient","display":"Transient Issue"},{"system":"http://hl7.org/fhir/issue-type","code":"lock-error","display":"Lock Error"},{"system":"http://hl7.org/fhir/issue-type","code":"no-store","display":"No Store Available"},{"system":"http://hl7.org/fhir/issue-type","code":"exception","display":"Exception"},{"system":"http://hl7.org/fhir/issue-type","code":"timeout","display":"Timeout"},{"system":"http://hl7.org/fhir/issue-type","code":"incomplete","display":"Incomplete Results"},{"system":"http://hl7.org/fhir/issue-type","code":"throttled","display":"Throttled"},{"system":"http://hl7.org/fhir/issue-type","code":"informational","display":"Informational Note"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IssueType","url":"http://hl7.org/fhir/ValueSet/issue-type"}]} {"identifier":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Narrative","url":"http://hl7.org/fhir/StructureDefinition/Narrative"},"base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"fields":{"status":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},"required":true,"excluded":false,"array":false,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"NarrativeStatus","url":"urn:fhir:binding:NarrativeStatus"},"enum":{"isOpen":false,"values":["generated","extensions","additional","empty"]}},"div":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"xhtml","url":"http://hl7.org/fhir/StructureDefinition/xhtml"},"required":true,"excluded":false,"array":false}},"description":"Base StructureDefinition for Narrative Type: A human-readable summary of the resource conveying the essential clinical and business information for the resource.","dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"xhtml","url":"http://hl7.org/fhir/StructureDefinition/xhtml"},{"kind":"binding","package":"shared","version":"1.0.0","name":"NarrativeStatus","url":"urn:fhir:binding:NarrativeStatus"}]} {"identifier":{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Resource","url":"http://hl7.org/fhir/StructureDefinition/Resource"},"fields":{"id":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},"required":false,"excluded":false,"array":false},"meta":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Meta","url":"http://hl7.org/fhir/StructureDefinition/Meta"},"required":false,"excluded":false,"array":false},"implicitRules":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},"required":false,"excluded":false,"array":false},"language":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},"required":false,"excluded":false,"array":false,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"Language","url":"urn:fhir:binding:Language"},"enum":{"isOpen":true,"values":["ar","bn","cs","da","de","de-AT","de-CH","de-DE","el","en","en-AU","en-CA","en-GB","en-IN","en-NZ","en-SG","en-US","es","es-AR","es-ES","es-UY","fi","fr","fr-BE","fr-CH","fr-FR","fy","fy-NL","hi","hr","it","it-CH","it-IT","ja","ko","nl","nl-BE","nl-NL","no","no-NO","pa","pl","pt","pt-BR","ru","ru-RU","sr","sr-RS","sv","sv-SE","te","zh","zh-CN","zh-HK","zh-SG","zh-TW"]}}},"description":"This is the base resource type for everything.","dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Meta","url":"http://hl7.org/fhir/StructureDefinition/Meta"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},{"kind":"binding","package":"shared","version":"1.0.0","name":"Language","url":"urn:fhir:binding:Language"}],"typeFamily":{"resources":[{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"DomainResource","url":"http://hl7.org/fhir/StructureDefinition/DomainResource"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Bundle","url":"http://hl7.org/fhir/StructureDefinition/Bundle"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"OperationOutcome","url":"http://hl7.org/fhir/StructureDefinition/OperationOutcome"}]}} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"decimal","url":"http://hl7.org/fhir/StructureDefinition/decimal"},"description":"Base StructureDefinition for decimal Type: A rational number with implicit precision","base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} @@ -2613,21 +2613,21 @@ exports[`IntrospectionWriter - TypeSchema output Check all introspection data in {"identifier":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Signature","url":"http://hl7.org/fhir/StructureDefinition/Signature"},"base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"fields":{"type":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Coding","url":"http://hl7.org/fhir/StructureDefinition/Coding"},"required":true,"excluded":false,"array":true,"min":1,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"SignatureType","url":"urn:fhir:binding:SignatureType"},"enum":{"isOpen":true,"values":["1.2.840.10065.1.12.1.1","1.2.840.10065.1.12.1.2","1.2.840.10065.1.12.1.3","1.2.840.10065.1.12.1.4","1.2.840.10065.1.12.1.5","1.2.840.10065.1.12.1.6","1.2.840.10065.1.12.1.7","1.2.840.10065.1.12.1.8","1.2.840.10065.1.12.1.9","1.2.840.10065.1.12.1.10","1.2.840.10065.1.12.1.11","1.2.840.10065.1.12.1.12","1.2.840.10065.1.12.1.13","1.2.840.10065.1.12.1.14","1.2.840.10065.1.12.1.15","1.2.840.10065.1.12.1.16","1.2.840.10065.1.12.1.17","1.2.840.10065.1.12.1.18"]}},"when":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"instant","url":"http://hl7.org/fhir/StructureDefinition/instant"},"required":true,"excluded":false,"array":false},"who":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Reference","url":"http://hl7.org/fhir/StructureDefinition/Reference"},"required":true,"excluded":false,"reference":[{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Device","url":"http://hl7.org/fhir/StructureDefinition/Device"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Organization","url":"http://hl7.org/fhir/StructureDefinition/Organization"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Patient","url":"http://hl7.org/fhir/StructureDefinition/Patient"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Practitioner","url":"http://hl7.org/fhir/StructureDefinition/Practitioner"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"PractitionerRole","url":"http://hl7.org/fhir/StructureDefinition/PractitionerRole"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"RelatedPerson","url":"http://hl7.org/fhir/StructureDefinition/RelatedPerson"}],"array":false},"onBehalfOf":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Reference","url":"http://hl7.org/fhir/StructureDefinition/Reference"},"required":false,"excluded":false,"reference":[{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Device","url":"http://hl7.org/fhir/StructureDefinition/Device"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Organization","url":"http://hl7.org/fhir/StructureDefinition/Organization"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Patient","url":"http://hl7.org/fhir/StructureDefinition/Patient"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Practitioner","url":"http://hl7.org/fhir/StructureDefinition/Practitioner"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"PractitionerRole","url":"http://hl7.org/fhir/StructureDefinition/PractitionerRole"},{"kind":"resource","package":"hl7.fhir.r4.core","version":"4.0.1","name":"RelatedPerson","url":"http://hl7.org/fhir/StructureDefinition/RelatedPerson"}],"array":false},"targetFormat":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},"required":false,"excluded":false,"array":false,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"MimeType","url":"urn:fhir:binding:MimeType"}},"sigFormat":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},"required":false,"excluded":false,"array":false,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"MimeType","url":"urn:fhir:binding:MimeType"}},"data":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"base64Binary","url":"http://hl7.org/fhir/StructureDefinition/base64Binary"},"required":false,"excluded":false,"array":false}},"description":"Base StructureDefinition for Signature Type: A signature along with supporting context. The signature may be a digital signature that is cryptographic in nature, or some other signature acceptable to the domain. This other signature may be as simple as a graphical image representing a hand-written signature, or a signature ceremony Different signature approaches have different utilities.","dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"base64Binary","url":"http://hl7.org/fhir/StructureDefinition/base64Binary"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"code","url":"http://hl7.org/fhir/StructureDefinition/code"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Coding","url":"http://hl7.org/fhir/StructureDefinition/Coding"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"instant","url":"http://hl7.org/fhir/StructureDefinition/instant"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Reference","url":"http://hl7.org/fhir/StructureDefinition/Reference"},{"kind":"binding","package":"shared","version":"1.0.0","name":"MimeType","url":"urn:fhir:binding:MimeType"},{"kind":"binding","package":"shared","version":"1.0.0","name":"SignatureType","url":"urn:fhir:binding:SignatureType"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"unsignedInt","url":"http://hl7.org/fhir/StructureDefinition/unsignedInt"},"description":"Base StructureDefinition for unsignedInt type: An integer with a value that is not negative (e.g. >= 0)","base":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"integer","url":"http://hl7.org/fhir/StructureDefinition/integer"},"dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"integer","url":"http://hl7.org/fhir/StructureDefinition/integer"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},"description":"Base StructureDefinition for uri Type: String of characters used to identify a name or a resource","base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"BundleType","url":"urn:fhir:binding:BundleType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"BundleType","url":"http://hl7.org/fhir/ValueSet/bundle-type"},"strength":"required","enum":{"isOpen":false,"values":["document","message","transaction","transaction-response","batch","batch-response","history","searchset","collection"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"BundleType","url":"http://hl7.org/fhir/ValueSet/bundle-type"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"HTTPVerb","url":"urn:fhir:binding:HTTPVerb"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"HttpVerb","url":"http://hl7.org/fhir/ValueSet/http-verb"},"strength":"required","enum":{"isOpen":false,"values":["GET","HEAD","POST","PUT","DELETE","PATCH"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"HttpVerb","url":"http://hl7.org/fhir/ValueSet/http-verb"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"SearchEntryMode","url":"urn:fhir:binding:SearchEntryMode"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SearchEntryMode","url":"http://hl7.org/fhir/ValueSet/search-entry-mode"},"strength":"required","enum":{"isOpen":false,"values":["match","include","outcome"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SearchEntryMode","url":"http://hl7.org/fhir/ValueSet/search-entry-mode"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"BundleType","url":"urn:fhir:binding:BundleType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"BundleType","url":"http://hl7.org/fhir/ValueSet/bundle-type"},"strength":"required","enum":{"isOpen":false,"values":["document","message","transaction","transaction-response","batch","batch-response","history","searchset","collection"]},"concepts":[{"system":"http://hl7.org/fhir/bundle-type","code":"document","display":"Document"},{"system":"http://hl7.org/fhir/bundle-type","code":"message","display":"Message"},{"system":"http://hl7.org/fhir/bundle-type","code":"transaction","display":"Transaction"},{"system":"http://hl7.org/fhir/bundle-type","code":"transaction-response","display":"Transaction Response"},{"system":"http://hl7.org/fhir/bundle-type","code":"batch","display":"Batch"},{"system":"http://hl7.org/fhir/bundle-type","code":"batch-response","display":"Batch Response"},{"system":"http://hl7.org/fhir/bundle-type","code":"history","display":"History List"},{"system":"http://hl7.org/fhir/bundle-type","code":"searchset","display":"Search Results"},{"system":"http://hl7.org/fhir/bundle-type","code":"collection","display":"Collection"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"BundleType","url":"http://hl7.org/fhir/ValueSet/bundle-type"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"HTTPVerb","url":"urn:fhir:binding:HTTPVerb"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"HttpVerb","url":"http://hl7.org/fhir/ValueSet/http-verb"},"strength":"required","enum":{"isOpen":false,"values":["GET","HEAD","POST","PUT","DELETE","PATCH"]},"concepts":[{"system":"http://hl7.org/fhir/http-verb","code":"GET","display":"GET"},{"system":"http://hl7.org/fhir/http-verb","code":"HEAD","display":"HEAD"},{"system":"http://hl7.org/fhir/http-verb","code":"POST","display":"POST"},{"system":"http://hl7.org/fhir/http-verb","code":"PUT","display":"PUT"},{"system":"http://hl7.org/fhir/http-verb","code":"DELETE","display":"DELETE"},{"system":"http://hl7.org/fhir/http-verb","code":"PATCH","display":"PATCH"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"HttpVerb","url":"http://hl7.org/fhir/ValueSet/http-verb"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"SearchEntryMode","url":"urn:fhir:binding:SearchEntryMode"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SearchEntryMode","url":"http://hl7.org/fhir/ValueSet/search-entry-mode"},"strength":"required","enum":{"isOpen":false,"values":["match","include","outcome"]},"concepts":[{"system":"http://hl7.org/fhir/search-entry-mode","code":"match","display":"Match"},{"system":"http://hl7.org/fhir/search-entry-mode","code":"include","display":"Include"},{"system":"http://hl7.org/fhir/search-entry-mode","code":"outcome","display":"Outcome"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SearchEntryMode","url":"http://hl7.org/fhir/ValueSet/search-entry-mode"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"boolean","url":"http://hl7.org/fhir/StructureDefinition/boolean"},"description":"Base StructureDefinition for boolean Type: Value of \\"true\\" or \\"false\\"","base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"xhtml","url":"http://hl7.org/fhir/StructureDefinition/xhtml"},"description":"Base StructureDefinition for xhtml Type","base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"NarrativeStatus","url":"urn:fhir:binding:NarrativeStatus"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"NarrativeStatus","url":"http://hl7.org/fhir/ValueSet/narrative-status"},"strength":"required","enum":{"isOpen":false,"values":["generated","extensions","additional","empty"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"NarrativeStatus","url":"http://hl7.org/fhir/ValueSet/narrative-status"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"NarrativeStatus","url":"urn:fhir:binding:NarrativeStatus"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"NarrativeStatus","url":"http://hl7.org/fhir/ValueSet/narrative-status"},"strength":"required","enum":{"isOpen":false,"values":["generated","extensions","additional","empty"]},"concepts":[{"system":"http://hl7.org/fhir/narrative-status","code":"generated","display":"Generated"},{"system":"http://hl7.org/fhir/narrative-status","code":"extensions","display":"Extensions"},{"system":"http://hl7.org/fhir/narrative-status","code":"additional","display":"Additional"},{"system":"http://hl7.org/fhir/narrative-status","code":"empty","display":"Empty"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"NarrativeStatus","url":"http://hl7.org/fhir/ValueSet/narrative-status"}]} {"identifier":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Meta","url":"http://hl7.org/fhir/StructureDefinition/Meta"},"base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"fields":{"versionId":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"id","url":"http://hl7.org/fhir/StructureDefinition/id"},"required":false,"excluded":false,"array":false},"lastUpdated":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"instant","url":"http://hl7.org/fhir/StructureDefinition/instant"},"required":false,"excluded":false,"array":false},"source":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},"required":false,"excluded":false,"array":false},"profile":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"canonical","url":"http://hl7.org/fhir/StructureDefinition/canonical"},"required":false,"excluded":false,"array":true},"security":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Coding","url":"http://hl7.org/fhir/StructureDefinition/Coding"},"required":false,"excluded":false,"array":true,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"SecurityLabels","url":"urn:fhir:binding:SecurityLabels"}},"tag":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Coding","url":"http://hl7.org/fhir/StructureDefinition/Coding"},"required":false,"excluded":false,"array":true,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"Tags","url":"urn:fhir:binding:Tags"}}},"description":"Base StructureDefinition for Meta Type: The metadata about a resource. This is content in the resource that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.","dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"canonical","url":"http://hl7.org/fhir/StructureDefinition/canonical"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Coding","url":"http://hl7.org/fhir/StructureDefinition/Coding"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"id","url":"http://hl7.org/fhir/StructureDefinition/id"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"instant","url":"http://hl7.org/fhir/StructureDefinition/instant"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},{"kind":"binding","package":"shared","version":"1.0.0","name":"SecurityLabels","url":"urn:fhir:binding:SecurityLabels"},{"kind":"binding","package":"shared","version":"1.0.0","name":"Tags","url":"urn:fhir:binding:Tags"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"Language","url":"urn:fhir:binding:Language"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Languages","url":"http://hl7.org/fhir/ValueSet/languages"},"strength":"preferred","enum":{"isOpen":true,"values":["ar","bn","cs","da","de","de-AT","de-CH","de-DE","el","en","en-AU","en-CA","en-GB","en-IN","en-NZ","en-SG","en-US","es","es-AR","es-ES","es-UY","fi","fr","fr-BE","fr-CH","fr-FR","fy","fy-NL","hi","hr","it","it-CH","it-IT","ja","ko","nl","nl-BE","nl-NL","no","no-NO","pa","pl","pt","pt-BR","ru","ru-RU","sr","sr-RS","sv","sv-SE","te","zh","zh-CN","zh-HK","zh-SG","zh-TW"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Languages","url":"http://hl7.org/fhir/ValueSet/languages"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"Language","url":"urn:fhir:binding:Language"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Languages","url":"http://hl7.org/fhir/ValueSet/languages"},"strength":"preferred","enum":{"isOpen":true,"values":["ar","bn","cs","da","de","de-AT","de-CH","de-DE","el","en","en-AU","en-CA","en-GB","en-IN","en-NZ","en-SG","en-US","es","es-AR","es-ES","es-UY","fi","fr","fr-BE","fr-CH","fr-FR","fy","fy-NL","hi","hr","it","it-CH","it-IT","ja","ko","nl","nl-BE","nl-NL","no","no-NO","pa","pl","pt","pt-BR","ru","ru-RU","sr","sr-RS","sv","sv-SE","te","zh","zh-CN","zh-HK","zh-SG","zh-TW"]},"concepts":[{"system":"urn:ietf:bcp:47","code":"ar","display":"Arabic"},{"system":"urn:ietf:bcp:47","code":"bn","display":"Bengali"},{"system":"urn:ietf:bcp:47","code":"cs","display":"Czech"},{"system":"urn:ietf:bcp:47","code":"da","display":"Danish"},{"system":"urn:ietf:bcp:47","code":"de","display":"German"},{"system":"urn:ietf:bcp:47","code":"de-AT","display":"German (Austria)"},{"system":"urn:ietf:bcp:47","code":"de-CH","display":"German (Switzerland)"},{"system":"urn:ietf:bcp:47","code":"de-DE","display":"German (Germany)"},{"system":"urn:ietf:bcp:47","code":"el","display":"Greek"},{"system":"urn:ietf:bcp:47","code":"en","display":"English"},{"system":"urn:ietf:bcp:47","code":"en-AU","display":"English (Australia)"},{"system":"urn:ietf:bcp:47","code":"en-CA","display":"English (Canada)"},{"system":"urn:ietf:bcp:47","code":"en-GB","display":"English (Great Britain)"},{"system":"urn:ietf:bcp:47","code":"en-IN","display":"English (India)"},{"system":"urn:ietf:bcp:47","code":"en-NZ","display":"English (New Zeland)"},{"system":"urn:ietf:bcp:47","code":"en-SG","display":"English (Singapore)"},{"system":"urn:ietf:bcp:47","code":"en-US","display":"English (United States)"},{"system":"urn:ietf:bcp:47","code":"es","display":"Spanish"},{"system":"urn:ietf:bcp:47","code":"es-AR","display":"Spanish (Argentina)"},{"system":"urn:ietf:bcp:47","code":"es-ES","display":"Spanish (Spain)"},{"system":"urn:ietf:bcp:47","code":"es-UY","display":"Spanish (Uruguay)"},{"system":"urn:ietf:bcp:47","code":"fi","display":"Finnish"},{"system":"urn:ietf:bcp:47","code":"fr","display":"French"},{"system":"urn:ietf:bcp:47","code":"fr-BE","display":"French (Belgium)"},{"system":"urn:ietf:bcp:47","code":"fr-CH","display":"French (Switzerland)"},{"system":"urn:ietf:bcp:47","code":"fr-FR","display":"French (France)"},{"system":"urn:ietf:bcp:47","code":"fy","display":"Frysian"},{"system":"urn:ietf:bcp:47","code":"fy-NL","display":"Frysian (Netherlands)"},{"system":"urn:ietf:bcp:47","code":"hi","display":"Hindi"},{"system":"urn:ietf:bcp:47","code":"hr","display":"Croatian"},{"system":"urn:ietf:bcp:47","code":"it","display":"Italian"},{"system":"urn:ietf:bcp:47","code":"it-CH","display":"Italian (Switzerland)"},{"system":"urn:ietf:bcp:47","code":"it-IT","display":"Italian (Italy)"},{"system":"urn:ietf:bcp:47","code":"ja","display":"Japanese"},{"system":"urn:ietf:bcp:47","code":"ko","display":"Korean"},{"system":"urn:ietf:bcp:47","code":"nl","display":"Dutch"},{"system":"urn:ietf:bcp:47","code":"nl-BE","display":"Dutch (Belgium)"},{"system":"urn:ietf:bcp:47","code":"nl-NL","display":"Dutch (Netherlands)"},{"system":"urn:ietf:bcp:47","code":"no","display":"Norwegian"},{"system":"urn:ietf:bcp:47","code":"no-NO","display":"Norwegian (Norway)"},{"system":"urn:ietf:bcp:47","code":"pa","display":"Punjabi"},{"system":"urn:ietf:bcp:47","code":"pl","display":"Polish"},{"system":"urn:ietf:bcp:47","code":"pt","display":"Portuguese"},{"system":"urn:ietf:bcp:47","code":"pt-BR","display":"Portuguese (Brazil)"},{"system":"urn:ietf:bcp:47","code":"ru","display":"Russian"},{"system":"urn:ietf:bcp:47","code":"ru-RU","display":"Russian (Russia)"},{"system":"urn:ietf:bcp:47","code":"sr","display":"Serbian"},{"system":"urn:ietf:bcp:47","code":"sr-RS","display":"Serbian (Serbia)"},{"system":"urn:ietf:bcp:47","code":"sv","display":"Swedish"},{"system":"urn:ietf:bcp:47","code":"sv-SE","display":"Swedish (Sweden)"},{"system":"urn:ietf:bcp:47","code":"te","display":"Telegu"},{"system":"urn:ietf:bcp:47","code":"zh","display":"Chinese"},{"system":"urn:ietf:bcp:47","code":"zh-CN","display":"Chinese (China)"},{"system":"urn:ietf:bcp:47","code":"zh-HK","display":"Chinese (Hong Kong)"},{"system":"urn:ietf:bcp:47","code":"zh-SG","display":"Chinese (Singapore)"},{"system":"urn:ietf:bcp:47","code":"zh-TW","display":"Chinese (Taiwan)"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Languages","url":"http://hl7.org/fhir/ValueSet/languages"}]} {"identifier":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Period","url":"http://hl7.org/fhir/StructureDefinition/Period"},"base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"fields":{"start":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"dateTime","url":"http://hl7.org/fhir/StructureDefinition/dateTime"},"required":false,"excluded":false,"array":false},"end":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"dateTime","url":"http://hl7.org/fhir/StructureDefinition/dateTime"},"required":false,"excluded":false,"array":false}},"description":"Base StructureDefinition for Period Type: A time period defined by a start and end date and optionally time.","dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"dateTime","url":"http://hl7.org/fhir/StructureDefinition/dateTime"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} {"identifier":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Reference","url":"http://hl7.org/fhir/StructureDefinition/Reference"},"base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"fields":{"reference":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},"required":false,"excluded":false,"array":false},"type":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},"required":false,"excluded":false,"array":false,"binding":{"kind":"binding","package":"shared","version":"1.0.0","name":"FHIRResourceTypeExt","url":"urn:fhir:binding:FHIRResourceTypeExt"}},"identifier":{"type":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Identifier","url":"http://hl7.org/fhir/StructureDefinition/Identifier"},"required":false,"excluded":false,"array":false},"display":{"type":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},"required":false,"excluded":false,"array":false}},"description":"Base StructureDefinition for Reference Type: A reference from one resource to another.","dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Identifier","url":"http://hl7.org/fhir/StructureDefinition/Identifier"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},{"kind":"binding","package":"shared","version":"1.0.0","name":"FHIRResourceTypeExt","url":"urn:fhir:binding:FHIRResourceTypeExt"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IdentifierType","url":"urn:fhir:binding:IdentifierType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierType","url":"http://hl7.org/fhir/ValueSet/identifier-type"},"strength":"extensible","enum":{"isOpen":true,"values":["DL","PPN","BRN","MR","MCN","EN","TAX","NIIP","PRN","MD","DR","ACSN","UDI","SNO","SB","PLAC","FILL","JHN"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierType","url":"http://hl7.org/fhir/ValueSet/identifier-type"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IdentifierUse","url":"urn:fhir:binding:IdentifierUse"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierUse","url":"http://hl7.org/fhir/ValueSet/identifier-use"},"strength":"required","enum":{"isOpen":false,"values":["usual","official","temp","secondary","old"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierUse","url":"http://hl7.org/fhir/ValueSet/identifier-use"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IdentifierType","url":"urn:fhir:binding:IdentifierType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierType","url":"http://hl7.org/fhir/ValueSet/identifier-type"},"strength":"extensible","enum":{"isOpen":true,"values":["DL","PPN","BRN","MR","MCN","EN","TAX","NIIP","PRN","MD","DR","ACSN","UDI","SNO","SB","PLAC","FILL","JHN"]},"concepts":[{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"DL"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"PPN"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"BRN"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"MR"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"MCN"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"EN"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"TAX"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"NIIP"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"PRN"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"MD"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"DR"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"ACSN"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"UDI"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"SNO"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"SB"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"PLAC"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"FILL"},{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"JHN"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierType","url":"http://hl7.org/fhir/ValueSet/identifier-type"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"IdentifierUse","url":"urn:fhir:binding:IdentifierUse"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierUse","url":"http://hl7.org/fhir/ValueSet/identifier-use"},"strength":"required","enum":{"isOpen":false,"values":["usual","official","temp","secondary","old"]},"concepts":[{"system":"http://hl7.org/fhir/identifier-use","code":"usual","display":"Usual"},{"system":"http://hl7.org/fhir/identifier-use","code":"official","display":"Official"},{"system":"http://hl7.org/fhir/identifier-use","code":"temp","display":"Temp"},{"system":"http://hl7.org/fhir/identifier-use","code":"secondary","display":"Secondary"},{"system":"http://hl7.org/fhir/identifier-use","code":"old","display":"Old"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"IdentifierUse","url":"http://hl7.org/fhir/ValueSet/identifier-use"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"base64Binary","url":"http://hl7.org/fhir/StructureDefinition/base64Binary"},"description":"Base StructureDefinition for base64Binary Type: A stream of bytes","base":{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"},"dependencies":[{"kind":"complex-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Element","url":"http://hl7.org/fhir/StructureDefinition/Element"}]} {"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"MimeType","url":"urn:fhir:binding:MimeType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Mimetypes","url":"http://hl7.org/fhir/ValueSet/mimetypes"},"strength":"required","dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"Mimetypes","url":"http://hl7.org/fhir/ValueSet/mimetypes"}]} -{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"SignatureType","url":"urn:fhir:binding:SignatureType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SignatureType","url":"http://hl7.org/fhir/ValueSet/signature-type"},"strength":"preferred","enum":{"isOpen":true,"values":["1.2.840.10065.1.12.1.1","1.2.840.10065.1.12.1.2","1.2.840.10065.1.12.1.3","1.2.840.10065.1.12.1.4","1.2.840.10065.1.12.1.5","1.2.840.10065.1.12.1.6","1.2.840.10065.1.12.1.7","1.2.840.10065.1.12.1.8","1.2.840.10065.1.12.1.9","1.2.840.10065.1.12.1.10","1.2.840.10065.1.12.1.11","1.2.840.10065.1.12.1.12","1.2.840.10065.1.12.1.13","1.2.840.10065.1.12.1.14","1.2.840.10065.1.12.1.15","1.2.840.10065.1.12.1.16","1.2.840.10065.1.12.1.17","1.2.840.10065.1.12.1.18"]},"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SignatureType","url":"http://hl7.org/fhir/ValueSet/signature-type"}]} +{"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"SignatureType","url":"urn:fhir:binding:SignatureType"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SignatureType","url":"http://hl7.org/fhir/ValueSet/signature-type"},"strength":"preferred","enum":{"isOpen":true,"values":["1.2.840.10065.1.12.1.1","1.2.840.10065.1.12.1.2","1.2.840.10065.1.12.1.3","1.2.840.10065.1.12.1.4","1.2.840.10065.1.12.1.5","1.2.840.10065.1.12.1.6","1.2.840.10065.1.12.1.7","1.2.840.10065.1.12.1.8","1.2.840.10065.1.12.1.9","1.2.840.10065.1.12.1.10","1.2.840.10065.1.12.1.11","1.2.840.10065.1.12.1.12","1.2.840.10065.1.12.1.13","1.2.840.10065.1.12.1.14","1.2.840.10065.1.12.1.15","1.2.840.10065.1.12.1.16","1.2.840.10065.1.12.1.17","1.2.840.10065.1.12.1.18"]},"concepts":[{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.1","display":"Author's Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.2","display":"Coauthor's Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.3","display":"Co-participant's Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.4","display":"Transcriptionist/Recorder Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.5","display":"Verification Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.6","display":"Validation Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.7","display":"Consent Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.8","display":"Signature Witness Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.9","display":"Event Witness Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.10","display":"Identity Witness Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.11","display":"Consent Witness Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.12","display":"Interpreter Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.13","display":"Review Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.14","display":"Source Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.15","display":"Addendum Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.16","display":"Modification Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.17","display":"Administrative (Error/Edit) Signature"},{"system":"urn:iso-astm:E1762-95:2013","code":"1.2.840.10065.1.12.1.18","display":"Timestamp Signature"}],"dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SignatureType","url":"http://hl7.org/fhir/ValueSet/signature-type"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"canonical","url":"http://hl7.org/fhir/StructureDefinition/canonical"},"description":"Base StructureDefinition for canonical type: A URI that is a reference to a canonical URL on a FHIR resource","base":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"},"dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"uri","url":"http://hl7.org/fhir/StructureDefinition/uri"}]} {"identifier":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"id","url":"http://hl7.org/fhir/StructureDefinition/id"},"description":"Base StructureDefinition for id type: Any combination of letters, numerals, \\"-\\" and \\".\\", with a length limit of 64 characters. (This might be an integer, an unprefixed OID, UUID or any other identifier pattern that meets these constraints.) Ids are case-insensitive.","base":{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"},"dependencies":[{"kind":"primitive-type","package":"hl7.fhir.r4.core","version":"4.0.1","name":"string","url":"http://hl7.org/fhir/StructureDefinition/string"}]} {"identifier":{"kind":"binding","package":"shared","version":"1.0.0","name":"SecurityLabels","url":"urn:fhir:binding:SecurityLabels"},"valueset":{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SecurityLabels","url":"http://hl7.org/fhir/ValueSet/security-labels"},"strength":"extensible","dependencies":[{"kind":"value-set","package":"hl7.fhir.r4.core","version":"4.0.1","name":"SecurityLabels","url":"http://hl7.org/fhir/ValueSet/security-labels"}]} diff --git a/test/api/write-generator/__snapshots__/typescript.test.ts.snap b/test/api/write-generator/__snapshots__/typescript.test.ts.snap index d6aec051..8b442ede 100644 --- a/test/api/write-generator/__snapshots__/typescript.test.ts.snap +++ b/test/api/write-generator/__snapshots__/typescript.test.ts.snap @@ -289,6 +289,7 @@ export interface CV extends CE { exports[`TypeScript CDA with Logical Model Promotion to Resource without resourceType 2`] = ` "export * from "./profiles"; +export * from "./bindings"; export type { Act } from "./Act"; export type { AD, ADItem } from "./AD"; export type { ADXP } from "./ADXP"; diff --git a/test/api/write-generator/multi-package/cda.test.ts b/test/api/write-generator/multi-package/cda.test.ts index cb4c73aa..2a7b3cf1 100644 --- a/test/api/write-generator/multi-package/cda.test.ts +++ b/test/api/write-generator/multi-package/cda.test.ts @@ -39,7 +39,7 @@ describe("CDA", async () => { it("should generate CDA-specific types", () => { const files = Object.keys(result.filesGenerated.typescript!); const cdaFiles = files.filter((f) => f.includes("hl7-cda-uv-core")); - expect(cdaFiles.length).toBe(124); + expect(cdaFiles.length).toBe(125); expect(files.some((f) => f.includes("/AD.ts") || f.includes("/CD.ts"))).toBeTrue(); }); diff --git a/test/api/write-generator/multi-package/sql-on-fhir.test.ts b/test/api/write-generator/multi-package/sql-on-fhir.test.ts index 0c2bd722..3377409c 100644 --- a/test/api/write-generator/multi-package/sql-on-fhir.test.ts +++ b/test/api/write-generator/multi-package/sql-on-fhir.test.ts @@ -40,7 +40,7 @@ describe("SQL-on-FHIR", async () => { it("should resolve R5 dependencies (required by SQL-on-FHIR)", () => { const files = Object.keys(result.filesGenerated.typescript!); const r5Files = files.filter((f) => f.includes("hl7-fhir-r5-core")); - expect(r5Files.length).toBe(45); + expect(r5Files.length).toBe(46); // Core R5 types should be included expect(result.filesGenerated.typescript!["generated/types/hl7-fhir-r5-core/Element.ts"]).toBeDefined(); diff --git a/test/api/write-generator/typescript.test.ts b/test/api/write-generator/typescript.test.ts index cd51945e..ce9b1034 100644 --- a/test/api/write-generator/typescript.test.ts +++ b/test/api/write-generator/typescript.test.ts @@ -11,7 +11,7 @@ describe("TypeScript Writer Generator", async () => { .generate(); expect(result.success).toBeTrue(); const files = result.filesGenerated.typescript!; - expect(Object.keys(files).length).toEqual(608); + expect(Object.keys(files).length).toEqual(609); it("generates Patient resource in inMemoryOnly mode with snapshot", async () => { expect(files["generated/types/hl7-fhir-r4-core/Patient.ts"]).toMatchSnapshot(); }); @@ -54,6 +54,26 @@ describe("TypeScript Writer Generator", async () => { expect(domainResourceTs).toContain("export interface DomainResource"); expect(domainResourceTs).toContain("contained?: T[]"); }); + it("emits bindings.ts with parse helpers for AdministrativeGender", () => { + const bindingsTs = files["generated/types/hl7-fhir-r4-core/bindings.ts"]; + expect(bindingsTs).toBeDefined(); + expect(bindingsTs).toContain( + 'export const AdministrativeGenderCodes = ["male", "female", "other", "unknown"] as const', + ); + expect(bindingsTs).toContain("export type AdministrativeGender = (typeof AdministrativeGenderCodes)[number]"); + expect(bindingsTs).toContain( + 'male: { system: "http://hl7.org/fhir/administrative-gender", code: "male", display: "Male" }', + ); + expect(bindingsTs).toContain("export const parseAdministrativeGender = (input: unknown"); + expect(bindingsTs).toContain("export const parseAdministrativeGenderCoding = (input: unknown"); + }); + it("re-exports bindings from package index", () => { + const indexTs = files["generated/types/hl7-fhir-r4-core/index.ts"]; + expect(indexTs).toContain('export * from "./bindings"'); + }); + it("copies profile-helpers.ts when bindings are emitted", () => { + expect(files["generated/types/profile-helpers.ts"]).toBeDefined(); + }); }); describe("TypeScript CDA with Logical Model Promotion to Resource", async () => { diff --git a/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap b/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap index bf7645ce..43b03c2b 100644 --- a/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap +++ b/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap @@ -380,6 +380,28 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with code 1`] = ` "unknown" ] }, + "concepts": [ + { + "system": "http://hl7.org/fhir/administrative-gender", + "code": "male", + "display": "Male" + }, + { + "system": "http://hl7.org/fhir/administrative-gender", + "code": "female", + "display": "Female" + }, + { + "system": "http://hl7.org/fhir/administrative-gender", + "code": "other", + "display": "Other" + }, + { + "system": "http://hl7.org/fhir/administrative-gender", + "code": "unknown", + "display": "Unknown" + } + ], "dependencies": [ { "kind": "value-set", @@ -504,6 +526,62 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with codable concep "UNK" ] }, + "concepts": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "A", + "display": "Annulled" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "D", + "display": "Divorced" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "I", + "display": "Interlocutory" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "L", + "display": "Legally Separated" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "M", + "display": "Married" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "P", + "display": "Polygamous" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "S", + "display": "Never Married" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "T", + "display": "Domestic partner" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "U", + "display": "unmarried" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", + "code": "W", + "display": "Widowed" + }, + { + "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor", + "code": "UNK" + } + ], "dependencies": [ { "kind": "value-set", @@ -1244,6 +1322,68 @@ exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification "entered-in-error" ] }, + "concepts": [ + { + "system": "http://hl7.org/fhir/task-status", + "code": "draft", + "display": "Draft" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "requested", + "display": "Requested" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "received", + "display": "Received" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "accepted", + "display": "Accepted" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "rejected", + "display": "Rejected" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "ready", + "display": "Ready" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "cancelled", + "display": "Cancelled" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "in-progress", + "display": "In Progress" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "on-hold", + "display": "On Hold" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "failed", + "display": "Failed" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "completed", + "display": "Completed" + }, + { + "system": "http://hl7.org/fhir/task-status", + "code": "entered-in-error", + "display": "Entered in Error" + } + ], "dependencies": [ { "kind": "value-set", @@ -1282,6 +1422,43 @@ exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification "other" ] }, + "concepts": [ + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "phone", + "display": "Phone" + }, + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "fax", + "display": "Fax" + }, + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "email", + "display": "Email" + }, + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "pager", + "display": "Pager" + }, + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "url", + "display": "URL" + }, + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "sms", + "display": "SMS" + }, + { + "system": "http://hl7.org/fhir/contact-point-system", + "code": "other", + "display": "Other" + } + ], "dependencies": [ { "kind": "value-set", diff --git a/test/unit/typeschema/transformer/binding.test.ts b/test/unit/typeschema/transformer/binding.test.ts index aa779448..93d0df7d 100644 --- a/test/unit/typeschema/transformer/binding.test.ts +++ b/test/unit/typeschema/transformer/binding.test.ts @@ -74,6 +74,12 @@ describe("Type Schema generator > Binding", async () => { }, ], enum: { values: ["male", "female", "other", "unknown"], isOpen: false }, + concepts: [ + { code: "male", display: "Male", system: "http://hl7.org/fhir/administrative-gender" }, + { code: "female", display: "Female", system: "http://hl7.org/fhir/administrative-gender" }, + { code: "other", display: "Other", system: "http://hl7.org/fhir/administrative-gender" }, + { code: "unknown", display: "Unknown", system: "http://hl7.org/fhir/administrative-gender" }, + ], strength: "required", valueset: {