-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #45 from jy95/timingExtension
feat: timingExtension
- Loading branch information
Showing
4 changed files
with
89 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// For typings autocomplete whatever your IDE | ||
import { expect, test, describe } from "@jest/globals"; | ||
import FhirDosageUtils from "../../src/index"; | ||
|
||
// types | ||
import type { Dosage } from "fhir/r4"; | ||
|
||
describe("fromDosageToText - timingExtension", () => { | ||
let dosageUtils: FhirDosageUtils; | ||
|
||
beforeAll(async () => { | ||
dosageUtils = await FhirDosageUtils.build({ | ||
displayOrder: ["timingExtension"], | ||
}); | ||
}); | ||
|
||
test("No extension", () => { | ||
const dosage: Dosage = { | ||
text: "no timingExtension", | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe(""); | ||
}); | ||
|
||
test("Empty", () => { | ||
const dosage: Dosage = { | ||
timing: { | ||
extension: [], | ||
}, | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe(""); | ||
}); | ||
|
||
test("1 item", () => { | ||
const dosage: Dosage = { | ||
timing: { | ||
extension: [ | ||
{ | ||
url: "https://www.ehealth.fgov.be/standards/fhir/medication/StructureDefinition/DosageOverride", | ||
valueBoolean: true, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe( | ||
'{"url":"https://www.ehealth.fgov.be/standards/fhir/medication/StructureDefinition/DosageOverride","valueBoolean":true}', | ||
); | ||
}); | ||
|
||
test("N+1 items", () => { | ||
const dosage: Dosage = { | ||
timing: { | ||
extension: [ | ||
{ | ||
url: "https://www.ehealth.fgov.be/standards/fhir/medication/StructureDefinition/DosageOverride", | ||
valueBoolean: true, | ||
}, | ||
{ | ||
url: "https://www.ehealth.fgov.be/standards/fhir/medication/StructureDefinition/DosageOverrideReason", | ||
valueCodeableConcept: { | ||
text: "Respect my authority ! - Eric Cartman", | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe( | ||
'{"url":"https://www.ehealth.fgov.be/standards/fhir/medication/StructureDefinition/DosageOverride","valueBoolean":true} {"url":"https://www.ehealth.fgov.be/standards/fhir/medication/StructureDefinition/DosageOverrideReason","valueCodeableConcept":{"text":"Respect my authority ! - Eric Cartman"}}', | ||
); | ||
}); | ||
}); |
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