Search in sources :

Example 1 with RCMRMT030101UK04EhrExtract

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

the class SpecimenMapperTest method testSpecimenIsMappedWithNoOptionalFields.

@Test
public void testSpecimenIsMappedWithNoOptionalFields() {
    RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("specimen_no_optional_fields.xml");
    List<Specimen> specimenList = specimenMapper.mapSpecimen(ehrExtract, List.of(DIAGNOSTIC_REPORT_WITH_SPECIMEN), PATIENT, PRACTICE_CODE);
    Specimen specimen = specimenList.get(0);
    assertThat(specimen.getCollection().getCollected()).isNull();
    assertThat(specimen.hasAccessionIdentifier()).isFalse();
    assertThat(specimen.getType().getText()).isNullOrEmpty();
    checkFixedValues(specimen);
}
Also used : Specimen(org.hl7.fhir.dstu3.model.Specimen) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Test(org.junit.jupiter.api.Test)

Example 2 with RCMRMT030101UK04EhrExtract

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

the class ProcedureRequestMapper method mapToProcedureRequest.

public ProcedureRequest mapToProcedureRequest(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04EhrComposition ehrComposition, RCMRMT030101UK04PlanStatement planStatement, Patient patient, List<Encounter> encounters, String practiseCode) {
    var id = planStatement.getId().getRoot();
    var procedureRequest = new ProcedureRequest();
    procedureRequest.setStatus(ProcedureRequestStatus.ACTIVE).setIntent(ProcedureRequestIntent.PLAN).setAuthoredOnElement(getAuthoredOn(planStatement.getAvailabilityTime(), ehrExtract, ehrComposition)).setOccurrence(getOccurrenceDate(planStatement.getEffectiveTime())).setSubject(new Reference(patient)).setMeta(generateMeta(META_PROFILE)).setId(id);
    procedureRequest.getIdentifier().add(buildIdentifier(id, practiseCode));
    procedureRequest.getNote().add(getNote(planStatement.getText()));
    procedureRequest.getReasonCode().add(codeableConceptMapper.mapToCodeableConcept(planStatement.getCode()));
    procedureRequest.getRequester().setAgent(ParticipantReferenceUtil.getParticipantReference(planStatement.getParticipant(), ehrComposition));
    setProcedureRequestContext(procedureRequest, ehrComposition, encounters);
    return procedureRequest;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest)

Example 3 with RCMRMT030101UK04EhrExtract

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

the class TemplateMapper method createQuestionnaireResponse.

private QuestionnaireResponse createQuestionnaireResponse(RCMRMT030101UK04CompoundStatement compoundStatement, String practiseCode, Patient patient, Optional<Reference> encounter, Observation parentObservation, RCMRMT030101UK04EhrComposition ehrComposition, RCMRMT030101UK04EhrExtract ehrExtract) {
    var questionnaireResponse = new QuestionnaireResponse();
    var id = compoundStatement.getId().get(0).getRoot();
    questionnaireResponse.addItem(createdLinkedId(compoundStatement)).setAuthoredElement(getAuthored(ehrComposition, ehrExtract)).setSubject(new Reference(patient)).setStatus(COMPLETED).setParent(List.of(new Reference(parentObservation))).setIdentifier(buildIdentifier(id, practiseCode)).setMeta(generateMeta(QUESTIONNAIRE_META_PROFILE)).setId(QUESTIONNAIRE_REFERENCE.formatted(id));
    encounter.ifPresent(questionnaireResponse::setContext);
    return questionnaireResponse;
}
Also used : ParticipantReferenceUtil.getParticipantReference(uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference) Reference(org.hl7.fhir.dstu3.model.Reference) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse)

Example 4 with RCMRMT030101UK04EhrExtract

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

the class SpecimenCompoundsMapper method handleSpecimenChildComponents.

public List<Observation> handleSpecimenChildComponents(RCMRMT030101UK04EhrExtract ehrExtract, List<Observation> observations, List<Observation> observationComments, List<DiagnosticReport> diagnosticReports, Patient patient, List<Encounter> encounters, String practiseCode) {
    final List<Observation> batteryObservations = new ArrayList<>();
    diagnosticReports.forEach(diagnosticReport -> getCompoundStatementByDRId(ehrExtract, diagnosticReport.getId()).ifPresent(parentCompoundStatement -> getSpecimenCompoundStatements(parentCompoundStatement).forEach(specimenCompoundStatement -> {
        getObservationStatementsInCompound(specimenCompoundStatement).forEach(specimenObservationStatement -> getObservationById(observations, specimenObservationStatement.getId().getRoot()).ifPresent(observation -> handleObservationStatement(specimenCompoundStatement, observation, diagnosticReport)));
        getCompoundStatementsInSpecimenCompound(specimenCompoundStatement, CLUSTER_CLASSCODE).forEach(clusterCompoundStatement -> handleClusterCompoundStatement(specimenCompoundStatement, clusterCompoundStatement, observations, observationComments, diagnosticReport));
        getCompoundStatementsInSpecimenCompound(specimenCompoundStatement, BATTERY_CLASSCODE).forEach(batteryCompoundStatement -> {
            handleBatteryCompoundStatement(specimenCompoundStatement, batteryCompoundStatement, observations, observationComments, diagnosticReport);
            final SpecimenBatteryParameters batteryParameters = SpecimenBatteryParameters.builder().ehrExtract(ehrExtract).batteryCompoundStatement(batteryCompoundStatement).specimenCompoundStatement(specimenCompoundStatement).ehrComposition(getCurrentEhrComposition(ehrExtract, parentCompoundStatement)).diagnosticReport(diagnosticReport).patient(patient).encounters(encounters).observations(observations).observationComments(observationComments).practiseCode(practiseCode).build();
            batteryObservations.add(batteryMapper.mapBatteryObservation(batteryParameters));
        });
    })));
    return batteryObservations;
}
Also used : RCMRMT030101UK04Component3(org.hl7.v3.RCMRMT030101UK04Component3) RCMRMT030101UK04ObservationStatement(org.hl7.v3.RCMRMT030101UK04ObservationStatement) IdType(org.hl7.fhir.dstu3.model.IdType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) TextUtil.getLastLine(uk.nhs.adaptors.pss.translator.util.TextUtil.getLastLine) Autowired(org.springframework.beans.factory.annotation.Autowired) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) StringUtils(org.apache.commons.lang3.StringUtils) ObservationRelationshipType(org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType) RCMRMT030101UK04Component02(org.hl7.v3.RCMRMT030101UK04Component02) ArrayList(java.util.ArrayList) Specimen(org.hl7.fhir.dstu3.model.ResourceType.Specimen) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) Service(org.springframework.stereotype.Service) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) SpecimenBatteryParameters(uk.nhs.adaptors.pss.translator.mapper.diagnosticreport.SpecimenBatteryMapper.SpecimenBatteryParameters) RCMRMT030101UK04CompoundStatement(org.hl7.v3.RCMRMT030101UK04CompoundStatement) CompoundStatementResourceExtractors(uk.nhs.adaptors.pss.translator.util.CompoundStatementResourceExtractors) Reference(org.hl7.fhir.dstu3.model.Reference) RCMRMT030101UK04EhrComposition(org.hl7.v3.RCMRMT030101UK04EhrComposition) Observation(org.hl7.fhir.dstu3.model.Observation) Objects(java.util.Objects) Encounter(org.hl7.fhir.dstu3.model.Encounter) List(java.util.List) Patient(org.hl7.fhir.dstu3.model.Patient) Optional(java.util.Optional) TextUtil.addLine(uk.nhs.adaptors.pss.translator.util.TextUtil.addLine) RCMRMT030101UK04NarrativeStatement(org.hl7.v3.RCMRMT030101UK04NarrativeStatement) ObservationRelatedComponent(org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent) Observation(org.hl7.fhir.dstu3.model.Observation) ArrayList(java.util.ArrayList) SpecimenBatteryParameters(uk.nhs.adaptors.pss.translator.mapper.diagnosticreport.SpecimenBatteryMapper.SpecimenBatteryParameters)

Example 5 with RCMRMT030101UK04EhrExtract

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

the class MedicationRequestOrderMapper method mapToOrderMedicationRequest.

public MedicationRequest mapToOrderMedicationRequest(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04MedicationStatement medicationStatement, RCMRMT030101UK04Prescribe supplyPrescribe, String practiseCode) {
    var ehrSupplyPrescribeIdExtract = extractEhrSupplyPrescribeId(supplyPrescribe);
    var inFulfillmentOfId = extractInFulfillmentOfId(supplyPrescribe);
    if (ehrSupplyPrescribeIdExtract.isPresent()) {
        var ehrSupplyPrescribeId = ehrSupplyPrescribeIdExtract.get();
        MedicationRequest medicationRequest = createMedicationRequestSkeleton(ehrSupplyPrescribeId);
        medicationRequest.addIdentifier(buildIdentifier(ehrSupplyPrescribeId, practiseCode));
        medicationRequest.setStatus(COMPLETED);
        medicationRequest.setIntent(ORDER);
        medicationRequest.addDosageInstruction(buildDosage(medicationStatement.getPertinentInformation()));
        medicationRequest.setDispenseRequest(buildDispenseRequestForPrescribe(supplyPrescribe));
        buildNotesForPrescribe(supplyPrescribe).forEach(medicationRequest::addNote);
        medicationMapper.extractMedicationReference(medicationStatement).ifPresent(medicationRequest::setMedication);
        inFulfillmentOfId.ifPresent(inFulfillmentId -> {
            var supplyAuthorise = extractSupplyAuthorise(ehrExtract, inFulfillmentId);
            buildPrescriptionTypeExtension(supplyAuthorise).ifPresent(medicationRequest::addExtension);
            medicationRequest.addBasedOn(buildMedicationRequestReference(inFulfillmentId));
        });
        return medicationRequest;
    }
    return null;
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest)

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