Search in sources :

Example 6 with ActivityDefinition

use of org.hl7.fhir.r4.model.ActivityDefinition 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 7 with ActivityDefinition

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

the class ActivityDefinitionApplyProvider method resolveDiagnosticReport.

private DiagnosticReport resolveDiagnosticReport(ActivityDefinition activityDefinition, String patientId) {
    DiagnosticReport diagnosticReport = new DiagnosticReport();
    diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.UNKNOWN);
    diagnosticReport.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        diagnosticReport.setCode(activityDefinition.getCode());
    } else {
        throw new ActivityDefinitionApplyException("Missing required ActivityDefinition.code property for DiagnosticReport");
    }
    if (activityDefinition.hasRelatedArtifact()) {
        List<Attachment> presentedFormAttachments = new ArrayList<>();
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            Attachment attachment = new Attachment();
            if (artifact.hasUrl()) {
                attachment.setUrl(artifact.getUrl());
            }
            if (artifact.hasDisplay()) {
                attachment.setTitle(artifact.getDisplay());
            }
            presentedFormAttachments.add(attachment);
        }
        diagnosticReport.setPresentedForm(presentedFormAttachments);
    }
    return diagnosticReport;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact)

Example 8 with ActivityDefinition

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

the class ActivityDefinitionApplyProvider method resolveMedicationRequest.

private MedicationRequest resolveMedicationRequest(ActivityDefinition activityDefinition, String patientId) throws ActivityDefinitionApplyException {
    // intent, medication, and subject are required
    MedicationRequest medicationRequest = new MedicationRequest();
    medicationRequest.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
    medicationRequest.setSubject(new Reference(patientId));
    if (activityDefinition.hasProduct()) {
        medicationRequest.setMedication(activityDefinition.getProduct());
    } else {
        throw new ActivityDefinitionApplyException("Missing required product property");
    }
    if (activityDefinition.hasDosage()) {
        medicationRequest.setDosageInstruction(activityDefinition.getDosage());
    }
    if (activityDefinition.hasBodySite()) {
        throw new ActivityDefinitionApplyException("BodySite does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasCode()) {
        throw new ActivityDefinitionApplyException("Code does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasQuantity()) {
        throw new ActivityDefinitionApplyException("Quantity does not map to " + activityDefinition.getKind());
    }
    return medicationRequest;
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Reference(org.hl7.fhir.dstu3.model.Reference)

Example 9 with ActivityDefinition

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

the class ActivityDefinitionApplyProvider method resolveCommunication.

private Communication resolveCommunication(ActivityDefinition activityDefinition, String patientId) {
    Communication communication = new Communication();
    communication.setStatus(Communication.CommunicationStatus.UNKNOWN);
    communication.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        communication.setReasonCode(Collections.singletonList(activityDefinition.getCode()));
    }
    if (activityDefinition.hasRelatedArtifact()) {
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            if (artifact.hasUrl()) {
                Attachment attachment = new Attachment().setUrl(artifact.getUrl());
                if (artifact.hasDisplay()) {
                    attachment.setTitle(artifact.getDisplay());
                }
                Communication.CommunicationPayloadComponent payload = new Communication.CommunicationPayloadComponent();
                payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
                communication.setPayload(Collections.singletonList(payload));
            }
        // TODO - other relatedArtifact types
        }
    }
    return communication;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact) Communication(org.hl7.fhir.dstu3.model.Communication)

Example 10 with ActivityDefinition

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

the class ActivityDefinitionApplyProvider method resolveProcedure.

private Procedure resolveProcedure(ActivityDefinition activityDefinition, String patientId) {
    Procedure procedure = new Procedure();
    // TODO - set the appropriate status
    procedure.setStatus(Procedure.ProcedureStatus.UNKNOWN);
    procedure.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        procedure.setCode(activityDefinition.getCode());
    }
    if (activityDefinition.hasBodySite()) {
        procedure.setBodySite(activityDefinition.getBodySite());
    }
    return procedure;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) Procedure(org.hl7.fhir.dstu3.model.Procedure)

Aggregations

Reference (org.hl7.fhir.dstu3.model.Reference)8 Reference (org.hl7.fhir.r4.model.Reference)8 Resource (org.hl7.fhir.dstu3.model.Resource)6 ArrayList (java.util.ArrayList)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)5 RelatedArtifact (org.hl7.fhir.r4.model.RelatedArtifact)5 Resource (org.hl7.fhir.r4.model.Resource)5 ActivityDefinition (org.hl7.fhir.dstu3.model.ActivityDefinition)4 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)4 ActivityDefinition (org.hl7.fhir.r4.model.ActivityDefinition)4 Attachment (org.hl7.fhir.r4.model.Attachment)4 DomainResource (org.hl7.fhir.r4.model.DomainResource)4 IdType (org.hl7.fhir.dstu3.model.IdType)3 RelatedArtifact (org.hl7.fhir.dstu3.model.RelatedArtifact)3 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)3 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)3 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)2 IdDt (ca.uhn.fhir.model.primitive.IdDt)2 IOException (java.io.IOException)2 URI (java.net.URI)2