Search in sources :

Example 21 with RCMRMT030101UK04EhrExtract

use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.

the class ObservationCommentMapper method mapObservation.

private Observation mapObservation(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04EhrComposition ehrComposition, RCMRMT030101UK04NarrativeStatement narrativeStatement, Patient patient, List<Encounter> encounters, String practiseCode) {
    var narrativeStatementId = narrativeStatement.getId();
    var observation = new Observation();
    observation.setId(narrativeStatement.getId().getRoot());
    observation.setMeta(generateMeta(META_URL));
    observation.setStatus(FINAL);
    observation.setSubject(new Reference(patient));
    observation.setIssuedElement(createIssued(ehrExtract, ehrComposition));
    observation.setCode(createCodeableConcept());
    observation.addPerformer(createPerformer(ehrComposition, narrativeStatement));
    observation.addIdentifier(buildIdentifier(narrativeStatementId.getRoot(), practiseCode));
    setObservationEffective(observation, narrativeStatement.getAvailabilityTime());
    setObservationComment(observation, narrativeStatement.getText());
    addContextToObservation(observation, encounters, ehrComposition);
    return observation;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ResourceFilterUtil.isDocumentReference(uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil.isDocumentReference) Observation(org.hl7.fhir.dstu3.model.Observation) ResourceUtil.addContextToObservation(uk.nhs.adaptors.pss.translator.util.ResourceUtil.addContextToObservation)

Example 22 with RCMRMT030101UK04EhrExtract

use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.

the class BundleMapperService method mapToBundle.

public Bundle mapToBundle(RCMRIN030000UK06Message xmlMessage, String losingPracticeOdsCode) throws BundleMappingException {
    try {
        Bundle bundle = generator.generateBundle();
        final RCMRMT030101UK04EhrExtract ehrExtract = getEhrExtract(xmlMessage);
        final RCMRMT030101UK04EhrFolder ehrFolder = getEhrFolder(xmlMessage);
        var agents = mapAgentDirectories(ehrFolder);
        var patient = mapPatient(getEhrExtract(xmlMessage), getPatientOrganization(agents));
        addEntry(bundle, patient);
        Organization authorOrg = organizationMapper.mapAuthorOrganization(losingPracticeOdsCode);
        addEntry(bundle, authorOrg);
        addEntries(bundle, agents);
        var mappedEncounterEhrCompositions = mapEncounters(ehrExtract, patient, losingPracticeOdsCode);
        var encounters = handleMappedEncounterResources(mappedEncounterEhrCompositions, bundle);
        var locations = mapLocations(ehrFolder, losingPracticeOdsCode);
        addEntries(bundle, locations);
        var procedureRequests = procedureRequestMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, procedureRequests);
        var referralRequests = referralRequestMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, referralRequests);
        var medicationResources = medicationRequestMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, medicationResources);
        var bloodPressures = bloodPressureMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, bloodPressures);
        var observations = observationMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, observations);
        var immunizations = immunizationMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, immunizations);
        var conditions = conditionMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, conditions);
        var observationComments = observationCommentMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, observationComments);
        var documentReferences = documentReferenceMapper.mapResources(ehrExtract, patient, encounters, authorOrg);
        addEntries(bundle, documentReferences);
        var templates = templateMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, templates);
        var allergyIntolerances = allergyIntoleranceMapper.mapResources(ehrExtract, patient, encounters, losingPracticeOdsCode);
        addEntries(bundle, allergyIntolerances);
        mapDiagnosticReports(bundle, ehrExtract, patient, encounters, observations, observationComments, losingPracticeOdsCode);
        conditionMapper.addReferences(bundle, conditions, ehrExtract);
        unknownPractitionerHandler.updateUnknownPractitionersRefs(bundle);
        LOGGER.debug("Mapped Bundle with [{}] entries", bundle.getEntry().size());
        return bundle;
    } catch (Exception e) {
        throw new BundleMappingException(e.getMessage());
    }
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Bundle(org.hl7.fhir.dstu3.model.Bundle) RCMRMT030101UK04EhrFolder(org.hl7.v3.RCMRMT030101UK04EhrFolder) BundleMappingException(uk.nhs.adaptors.pss.translator.exception.BundleMappingException) BundleMappingException(uk.nhs.adaptors.pss.translator.exception.BundleMappingException)

Example 23 with RCMRMT030101UK04EhrExtract

use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.

the class ConditionMapperTest method testConditionIsMappedCorrectlyNoReferences.

@Test
public void testConditionIsMappedCorrectlyNoReferences() {
    when(dateTimeMapper.mapDateTime(any())).thenReturn(EHR_EXTRACT_AVAILABILITY_DATETIME);
    final List<Encounter> emptyEncounterList = List.of();
    final RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("linkset_valid.xml");
    final List<Condition> conditions = conditionMapper.mapResources(ehrExtract, patient, emptyEncounterList, PRACTISE_CODE);
    assertThat(conditions).isNotEmpty();
    final Condition condition = conditions.get(0);
    assertGeneratedComponentsAreCorrect(condition);
    assertThat(condition.getId()).isEqualTo(LINKSET_ID);
    assertThat(condition.getExtensionsByUrl(ACTUAL_PROBLEM_URL).size()).isEqualTo(0);
    assertThat(condition.getExtensionsByUrl(PROBLEM_SIGNIFICANCE_URL).size()).isEqualTo(1);
    assertThat(condition.getExtensionsByUrl(RELATED_CLINICAL_CONTENT_URL).size()).isEqualTo(0);
    assertThat(condition.getClinicalStatus().getDisplay()).isEqualTo("Active");
    assertThat(condition.getCode().getCodingFirstRep().hasDisplay()).isFalse();
    assertThat(condition.getSubject().getResource().getIdElement().getIdPart()).isEqualTo(PATIENT_ID);
    assertThat(condition.getAsserter().getReference()).isEqualTo(ASSERTER_ID_REFERENCE);
    assertThat(condition.getContext().hasReference()).isFalse();
    assertThat(condition.getOnsetDateTimeType()).isEqualTo(EHR_EXTRACT_AVAILABILITY_DATETIME);
    assertThat(condition.getAbatementDateTimeType()).isEqualTo(EHR_EXTRACT_AVAILABILITY_DATETIME);
    assertThat(condition.getAssertedDateElement().getValue()).isEqualTo(EHR_EXTRACT_AVAILABILITY_DATETIME.getValue());
    assertThat(condition.getNote().size()).isEqualTo(0);
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Encounter(org.hl7.fhir.dstu3.model.Encounter) Test(org.junit.jupiter.api.Test)

Example 24 with RCMRMT030101UK04EhrExtract

use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EncounterMapperTest method testInvalidEhrCompositions.

@ParameterizedTest
@MethodSource("invalidEhrCompositionTestFiles")
public void testInvalidEhrCompositions(String inputXML) {
    final RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtractElement(inputXML);
    Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(ehrExtract, patient, PRACTISE_CODE);
    assertThat(mappedResources.get(ENCOUNTER_KEY).size()).isZero();
    assertThat(mappedResources.get(CONSULTATION_KEY).size()).isZero();
    assertThat(mappedResources.get(TOPIC_KEY).size()).isZero();
    assertThat(mappedResources.get(CATEGORY_KEY).size()).isZero();
}
Also used : DomainResource(org.hl7.fhir.dstu3.model.DomainResource) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 25 with RCMRMT030101UK04EhrExtract

use of org.hl7.v3.RCMRMT030101UK04EhrExtract in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EncounterMapperTest method testEncounterPeriod.

@ParameterizedTest
@MethodSource("encounterPeriodTestFiles")
public void testEncounterPeriod(String inputXML, String startDate, String endDate) {
    when(consultationListMapper.mapToConsultation(any(RCMRMT030101UK04EhrExtract.class), any(Encounter.class))).thenReturn(getList());
    when(consultationListMapper.mapToTopic(any(ListResource.class), isNull())).thenReturn(getList());
    final RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtractElement(inputXML);
    Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(ehrExtract, patient, PRACTISE_CODE);
    var encounterList = mappedResources.get(ENCOUNTER_KEY);
    assertThat(encounterList.size()).isOne();
    var encounter = (Encounter) mappedResources.get(ENCOUNTER_KEY).get(0);
    assertEncounter(encounter, "5EB5D070-8FE1-11EC-B1E5-0800200C9A66", false, startDate, endDate);
}
Also used : DomainResource(org.hl7.fhir.dstu3.model.DomainResource) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Encounter(org.hl7.fhir.dstu3.model.Encounter) List(java.util.List) ListResource(org.hl7.fhir.dstu3.model.ListResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

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