diff --git a/examples/typescript-r4/README.md b/examples/typescript-r4/README.md index f0f1670dc..d0cd154b0 100644 --- a/examples/typescript-r4/README.md +++ b/examples/typescript-r4/README.md @@ -104,7 +104,7 @@ const baseObservation: Observation = { // Use profile class to add required slices const profile = new bodyweightProfile(baseObservation) - .setVscat({ text: 'Vital Signs' }); + .setVSCat({ text: 'Vital Signs' }); const observation = profile.toResource(); ``` diff --git a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bodyweight.ts b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bodyweight.ts index f74b3b374..525fae454 100644 --- a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bodyweight.ts +++ b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bodyweight.ts @@ -127,7 +127,7 @@ export class observation_bodyweightProfile { return this.resource as observation_bodyweight } - public setVscat (input?: Observation_bodyweight_Category_VSCatSliceInput): this { + public setVSCat (input?: Observation_bodyweight_Category_VSCatSliceInput): this { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as CodeableConcept const list = (this.resource.category ??= []) @@ -140,7 +140,7 @@ export class observation_bodyweightProfile { return this } - public getVscat (): Observation_bodyweight_Category_VSCatSliceInput | undefined { + public getVSCat (): Observation_bodyweight_Category_VSCatSliceInput | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -149,7 +149,7 @@ export class observation_bodyweightProfile { return extractSliceSimplified(item as unknown as Record, ["coding"]) as Observation_bodyweight_Category_VSCatSliceInput } - public getVscatRaw (): CodeableConcept | undefined { + public getVSCatRaw (): CodeableConcept | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined diff --git a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bp.ts b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bp.ts index 43aa12a2a..571250e7c 100644 --- a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bp.ts +++ b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_bp.ts @@ -140,7 +140,7 @@ export class observation_bpProfile { return this.resource as observation_bp } - public setVscat (input?: Observation_bp_Category_VSCatSliceInput): this { + public setVSCat (input?: Observation_bp_Category_VSCatSliceInput): this { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as CodeableConcept const list = (this.resource.category ??= []) @@ -153,7 +153,7 @@ export class observation_bpProfile { return this } - public setSystolicBp (input?: Observation_bp_Component_SystolicBPSliceInput): this { + public setSystolicBP (input?: Observation_bp_Component_SystolicBPSliceInput): this { const match = {"code":{"coding":{"code":"8480-6","system":"http://loinc.org"}}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as ObservationComponent const list = (this.resource.component ??= []) @@ -166,7 +166,7 @@ export class observation_bpProfile { return this } - public setDiastolicBp (input?: Observation_bp_Component_DiastolicBPSliceInput): this { + public setDiastolicBP (input?: Observation_bp_Component_DiastolicBPSliceInput): this { const match = {"code":{"coding":{"code":"8462-4","system":"http://loinc.org"}}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as ObservationComponent const list = (this.resource.component ??= []) @@ -179,7 +179,7 @@ export class observation_bpProfile { return this } - public getVscat (): Observation_bp_Category_VSCatSliceInput | undefined { + public getVSCat (): Observation_bp_Category_VSCatSliceInput | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -188,7 +188,7 @@ export class observation_bpProfile { return extractSliceSimplified(item as unknown as Record, ["coding"]) as Observation_bp_Category_VSCatSliceInput } - public getVscatRaw (): CodeableConcept | undefined { + public getVSCatRaw (): CodeableConcept | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -196,7 +196,7 @@ export class observation_bpProfile { return item } - public getSystolicBp (): Observation_bp_Component_SystolicBPSliceInput | undefined { + public getSystolicBP (): Observation_bp_Component_SystolicBPSliceInput | undefined { const match = {"code":{"coding":{"code":"8480-6","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined @@ -205,7 +205,7 @@ export class observation_bpProfile { return extractSliceSimplified(item as unknown as Record, ["code"]) as Observation_bp_Component_SystolicBPSliceInput } - public getSystolicBpRaw (): ObservationComponent | undefined { + public getSystolicBPRaw (): ObservationComponent | undefined { const match = {"code":{"coding":{"code":"8480-6","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined @@ -213,7 +213,7 @@ export class observation_bpProfile { return item } - public getDiastolicBp (): Observation_bp_Component_DiastolicBPSliceInput | undefined { + public getDiastolicBP (): Observation_bp_Component_DiastolicBPSliceInput | undefined { const match = {"code":{"coding":{"code":"8462-4","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined @@ -222,7 +222,7 @@ export class observation_bpProfile { return extractSliceSimplified(item as unknown as Record, ["code"]) as Observation_bp_Component_DiastolicBPSliceInput } - public getDiastolicBpRaw (): ObservationComponent | undefined { + public getDiastolicBPRaw (): ObservationComponent | undefined { const match = {"code":{"coding":{"code":"8462-4","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined diff --git a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_vitalsigns.ts b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_vitalsigns.ts index bf5e9c9ee..4bb7c72e0 100644 --- a/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_vitalsigns.ts +++ b/examples/typescript-r4/fhir-types/hl7-fhir-r4-core/profiles/Observation_observation_vitalsigns.ts @@ -118,7 +118,7 @@ export class observation_vitalsignsProfile { return this.resource as observation_vitalsigns } - public setVscat (input?: Observation_vitalsigns_Category_VSCatSliceInput): this { + public setVSCat (input?: Observation_vitalsigns_Category_VSCatSliceInput): this { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as CodeableConcept const list = (this.resource.category ??= []) @@ -131,7 +131,7 @@ export class observation_vitalsignsProfile { return this } - public getVscat (): Observation_vitalsigns_Category_VSCatSliceInput | undefined { + public getVSCat (): Observation_vitalsigns_Category_VSCatSliceInput | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -140,7 +140,7 @@ export class observation_vitalsignsProfile { return extractSliceSimplified(item as unknown as Record, ["coding"]) as Observation_vitalsigns_Category_VSCatSliceInput } - public getVscatRaw (): CodeableConcept | undefined { + public getVSCatRaw (): CodeableConcept | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined diff --git a/examples/typescript-r4/profile-bodyweight.test.ts b/examples/typescript-r4/profile-bodyweight.test.ts index 79cacb5ce..15c95eb20 100644 --- a/examples/typescript-r4/profile-bodyweight.test.ts +++ b/examples/typescript-r4/profile-bodyweight.test.ts @@ -117,22 +117,22 @@ describe("bodyweight profile slice accessors", () => { subject: { reference: "Patient/pt-1" }, }); - test("getVscat returns empty simplified view from auto-populated stub", () => { + test("getVSCat returns empty simplified view from auto-populated stub", () => { // category is auto-populated with VSCat discriminator match - expect(profile.getVscatRaw()).toBeDefined(); - const raw = profile.getVscatRaw()!; + expect(profile.getVSCatRaw()).toBeDefined(); + const raw = profile.getVSCatRaw()!; expect(raw.coding as unknown).toEqual({ code: "vital-signs", system: "http://terminology.hl7.org/CodeSystem/observation-category", }); // simplified view strips discriminator keys, leaving empty object - expect(profile.getVscat()).toEqual({}); + expect(profile.getVSCat()).toEqual({}); }); - test("setVscat adds category with discriminator values", () => { - profile.setVscat({ text: "Vital Signs" }); + test("setVSCat adds category with discriminator values", () => { + profile.setVSCat({ text: "Vital Signs" }); - const raw = profile.getVscatRaw()!; + const raw = profile.getVSCatRaw()!; expect(raw.text).toBe("Vital Signs"); expect(raw.coding as unknown).toEqual({ code: "vital-signs", @@ -140,22 +140,22 @@ describe("bodyweight profile slice accessors", () => { }); }); - test("getVscat returns simplified view without discriminator", () => { - const simplified = profile.getVscat(); + test("getVSCat returns simplified view without discriminator", () => { + const simplified = profile.getVSCat(); expect(simplified).toEqual({ text: "Vital Signs" }); expect("coding" in simplified!).toBe(false); }); - test("getVscatRaw returns full element including discriminator", () => { - const raw = profile.getVscatRaw()!; + test("getVSCatRaw returns full element including discriminator", () => { + const raw = profile.getVSCatRaw()!; expect(raw.text).toBe("Vital Signs"); expect(raw.coding).toBeDefined(); }); - test("setVscat replaces existing slice element", () => { - profile.setVscat({ text: "Updated" }); + test("setVSCat replaces existing slice element", () => { + profile.setVSCat({ text: "Updated" }); - expect(profile.getVscat()!.text).toBe("Updated"); + expect(profile.getVSCat()!.text).toBe("Updated"); expect(profile.toResource().category!.length).toBe(1); }); }); @@ -228,7 +228,7 @@ describe("bodyweight profile mutability", () => { profile.setStatus("amended"); expect(obs.status).toBe("amended"); - profile.setVscat({ text: "Vital Signs" }); + profile.setVSCat({ text: "Vital Signs" }); expect(obs.category!.length).toBe(1); }); }); diff --git a/examples/typescript-r4/profile-bp.test.ts b/examples/typescript-r4/profile-bp.test.ts index 480ac8e6e..6f6afed5b 100644 --- a/examples/typescript-r4/profile-bp.test.ts +++ b/examples/typescript-r4/profile-bp.test.ts @@ -39,35 +39,35 @@ describe("blood pressure profile", () => { const obs = fresh.toResource(); expect(obs.component).toHaveLength(2); // stubs contain only discriminator match values - expect(fresh.getSystolicBpRaw()).toBeDefined(); - expect(fresh.getDiastolicBpRaw()).toBeDefined(); + expect(fresh.getSystolicBPRaw()).toBeDefined(); + expect(fresh.getDiastolicBPRaw()).toBeDefined(); }); - test("setSystolicBp / getSystolicBp / getSystolicBpRaw", () => { - profile.setSystolicBp({ + test("setSystolicBP / getSystolicBP / getSystolicBPRaw", () => { + profile.setSystolicBP({ valueQuantity: { value: 120, unit: "mmHg", system: "http://unitsofmeasure.org", code: "mm[Hg]" }, }); - expect(profile.getSystolicBp()).toEqual({ + expect(profile.getSystolicBP()).toEqual({ valueQuantity: { value: 120, unit: "mmHg", system: "http://unitsofmeasure.org", code: "mm[Hg]" }, }); - expect(profile.getSystolicBpRaw() as unknown).toEqual({ + expect(profile.getSystolicBPRaw() as unknown).toEqual({ valueQuantity: { value: 120, unit: "mmHg", system: "http://unitsofmeasure.org", code: "mm[Hg]" }, code: { coding: { code: "8480-6", system: "http://loinc.org" } }, }); }); - test("setDiastolicBp / getDiastolicBp / getDiastolicBpRaw", () => { - profile.setDiastolicBp({ + test("setDiastolicBP / getDiastolicBP / getDiastolicBPRaw", () => { + profile.setDiastolicBP({ valueQuantity: { value: 80, unit: "mmHg", system: "http://unitsofmeasure.org", code: "mm[Hg]" }, }); - expect(profile.getDiastolicBp()).toEqual({ + expect(profile.getDiastolicBP()).toEqual({ valueQuantity: { value: 80, unit: "mmHg", system: "http://unitsofmeasure.org", code: "mm[Hg]" }, }); - expect(profile.getDiastolicBpRaw() as unknown).toEqual({ + expect(profile.getDiastolicBPRaw() as unknown).toEqual({ valueQuantity: { value: 80, unit: "mmHg", system: "http://unitsofmeasure.org", code: "mm[Hg]" }, code: { coding: { code: "8462-4", system: "http://loinc.org" } }, }); @@ -78,25 +78,25 @@ describe("blood pressure profile", () => { // auto-populated stubs + set values = still 2 items (set replaces stubs) expect(obs.component).toHaveLength(2); - const systolicCode = profile.getSystolicBpRaw()!.code as Record; - const diastolicCode = profile.getDiastolicBpRaw()!.code as Record; + const systolicCode = profile.getSystolicBPRaw()!.code as Record; + const diastolicCode = profile.getDiastolicBPRaw()!.code as Record; expect(systolicCode.coding).toEqual({ code: "8480-6", system: "http://loinc.org" }); expect(diastolicCode.coding).toEqual({ code: "8462-4", system: "http://loinc.org" }); - expect(profile.getSystolicBpRaw()!.valueQuantity!.value).toBe(120); - expect(profile.getDiastolicBpRaw()!.valueQuantity!.value).toBe(80); + expect(profile.getSystolicBPRaw()!.valueQuantity!.value).toBe(120); + expect(profile.getDiastolicBPRaw()!.valueQuantity!.value).toBe(80); }); - test("setSystolicBp replaces an existing systolic component", () => { - profile.setSystolicBp({ valueQuantity: { value: 130, unit: "mmHg" } }); + test("setSystolicBP replaces an existing systolic component", () => { + profile.setSystolicBP({ valueQuantity: { value: 130, unit: "mmHg" } }); expect(profile.toResource().component).toHaveLength(2); - expect(profile.getSystolicBpRaw()!.valueQuantity!.value).toBe(130); + expect(profile.getSystolicBPRaw()!.valueQuantity!.value).toBe(130); }); - test("setVscat adds category with discriminator values", () => { - profile.setVscat({ text: "Vital Signs" }); + test("setVSCat adds category with discriminator values", () => { + profile.setVSCat({ text: "Vital Signs" }); - const raw = profile.getVscatRaw()!; + const raw = profile.getVSCatRaw()!; expect(raw.text).toBe("Vital Signs"); expect(raw.coding as unknown).toEqual({ code: "vital-signs", @@ -113,26 +113,26 @@ describe("blood pressure profile", () => { test("fluent chaining across all accessor types", () => { const result = profile .setStatus("final") - .setVscat({ text: "Vital Signs" }) + .setVSCat({ text: "Vital Signs" }) .setEffectiveDateTime("2024-06-15") .setSubject({ reference: "Patient/pt-2" }) - .setSystolicBp({ valueQuantity: { value: 120, unit: "mmHg" } }) - .setDiastolicBp({ valueQuantity: { value: 80, unit: "mmHg" } }); + .setSystolicBP({ valueQuantity: { value: 120, unit: "mmHg" } }) + .setDiastolicBP({ valueQuantity: { value: 80, unit: "mmHg" } }); expect(result).toBe(profile); expect(profile.getStatus()).toBe("final"); - expect(profile.getVscat()!.text).toBe("Vital Signs"); + expect(profile.getVSCat()!.text).toBe("Vital Signs"); expect(profile.getEffectiveDateTime()).toBe("2024-06-15"); expect(profile.getSubject()!.reference).toBe("Patient/pt-2"); - expect(profile.getSystolicBpRaw()!.valueQuantity!.value).toBe(120); - expect(profile.getDiastolicBpRaw()!.valueQuantity!.value).toBe(80); + expect(profile.getSystolicBPRaw()!.valueQuantity!.value).toBe(120); + expect(profile.getDiastolicBPRaw()!.valueQuantity!.value).toBe(80); }); - test("setSystolicBp with no args inserts discriminator-only component", () => { + test("setSystolicBP with no args inserts discriminator-only component", () => { const fresh = createBp(); - fresh.setSystolicBp(); + fresh.setSystolicBP(); - const raw = fresh.getSystolicBpRaw()!; + const raw = fresh.getSystolicBPRaw()!; const rawCode = raw.code as Record; expect(rawCode.coding).toEqual({ code: "8480-6", system: "http://loinc.org" }); expect(raw.valueQuantity).toBeUndefined(); diff --git a/src/api/writer-generator/typescript/name.ts b/src/api/writer-generator/typescript/name.ts index 6c07341d5..71d9fdeb5 100644 --- a/src/api/writer-generator/typescript/name.ts +++ b/src/api/writer-generator/typescript/name.ts @@ -15,7 +15,7 @@ import type { TypeSchemaIndex } from "@root/typeschema/utils"; // biome-ignore format: too long const tsKeywords = new Set([ "class", "function", "return", "if", "for", "while", "const", "let", "var", "import", "export", "interface" ]); -const normalizeTsName = (n: string): string => { +export const normalizeTsName = (n: string): string => { if (tsKeywords.has(n)) n = `${n}_`; return n.replace(/\[x\]/g, "_x_").replace(/[- :.]/g, "_"); }; @@ -100,8 +100,7 @@ export const tsExtensionInputTypeName = (profileName: string, extensionName: str }; export const tsSliceMethodName = (sliceName: string): string => { - const normalized = tsCamelCase(sliceName); - return `set${uppercaseFirstLetter(normalized || "Slice")}`; + return `set${uppercaseFirstLetter(normalizeTsName(sliceName) || "Slice")}`; }; export const tsExtensionMethodName = (name: string): string => { @@ -122,6 +121,6 @@ export const tsQualifiedExtensionMethodName = (name: string, path?: string): str export const tsQualifiedSliceMethodName = (fieldName: string, sliceName: string): string => { const fieldPart = uppercaseFirstLetter(tsCamelCase(fieldName) || "Field"); - const slicePart = uppercaseFirstLetter(tsCamelCase(sliceName) || "Slice"); + const slicePart = uppercaseFirstLetter(normalizeTsName(sliceName) || "Slice"); return `setSlice${fieldPart}${slicePart}`; }; diff --git a/src/api/writer-generator/typescript/profile.ts b/src/api/writer-generator/typescript/profile.ts index 2f7387cb8..81467f265 100644 --- a/src/api/writer-generator/typescript/profile.ts +++ b/src/api/writer-generator/typescript/profile.ts @@ -19,6 +19,7 @@ import { } from "@root/typeschema/types"; import type { TypeSchemaIndex } from "@root/typeschema/utils"; import { + normalizeTsName, tsCamelCase, tsExtensionInputTypeName, tsExtensionMethodName, @@ -1079,7 +1080,7 @@ export const generateProfileClass = ( // 1. get{SliceName}() - returns simplified (without discriminator fields) // 2. get{SliceName}Raw() - returns full FHIR type with all fields for (const sliceDef of sliceDefs) { - const baseName = uppercaseFirstLetter(tsCamelCase(sliceDef.sliceName)); + const baseName = uppercaseFirstLetter(normalizeTsName(sliceDef.sliceName)); const getMethodName = `get${baseName}`; const getRawMethodName = `get${baseName}Raw`; if (generatedGetMethods.has(getMethodName)) continue; diff --git a/test/api/write-generator/__snapshots__/typescript.test.ts.snap b/test/api/write-generator/__snapshots__/typescript.test.ts.snap index 5283cdf9a..7ac6dd141 100644 --- a/test/api/write-generator/__snapshots__/typescript.test.ts.snap +++ b/test/api/write-generator/__snapshots__/typescript.test.ts.snap @@ -441,7 +441,7 @@ export class observation_bodyweightProfile { return this.resource as observation_bodyweight } - public setVscat (input?: Observation_bodyweight_Category_VSCatSliceInput): this { + public setVSCat (input?: Observation_bodyweight_Category_VSCatSliceInput): this { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as CodeableConcept const list = (this.resource.category ??= []) @@ -454,7 +454,7 @@ export class observation_bodyweightProfile { return this } - public getVscat (): Observation_bodyweight_Category_VSCatSliceInput | undefined { + public getVSCat (): Observation_bodyweight_Category_VSCatSliceInput | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -463,7 +463,7 @@ export class observation_bodyweightProfile { return extractSliceSimplified(item as unknown as Record, ["coding"]) as Observation_bodyweight_Category_VSCatSliceInput } - public getVscatRaw (): CodeableConcept | undefined { + public getVSCatRaw (): CodeableConcept | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -638,7 +638,7 @@ export class observation_bpProfile { return this.resource as observation_bp } - public setVscat (input?: Observation_bp_Category_VSCatSliceInput): this { + public setVSCat (input?: Observation_bp_Category_VSCatSliceInput): this { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as CodeableConcept const list = (this.resource.category ??= []) @@ -651,7 +651,7 @@ export class observation_bpProfile { return this } - public setSystolicBp (input?: Observation_bp_Component_SystolicBPSliceInput): this { + public setSystolicBP (input?: Observation_bp_Component_SystolicBPSliceInput): this { const match = {"code":{"coding":{"code":"8480-6","system":"http://loinc.org"}}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as ObservationComponent const list = (this.resource.component ??= []) @@ -664,7 +664,7 @@ export class observation_bpProfile { return this } - public setDiastolicBp (input?: Observation_bp_Component_DiastolicBPSliceInput): this { + public setDiastolicBP (input?: Observation_bp_Component_DiastolicBPSliceInput): this { const match = {"code":{"coding":{"code":"8462-4","system":"http://loinc.org"}}} as Record const value = applySliceMatch((input ?? {}) as Record, match) as unknown as ObservationComponent const list = (this.resource.component ??= []) @@ -677,7 +677,7 @@ export class observation_bpProfile { return this } - public getVscat (): Observation_bp_Category_VSCatSliceInput | undefined { + public getVSCat (): Observation_bp_Category_VSCatSliceInput | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -686,7 +686,7 @@ export class observation_bpProfile { return extractSliceSimplified(item as unknown as Record, ["coding"]) as Observation_bp_Category_VSCatSliceInput } - public getVscatRaw (): CodeableConcept | undefined { + public getVSCatRaw (): CodeableConcept | undefined { const match = {"coding":{"code":"vital-signs","system":"http://terminology.hl7.org/CodeSystem/observation-category"}} as Record const list = this.resource.category if (!list) return undefined @@ -694,7 +694,7 @@ export class observation_bpProfile { return item } - public getSystolicBp (): Observation_bp_Component_SystolicBPSliceInput | undefined { + public getSystolicBP (): Observation_bp_Component_SystolicBPSliceInput | undefined { const match = {"code":{"coding":{"code":"8480-6","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined @@ -703,7 +703,7 @@ export class observation_bpProfile { return extractSliceSimplified(item as unknown as Record, ["code"]) as Observation_bp_Component_SystolicBPSliceInput } - public getSystolicBpRaw (): ObservationComponent | undefined { + public getSystolicBPRaw (): ObservationComponent | undefined { const match = {"code":{"coding":{"code":"8480-6","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined @@ -711,7 +711,7 @@ export class observation_bpProfile { return item } - public getDiastolicBp (): Observation_bp_Component_DiastolicBPSliceInput | undefined { + public getDiastolicBP (): Observation_bp_Component_DiastolicBPSliceInput | undefined { const match = {"code":{"coding":{"code":"8462-4","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined @@ -720,7 +720,7 @@ export class observation_bpProfile { return extractSliceSimplified(item as unknown as Record, ["code"]) as Observation_bp_Component_DiastolicBPSliceInput } - public getDiastolicBpRaw (): ObservationComponent | undefined { + public getDiastolicBPRaw (): ObservationComponent | undefined { const match = {"code":{"coding":{"code":"8462-4","system":"http://loinc.org"}}} as Record const list = this.resource.component if (!list) return undefined diff --git a/test/api/write-generator/multi-package/__snapshots__/cda.test.ts.snap b/test/api/write-generator/multi-package/__snapshots__/cda.test.ts.snap index 3973195ae..47cf23790 100644 --- a/test/api/write-generator/multi-package/__snapshots__/cda.test.ts.snap +++ b/test/api/write-generator/multi-package/__snapshots__/cda.test.ts.snap @@ -1,185 +1,5 @@ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots -exports[`CCDA TypeScript Generation should generate ClinicalDocument type 1`] = ` -"// 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 type { ANY } from "../hl7-cda-uv-core/ANY"; -import type { Authenticator } from "../hl7-cda-uv-core/Authenticator"; -import type { Author } from "../hl7-cda-uv-core/Author"; -import type { Authorization } from "../hl7-cda-uv-core/Authorization"; -import type { CD } from "../hl7-cda-uv-core/CD"; -import type { CE } from "../hl7-cda-uv-core/CE"; -import type { Component } from "../hl7-cda-uv-core/Component"; -import type { ComponentOf } from "../hl7-cda-uv-core/ComponentOf"; -import type { CS } from "../hl7-cda-uv-core/CS"; -import type { Custodian } from "../hl7-cda-uv-core/Custodian"; -import type { DataEnterer } from "../hl7-cda-uv-core/DataEnterer"; -import type { DocumentationOf } from "../hl7-cda-uv-core/DocumentationOf"; -import type { II } from "../hl7-cda-uv-core/II"; -import type { Informant } from "../hl7-cda-uv-core/Informant"; -import type { InformationRecipient } from "../hl7-cda-uv-core/InformationRecipient"; -import type { InFulfillmentOf } from "../hl7-cda-uv-core/InFulfillmentOf"; -import type { INT } from "../hl7-cda-uv-core/INT"; -import type { LegalAuthenticator } from "../hl7-cda-uv-core/LegalAuthenticator"; -import type { Participant1 } from "../hl7-cda-uv-core/Participant1"; -import type { RecordTarget } from "../hl7-cda-uv-core/RecordTarget"; -import type { RelatedDocument } from "../hl7-cda-uv-core/RelatedDocument"; -import type { ST } from "../hl7-cda-uv-core/ST"; -import type { TS } from "../hl7-cda-uv-core/TS"; - -import type { Element } from "../hl7-fhir-r5-core/Element"; -// CanonicalURL: http://hl7.org/cda/stds/core/StructureDefinition/ClinicalDocument (pkg: hl7.cda.uv.core#2.0.1-sd) -export interface ClinicalDocument extends ANY { - authenticator?: Authenticator[]; - author: Author[]; - authorization?: Authorization[]; - classCode?: string; - _classCode?: Element; - code: CE; - component: Component; - componentOf?: ComponentOf; - confidentialityCode: CE; - copyTime?: TS; - custodian: Custodian; - dataEnterer?: DataEnterer; - documentationOf?: DocumentationOf[]; - effectiveTime: TS; - id: II; - informant?: Informant[]; - informationRecipient?: InformationRecipient[]; - inFulfillmentOf?: InFulfillmentOf[]; - languageCode?: CS; - legalAuthenticator?: LegalAuthenticator; - moodCode?: ("INT" | "APT" | "ARQ" | "PRMS" | "PRP" | "RQO" | "SLOT" | "DEF" | "EVN" | "EVN.CRT" | "GOL" | "OPT" | "PERM" | "PERMRQ"); - _moodCode?: Element; - participant?: Participant1[]; - realmCode?: CS[]; - recordTarget: RecordTarget[]; - relatedDocument?: RelatedDocument[]; - sdtcCategory?: CD[]; - sdtcStatusCode?: CS; - setId?: II; - templateId?: II[]; - title?: ST; - typeId?: II; - versionNumber?: INT; -} -" -`; - -exports[`CCDA Python Generation should generate ClinicalDocument type (promoted logical) 1`] = ` -"# 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. - -from __future__ import annotations -from pydantic import BaseModel, ConfigDict, Field, PositiveInt -from typing import List as PyList, Literal - - - -class ClinicalDocument(ANY): - model_config = ConfigDict(validate_by_name=True, serialize_by_alias=True, extra="forbid") - resource_type: Literal['ClinicalDocument'] = Field( - default='ClinicalDocument', - alias='resourceType', - serialization_alias='resourceType', - frozen=True, - pattern='ClinicalDocument' - ) - authenticator: PyList[Authenticator] | None = Field(None, alias="authenticator", serialization_alias="authenticator") - author: PyList[Author] = Field(alias="author", serialization_alias="author") - authorization: PyList[Authorization] | None = Field(None, alias="authorization", serialization_alias="authorization") - class_code: str | None = Field(None, alias="classCode", serialization_alias="classCode") - code: CE = Field(alias="code", serialization_alias="code") - component: Component = Field(alias="component", serialization_alias="component") - component_of: ComponentOf | None = Field(None, alias="componentOf", serialization_alias="componentOf") - confidentiality_code: CE = Field(alias="confidentialityCode", serialization_alias="confidentialityCode") - copy_time: TS | None = Field(None, alias="copyTime", serialization_alias="copyTime") - custodian: Custodian = Field(alias="custodian", serialization_alias="custodian") - data_enterer: DataEnterer | None = Field(None, alias="dataEnterer", serialization_alias="dataEnterer") - documentation_of: PyList[DocumentationOf] | None = Field(None, alias="documentationOf", serialization_alias="documentationOf") - effective_time: TS = Field(alias="effectiveTime", serialization_alias="effectiveTime") - id: II = Field(alias="id", serialization_alias="id") - informant: PyList[Informant] | None = Field(None, alias="informant", serialization_alias="informant") - information_recipient: PyList[InformationRecipient] | None = Field(None, alias="informationRecipient", serialization_alias="informationRecipient") - in_fulfillment_of: PyList[InFulfillmentOf] | None = Field(None, alias="inFulfillmentOf", serialization_alias="inFulfillmentOf") - language_code: CS | None = Field(None, alias="languageCode", serialization_alias="languageCode") - legal_authenticator: LegalAuthenticator | None = Field(None, alias="legalAuthenticator", serialization_alias="legalAuthenticator") - mood_code: Literal["INT", "APT", "ARQ", "PRMS", "PRP", "RQO", "SLOT", "DEF", "EVN", "EVN.CRT", "GOL", "OPT", "PERM", "PERMRQ"] | None = Field(None, alias="moodCode", serialization_alias="moodCode") - participant: PyList[Participant1] | None = Field(None, alias="participant", serialization_alias="participant") - realm_code: PyList[CS] | None = Field(None, alias="realmCode", serialization_alias="realmCode") - record_target: PyList[RecordTarget] = Field(alias="recordTarget", serialization_alias="recordTarget") - related_document: PyList[RelatedDocument] | None = Field(None, alias="relatedDocument", serialization_alias="relatedDocument") - sdtc_category: PyList[CD] | None = Field(None, alias="sdtcCategory", serialization_alias="sdtcCategory") - sdtc_status_code: CS | None = Field(None, alias="sdtcStatusCode", serialization_alias="sdtcStatusCode") - set_id: II | None = Field(None, alias="setId", serialization_alias="setId") - template_id: PyList[II] | None = Field(None, alias="templateId", serialization_alias="templateId") - title: ST | None = Field(None, alias="title", serialization_alias="title") - type_id: II | None = Field(None, alias="typeId", serialization_alias="typeId") - version_number: INT | None = Field(None, alias="versionNumber", serialization_alias="versionNumber") - - def to_json(self, indent: int | None = None) -> str: - return self.model_dump_json(exclude_unset=True, exclude_none=True, indent=indent) - - @classmethod - def from_json(cls, json: str) -> ClinicalDocument: - return cls.model_validate_json(json) - -" -`; - -exports[`CCDA C# Generation should generate ClinicalDocument type (promoted logical) 1`] = ` -"// 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. - - -namespace Fhir.Types.Hl7CdaUvCore; - -public class ClinicalDocument : ANY { - public Authenticator[]? Authenticator { get; set; } - public required Author[] Author { get; set; } - public Authorization[]? Authorization { get; set; } - public string? ClassCode { get; set; } - public required CE Code { get; set; } - public required Component Component { get; set; } - public ComponentOf? ComponentOf { get; set; } - public required CE ConfidentialityCode { get; set; } - public TS? CopyTime { get; set; } - public required Custodian Custodian { get; set; } - public DataEnterer? DataEnterer { get; set; } - public DocumentationOf[]? DocumentationOf { get; set; } - public required TS EffectiveTime { get; set; } - public required II Id { get; set; } - public Informant[]? Informant { get; set; } - public InformationRecipient[]? InformationRecipient { get; set; } - public InFulfillmentOf[]? InFulfillmentOf { get; set; } - public CS? LanguageCode { get; set; } - public LegalAuthenticator? LegalAuthenticator { get; set; } - public ClinicalDocumentMoodCodeBindingEnum? MoodCode { get; set; } - public Participant1[]? Participant { get; set; } - public CS[]? RealmCode { get; set; } - public required RecordTarget[] RecordTarget { get; set; } - public RelatedDocument[]? RelatedDocument { get; set; } - public CD[]? SdtcCategory { get; set; } - public CS? SdtcStatusCode { get; set; } - public II? SetId { get; set; } - public II[]? TemplateId { get; set; } - public ST? Title { get; set; } - public II? TypeId { get; set; } - public INT? VersionNumber { get; set; } - - public override string ToString() => - JsonSerializer.Serialize(this, Helper.JsonSerializerOptions); - -} - -" -`; - exports[`CDA TypeScript Generation should generate ClinicalDocument type 1`] = ` "// WARNING: This file is autogenerated by @atomic-ehr/codegen. // GitHub: https://github.com/atomic-ehr/codegen