Search in sources :

Example 16 with Procedure

use of org.hl7.fhir.r4.model.Procedure in project elexis-server by elexis.

the class ServiceRequestTest method createServiceRequest.

@Test
public void createServiceRequest() {
    Condition problem = new Condition();
    problem.setCode(new CodeableConcept().addCoding(new Coding("http://hl7.org/fhir/sid/icpc-2", "A04", "Müdigkeit")));
    problem.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
    problem.addCategory().addCoding(new Coding(ConditionCategory.PROBLEMLISTITEM.getSystem(), ConditionCategory.PROBLEMLISTITEM.toCode(), ConditionCategory.PROBLEMLISTITEM.getDisplay()));
    MethodOutcome problemOutcome = client.create().resource(problem).execute();
    Encounter encounter = new Encounter();
    EncounterParticipantComponent participant = new EncounterParticipantComponent();
    participant.setIndividual(new Reference("Practitioner/" + TestDatabaseInitializer.getMandant().getId()));
    encounter.addParticipant(participant);
    encounter.setPeriod(new Period().setStart(AllTests.getDate(LocalDate.of(2016, Month.DECEMBER, 1).atStartOfDay())).setEnd(AllTests.getDate(LocalDate.of(2016, Month.DECEMBER, 1).atTime(23, 59, 59))));
    encounter.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
    encounter.addDiagnosis().setCondition(new Reference(new IdType(problem.getResourceType().name(), problemOutcome.getId().getIdPart())));
    encounter.addType(new CodeableConcept().addCoding(new Coding("www.elexis.info/encounter/type", "struct", "structured enconter")));
    MethodOutcome encounterOutcome = client.create().resource(encounter).execute();
    assertNotNull(encounterOutcome);
    assertTrue(encounterOutcome.getCreated());
    assertNotNull(encounterOutcome.getId());
    // add subjective to the encounter
    Observation subjective = new Observation();
    Narrative narrative = new Narrative();
    String divEncodedText = "Subjective\nTest".replaceAll("(\r\n|\r|\n)", "<br />");
    narrative.setDivAsString(divEncodedText);
    subjective.setText(narrative);
    subjective.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
    subjective.addCategory().addCoding(new Coding(IdentifierSystem.ELEXIS_SOAP.getSystem(), ObservationCategory.SOAP_SUBJECTIVE.getCode(), ObservationCategory.SOAP_SUBJECTIVE.getLocalized()));
    subjective.setEncounter(new Reference(new IdType(encounter.getResourceType().name(), encounterOutcome.getId().getIdPart())));
    MethodOutcome subjectiveOutcome = client.create().resource(subjective).execute();
    assertTrue(subjectiveOutcome.getCreated());
    // add procedure request to encounter
    ServiceRequest serviceRequest = new ServiceRequest();
    narrative = new Narrative();
    divEncodedText = "Procedure\nTest".replaceAll("(\r\n|\r|\n)", "<br />");
    narrative.setDivAsString(divEncodedText);
    serviceRequest.setText(narrative);
    serviceRequest.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
    serviceRequest.setEncounter(new Reference(new IdType(encounter.getResourceType().name(), encounterOutcome.getId().getIdPart())));
    MethodOutcome outcome = client.create().resource(serviceRequest).execute();
    assertNotNull(outcome);
    assertTrue(outcome.getCreated());
    assertNotNull(outcome.getId());
    ServiceRequest readServiceRequest = client.read().resource(ServiceRequest.class).withId(outcome.getId()).execute();
    assertNotNull(readServiceRequest);
    assertEquals(outcome.getId().getIdPart(), readServiceRequest.getIdElement().getIdPart());
    assertEquals(serviceRequest.getSubject().getReferenceElement().getIdPart(), readServiceRequest.getSubject().getReferenceElement().getIdPart());
    assertEquals(serviceRequest.getEncounter().getReferenceElement().getIdPart(), readServiceRequest.getEncounter().getReferenceElement().getIdPart());
    assertTrue(readServiceRequest.getText().getDivAsString().contains("Test"));
    // check if the consultation text has been updated
    // search by patient and date
    Bundle results = client.search().forResource(Encounter.class).where(Encounter.PATIENT.hasId(AllTests.getTestDatabaseInitializer().getPatient().getId())).and(Encounter.DATE.exactly().day(AllTests.getDate(LocalDate.of(2016, Month.DECEMBER, 1).atStartOfDay()))).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    Encounter readEncounter = (Encounter) entries.get(0).getResource();
    assertNotNull(readEncounter);
    assertEquals(readEncounter.getIdElement().getIdPart(), encounterOutcome.getId().getIdPart());
    List<Identifier> identifier = readEncounter.getIdentifier();
    String consultationId = null;
    for (Identifier id : identifier) {
        if (id.getSystem().equals(IdentifierSystem.ELEXIS_CONSID.getSystem())) {
            consultationId = id.getValue();
        }
    }
    assertNotNull(consultationId);
    Optional<IEncounter> behandlung = AllTests.getModelService().load(consultationId, IEncounter.class);
    assertTrue(behandlung.isPresent());
    assertTrue(behandlung.get().getVersionedEntry().getHead().contains("Procedure"));
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Reference(org.hl7.fhir.r4.model.Reference) Bundle(org.hl7.fhir.r4.model.Bundle) Period(org.hl7.fhir.r4.model.Period) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) IdType(org.hl7.fhir.r4.model.IdType) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) IEncounter(ch.elexis.core.model.IEncounter) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) Narrative(org.hl7.fhir.r4.model.Narrative) Observation(org.hl7.fhir.r4.model.Observation) Encounter(org.hl7.fhir.r4.model.Encounter) IEncounter(ch.elexis.core.model.IEncounter) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 17 with Procedure

use of org.hl7.fhir.r4.model.Procedure in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskPollingService method handleFinishedTask.

protected void handleFinishedTask(Bundle resultBundle, Task ehrTask, ServiceRequest ehrServiceRequest, Task cpTask, Endpoint endpoint) {
    if (Task.TaskStatus.COMPLETED.equals(cpTask.getStatus())) {
        ehrServiceRequest.setStatus(ServiceRequest.ServiceRequestStatus.COMPLETED);
        resultBundle.addEntry(FhirUtil.createPutEntry(ehrServiceRequest));
    }
    // property.
    if (Task.TaskStatus.COMPLETED.equals(cpTask.getStatus()) || Task.TaskStatus.CANCELLED.equals(cpTask.getStatus())) {
        // Modify Task.output. If task output is of type resulting-activity and contains a Reference to a proper
        // Procedure - copy output changing a Procedure reference to a local one.
        List<TaskOutputComponent> cpOutputs = cpTask.getOutput().stream().filter(t -> t.getValue() instanceof CodeableConcept || (t.getValue() instanceof Reference && ((Reference) t.getValue()).getReferenceElement().getResourceType().equals(Procedure.class.getSimpleName()))).collect(Collectors.toList());
        if (cpOutputs.size() == 0) {
            log.warn("Not output of type 'http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/sdohcc-temporary-codes|resulting" + "-activity' with a reference to a proper Procedure is present in task with id '{}' at '{}'. " + "Expecting a reference to a Procedure resource.", cpTask.getIdElement().getIdPart(), endpoint.getAddress());
        }
        Map<String, Procedure> cpProcedureMap = getCpProcedures(cpOutputs, endpoint);
        for (Task.TaskOutputComponent cpOutput : cpOutputs) {
            Task.TaskOutputComponent ehrTaskOutput = cpOutput.copy();
            if (cpOutput.getValue() instanceof Reference) {
                Reference cpProcedureReference = (Reference) cpOutput.getValue();
                String cpProcedureId = cpProcedureReference.getReferenceElement().getIdPart();
                Procedure cpProcedure = cpProcedureMap.get(cpProcedureId);
                // All Procedures have the same reason reference as ServiceRequest
                Procedure resultProcedure = copyProcedure(cpProcedure, ehrTask.getFor(), ehrTask.getFocus(), ehrServiceRequest.getReasonReference());
                resultProcedure.setId(IdType.newRandomUuid());
                resultProcedure.addIdentifier().setSystem(endpoint.getAddress()).setValue(cpProcedureId);
                // Add Procedure to result bundle
                resultBundle.addEntry(FhirUtil.createPostEntry(resultProcedure));
                ehrTaskOutput.setValue(FhirUtil.toReference(Procedure.class, resultProcedure.getIdElement().getIdPart(), cpProcedureReference.getDisplay()));
            }
            ehrTask.addOutput(ehrTaskOutput);
        }
    }
}
Also used : Date(java.util.Date) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent) Constants(ca.uhn.fhir.rest.api.Constants) RequiredArgsConstructor(lombok.RequiredArgsConstructor) LocalDateTime(java.time.LocalDateTime) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Endpoint(org.hl7.fhir.r4.model.Endpoint) Scheduled(org.springframework.scheduling.annotation.Scheduled) Reference(org.hl7.fhir.r4.model.Reference) TaskStatus(org.hl7.fhir.r4.model.Task.TaskStatus) Function(java.util.function.Function) ArrayList(java.util.ArrayList) JSONParser(net.minidev.json.parser.JSONParser) TasksPollingInfo(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor.TasksPollingInfo) Procedure(org.hl7.fhir.r4.model.Procedure) Task(org.hl7.fhir.r4.model.Task) FhirContext(ca.uhn.fhir.context.FhirContext) TaskInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskInfoBundleExtractor.TaskInfoHolder) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) Map(java.util.Map) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) SearchModifierCode(org.hl7.fhir.r4.model.codesystems.SearchModifierCode) Observation(org.hl7.fhir.r4.model.Observation) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) SDOHProfiles(org.hl7.gravity.refimpl.sdohexchange.fhir.SDOHProfiles) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) Set(java.util.Set) TaskFailBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskFailBundleFactory) CpClientException(org.hl7.gravity.refimpl.sdohexchange.service.CpService.CpClientException) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) ZoneId(java.time.ZoneId) Organization(org.hl7.fhir.r4.model.Organization) Slf4j(lombok.extern.slf4j.Slf4j) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse) TaskPollingUpdateException(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor.TaskPollingUpdateException) List(java.util.List) TasksPollingBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor) JSONObject(net.minidev.json.JSONObject) Bundle(org.hl7.fhir.r4.model.Bundle) OrganizationTypeCode(org.hl7.gravity.refimpl.sdohexchange.codes.OrganizationTypeCode) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Task(org.hl7.fhir.r4.model.Task) Reference(org.hl7.fhir.r4.model.Reference) Procedure(org.hl7.fhir.r4.model.Procedure) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent)

Example 18 with Procedure

use of org.hl7.fhir.r4.model.Procedure in project Gravity-SDOH-Exchange-RI by FHIR.

the class OurTaskPollingService method handleFinishedTask.

protected void handleFinishedTask(Bundle resultBundle, Task task, ServiceRequest serviceRequest, Task ourTask) {
    boolean isFinished = false;
    if (TaskStatus.COMPLETED.equals(ourTask.getStatus())) {
        serviceRequest.setStatus(ServiceRequest.ServiceRequestStatus.COMPLETED);
        resultBundle.addEntry(FhirUtil.createPutEntry(serviceRequest));
        isFinished = true;
    } else if (TaskStatus.CANCELLED.equals(ourTask.getStatus()) || TaskStatus.REJECTED.equals(ourTask.getStatus()) || TaskStatus.FAILED.equals(ourTask.getStatus())) {
        serviceRequest.setStatus(ServiceRequest.ServiceRequestStatus.REVOKED);
        resultBundle.addEntry(FhirUtil.createPutEntry(serviceRequest));
        isFinished = true;
    }
    // property.
    if (isFinished) {
        // Modify Task.output. If task output is of type resulting-activity and contains a Reference to a proper
        // Procedure - copy output changing a Procedure reference to a local one.
        List<TaskOutputComponent> ourTaskOutputs = ourTask.getOutput().stream().filter(t -> t.getValue() instanceof CodeableConcept || (t.getValue() instanceof Reference && ((Reference) t.getValue()).getReferenceElement().getResourceType().equals(Procedure.class.getSimpleName()))).collect(Collectors.toList());
        if (ourTaskOutputs.size() == 0) {
            log.warn("No output of type 'http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/sdohcc-temporary-codes|resulting" + "-activity' with a reference to a proper Procedure is present in task with id '{}'. " + "Expecting a reference to a Procedure resource.", ourTask.getIdElement().getIdPart());
        }
        Map<String, Procedure> ourProcedureMap = getOurTaskProcedures(ourTaskOutputs);
        for (TaskOutputComponent ourTaskOutput : ourTaskOutputs) {
            TaskOutputComponent taskOutput = ourTaskOutput.copy();
            if (ourTaskOutput.getValue() instanceof Reference) {
                Reference ourProcedureReference = (Reference) ourTaskOutput.getValue();
                String ourProcedureId = ourProcedureReference.getReferenceElement().getIdPart();
                Procedure ourProcedure = ourProcedureMap.get(ourProcedureId);
                // All Procedures have the same reason reference as ServiceRequest
                Procedure resultProcedure = copyProcedure(ourProcedure, task.getFor(), task.getFocus(), serviceRequest.getReasonReference());
                resultProcedure.setId(IdType.newRandomUuid());
                // TODO add identifier
                // resultProcedure.addIdentifier()
                // .setSystem(SERVER_BASE)
                // .setValue(ourProcedureId);
                // Add Procedure to result bundle
                resultBundle.addEntry(FhirUtil.createPostEntry(resultProcedure));
                taskOutput.setValue(FhirUtil.toReference(Procedure.class, resultProcedure.getIdElement().getIdPart(), ourProcedureReference.getDisplay()));
            }
            task.addOutput(taskOutput);
        }
    }
}
Also used : OurTaskPollingUpdateException(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.OurTasksPollingBundleExtractor.OurTaskPollingUpdateException) OurTasksPollingInfo(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.OurTasksPollingBundleExtractor.OurTasksPollingInfo) Date(java.util.Date) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent) RequiredArgsConstructor(lombok.RequiredArgsConstructor) LocalDateTime(java.time.LocalDateTime) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Scheduled(org.springframework.scheduling.annotation.Scheduled) Reference(org.hl7.fhir.r4.model.Reference) TaskStatus(org.hl7.fhir.r4.model.Task.TaskStatus) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Procedure(org.hl7.fhir.r4.model.Procedure) Task(org.hl7.fhir.r4.model.Task) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) Map(java.util.Map) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) SearchModifierCode(org.hl7.fhir.r4.model.codesystems.SearchModifierCode) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) SDOHProfiles(org.hl7.gravity.refimpl.sdohexchange.fhir.SDOHProfiles) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) TaskFailBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskFailBundleFactory) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) ZoneId(java.time.ZoneId) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) OurTasksPollingBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.OurTasksPollingBundleExtractor) Bundle(org.hl7.fhir.r4.model.Bundle) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Reference(org.hl7.fhir.r4.model.Reference) Procedure(org.hl7.fhir.r4.model.Procedure) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 19 with Procedure

use of org.hl7.fhir.r4.model.Procedure in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskUpdateBundleFactory method createProceduresOutput.

private void createProceduresOutput(Bundle updateBundle) {
    for (Coding code : procedureCodes) {
        Procedure procedure = createProcedure(code);
        updateBundle.addEntry(FhirUtil.createPostEntry(procedure));
        Task.TaskOutputComponent taskOutput = createTaskOutput(FhirUtil.toReference(Procedure.class, procedure.getIdElement().getIdPart(), String.format("%s (%s)", code.getDisplay(), code.getCode())));
        task.getOutput().add(taskOutput);
    }
}
Also used : Task(org.hl7.fhir.r4.model.Task) Coding(org.hl7.fhir.r4.model.Coding) Procedure(org.hl7.fhir.r4.model.Procedure)

Example 20 with Procedure

use of org.hl7.fhir.r4.model.Procedure in project org.hl7.fhir.core by hapifhir.

the class CCDAConverter method processProcedure.

protected void processProcedure(ListResource list, Element procedure, ProcedureType type) throws Exception {
    switch(type) {
        case Procedure:
            cda.checkTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.14");
            break;
        case Observation:
            cda.checkTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.13");
            break;
        case Act:
            cda.checkTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.12");
    }
    checkNoNegationOrNullFlavor(procedure, "Procedure (" + type + ")");
    checkNoSubject(procedure, "Procedure (" + type + ")");
    Procedure p = new Procedure();
    addItemToList(list, p);
    // moodCode is either INT or EVN. INT is not handled yet. INT is deprecated anyway
    if (procedure.getAttribute("moodCode").equals("INT"))
        p.getModifierExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-planned", Factory.newBoolean(true), false));
    // SHALL contain at least one [1..*] id (CONF:7655).
    for (Element e : cda.getChildren(procedure, "id")) p.getIdentifier().add(convert.makeIdentifierFromII(e));
    // SHALL contain exactly one [1..1] code (CONF:7656).
    // This code @code in a procedure activity SHOULD be selected from LOINC or SNOMED CT and MAY be selected from CPT-4, ICD9 Procedures, ICD10 Procedures
    p.setCode(convert.makeCodeableConceptFromCD(cda.getChild(procedure, "code")));
    // SHALL contain exactly one [1..1] statusCode/@code, which SHALL be selected from ValueSet 2.16.840.1.113883.11.20.9.22 ProcedureAct
    // completed | active | aborted | cancelled - not in FHIR
    p.getModifierExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-status", Factory.newCode(cda.getStatus(procedure)), false));
    // SHOULD contain zero or one [0..1] effectiveTime (CONF:7662).
    p.setPerformed(convert.makePeriodFromIVL(cda.getChild(procedure, "effectiveTime")));
    // MAY contain zero or one [0..1] priorityCode/@code, which SHALL be selected from ValueSet 2.16.840.1.113883.1.11.16866 ActPriority DYNAMIC (CONF:7668)
    p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-priority", convert.makeCodeableConceptFromCD(cda.getChild(procedure, "priorityCode")), false));
    // MAY contain zero or one [0..1] methodCode (CONF:7670).
    p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-method", convert.makeCodeableConceptFromCD(cda.getChild(procedure, "methodCode")), false));
    if (type == ProcedureType.Observation) {
    // for Procedure-Observation:
    // 9.	SHALL contain exactly one [1..1] value (CONF:16846).
    // don't know what this is. It's not the actual result of the procedure (that goes in results "This section records ... procedure observations"), and there seems to be no value. The example as <value xsi:type="CD"/> which is not valid
    // so we ignore this for now
    }
    // SHOULD contain zero or more [0..*] targetSiteCode/@code, which SHALL be selected from ValueSet 2.16.840.1.113883.3.88.12.3221.8.9 Body site DYNAMIC (CONF:7683).
    for (Element e : cda.getChildren(procedure, "targetSiteCode")) p.addBodySite(convert.makeCodeableConceptFromCD(e));
    // SHOULD contain zero or more [0..*] performer (CONF:7718) such that it
    for (Element e : cda.getChildren(procedure, "performer")) {
        ProcedurePerformerComponent pp = new ProcedurePerformerComponent();
        p.getPerformer().add(pp);
        pp.setActor(makeReferenceToPractitionerForAssignedEntity(e, p));
    }
    for (Element participant : cda.getChildren(procedure, "participant")) {
        Element participantRole = cda.getlastChild(participant);
        if (type == ProcedureType.Procedure && cda.hasTemplateId(participantRole, "2.16.840.1.113883.10.20.22.4.37")) {
            // MAY contain zero or more [0..*] participant (CONF:7751) such that it  SHALL contain exactly one [1..1] @typeCode="DEV" Device
            // implanted devices
            p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/implanted-devices", Factory.makeReference(processDevice(participantRole, p)), false));
        } else if (cda.hasTemplateId(participantRole, "2.16.840.1.113883.10.20.22.4.32")) {
            // MAY contain zero or more [0..*] participant (CONF:7765) such that it SHALL contain exactly one [1..1] Service Delivery Location (templateId:2.16.840.1.113883.10.20.22.4.32) (CONF:7767)
            p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/location", Factory.makeReference(processSDLocation(participantRole, p)), false));
        }
    }
    for (Element e : cda.getChildren(procedure, "entryRelationship")) {
        Element a = /* act*/
        cda.getlastChild(e);
        if (a.getLocalName().equals("encounter")) {
        // MAY contain zero or more [0..*] entryRelationship (CONF:7768) such that it SHALL contain exactly one encounter which SHALL contain exactly one [1..1] id (CONF:7773).
        // todo - and process as a full encounter while we're at it
        } else if (cda.hasTemplateId(a, "2.16.840.1.113883.10.20.22.4.20")) {
            // MAY contain zero or one [0..1] entryRelationship (CONF:7775) such that it SHALL contain exactly one [1..1] Instructions (templateId:2.16.840.1.113883.10.20.22.4.20) (CONF:7778).
            // had code for type, plus text for instructions
            Extension n = Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-instructions", null, true);
            n.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-instructions-type", convert.makeCodeableConceptFromCD(cda.getChild(a, "code")), false));
            n.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-instructions-text", convert.makeStringFromED(cda.getChild(a, "text")), false));
            p.getExtension().add(n);
        } else if (cda.hasTemplateId(a, "2.16.840.1.113883.10.20.22.4.19")) {
            // MAY contain zero or more [0..*] entryRelationship (CONF:7779) such that it SHALL contain exactly one [1..1] Indication (templateId:2.16.840.1.113883.10.20.22.4.19) (CONF:7781).
            p.addReasonCode(processIndication(a));
        } else if (cda.hasTemplateId(cda.getlastChild(e), "2.16.840.1.113883.10.20.22.4.16")) {
        // MAY contain zero or one [0..1] entryRelationship (CONF:7886) such that it SHALL contain exactly one [1..1] Medication Activity (templateId:2.16.840.1.113883.10.20.22.4.16) (CONF:7888).
        // todo
        }
    }
}
Also used : Element(org.w3c.dom.Element) ProcedurePerformerComponent(org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent)

Aggregations

Procedure (org.hl7.fhir.r4.model.Procedure)22 Test (org.junit.jupiter.api.Test)19 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)14 Coding (org.hl7.fhir.r4.model.Coding)14 ArrayList (java.util.ArrayList)12 Bundle (org.hl7.fhir.r4.model.Bundle)11 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)9 Reference (org.hl7.fhir.r4.model.Reference)9 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)8 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)8 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)8 CCWProcedure (gov.cms.bfd.server.war.commons.CCWProcedure)7 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)7 Coding (org.hl7.fhir.dstu3.model.Coding)7 Date (java.util.Date)6 List (java.util.List)6 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)6 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)5 Collectors (java.util.stream.Collectors)5