-
-
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.
- Loading branch information
Showing
4 changed files
with
85 additions
and
5 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
80 changes: 80 additions & 0 deletions
80
src/test/java/jy95/fhir/r4/dosage/utils/translators/TimingCodeTest.java
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,80 @@ | ||
package jy95.fhir.r4.dosage.utils.translators; | ||
|
||
import jy95.fhir.r4.dosage.utils.AbstractFhirTest; | ||
import jy95.fhir.r4.dosage.utils.classes.FhirDosageUtils; | ||
import jy95.fhir.r4.dosage.utils.types.DisplayOrder; | ||
import org.hl7.fhir.r4.model.CodeableConcept; | ||
import org.hl7.fhir.r4.model.Coding; | ||
import org.hl7.fhir.r4.model.Dosage; | ||
import org.hl7.fhir.r4.model.Timing; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TimingCodeTest extends AbstractFhirTest { | ||
|
||
@ParameterizedTest | ||
@MethodSource("localeProvider") | ||
void testNoCode(Locale locale) throws ExecutionException, InterruptedException { | ||
Dosage dosage = new Dosage(); | ||
FhirDosageUtils dosageUtils = getDosageUtilsInstance(locale, DisplayOrder.TIMING_CODE); | ||
String result = dosageUtils.asHumanReadableText(dosage).get(); | ||
assertEquals("", result); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("localeProvider") | ||
void testWithTimingCodeText(Locale locale) throws ExecutionException, InterruptedException { | ||
Dosage dosage = new Dosage(); | ||
CodeableConcept cc1 = new CodeableConcept(); | ||
cc1.setText("Take medication in the morning on weekends and days off work"); | ||
Timing timing = new Timing(); | ||
timing.setCode(cc1); | ||
dosage.setTiming(timing); | ||
FhirDosageUtils dosageUtils = getDosageUtilsInstance(locale, DisplayOrder.TIMING_CODE); | ||
String result = dosageUtils.asHumanReadableText(dosage).get(); | ||
assertEquals("Take medication in the morning on weekends and days off work", result); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("localeProvider") | ||
void testWithTimingCodeCodeAndDisplay(Locale locale) throws ExecutionException, InterruptedException { | ||
Dosage dosage = new Dosage(); | ||
CodeableConcept cc1 = new CodeableConcept(); | ||
cc1.setCoding( | ||
List.of( | ||
new Coding("http://hl7.org/fhir/ValueSet/timing-abbreviation", "BID", "Two times a day at institution specified time") | ||
) | ||
); | ||
Timing timing = new Timing(); | ||
timing.setCode(cc1); | ||
dosage.setTiming(timing); | ||
FhirDosageUtils dosageUtils = getDosageUtilsInstance(locale, DisplayOrder.TIMING_CODE); | ||
String result = dosageUtils.asHumanReadableText(dosage).get(); | ||
assertEquals("Two times a day at institution specified time", result); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("localeProvider") | ||
void testWithTimingCodeCodeOnly(Locale locale) throws ExecutionException, InterruptedException { | ||
Dosage dosage = new Dosage(); | ||
CodeableConcept cc1 = new CodeableConcept(); | ||
cc1.setCoding( | ||
List.of( | ||
new Coding("http://hl7.org/fhir/ValueSet/timing-abbreviation", "BID", null) | ||
) | ||
); | ||
Timing timing = new Timing(); | ||
timing.setCode(cc1); | ||
dosage.setTiming(timing); | ||
FhirDosageUtils dosageUtils = getDosageUtilsInstance(locale, DisplayOrder.TIMING_CODE); | ||
String result = dosageUtils.asHumanReadableText(dosage).get(); | ||
assertEquals("BID", result); | ||
} | ||
|
||
} |