Search in sources :

Example 11 with RCMRMT030101UK04EhrComposition

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

the class EncounterMapper method generateFlatConsultation.

private void generateFlatConsultation(ListResource consultation, List<ListResource> topics, RCMRMT030101UK04EhrComposition ehrComposition) {
    var topic = consultationListMapper.mapToTopic(consultation, null);
    List<Reference> entryReferences = new ArrayList<>();
    resourceReferenceUtil.extractChildReferencesFromEhrComposition(ehrComposition, entryReferences);
    entryReferences.forEach(reference -> addEntry(topic, reference));
    consultation.addEntry(new ListEntryComponent(new Reference(topic)));
    topics.add(topic);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) ListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)

Example 12 with RCMRMT030101UK04EhrComposition

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

the class EncounterMapper method setEncounterLocation.

private void setEncounterLocation(Encounter encounter, RCMRMT030101UK04EhrComposition ehrComposition) {
    if (ehrComposition.getLocation() != null) {
        var location = new EncounterLocationComponent();
        location.setLocation(new Reference(LOCATION_REFERENCE.formatted(ehrComposition.getId().getRoot())));
        encounter.setLocation(List.of(location));
    }
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) EncounterLocationComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent)

Example 13 with RCMRMT030101UK04EhrComposition

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

the class ImmunizationMapper method mapImmunization.

private Immunization mapImmunization(RCMRMT030101UK04EhrComposition ehrComposition, RCMRMT030101UK04ObservationStatement observationStatement, Patient patientResource, List<Encounter> encounterList, String practiseCode) {
    Immunization immunization = new Immunization();
    var id = observationStatement.getId().getRoot();
    var practitioner = ParticipantReferenceUtil.getParticipantReference(observationStatement.getParticipant(), ehrComposition);
    var encounter = getEncounterReference(encounterList, ehrComposition.getId());
    immunization.setMeta(generateMeta(META_PROFILE));
    immunization.addIdentifier(buildIdentifier(id, practiseCode));
    immunization.addExtension(createVaccineProcedureExtension(observationStatement));
    immunization.addExtension(createRecordedTimeExtension(ehrComposition));
    immunization.setEncounter(encounter).addPractitioner(new ImmunizationPractitionerComponent(practitioner)).setStatus(ImmunizationStatus.COMPLETED).setNotGiven(false).setPrimarySource(false).setPatient(new Reference(patientResource)).setId(id);
    buildNote(observationStatement).forEach(immunization::addNote);
    setDateFields(immunization, observationStatement);
    return immunization;
}
Also used : Immunization(org.hl7.fhir.dstu3.model.Immunization) Reference(org.hl7.fhir.dstu3.model.Reference) ImmunizationPractitionerComponent(org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent)

Example 14 with RCMRMT030101UK04EhrComposition

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

the class ImmunizationMapper method createRecordedTimeExtension.

private Extension createRecordedTimeExtension(RCMRMT030101UK04EhrComposition ehrComposition) {
    var extension = new Extension();
    extension.setUrl(RECORDED_DATE_EXTENSION_URL);
    if (ehrComposition.getAuthor() != null) {
        return extension.setValue(new StringType(ehrComposition.getAuthor().getTime().getValue()));
    } else if (ehrComposition.getEffectiveTime() != null && ehrComposition.getAvailabilityTime().getNullFlavor() == null) {
        return extension.setValue(new StringType(DateFormatUtil.parseToDateTimeType(ehrComposition.getAvailabilityTime().getValue()).asStringValue()));
    }
    return null;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) StringType(org.hl7.fhir.dstu3.model.StringType)

Example 15 with RCMRMT030101UK04EhrComposition

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

Aggregations

Reference (org.hl7.fhir.dstu3.model.Reference)17 ArrayList (java.util.ArrayList)5 RCMRMT030101UK04EhrComposition (org.hl7.v3.RCMRMT030101UK04EhrComposition)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ListEntryComponent (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)3 Test (org.junit.jupiter.api.Test)3 ParticipantReferenceUtil.getParticipantReference (uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference)3 Observation (org.hl7.fhir.dstu3.model.Observation)2 StringType (org.hl7.fhir.dstu3.model.StringType)2 ResourceUtil.addContextToObservation (uk.nhs.adaptors.pss.translator.util.ResourceUtil.addContextToObservation)2 Annotation (org.hl7.fhir.dstu3.model.Annotation)1 Condition (org.hl7.fhir.dstu3.model.Condition)1 DiagnosticReport (org.hl7.fhir.dstu3.model.DiagnosticReport)1 DocumentReference (org.hl7.fhir.dstu3.model.DocumentReference)1 EncounterLocationComponent (org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent)1 Extension (org.hl7.fhir.dstu3.model.Extension)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 Immunization (org.hl7.fhir.dstu3.model.Immunization)1 ImmunizationPractitionerComponent (org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent)1 Period (org.hl7.fhir.dstu3.model.Period)1