Search in sources :

Example 1 with RCMRMT030101UK04EhrFolder

use of org.hl7.v3.RCMRMT030101UK04EhrFolder 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)

Aggregations

Bundle (org.hl7.fhir.dstu3.model.Bundle)1 Organization (org.hl7.fhir.dstu3.model.Organization)1 RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)1 RCMRMT030101UK04EhrFolder (org.hl7.v3.RCMRMT030101UK04EhrFolder)1 BundleMappingException (uk.nhs.adaptors.pss.translator.exception.BundleMappingException)1