Search in sources :

Example 1 with Composition

use of org.hl7.fhir.dstu2.model.Composition in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_doc_status_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_doc_status_test(String segment) {
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||PA||AV|||<PHYSID2>||\n" + "OBX|1|ST|100||This is content|||||||X\n";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    DocumentReference.ReferredDocumentStatus docStatus = report.getDocStatus();
    // TXA.17
    assertThat(docStatus.toCode()).isEqualTo("preliminary");
    assertThat(docStatus.getDefinition()).contains("This is a preliminary composition or document (also known as initial or interim).");
    assertThat(docStatus.getSystem()).isEqualTo("http://hl7.org/fhir/composition-status");
    // Check OBX.11 as fallback
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1|||555|||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||F";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    docStatus = report.getDocStatus();
    // OBX.11
    assertThat(docStatus.toCode()).isEqualTo("final");
    assertThat(docStatus.getDefinition()).contains("This version of the composition is complete and verified by an appropriate person and no further work is planned.");
    assertThat(docStatus.getSystem()).isEqualTo("http://hl7.org/fhir/composition-status");
    // Check a value that is not mapped results is no docStatus
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS\n" + "OBR|1|||555|||20170825010500|||||||||||||002|||||F\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    // OBX-11 'X' is not mapped
    assertThat(report.getDocStatus()).isNull();
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Composition

use of org.hl7.fhir.dstu2.model.Composition in project cqf-ruler by DBCG.

the class CareGapsProvider method patientReports.

// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
private Parameters.ParametersParameterComponent patientReports(RequestDetails requestDetails, String periodStart, String periodEnd, Patient patient, List<String> status, List<Measure> measures, String organization) {
    // TODO: add organization to report, if it exists.
    Composition composition = getComposition(patient);
    List<DetectedIssue> detectedIssues = new ArrayList<>();
    Map<String, Resource> evaluatedResources = new HashMap<>();
    List<MeasureReport> reports = getReports(requestDetails, periodStart, periodEnd, patient, status, measures, composition, detectedIssues, evaluatedResources);
    if (reports.isEmpty()) {
        return null;
    }
    return initializePatientParameter(patient).setResource(addBundleEntries(requestDetails.getFhirServerBase(), composition, detectedIssues, reports, evaluatedResources));
}
Also used : Composition(org.hl7.fhir.r4.model.Composition) DetectedIssue(org.hl7.fhir.r4.model.DetectedIssue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Resource(org.hl7.fhir.r4.model.Resource) MeasureReport(org.hl7.fhir.r4.model.MeasureReport)

Example 3 with Composition

use of org.hl7.fhir.dstu2.model.Composition in project summary-care-record-api by NHSDigital.

the class GpSummaryMapper method addAuthorOrganisation.

private void addAuthorOrganisation(Node document, List<Resource> resources, Composition composition) {
    xmlUtils.detachOptionalNodeByXPath(document, GP_SUMMARY_AUTHOR_AGENT_ORG_SDS_XPATH).ifPresent(agentOrganisationSds -> {
        Organization organisation = organisationSdsMapper.mapOrganizationSds(agentOrganisationSds);
        resources.add(organisation);
        composition.addAuthor(new Reference(organisation));
    });
    xmlUtils.detachOptionalNodeByXPath(document, GP_SUMMARY_AUTHOR_AGENT_ORG_XPATH).ifPresent(agentOrganisation -> {
        List<? extends Resource> organisationResources = agentOrganisationMapper.map(agentOrganisation);
        resources.addAll(organisationResources);
        composition.addAuthor(findPractitionerRole(organisationResources));
    });
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Reference(org.hl7.fhir.r4.model.Reference)

Example 4 with Composition

use of org.hl7.fhir.dstu2.model.Composition in project summary-care-record-api by NHSDigital.

the class GpSummaryMapper method map.

@SneakyThrows
public List<Resource> map(Node document) {
    var gpSummaryId = xmlUtils.getValueByXPath(document, GP_SUMMARY_ID_XPATH);
    var gpSummaryCodeCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_CODE_XPATH);
    var gpSummaryCodeDisplayName = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_DISPLAY_NAME_XPATH);
    var gpSummaryStatusCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_STATUS_CODE_XPATH);
    var gpSummaryEffectiveTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_EFFECTIVE_TIME_XPATH), InstantType.class);
    var authorTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_AUTHOR_TIME_XPATH), DateTimeType.class);
    var replacementOfPriorMessageRefIdRoot = xmlUtils.getOptionalValueByXPath(document, REPLACEMENT_OF_PRIOR_MESSAGE_REF_ID_ROOT_XPATH);
    var pertinentRootCreTypeCodeCode = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_CODE_XPATH);
    var pertinentRootCreTypeCodeDisplayName = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_DISPLAY_NAME_XPATH);
    var presentationTextValue = xmlUtils.detachOptionalNodeByXPath(document, PRESENTATION_TEXT_VALUE);
    var eventId = xmlUtils.getValueByXPath(document, EVENT_ID_XPATH);
    List<Resource> resources = new ArrayList<>();
    var composition = new Composition();
    composition.setId(eventId);
    composition.setIdentifier(new Identifier().setValue(gpSummaryId).setSystem("https://tools.ietf.org/html/rfc4122"));
    composition.setType(new CodeableConcept().addCoding(new Coding().setCode(gpSummaryCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(gpSummaryCodeDisplayName)));
    composition.setMeta(new Meta().setLastUpdatedElement(gpSummaryEffectiveTime));
    composition.setStatus(mapCompositionStatus(gpSummaryStatusCode));
    composition.setDateElement(authorTime);
    replacementOfPriorMessageRefIdRoot.ifPresent(val -> composition.addRelatesTo(new Composition.CompositionRelatesToComponent().setTarget(new Identifier().setValue(val)).setCode(REPLACES)));
    composition.addCategory(new CodeableConcept().addCoding(new Coding().setCode(pertinentRootCreTypeCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(pertinentRootCreTypeCodeDisplayName)));
    Map<String, List<String>> references = sectionReferences(document);
    presentationTextValue.map(htmlParser::parse).map(Collection::stream).ifPresent(it -> it.forEach(section -> {
        if (section.getTitle() != null && CODED_ENTRY_RESOURCE_MAP.keySet().contains(section.getTitle()) && references.containsKey(section.getTitle())) {
            for (String codedEntryId : references.get(section.getTitle())) {
                section.addEntry(new Reference(CODED_ENTRY_RESOURCE_MAP.get(section.getTitle()) + "/" + codedEntryId));
            }
        }
        composition.addSection(section);
    }));
    resources.add(composition);
    addAuthor(document, resources, composition);
    return resources;
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Collection(java.util.Collection) Identifier(org.hl7.fhir.r4.model.Identifier) RequiredArgsConstructor(lombok.RequiredArgsConstructor) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Resource(org.hl7.fhir.r4.model.Resource) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Composition(org.hl7.fhir.r4.model.Composition) Reference(org.hl7.fhir.r4.model.Reference) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) ArrayList(java.util.ArrayList) Organization(org.hl7.fhir.r4.model.Organization) List(java.util.List) InstantType(org.hl7.fhir.r4.model.InstantType) Component(org.springframework.stereotype.Component) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) Map(java.util.Map) Node(org.w3c.dom.Node) REPLACES(org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.REPLACES) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) Meta(org.hl7.fhir.r4.model.Meta) Meta(org.hl7.fhir.r4.model.Meta) Composition(org.hl7.fhir.r4.model.Composition) Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) ArrayList(java.util.ArrayList) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) List(java.util.List) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) SneakyThrows(lombok.SneakyThrows)

Example 5 with Composition

use of org.hl7.fhir.dstu2.model.Composition in project summary-care-record-api by NHSDigital.

the class GetScrService method setPatientReferences.

private void setPatientReferences(Resource resource, Patient patient) {
    if (resource instanceof RelatedPerson) {
        RelatedPerson relatedPerson = (RelatedPerson) resource;
        relatedPerson.setPatient(new Reference(patient));
    } else if (resource instanceof Composition) {
        Composition composition = (Composition) resource;
        composition.setSubject(new Reference(patient));
    }
}
Also used : Composition(org.hl7.fhir.r4.model.Composition) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson)

Aggregations

ArrayList (java.util.ArrayList)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)12 Coding (org.hl7.fhir.r4.model.Coding)8 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)7 Composition (org.hl7.fhir.r4.model.Composition)6 IOException (java.io.IOException)5 Composition (org.hl7.fhir.dstu3.model.Composition)5 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 Reference (org.hl7.fhir.r4.model.Reference)5 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Encounter (org.hl7.fhir.dstu3.model.Encounter)3 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)3 Reference (org.hl7.fhir.dstu3.model.Reference)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 Map (java.util.Map)2