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();
}
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();
}
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();
}
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();
}
Aggregations