use of org.hl7.fhir.dstu2016may.model.DateTimeType in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7EventTypeFHIRConversionTest method validate_evn_segment.
@Test
void validate_evn_segment() {
String hl7message = "MSH|^~\\&|||||||ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r" + // + "EVN||||851||20210319134735|\r" // TODO, not working with this value
"EVN||||O||20210319134735|\r" + "PV1|1|I||R|||||||||R|1||||||||||||||||||||||||||||||||||||||";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
FHIRContext context = new FHIRContext(true, false);
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
// Find the encounter from the FHIR bundle.
List<Resource> encounterResource = e.stream().filter(v -> ResourceType.Encounter == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(encounterResource).hasSize(1);
Encounter encounter = (Encounter) encounterResource.get(0);
// ENV.4 is used for reasonCode
List<CodeableConcept> reasonCodes = encounter.getReasonCode();
assertEquals(1, reasonCodes.size());
CodeableConcept encounterReason = encounter.getReasonCodeFirstRep();
Coding encounterReasonCoding = encounterReason.getCodingFirstRep();
// assertThat(encounterReasonCoding.getCode()).isEqualTo("851"); // TODO, should be able to use user-defined values
assertThat(encounterReasonCoding.getCode()).isEqualTo("O");
// EVN.6 is used for start period (with no end) if there is no PV1.44
Base period = encounter.getNamedProperty("period").getValues().get(0);
String startPeriod = period.getNamedProperty("start").getValues().get(0).toString();
int endPeriodSize = period.getNamedProperty("end").getValues().size();
assertThat(startPeriod).isEqualTo("DateTimeType[2021-03-19T13:47:35+08:00]");
assertThat(endPeriodSize).isZero();
}
use of org.hl7.fhir.dstu2016may.model.DateTimeType 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.hl7.fhir.dstu2016may.model.DateTimeType in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method confirmCanFindEventWithExistenceOfThirdEvent.
@Test
public void confirmCanFindEventWithExistenceOfThirdEvent() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
Observation observation = new Observation();
DateTimeType observationEffective = new DateTimeType(new Date());
observationEffective.setYear(2015);
observationEffective.setMonth(0);
observationEffective.setDay(5);
observation.setEffective(observationEffective);
FhirServerConfig fhirConfig = getFhirServerConfig();
mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", getFhirParser(), CONDITION_IN, fhirConfig);
mockFhirResourceRetrieval("/Encounter?subject=Patient%2F123&_format=json", getFhirParser(), ENCOUNTER_1, fhirConfig);
mockFhirResourceRetrieval("/Observation?subject=Patient%2F123&_format=json", getFhirParser(), observation, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "ObservationWithin30DaysOfCondition";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test2", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
expected.put(expression, true);
Assert.assertEquals(expected, actual.getExpressionResults());
}
use of org.hl7.fhir.dstu2016may.model.DateTimeType in project summary-care-record-api by NHSDigital.
the class DiagnosisMapper method mapAuthor.
private void mapAuthor(List<Resource> resources, Encounter encounter, Node author) {
DateTimeType time = parseDate(xmlUtils.getValueByXPath(author, DIAGNOSIS_PARTICIPANT_TIME_XPATH), DateTimeType.class);
participantMapper.map(author).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).forEach(it -> encounter.addParticipant(new EncounterParticipantComponent().setPeriod(new Period().setStartElement(time)).addType(getParticipationType("AUT", "author")).setIndividual(new Reference(it))));
}
use of org.hl7.fhir.dstu2016may.model.DateTimeType in project summary-care-record-api by NHSDigital.
the class FindingMapper method mapPerformer.
private void mapPerformer(List<Resource> resources, Encounter encounter, Node performer) {
DateTimeType time = parseDate(xmlUtils.getValueByXPath(performer, FINDING_PARTICIPANT_TIME_XPATH), DateTimeType.class);
participantMapper.map(performer).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).map(Reference::new).forEach(it -> {
EncounterParticipantComponent participant = new EncounterParticipantComponent();
String modeCode = xmlUtils.getValueByXPath(performer, FINDING_PERFORMER_MODE_CODE_XPATH);
participant.addExtension(PERFORMER_EXTENSION_URL, new CodeableConcept(new Coding().setSystem(ENCOUNTER_PARTICIPATION_MODE_SYSTEM).setCode(modeCode).setDisplay(getParticipationModeDisplay(modeCode))));
encounter.addParticipant(participant.setPeriod(new Period().setStartElement(time)).addType(getParticipationType("PRF", "performer")).setIndividual(it));
});
}
Aggregations