Search in sources :

Example 1 with CarePlanActivityBuilder

use of org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder in project cqf-ruler by DBCG.

the class Session method resolveActions.

private CarePlan resolveActions(RequestDetails theRequest, Session session) {
    for (PlanDefinition.PlanDefinitionActionComponent action : session.getPlanDefinition().getAction()) {
        // TODO - Apply input/output dataRequirements?
        if (meetsConditions(theRequest, session, action)) {
            Resource result = resolveDefinition(theRequest, session, action);
            RequestGroupActionComponent currentActionTarget = null;
            if (result != null) {
                currentActionTarget = new RequestGroupActionBuilder().buildResource(new Reference("#" + result.getId())).build();
                session.getRequestGroupBuilder().buildContained(result).addAction(currentActionTarget);
            }
            resolveDynamicActions(theRequest, session, currentActionTarget, action);
        }
    }
    RequestGroup result = session.getRequestGroupBuilder().build();
    if (result.getId() == null) {
        result.setId(UUID.randomUUID().toString());
    }
    session.getCarePlanBuilder().buildContained(result).buildActivity(new CarePlanActivityBuilder().buildReference(new Reference("#" + result.getId())).build());
    return session.getCarePlan();
}
Also used : RequestGroupActionComponent(org.hl7.fhir.dstu3.model.RequestGroup.RequestGroupActionComponent) RequestGroupActionBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.RequestGroupActionBuilder) Reference(org.hl7.fhir.dstu3.model.Reference) RequestGroup(org.hl7.fhir.dstu3.model.RequestGroup) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) Resource(org.hl7.fhir.dstu3.model.Resource) PlanDefinition(org.hl7.fhir.dstu3.model.PlanDefinition) CarePlanActivityBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanActivityBuilder)

Example 2 with CarePlanActivityBuilder

use of org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder in project cqf-ruler by DBCG.

the class Session method resolveCdsHooksPlanDefinition.

// For library use
public CarePlan resolveCdsHooksPlanDefinition(RequestDetails theRequest, Context context, PlanDefinition planDefinition, String patientId) {
    CarePlanBuilder carePlanBuilder = new CarePlanBuilder();
    RequestGroupBuilder requestGroupBuilder = new RequestGroupBuilder().buildStatus().buildIntent();
    // links
    if (planDefinition.hasRelatedArtifact()) {
        List<Extension> extensions = new ArrayList<>();
        for (RelatedArtifact relatedArtifact : planDefinition.getRelatedArtifact()) {
            AttachmentBuilder attachmentBuilder = new AttachmentBuilder();
            ExtensionBuilder extensionBuilder = new ExtensionBuilder();
            if (relatedArtifact.hasDisplay()) {
                // label
                attachmentBuilder.buildTitle(relatedArtifact.getDisplay());
            }
            if (relatedArtifact.hasUrl()) {
                // url
                attachmentBuilder.buildUrl(relatedArtifact.getUrl());
            }
            if (relatedArtifact.hasExtension()) {
                // type
                attachmentBuilder.buildExtension(relatedArtifact.getExtension());
            }
            extensionBuilder.buildUrl("http://example.org");
            extensionBuilder.buildValue(attachmentBuilder.build());
            extensions.add(extensionBuilder.build());
        }
        requestGroupBuilder.buildExtension(extensions);
    }
    resolveActions(theRequest, planDefinition, planDefinition.getAction(), context, patientId, requestGroupBuilder, new ArrayList<>());
    CarePlanActivityBuilder carePlanActivityBuilder = new CarePlanActivityBuilder();
    carePlanActivityBuilder.buildReferenceTarget(requestGroupBuilder.build());
    carePlanBuilder.buildActivity(carePlanActivityBuilder.build());
    return carePlanBuilder.build();
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) AttachmentBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.AttachmentBuilder) CarePlanBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanBuilder) RequestGroupBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.RequestGroupBuilder) ArrayList(java.util.ArrayList) ExtensionBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.ExtensionBuilder) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact) CarePlanActivityBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanActivityBuilder)

Example 3 with CarePlanActivityBuilder

use of org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder in project cqf-ruler by DBCG.

the class Session method resolveActions.

private CarePlan resolveActions(Session session, RequestDetails theRequest) {
    RequestGroup theRequestGroup = session.getRequestGroupBuilder().build();
    for (PlanDefinition.PlanDefinitionActionComponent action : session.getPlanDefinition().getAction()) {
        // TODO - Apply input/output dataRequirements?
        if (meetsConditions(session, action, theRequest)) {
            Resource result = resolveDefinition(session, action, theRequest);
            RequestGroupActionComponent currentActionTarget = null;
            if (result != null) {
                currentActionTarget = new RequestGroupActionBuilder().buildResource(new Reference("#" + result.getId())).build();
                session.getRequestGroupBuilder().buildContained(result).addAction(currentActionTarget);
            }
            resolveDynamicActions(session, action, currentActionTarget, theRequest);
        }
    }
    if (theRequestGroup.getId() == null) {
        theRequestGroup.setId(UUID.randomUUID().toString());
    }
    session.getCarePlanBuilder().buildContained(theRequestGroup).buildActivity(new CarePlanActivityBuilder().buildReference(new Reference("#" + theRequestGroup.getId())).build());
    return session.getCarePlan();
}
Also used : RequestGroupActionComponent(org.hl7.fhir.r4.model.RequestGroup.RequestGroupActionComponent) RequestGroupActionBuilder(org.opencds.cqf.ruler.cr.r4.builder.RequestGroupActionBuilder) RequestGroup(org.hl7.fhir.r4.model.RequestGroup) Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) DomainResource(org.hl7.fhir.r4.model.DomainResource) PlanDefinition(org.hl7.fhir.r4.model.PlanDefinition) CarePlanActivityBuilder(org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder)

Example 4 with CarePlanActivityBuilder

use of org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder in project cqf-ruler by DBCG.

the class Session method resolveCdsHooksPlanDefinition.

// For library use
public CarePlan resolveCdsHooksPlanDefinition(Context context, PlanDefinition planDefinition, String patientId, RequestDetails theRequest) {
    CarePlanBuilder carePlanBuilder = new CarePlanBuilder();
    RequestGroupBuilder requestGroupBuilder = new RequestGroupBuilder().buildStatus().buildIntent();
    // links
    if (planDefinition.hasRelatedArtifact()) {
        List<Extension> extensions = new ArrayList<>();
        for (RelatedArtifact relatedArtifact : planDefinition.getRelatedArtifact()) {
            AttachmentBuilder attachmentBuilder = new AttachmentBuilder();
            ExtensionBuilder extensionBuilder = new ExtensionBuilder();
            if (relatedArtifact.hasDisplay()) {
                // label
                attachmentBuilder.buildTitle(relatedArtifact.getDisplay());
            }
            if (relatedArtifact.hasUrl()) {
                // url
                attachmentBuilder.buildUrl(relatedArtifact.getUrl());
            }
            if (relatedArtifact.hasExtension()) {
                // type
                attachmentBuilder.buildExtension(relatedArtifact.getExtension());
            }
            extensionBuilder.buildUrl("http://example.org");
            extensionBuilder.buildValue(attachmentBuilder.build());
            extensions.add(extensionBuilder.build());
        }
        requestGroupBuilder.buildExtension(extensions);
    }
    resolveActions(planDefinition.getAction(), context, patientId, requestGroupBuilder, new ArrayList<>(), theRequest);
    CarePlanActivityBuilder carePlanActivityBuilder = new CarePlanActivityBuilder();
    carePlanActivityBuilder.buildReferenceTarget(requestGroupBuilder.build());
    carePlanBuilder.buildActivity(carePlanActivityBuilder.build());
    return carePlanBuilder.build();
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) AttachmentBuilder(org.opencds.cqf.ruler.cr.r4.builder.AttachmentBuilder) CarePlanBuilder(org.opencds.cqf.ruler.cr.r4.builder.CarePlanBuilder) RequestGroupBuilder(org.opencds.cqf.ruler.cr.r4.builder.RequestGroupBuilder) ArrayList(java.util.ArrayList) ExtensionBuilder(org.opencds.cqf.ruler.cr.r4.builder.ExtensionBuilder) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact) CarePlanActivityBuilder(org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder)

Aggregations

ArrayList (java.util.ArrayList)2 CarePlanActivityBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanActivityBuilder)2 CarePlanActivityBuilder (org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder)2 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)1 Extension (org.hl7.fhir.dstu3.model.Extension)1 PlanDefinition (org.hl7.fhir.dstu3.model.PlanDefinition)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 RelatedArtifact (org.hl7.fhir.dstu3.model.RelatedArtifact)1 RequestGroup (org.hl7.fhir.dstu3.model.RequestGroup)1 RequestGroupActionComponent (org.hl7.fhir.dstu3.model.RequestGroup.RequestGroupActionComponent)1 Resource (org.hl7.fhir.dstu3.model.Resource)1 DomainResource (org.hl7.fhir.r4.model.DomainResource)1 Extension (org.hl7.fhir.r4.model.Extension)1 PlanDefinition (org.hl7.fhir.r4.model.PlanDefinition)1 Reference (org.hl7.fhir.r4.model.Reference)1 RelatedArtifact (org.hl7.fhir.r4.model.RelatedArtifact)1 RequestGroup (org.hl7.fhir.r4.model.RequestGroup)1 RequestGroupActionComponent (org.hl7.fhir.r4.model.RequestGroup.RequestGroupActionComponent)1 Resource (org.hl7.fhir.r4.model.Resource)1 AttachmentBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.AttachmentBuilder)1