Search in sources :

Example 11 with RCMRMT030101UK04EhrExtract

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);
}
Also used : RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Observation(org.hl7.fhir.dstu3.model.Observation) Test(org.junit.jupiter.api.Test)

Example 12 with RCMRMT030101UK04EhrExtract

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();
}
Also used : Specimen(org.hl7.fhir.dstu3.model.Specimen) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Test(org.junit.jupiter.api.Test)

Example 13 with RCMRMT030101UK04EhrExtract

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());
}
Also used : Specimen(org.hl7.fhir.dstu3.model.Specimen) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Test(org.junit.jupiter.api.Test)

Example 14 with RCMRMT030101UK04EhrExtract

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());
}
Also used : RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Reference(org.hl7.fhir.dstu3.model.Reference) RCMRMT030101UK04Component2(org.hl7.v3.RCMRMT030101UK04Component2) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 15 with RCMRMT030101UK04EhrExtract

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());
}
Also used : RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Reference(org.hl7.fhir.dstu3.model.Reference) RCMRMT030101UK04Component2(org.hl7.v3.RCMRMT030101UK04Component2) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Aggregations

RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)19 Reference (org.hl7.fhir.dstu3.model.Reference)13 Test (org.junit.jupiter.api.Test)13 Condition (org.hl7.fhir.dstu3.model.Condition)7 IdType (org.hl7.fhir.dstu3.model.IdType)7 List (java.util.List)5 Encounter (org.hl7.fhir.dstu3.model.Encounter)5 Observation (org.hl7.fhir.dstu3.model.Observation)5 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)4 RCMRMT030101UK04Component2 (org.hl7.v3.RCMRMT030101UK04Component2)4 ArrayList (java.util.ArrayList)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Specimen (org.hl7.fhir.dstu3.model.Specimen)3 RCMRMT030101UK04EhrComposition (org.hl7.v3.RCMRMT030101UK04EhrComposition)3 Service (org.springframework.stereotype.Service)3 ParticipantReferenceUtil.getParticipantReference (uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference)3 Coding (org.hl7.fhir.dstu3.model.Coding)2 DateTimeType (org.hl7.fhir.dstu3.model.DateTimeType)2 DiagnosticReport (org.hl7.fhir.dstu3.model.DiagnosticReport)2