Search in sources :

Example 6 with RCMRMT030101UK04EhrComposition

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

the class DocumentReferenceMapper method mapDocumentReference.

private DocumentReference mapDocumentReference(RCMRMT030101UK04NarrativeStatement narrativeStatement, RCMRMT030101UK04EhrComposition ehrComposition, Patient patient, RCMRMT030101UK04EhrExtract ehrExtract, List<Encounter> encounterList, Organization organization) {
    DocumentReference documentReference = new DocumentReference();
    var id = narrativeStatement.getReference().get(0).getReferredToExternalDocument().getId().getRoot();
    documentReference.addIdentifier(buildIdentifier(id, organization.getIdentifierFirstRep().getValue()));
    documentReference.setId(id);
    documentReference.getMeta().addProfile(META_PROFILE);
    documentReference.setStatus(DocumentReferenceStatus.CURRENT);
    documentReference.setType(getType(narrativeStatement));
    documentReference.setSubject(new Reference(patient));
    documentReference.setIndexedElement(getIndexed(ehrExtract));
    documentReference.setDescription(buildDescription(narrativeStatement));
    documentReference.setCustodian(new Reference(organization));
    getAuthor(narrativeStatement, ehrComposition).ifPresent(documentReference::addAuthor);
    if (narrativeStatement.hasAvailabilityTime() && narrativeStatement.getAvailabilityTime().hasValue()) {
        documentReference.setCreatedElement(DateFormatUtil.parseToDateTimeType(narrativeStatement.getAvailabilityTime().getValue()));
    }
    var encounterReference = encounterList.stream().filter(encounter -> encounter.getId().equals(ehrComposition.getId().getRoot())).findFirst().map(Reference::new);
    if (encounterReference.isPresent()) {
        DocumentReference.DocumentReferenceContextComponent documentReferenceContextComponent = new DocumentReference.DocumentReferenceContextComponent().setEncounter(encounterReference.get());
        documentReference.setContext(documentReferenceContextComponent);
    }
    setContentAttachments(documentReference, narrativeStatement);
    return documentReference;
}
Also used : ParticipantReferenceUtil.getParticipantReference(uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference) Reference(org.hl7.fhir.dstu3.model.Reference) DocumentReference(org.hl7.fhir.dstu3.model.DocumentReference) DocumentReference(org.hl7.fhir.dstu3.model.DocumentReference)

Example 7 with RCMRMT030101UK04EhrComposition

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

the class EncounterMapper method generateLinkSetTopicLists.

private void generateLinkSetTopicLists(RCMRMT030101UK04EhrComposition ehrComposition, ListResource consultation, List<ListResource> topics) {
    var linkSetList = getLinkSets(ehrComposition);
    if (!CollectionUtils.isEmpty(linkSetList)) {
        var linkSetTopic = consultationListMapper.mapToTopic(consultation, null);
        addLinkSetsAsTopicEntries(linkSetList, linkSetTopic);
        consultation.addEntry(new ListEntryComponent(new Reference(linkSetTopic)));
        topics.add(linkSetTopic);
    }
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)

Example 8 with RCMRMT030101UK04EhrComposition

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

the class ConditionMapper method getCondition.

private Condition getCondition(RCMRMT030101UK04EhrExtract ehrExtract, Patient patient, List<Encounter> encounters, RCMRMT030101UK04EhrComposition composition, RCMRMT030101UK04LinkSet linkSet, String practiseCode) {
    String id = linkSet.getId().getRoot();
    Condition condition = (Condition) new Condition().addIdentifier(buildIdentifier(id, practiseCode)).addCategory(generateCategory()).setId(id).setMeta(generateMeta(META_PROFILE));
    buildClinicalStatus(linkSet.getCode()).ifPresentOrElse(condition::setClinicalStatus, () -> {
        condition.setClinicalStatus(ACTIVE);
        condition.addNote(new Annotation(new StringType(DEFAULT_CLINICAL_STATUS)));
    });
    condition.setSubject(new Reference(patient));
    condition.addExtension(buildProblemSignificance(linkSet.getCode()));
    generateAnnotationToMinor(linkSet.getCode()).ifPresent(condition::addNote);
    buildContext(composition, encounters).ifPresent(condition::setContext);
    buildOnsetDateTimeType(linkSet).ifPresent(condition::setOnset);
    buildAbatementDateTimeType(linkSet.getEffectiveTime()).ifPresent(condition::setAbatement);
    buildAssertedDateTimeType(composition).ifPresentOrElse(condition::setAssertedDateElement, () -> condition.setAssertedDateElement(parseToDateTimeType(ehrExtract.getAvailabilityTime().getValue())));
    composition.getParticipant2().stream().findFirst().ifPresent(participant2 -> condition.setAsserter(new Reference(new IdType(ResourceType.Practitioner.name(), participant2.getAgentRef().getId().getRoot()))));
    return condition;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) Annotation(org.hl7.fhir.dstu3.model.Annotation) RCMRMT030101UK04Annotation(org.hl7.v3.RCMRMT030101UK04Annotation) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 9 with RCMRMT030101UK04EhrComposition

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

the class EncounterMapper method getPeriod.

private Period getPeriod(RCMRMT030101UK04EhrComposition ehrComposition) {
    Period period = new Period();
    var effectiveTime = ehrComposition.getEffectiveTime();
    var availabilityTime = ehrComposition.getAvailabilityTime();
    if (effectiveTime.hasCenter()) {
        return period.setStartElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getCenter().getValue()));
    } else if (effectiveTime.hasLow() && effectiveTime.hasHigh()) {
        return period.setStartElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getLow().getValue())).setEndElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getHigh().getValue()));
    } else if (effectiveTime.hasLow() && !effectiveTime.hasHigh()) {
        return period.setStartElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getLow().getValue()));
    } else if (!effectiveTime.hasLow() && effectiveTime.hasHigh()) {
        return period.setEndElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getHigh().getValue()));
    } else if (effectiveTime.getCenter() != null && effectiveTime.getCenter().hasNullFlavor() && CsNullFlavor.UNK.value().equals(effectiveTime.getCenter().getNullFlavor().value())) {
        return null;
    } else if (availabilityTime.hasValue()) {
        return period.setStartElement(DateFormatUtil.parseToDateTimeType(availabilityTime.getValue()));
    }
    return null;
}
Also used : Period(org.hl7.fhir.dstu3.model.Period)

Example 10 with RCMRMT030101UK04EhrComposition

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

the class EncounterMapper method generateStructuredConsultation.

private void generateStructuredConsultation(List<RCMRMT030101UK04CompoundStatement> topicCompoundStatementList, RCMRMT030101UK04EhrComposition ehrComposition, ListResource consultation, List<ListResource> topics, List<ListResource> categories) {
    topicCompoundStatementList.forEach(topicCompoundStatement -> {
        var topic = consultationListMapper.mapToTopic(consultation, topicCompoundStatement);
        consultation.addEntry(new ListEntryComponent(new Reference(topic)));
        generateCategoryLists(topicCompoundStatement, topic, categories);
        generateLinkSetTopicLists(ehrComposition, consultation, topics);
        topics.add(topic);
    });
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)

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