-
-
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.
test: timeOfDay / patientInstruction
- Loading branch information
Showing
2 changed files
with
98 additions
and
0 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,34 @@ | ||
// 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 - patientInstruction", () => { | ||
let dosageUtils: FhirDosageUtils; | ||
|
||
beforeAll(async () => { | ||
dosageUtils = await FhirDosageUtils.build({ | ||
displayOrder: ["patientInstruction"], | ||
}); | ||
}); | ||
|
||
test("No patientInstruction", () => { | ||
const dosage: Dosage = { | ||
text: "no patientInstruction", | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe(""); | ||
}); | ||
|
||
test("Simple case", () => { | ||
const dosage: Dosage = { | ||
patientInstruction: "patientInstruction", | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe("patientInstruction"); | ||
}); | ||
}); |
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,64 @@ | ||
// 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 - timeOfDay", () => { | ||
let dosageUtils: FhirDosageUtils; | ||
|
||
beforeAll(async () => { | ||
dosageUtils = await FhirDosageUtils.build({ | ||
displayOrder: ["timeOfDay"], | ||
}); | ||
}); | ||
|
||
test("No timeOfDay", () => { | ||
const dosage: Dosage = { | ||
text: "no timeOfDay", | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe(""); | ||
}); | ||
|
||
test("timeOfDay - empty", () => { | ||
const dosage: Dosage = { | ||
timing: { | ||
repeat: { | ||
timeOfDay: [], | ||
}, | ||
}, | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe(""); | ||
}); | ||
|
||
test("timeOfDay - 1 item", () => { | ||
const dosage: Dosage = { | ||
timing: { | ||
repeat: { | ||
timeOfDay: ["15:00:00"], | ||
}, | ||
}, | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe("at 15:00"); | ||
}); | ||
|
||
test("timeOfDay - N+1 items", () => { | ||
const dosage: Dosage = { | ||
timing: { | ||
repeat: { | ||
timeOfDay: ["15:00:00", "12:12:12"], | ||
}, | ||
}, | ||
}; | ||
|
||
let result = dosageUtils.fromDosageToText(dosage); | ||
expect(result).toBe("at 15:00 and 12:12:12"); | ||
}); | ||
}); |