Search in sources :

Example 1 with CommunicationRequest

use of org.hl7.fhir.r4.model.CommunicationRequest in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveCommunicationRequest.

// TODO - extend this to be more complete
private CommunicationRequest resolveCommunicationRequest(ActivityDefinition activityDefinition, String patientId) {
    CommunicationRequest communicationRequest = new CommunicationRequest();
    communicationRequest.setStatus(CommunicationRequest.CommunicationRequestStatus.UNKNOWN);
    communicationRequest.setSubject(new Reference(patientId));
    // Unsure if this is correct - this is the way Motive is doing it...
    if (activityDefinition.hasCode()) {
        if (activityDefinition.getCode().hasText()) {
            communicationRequest.addPayload().setContent(new StringType(activityDefinition.getCode().getText()));
        }
    }
    return communicationRequest;
}
Also used : StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) CommunicationRequest(org.hl7.fhir.dstu3.model.CommunicationRequest)

Example 2 with CommunicationRequest

use of org.hl7.fhir.r4.model.CommunicationRequest in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveActivityDefinition.

// For library use
public Resource resolveActivityDefinition(ActivityDefinition activityDefinition, String patientId, String practitionerId, String organizationId, RequestDetails theRequest) throws FHIRException {
    Resource result = newResource(activityDefinition.getKind().toCode());
    switch(result.fhirType()) {
        case "ServiceRequest":
            result = resolveServiceRequest(activityDefinition, patientId, practitionerId, organizationId);
            break;
        case "MedicationRequest":
            result = resolveMedicationRequest(activityDefinition, patientId);
            break;
        case "SupplyRequest":
            result = resolveSupplyRequest(activityDefinition, practitionerId, organizationId);
            break;
        case "Procedure":
            result = resolveProcedure(activityDefinition, patientId);
            break;
        case "DiagnosticReport":
            result = resolveDiagnosticReport(activityDefinition, patientId);
            break;
        case "Communication":
            result = resolveCommunication(activityDefinition, patientId);
            break;
        case "CommunicationRequest":
            result = resolveCommunicationRequest(activityDefinition, patientId);
            break;
        case "Task":
            result = resolveTask(activityDefinition, patientId);
            break;
    }
    for (ActivityDefinition.ActivityDefinitionDynamicValueComponent dynamicValue : activityDefinition.getDynamicValue()) {
        // ActivityDefinition apply operation does not fail.
        try {
            if (dynamicValue.getExpression() != null) {
                // Special case for setting a Patient reference
                if ("Patient".equals(dynamicValue.getExpression().getExpression())) {
                    this.modelResolver.setValue(result, dynamicValue.getPath(), new Reference(patientId));
                } else {
                    /*
						 * TODO: Passing the activityDefinition as context here because that's what will
						 * have the libraries, but perhaps the "context" here should be the result
						 * resource?
						 */
                    Object value = expressionEvaluation.evaluateInContext(activityDefinition, dynamicValue.getExpression().getExpression(), patientId, theRequest);
                    if (value != null) {
                        logger.debug("dynamicValue value: {}", value);
                        if (value instanceof Boolean) {
                            value = new BooleanType((Boolean) value);
                        } else if (value instanceof DateTime) {
                            value = Date.from(((DateTime) value).getDateTime().toInstant());
                        } else if (value instanceof String) {
                            value = new StringType((String) value);
                        }
                        this.modelResolver.setValue(result, dynamicValue.getPath(), value);
                    } else {
                        logger.warn("WARNING: ActivityDefinition has null value for path: {}", dynamicValue.getPath());
                    }
                }
            }
        } catch (Exception e) {
            logger.error("ERROR: ActivityDefinition dynamicValue {} could not be applied and threw exception {}", dynamicValue.getPath(), e.toString());
            logger.error(e.toString());
        }
    }
    return result;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) BooleanType(org.hl7.fhir.r4.model.BooleanType) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) FHIRException(org.hl7.fhir.exceptions.FHIRException) ActivityDefinition(org.hl7.fhir.r4.model.ActivityDefinition)

Example 3 with CommunicationRequest

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

the class RdfParser method composeCommunicationRequestCommunicationRequestPayloadComponent.

protected void composeCommunicationRequestCommunicationRequestPayloadComponent(Complex parent, String parentType, String name, CommunicationRequest.CommunicationRequestPayloadComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "payload", name, element, index);
    if (element.hasContent())
        composeType(t, "CommunicationRequest", "content", element.getContent(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 4 with CommunicationRequest

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

the class RdfParser method composeCommunicationRequestCommunicationRequestRequesterComponent.

protected void composeCommunicationRequestCommunicationRequestRequesterComponent(Complex parent, String parentType, String name, CommunicationRequest.CommunicationRequestRequesterComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "requester", name, element, index);
    if (element.hasAgent())
        composeReference(t, "CommunicationRequest", "agent", element.getAgent(), -1);
    if (element.hasOnBehalfOf())
        composeReference(t, "CommunicationRequest", "onBehalfOf", element.getOnBehalfOf(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 5 with CommunicationRequest

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

the class RdfParser method composeCommunicationRequest.

protected void composeCommunicationRequest(Complex parent, String parentType, String name, CommunicationRequest element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "CommunicationRequest", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "CommunicationRequest", "identifier", element.getIdentifier().get(i), i);
    if (element.hasCategory())
        composeCodeableConcept(t, "CommunicationRequest", "category", element.getCategory(), -1);
    if (element.hasSender())
        composeReference(t, "CommunicationRequest", "sender", element.getSender(), -1);
    for (int i = 0; i < element.getRecipient().size(); i++) composeReference(t, "CommunicationRequest", "recipient", element.getRecipient().get(i), i);
    for (int i = 0; i < element.getPayload().size(); i++) composeCommunicationRequestCommunicationRequestPayloadComponent(t, "CommunicationRequest", "payload", element.getPayload().get(i), i);
    for (int i = 0; i < element.getMedium().size(); i++) composeCodeableConcept(t, "CommunicationRequest", "medium", element.getMedium().get(i), i);
    if (element.hasRequester())
        composeReference(t, "CommunicationRequest", "requester", element.getRequester(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "CommunicationRequest", "status", element.getStatusElement(), -1);
    if (element.hasEncounter())
        composeReference(t, "CommunicationRequest", "encounter", element.getEncounter(), -1);
    if (element.hasScheduled())
        composeType(t, "CommunicationRequest", "scheduled", element.getScheduled(), -1);
    for (int i = 0; i < element.getReason().size(); i++) composeCodeableConcept(t, "CommunicationRequest", "reason", element.getReason().get(i), i);
    if (element.hasRequestedOnElement())
        composeDateTime(t, "CommunicationRequest", "requestedOn", element.getRequestedOnElement(), -1);
    if (element.hasSubject())
        composeReference(t, "CommunicationRequest", "subject", element.getSubject(), -1);
    if (element.hasPriority())
        composeCodeableConcept(t, "CommunicationRequest", "priority", element.getPriority(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)3 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)2 Reference (org.hl7.fhir.r4.model.Reference)2 StringType (org.hl7.fhir.r4.model.StringType)2 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 ActivityDefinition (org.hl7.fhir.dstu3.model.ActivityDefinition)1 BooleanType (org.hl7.fhir.dstu3.model.BooleanType)1 CommunicationRequest (org.hl7.fhir.dstu3.model.CommunicationRequest)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 Resource (org.hl7.fhir.dstu3.model.Resource)1 StringType (org.hl7.fhir.dstu3.model.StringType)1 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)1 ActivityDefinition (org.hl7.fhir.r4.model.ActivityDefinition)1 Attachment (org.hl7.fhir.r4.model.Attachment)1 BooleanType (org.hl7.fhir.r4.model.BooleanType)1 CommunicationRequest (org.hl7.fhir.r4.model.CommunicationRequest)1 RelatedArtifact (org.hl7.fhir.r4.model.RelatedArtifact)1