@@ -9,7 +9,6 @@ import { observation_bpProfile } from "./profiles/Observation_observation_bp";
99
1010const bp = observation_bpProfile .create ({
1111 status: " final" ,
12- category: [],
1312 subject: { reference: " Patient/pt-1" },
1413});
1514
@@ -22,21 +21,32 @@ bp.setVscat({ text: "Vital Signs" })
2221// Validate against profile constraints
2322bp .validate (); // [] -- valid
2423
25- // Get plain FHIR JSON
24+ // Get plain FHIR JSON -- ready for API calls, storage, etc.
2625const obs = bp .toResource ();
2726// {
28- // resourceType: "Observation",
29- // meta: { profile: ["http://hl7.org/fhir/StructureDefinition/bp"] },
30- // status: "final",
31- // code: { coding: [{ code: "85354-9", system: "http://loinc.org" }] },
32- // category: [{ text: "Vital Signs", coding: { code: "vital-signs", system: "http://terminology.hl7.org/CodeSystem/ observation-category" } }],
33- // subject: { reference: "Patient/pt-1" },
34- // effectiveDateTime: "2024-06-15",
35- // component: [
36- // { code: { coding: { code: "8480-6", system: "http://loinc.org" } }, valueQuantity: { value: 120, unit: "mmHg" } },
37- // { code: { coding: { code: "8462-4", system: "http://loinc.org" } }, valueQuantity: { value: 80, unit: "mmHg" } },
38- // ],
27+ // resourceType: "Observation",
28+ // meta: { profile: ["http://hl7.org/fhir/StructureDefinition/bp"] },
29+ // status: "final",
30+ // code: { coding: [{ code: "85354-9", system: "http://loinc.org" }] },
31+ // category: [{ coding: [ { code: "vital-signs", system: "http://... observation-category" }] }],
32+ // subject: { reference: "Patient/pt-1" },
33+ // effectiveDateTime: "2024-06-15",
34+ // component: [
35+ // { code: { coding: [ { code: "8480-6", system: "http://loinc.org" }] }, valueQuantity: { value: 120, unit: "mmHg" } },
36+ // { code: { coding: [ { code: "8462-4", system: "http://loinc.org" }] }, valueQuantity: { value: 80, unit: "mmHg" } },
37+ // ],
3938// }
39+
40+ // Wrap any Observation back into a profile to read slices
41+ const bp2 = observation_bpProfile .from (obs );
42+
43+ bp2 .getSystolicBp (); // { valueQuantity: { value: 120, unit: "mmHg" } }
44+ bp2 .getDiastolicBp (); // { valueQuantity: { value: 80, unit: "mmHg" } }
45+ bp2 .getVscat (); // { text: "Vital Signs" }
46+ bp2 .getEffectiveDateTime (); // "2024-06-15"
47+
48+ // Raw getters return the full FHIR element including discriminator values
49+ bp2 .getSystolicBpRaw (); // { code: { coding: [{ code: "8480-6", ... }] }, valueQuantity: { value: 120, ... } }
4050```
4151
4252Supports resource profiles, simple/complex extension profiles, slice accessors, choice types, and ` validate() ` checking required fields, fixed values, slice cardinality, enum bindings, and reference types.
0 commit comments