Search in sources :

Example 1 with ExtensionBuilder

use of org.opencds.cqf.ruler.cr.dstu3.builder.ExtensionBuilder 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 2 with ExtensionBuilder

use of org.opencds.cqf.ruler.cr.dstu3.builder.ExtensionBuilder 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 Extension (org.hl7.fhir.dstu3.model.Extension)1 RelatedArtifact (org.hl7.fhir.dstu3.model.RelatedArtifact)1 Extension (org.hl7.fhir.r4.model.Extension)1 RelatedArtifact (org.hl7.fhir.r4.model.RelatedArtifact)1 AttachmentBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.AttachmentBuilder)1 CarePlanActivityBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanActivityBuilder)1 CarePlanBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanBuilder)1 ExtensionBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.ExtensionBuilder)1 RequestGroupBuilder (org.opencds.cqf.ruler.cr.dstu3.builder.RequestGroupBuilder)1 AttachmentBuilder (org.opencds.cqf.ruler.cr.r4.builder.AttachmentBuilder)1 CarePlanActivityBuilder (org.opencds.cqf.ruler.cr.r4.builder.CarePlanActivityBuilder)1 CarePlanBuilder (org.opencds.cqf.ruler.cr.r4.builder.CarePlanBuilder)1 ExtensionBuilder (org.opencds.cqf.ruler.cr.r4.builder.ExtensionBuilder)1 RequestGroupBuilder (org.opencds.cqf.ruler.cr.r4.builder.RequestGroupBuilder)1