use of org.molgenis.api.metadata.v3.model.Range in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestDoseRangeRXO.
@Test
void dosageInstructionTestDoseRangeRXO() {
// Test dosageInstruction.DoseRange using RXO segment WITH a range (RXO.2 exists and RXO.3 exists)
String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + // RXO.5 through RXO.35 not used.
"RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC^^^^^^dexamethasone (DECADRON) 4 MG TABS|100|150|CC||||||||||||||||||||||||||\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);
Range doseRange = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getDoseRange();
// doseRange.low(RXO.2)
assertThat(doseRange.getLow().getValue()).hasToString("100.0");
// RXO.4
assertThat(doseRange.getLow().getUnit()).isEqualTo("CC");
// Defaulted
assertThat(doseRange.getLow().getSystem()).isEqualTo("http://unitsofmeasure.org");
// doseRange.high(RXO.3)
assertThat(doseRange.getHigh().getValue()).hasToString("150.0");
// RXO.4
assertThat(doseRange.getHigh().getUnit()).isEqualTo("CC");
// Defaulted
assertThat(doseRange.getHigh().getSystem()).isEqualTo("http://unitsofmeasure.org");
// Verify no extraneous resources
// Expect MedicationRequest and Patient
assertThat(e).hasSize(2);
}
use of org.molgenis.api.metadata.v3.model.Range in project quality-measure-and-cohort-service by Alvearie.
the class CQLToFHIRMeasureReportHelperTest method testIntervalQuantity_shouldReturnRange.
@Test
public void testIntervalQuantity_shouldReturnRange() {
String unit = "ml";
BigDecimal startAmount = new BigDecimal("4.0");
BigDecimal endAmount = new BigDecimal("5.0");
Quantity startQuantity = new Quantity().withUnit(unit).withValue(startAmount);
Quantity endQuantity = new Quantity().withUnit(unit).withValue(endAmount);
IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(new Interval(startQuantity, true, endQuantity, true));
assertTrue(fhirTypeValue instanceof Range);
Range castResult = (Range) fhirTypeValue;
verifyBaseTypeAsQuantity(castResult.getLow(), startAmount, unit);
verifyBaseTypeAsQuantity(castResult.getHigh(), endAmount, unit);
}
use of org.molgenis.api.metadata.v3.model.Range 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));
}
use of org.molgenis.api.metadata.v3.model.Range in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testRange__shouldReturnIntervalParameterOfQuantityParameter.
@Test
public void testRange__shouldReturnIntervalParameterOfQuantityParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("Range");
String lowString = "1.5";
String highString = "2.5";
BigDecimal lowValue = new BigDecimal(lowString);
BigDecimal highValue = new BigDecimal(highString);
String unit = "ml";
Range fhirValue = new Range().setLow(new org.hl7.fhir.r4.model.Quantity().setValue(lowValue).setUnit(unit)).setHigh(new org.hl7.fhir.r4.model.Quantity().setValue(highValue).setUnit(unit));
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
IntervalParameter expectedParameter = new IntervalParameter(new QuantityParameter().setUnit(unit).setAmount(lowString), true, new QuantityParameter().setUnit(unit).setAmount(highString), true);
assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
use of org.molgenis.api.metadata.v3.model.Range in project quality-measure-and-cohort-service by Alvearie.
the class FHIRRestUtilsTest method testConstructAppropriateJsonRange.
@Test
public void testConstructAppropriateJsonRange() {
ParameterDefinition definition = new ParameterDefinition();
definition.setType("Range");
Extension extension = new Extension();
extension.setUrl("http://ibm.com/fhir/cdm/StructureDefinition/default-value");
Range range = new Range();
Quantity lowQuantity = new Quantity();
lowQuantity.setUnit("year");
lowQuantity.setValue(10);
Quantity highQuantity = new Quantity();
highQuantity.setUnit("year");
highQuantity.setValue(100);
range.setLow(lowQuantity);
range.setHigh(highQuantity);
extension.setValue(range);
List<Extension> extensions = new ArrayList<>();
extensions.add(extension);
definition.setExtension(extensions);
String defaultResult = FHIRRestUtils.complicatedTypeValueConstructor(definition);
assertEquals("{\"low\":{\"value\":10,\"unit\":\"year\"},\"high\":{\"value\":100,\"unit\":\"year\"}}", defaultResult);
}
Aggregations