use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class SpecimenBatteryMapperTest method testMappingObservationFromBatteryCompoundStatement.
@Test
public void testMappingObservationFromBatteryCompoundStatement() {
final RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("specimen_battery_compound_statement.xml");
var batteryCompoundStatement = getBatteryCompoundStatements(ehrExtract);
final List<Observation> observations = getObservations();
var batteryParameters = SpecimenBatteryParameters.builder().ehrExtract(ehrExtract).batteryCompoundStatement(batteryCompoundStatement).specimenCompoundStatement(getSpecimenCompoundStatement(ehrExtract)).ehrComposition(getEhrComposition(ehrExtract)).diagnosticReport(DIAGNOSTIC_REPORT).patient(PATIENT).encounters(encounters).practiseCode(PRACTISE_CODE).observations(observations).build();
final Observation observation = specimenBatteryMapper.mapBatteryObservation(batteryParameters);
assertThat(observation.getId()).isEqualTo(OBSERVATION_ID);
assertThat(observation.getIdentifierFirstRep().getSystem()).contains(PRACTISE_CODE);
assertThat(observation.getEffectiveDateTimeType().getValueAsString()).isEqualTo(OBSERVATION_EFFECTIVE.getValueAsString());
assertThat(observation.getIssuedElement().getValueAsString()).isEqualTo(OBSERVATION_ISSUED.getValueAsString());
assertThat(observation.getSpecimen().hasReference()).isTrue();
assertThat(observation.getSpecimen().getReference()).contains(SPECIMEN_ID);
assertThat(observation.getStatus()).isEqualTo(ObservationStatus.FINAL);
assertThat(observation.getMeta().getProfile().get(0).getValue()).contains(META_PROFILE_SUFFIX);
assertThat(observation.getComment()).isEqualTo(EXPECTED_COMMENT);
assertThat(observation.getContext().hasReference()).isTrue();
assertThat(observation.getContext().getReference()).contains(ENCOUNTER_ID);
assertThat(observations.get(0).getRelated()).isNotEmpty();
assertThat(observations.get(0).getRelatedFirstRep().getType()).isEqualTo(ObservationRelationshipType.DERIVEDFROM);
assertSubject(observation);
assertRelated(observation);
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class SpecimenMapperTest method testInvalidSpecimenIsNotMapped.
@Test
public void testInvalidSpecimenIsNotMapped() {
RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("specimen_invalid.xml");
List<Specimen> specimenList = specimenMapper.mapSpecimen(ehrExtract, List.of(DIAGNOSTIC_REPORT_WITHOUT_SPECIMEN), PATIENT, PRACTICE_CODE);
assertThat(specimenList).isEmpty();
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class SpecimenMapperTest method testSpecimenIsMapped.
@Test
public void testSpecimenIsMapped() {
when(dateTimeMapper.mapDateTime(any())).thenCallRealMethod();
RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("specimen_valid.xml");
List<Specimen> specimenList = specimenMapper.mapSpecimen(ehrExtract, List.of(DIAGNOSTIC_REPORT_WITH_SPECIMEN), PATIENT, PRACTICE_CODE);
assertThat(specimenList).isNotEmpty();
final Specimen specimen = specimenList.get(0);
checkFixedValues(specimen);
assertThat(specimen.getNote().get(0).getText()).isEqualTo(NOTE_TEXT);
assertThat(specimen.getAccessionIdentifier().getValue()).isEqualTo(ACCESSION_IDENTIFIER_VALUE);
assertThat(specimen.getType().getText()).isEqualTo(SPECIMEN_TYPE_TEXT);
assertThat(specimen.getCollection().getCollected().toString()).isEqualTo(SPECIMEN_COLLECTED_DATETIME.toString());
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationRequestOrderMapperTest method When_MappingPrescribeResourceWithNoOptionals_Expect_AllFieldsToBeMappedCorrectly.
@Test
public void When_MappingPrescribeResourceWithNoOptionals_Expect_AllFieldsToBeMappedCorrectly() {
var medicationStatement = unmarshallMedicationStatement("medicationStatementPrescribeNoOptionals.xml");
var prescribe = medicationStatement.getComponent().stream().filter(RCMRMT030101UK04Component2::hasEhrSupplyPrescribe).map(RCMRMT030101UK04Component2::getEhrSupplyPrescribe).findFirst();
when(medicationMapper.extractMedicationReference(any())).thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));
assertThat(prescribe.isPresent()).isTrue();
var medicationRequest = medicationRequestOrderMapper.mapToOrderMedicationRequest(new RCMRMT030101UK04EhrExtract(), medicationStatement, prescribe.get(), PRACTISE_CODE);
assertCommonValues(medicationRequest);
medicationRequest.getExtensionsByUrl("https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-PrescriptionType-1").forEach(extension -> assertPrescriptionType(extension, "Repeat"));
assertThat(medicationRequest.getBasedOnFirstRep().getReferenceElement().getIdPart()).isEqualTo(TEST_ID);
assertThat(medicationRequest.getNote().size()).isEqualTo(1);
assertThat(medicationRequest.getDosageInstructionFirstRep().getText()).isEqualTo(TAKE_ONE_DAILY);
assertThat(medicationRequest.getDispenseRequest().getQuantity().getValue()).isNull();
assertThat(medicationRequest.getDispenseRequest().getValidityPeriod().getStartElement().getValue()).isEqualTo(DateFormatUtil.parseToDateTimeType(AVAILABILITY_TIME).getValue());
}
use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationRequestOrderMapperTest method When_MappingPrescribeResourceWithAllOptionals_Expect_AllFieldsToBeMappedCorrectly.
@Test
public void When_MappingPrescribeResourceWithAllOptionals_Expect_AllFieldsToBeMappedCorrectly() {
var medicationStatement = unmarshallMedicationStatement("medicationStatementPrescribeAllOptionals.xml");
var prescribe = medicationStatement.getComponent().stream().filter(RCMRMT030101UK04Component2::hasEhrSupplyPrescribe).map(RCMRMT030101UK04Component2::getEhrSupplyPrescribe).findFirst();
when(medicationMapper.extractMedicationReference(any())).thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));
assertThat(prescribe.isPresent()).isTrue();
var medicationRequest = medicationRequestOrderMapper.mapToOrderMedicationRequest(new RCMRMT030101UK04EhrExtract(), medicationStatement, prescribe.get(), PRACTISE_CODE);
assertCommonValues(medicationRequest);
medicationRequest.getExtensionsByUrl("https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-PrescriptionType-1").forEach(extension -> assertPrescriptionType(extension, "Repeat"));
assertThat(medicationRequest.getBasedOnFirstRep().getReferenceElement().getIdPart()).isEqualTo(TEST_ID);
assertThat(medicationRequest.getNote().size()).isEqualTo(THREE);
assertThat(medicationRequest.getDosageInstructionFirstRep().getText()).isEqualTo(TAKE_ONE_DAILY);
assertThat(medicationRequest.getDispenseRequest().getQuantity().getValue().intValue()).isEqualTo(SEVEN);
assertThat(medicationRequest.getDispenseRequest().getValidityPeriod().getStartElement().getValue()).isEqualTo(DateFormatUtil.parseToDateTimeType(AVAILABILITY_TIME).getValue());
}
Aggregations