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;
}
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());
}
}
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);
}
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();
}
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);
}
Aggregations