-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2224 from metriport/1603-add-immunizations-section
1603 add immunizations and vital signs sections
- Loading branch information
Showing
25 changed files
with
1,670 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/core/src/fhir-to-cda/cda-templates/components/__tests__/immunization.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { Bundle, Immunization, Location } from "@medplum/fhirtypes"; | ||
import _ from "lodash"; | ||
import path from "path"; | ||
import { removeEmptyFields } from "../../clinical-document/clinical-document"; | ||
import { xmlBuilder } from "../../clinical-document/shared"; | ||
import { buildImmunizations } from "../immunizations"; | ||
import { immunizationFlu } from "./immunizations-examples"; | ||
import { location1 } from "./encounter-examples"; | ||
import { makeImmunization } from "./make-immunization"; | ||
import { createEmptyBundle, getXmlContentFromFile } from "./shared"; | ||
import { makeLocation } from "./make-encounter"; | ||
|
||
let immunizationId: string; | ||
let locationId: string; | ||
let bundle: Bundle; | ||
let immunization: Immunization; | ||
let location: Location; | ||
|
||
beforeEach(() => { | ||
immunizationId = faker.string.uuid(); | ||
locationId = faker.string.uuid(); | ||
immunization = makeImmunization({ ...immunizationFlu }, { imm: immunizationId, loc: locationId }); | ||
location = makeLocation({ ...location1, id: locationId }); | ||
bundle = createEmptyBundle(); | ||
}); | ||
|
||
describe("buildImmunizations", () => { | ||
it("correctly maps a single Immunization", () => { | ||
bundle.entry?.push({ resource: immunization }); | ||
bundle.entry?.push({ resource: location }); | ||
|
||
const filePath = path.join(__dirname, "./xmls/immunization-section-single-entry.xml"); | ||
const xmlTemplate = _.template(getXmlContentFromFile(filePath)); | ||
const params = { | ||
immunizationId, | ||
locationId, | ||
}; | ||
const xmlContent = xmlTemplate(params); | ||
const res = buildImmunizations(bundle); | ||
const cleanedJsonObj = removeEmptyFields(res); | ||
const xmlRes = xmlBuilder.build(cleanedJsonObj); | ||
expect(xmlRes).toEqual(xmlContent); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/core/src/fhir-to-cda/cda-templates/components/__tests__/immunizations-examples.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Immunization } from "@medplum/fhirtypes"; | ||
|
||
export const immunizationFlu: Partial<Immunization> = { | ||
status: "completed", | ||
vaccineCode: { | ||
coding: [ | ||
{ | ||
system: "http:https://hl7.org/fhir/sid/cvx", | ||
code: "140", | ||
display: "Influenza, seasonal, injectable, preservative free", | ||
}, | ||
], | ||
text: "Influenza, seasonal, injectable, preservative free", | ||
}, | ||
patient: { | ||
reference: "Patient/018ef2b1-a952-7a43-9124-7a86f10b9d78", | ||
}, | ||
encounter: { | ||
reference: "Encounter/90170bdf-3029-49d9-ba31-48c942bf3799", | ||
}, | ||
occurrenceDateTime: "2013-09-19T18:14:30-07:00", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/core/src/fhir-to-cda/cda-templates/components/__tests__/make-immunization.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Immunization } from "@medplum/fhirtypes"; | ||
import { makeBaseDomain, makeSubjectReference } from "./shared"; | ||
|
||
export function makeImmunization( | ||
params: Partial<Immunization> = {}, | ||
ids: { imm: string; loc: string } | ||
): Immunization { | ||
return { | ||
...makeBaseDomain(), | ||
...makeSubjectReference(), | ||
resourceType: "Immunization", | ||
...params, | ||
id: ids.imm, | ||
location: { reference: `Location/${ids.loc}` }, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
packages/core/src/fhir-to-cda/cda-templates/components/__tests__/vital-signs-examples.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { Observation } from "@medplum/fhirtypes"; | ||
|
||
export const vitalSignObservationTemplate: Partial<Observation> = { | ||
resourceType: "Observation", | ||
status: "final", | ||
category: [ | ||
{ | ||
coding: [ | ||
{ | ||
system: "http:https://terminology.hl7.org/CodeSystem/observation-category", | ||
code: "vital-signs", | ||
display: "Vital signs", | ||
}, | ||
], | ||
}, | ||
], | ||
code: { | ||
coding: [ | ||
{ | ||
system: "http:https://loinc.org", | ||
code: "72514-3", | ||
display: "Pain severity - 0-10 verbal numeric rating [Score] - Reported", | ||
}, | ||
], | ||
text: "Pain severity - 0-10 verbal numeric rating [Score] - Reported", | ||
}, | ||
effectiveDateTime: "2013-09-19T18:14:30-07:00", | ||
valueQuantity: { | ||
value: 0, | ||
unit: "{score}", | ||
system: "http:https://unitsofmeasure.org", | ||
code: "{score}", | ||
}, | ||
}; | ||
|
||
export const obsHeartRate: Partial<Observation> = { | ||
code: { | ||
text: "Heart rate", | ||
coding: [{ code: "8867-4", system: "http:https://loinc.org" }], | ||
}, | ||
effectiveDateTime: "2013-09-19T18:14:30-07:00", | ||
valueQuantity: { value: 92, unit: "/min", system: "http:https://unitsofmeasure.org" }, | ||
}; | ||
|
||
export const obsTemperature: Partial<Observation> = { | ||
code: { | ||
text: "Body temperature", | ||
coding: [{ code: "8310-5", system: "http:https://loinc.org" }], | ||
}, | ||
effectiveDateTime: "2013-09-19T18:14:30-07:00", | ||
valueQuantity: { value: 36.72, unit: "Cel", system: "http:https://unitsofmeasure.org" }, | ||
}; | ||
|
||
export const obsRespiratoryRate: Partial<Observation> = { | ||
code: { | ||
text: "Respiratory rate", | ||
coding: [{ code: "9279-1", system: "http:https://loinc.org" }], | ||
}, | ||
effectiveDateTime: "2013-09-19T18:14:30-07:00", | ||
valueQuantity: { value: 16, unit: "/min", system: "http:https://unitsofmeasure.org" }, | ||
}; | ||
|
||
export const obsWeight: Partial<Observation> = { | ||
code: { | ||
text: "Body weight", | ||
coding: [{ code: "29463-7", system: "http:https://loinc.org" }], | ||
}, | ||
effectiveDateTime: "2013-09-02T18:14:30-07:00", | ||
valueQuantity: { value: 63.504, unit: "kg", system: "http:https://unitsofmeasure.org" }, | ||
}; | ||
|
||
export const obsSystolic: Partial<Observation> = { | ||
code: { | ||
text: "Systolic blood pressure", | ||
coding: [{ code: "8480-6", system: "http:https://loinc.org" }], | ||
}, | ||
effectiveDateTime: "2013-09-02T18:14:30-07:00", | ||
valueQuantity: { value: 104, unit: "mm[Hg]", system: "http:https://unitsofmeasure.org" }, | ||
}; | ||
|
||
export const obsDiastolic: Partial<Observation> = { | ||
code: { | ||
text: "Diastolic blood pressure", | ||
coding: [{ code: "8462-4", system: "http:https://loinc.org" }], | ||
}, | ||
effectiveDateTime: "2013-09-02T18:14:30-07:00", | ||
valueQuantity: { value: 78, unit: "mm[Hg]", system: "http:https://unitsofmeasure.org" }, | ||
}; | ||
|
||
export const obsHeight: Partial<Observation> = { | ||
code: { | ||
coding: [ | ||
{ | ||
system: "http:https://loinc.org", | ||
code: "8302-2", | ||
display: "Body Height", | ||
}, | ||
], | ||
text: "Body Height", | ||
}, | ||
effectiveDateTime: "2013-09-02T18:14:30-07:00", | ||
valueQuantity: { | ||
value: 172.3, | ||
unit: "cm", | ||
system: "http:https://unitsofmeasure.org", | ||
code: "cm", | ||
}, | ||
}; |
Oops, something went wrong.