use of org.hl7.fhir.r4.model.Ratio in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateRatioRXE.
@Test
void dosageInstructionTestRateRatioRXE() {
// Test dosageInstruction.RateRatio from RXE.22,23,24
String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|||||E|||||||||||||||||||||||I\n" + "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|||||||||||||||||||" + // RXE.24.3 empty to cause default in dosageInstruction.doseAndRate.rateRatio.numerator.system
"|PC|7|PC||||||||||||||||\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
// Confirm that one medicationRequest was created.
assertThat(medicationRequestList).hasSize(1);
MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
Ratio rateRatio = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateRatio();
// dosageInstruction.doseAndRate.rateRatio.numerator(RXE.23)
// RXE.23
assertThat(rateRatio.getNumerator().getValue()).hasToString("7.0");
// RXE.24
assertThat(rateRatio.getNumerator().getUnit()).isEqualTo("PC");
// Defaulted
assertThat(rateRatio.getNumerator().getSystem()).isEqualTo("http://unitsofmeasure.org");
// dosageInstruction.doseAndRate.rateRatio.denominator
assertThat(rateRatio.getDenominator().getValue()).hasToString("1.0");
// RXE.22
assertThat(rateRatio.getDenominator().getUnit()).isEqualTo("PC");
assertThat(rateRatio.getDenominator().getSystem()).isEqualTo("http://unitsofmeasure.org");
// Verify no extraneous resources
// Expect MedicationRequest, Patient
assertThat(e).hasSize(2);
}
use of org.hl7.fhir.r4.model.Ratio in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestMaxDosePerPeriodRXO.
@Test
void dosageInstructionTestMaxDosePerPeriodRXO() {
// Test dosageInstruction.maxDosePerPeriod from RXO.23
String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + "RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC|||||" + // RXO.8 through RXO.22 optional
"||||||||||||||||" + // RXO.23 to dosageInstruction.maxDosePerPeriod.numerator
"|7^PC|\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
// Confirm that one medicationRequest was created.
assertThat(medicationRequestList).hasSize(1);
MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
Ratio maxDose = medicationRequest.getDosageInstructionFirstRep().getMaxDosePerPeriod();
// dosageInstruction.maxDosePerPeriod.numerator(RXO.23)
assertThat(maxDose.getNumerator().getValue()).hasToString("7.0");
assertThat(maxDose.getNumerator().getUnit()).isEqualTo("PC");
assertThat(maxDose.getNumerator().getSystem()).isEqualTo("http://unitsofmeasure.org");
// dosageInstruction.maxDosePerPeriod.denominator
assertThat(maxDose.getDenominator().getValue()).hasToString("1.0");
assertThat(maxDose.getDenominator().getUnit()).isEqualTo("day");
assertThat(maxDose.getDenominator().getSystem()).isEqualTo("http://unitsofmeasure.org");
// Verify no extraneous resources
// Expect MedicationRequest, Patient, and Encounter
assertThat(e).hasSize(3);
}
use of org.hl7.fhir.r4.model.Ratio in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method testObservationSN_valueRatio_slash_result.
@Test
void testObservationSN_valueRatio_slash_result() throws IOException {
String hl7message = baseMessage + "OBX|1|SN|111^LabWithRatio||^2^/^3|";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
assertThat(obsResource).hasSize(1);
Observation obs = (Observation) obsResource.get(0);
assertTrue(obs.hasValueRatio());
Ratio r = obs.getValueRatio();
assertEquals(2f, r.getNumerator().getValue().floatValue());
assertEquals(3f, r.getDenominator().getValue().floatValue());
}
use of org.hl7.fhir.r4.model.Ratio in project quality-measure-and-cohort-service by Alvearie.
the class CQLToFHIRMeasureReportHelperTest method testRatio.
@Test
public void testRatio() {
String unit = "ml";
BigDecimal amount1 = new BigDecimal("4.0");
Quantity quantity1 = new Quantity().withUnit(unit).withValue(amount1);
BigDecimal amount2 = new BigDecimal("7.0");
Quantity quantity2 = new Quantity().withUnit(unit).withValue(amount2);
Ratio ratio = new Ratio().setNumerator(quantity1).setDenominator(quantity2);
IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(ratio);
assertTrue(fhirTypeValue instanceof org.hl7.fhir.r4.model.Ratio);
org.hl7.fhir.r4.model.Ratio castResult = (org.hl7.fhir.r4.model.Ratio) fhirTypeValue;
verifyBaseTypeAsQuantity(castResult.getNumerator(), amount1, unit);
verifyBaseTypeAsQuantity(castResult.getDenominator(), amount2, unit);
}
use of org.hl7.fhir.r4.model.Ratio in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___FHIR_measure_parameters_on_measure_report.
@Test
public void measure_report_generated___FHIR_measure_parameters_on_measure_report() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
Map<String, Type> measureParameters = new HashMap<>();
measureParameters.put("base64Param", new Base64BinaryType("AAA"));
measureParameters.put("booleanParam", new BooleanType(false));
measureParameters.put("dateParam", new DateType("2020-01-01"));
measureParameters.put("dateTimeParam", new DateTimeType("2020-01-01T12:00:00"));
measureParameters.put("decimalParam", new DecimalType(12.0));
measureParameters.put("instantParam", new InstantType("2020-01-01T12:00:00-04:00"));
measureParameters.put("integerParam", new IntegerType(1));
measureParameters.put("stringParam", new StringType("str"));
measureParameters.put("timeParam", new TimeType("05:30:00"));
measureParameters.put("uriParam", new UriType("abcde"));
measureParameters.put("codeableConceptParam", new CodeableConcept().setText("display").addCoding(new Coding().setCode("val").setSystem("sys").setDisplay("display")));
measureParameters.put("codingParam", new Coding().setCode("v").setSystem("s").setDisplay("d"));
measureParameters.put("periodParam", new Period().setStart(new Date(1)).setEnd(new Date(2)));
measureParameters.put("quantityParam", new Quantity().setValue(1).setUnit("g"));
measureParameters.put("rangeParam", new Range().setLow(new Quantity().setUnit("g").setValue(1)).setHigh(new Quantity().setUnit("g").setValue(5)));
measureParameters.put("ratioParam", new Ratio().setNumerator(new Quantity().setUnit("g").setValue(1)).setDenominator(new Quantity().setUnit("g").setValue(5)));
List<Extension> parameterExtensions = measureParameters.entrySet().stream().map(x -> createMeasureParameter(x.getKey(), x.getValue())).collect(Collectors.toList());
measure.setExtension(parameterExtensions);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null);
assertNotNull(report);
List<String> parameterNames = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).map(ParameterDefinition::getName).collect(Collectors.toList());
// Expected parameters are the ones listed above, plus the special parameters
// measurement period and product line
assertEquals(measureParameters.size() + 2, parameterNames.size());
assertTrue(parameterNames.containsAll(measureParameters.keySet()));
assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
Aggregations