use of org.hl7.fhir.dstu3.model.RequestGroup 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.hl7.fhir.dstu3.model.RequestGroup in project cqf-ruler by DBCG.
the class STU3CarePlanToCdsCard method convert.
private static List<CdsCard> convert(RequestGroup requestGroup) {
List<CdsCard> cards = new ArrayList<>();
// links
List<CdsCard.Links> links = new ArrayList<>();
if (requestGroup.hasExtension()) {
for (Extension extension : requestGroup.getExtension()) {
CdsCard.Links link = new CdsCard.Links();
if (extension.getValue() instanceof Attachment) {
Attachment attachment = (Attachment) extension.getValue();
if (attachment.hasUrl()) {
link.setUrl(attachment.getUrl());
}
if (attachment.hasTitle()) {
link.setLabel(attachment.getTitle());
}
if (attachment.hasExtension()) {
link.setType(attachment.getExtensionFirstRep().getValue().primitiveValue());
}
} else {
throw new RuntimeException("Invalid link extension type: " + extension.getValue().fhirType());
}
links.add(link);
}
}
if (requestGroup.hasAction()) {
for (RequestGroup.RequestGroupActionComponent action : requestGroup.getAction()) {
IParser jsonParser = FhirContext.forCached(FhirVersionEnum.DSTU3).newJsonParser().setPrettyPrint(true);
CdsCard card = new CdsCard(jsonParser);
// basic
if (action.hasTitle()) {
card.setSummary(action.getTitle());
}
if (action.hasDescription()) {
card.setDetail(action.getDescription());
}
if (action.hasExtension()) {
card.setIndicator(action.getExtensionFirstRep().getValue().toString());
}
// source
if (action.hasDocumentation()) {
// Assuming first related artifact has everything
RelatedArtifact documentation = action.getDocumentationFirstRep();
CdsCard.Source source = new CdsCard.Source();
if (documentation.hasDisplay()) {
source.setLabel(documentation.getDisplay());
}
if (documentation.hasUrl()) {
source.setUrl(documentation.getUrl());
}
if (documentation.hasDocument() && documentation.getDocument().hasUrl()) {
source.setIcon(documentation.getDocument().getUrl());
}
card.setSource(source);
}
if (action.hasSelectionBehavior()) {
card.setSelectionBehavior(action.getSelectionBehavior().toCode());
}
// suggestions
// TODO - uuid
boolean hasSuggestions = false;
CdsCard.Suggestions suggestions = new CdsCard.Suggestions();
CdsCard.Suggestions.Action actions = new CdsCard.Suggestions.Action();
if (action.hasLabel()) {
suggestions.setLabel(action.getLabel());
hasSuggestions = true;
if (action.hasDescription()) {
actions.setDescription(action.getDescription());
}
if (action.hasType() && !action.getType().getCode().equals("fire-event")) {
String code = action.getType().getCode();
actions.setType(CdsCard.Suggestions.Action.ActionType.valueOf(code.equals("remove") ? "delete" : code));
}
if (action.hasResource()) {
if (actions.getType().name().equalsIgnoreCase("create")) {
action.getResourceTarget().setId((String) null);
}
actions.setResource(action.getResourceTarget());
}
}
if (hasSuggestions) {
suggestions.addAction(actions);
card.addSuggestion(suggestions);
}
if (!links.isEmpty()) {
card.setLinks(links);
}
cards.add(card);
}
}
return cards;
}
use of org.hl7.fhir.dstu3.model.RequestGroup in project cqf-ruler by DBCG.
the class STU3CarePlanToCdsCard method convert.
public static List<CdsCard> convert(CarePlan carePlan) {
List<CdsCard> cards = new ArrayList<>();
for (CarePlan.CarePlanActivityComponent activity : carePlan.getActivity()) {
if (activity.getReferenceTarget() != null && activity.getReferenceTarget() instanceof RequestGroup) {
RequestGroup requestGroup = (RequestGroup) activity.getReferenceTarget();
cards = convert(requestGroup);
}
}
return cards;
}
use of org.hl7.fhir.dstu3.model.RequestGroup in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeRequestGroupRequestGroupActionComponent.
protected void composeRequestGroupRequestGroupActionComponent(Complex parent, String parentType, String name, RequestGroup.RequestGroupActionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "action", name, element, index);
if (element.hasLabelElement())
composeString(t, "RequestGroup", "label", element.getLabelElement(), -1);
if (element.hasTitleElement())
composeString(t, "RequestGroup", "title", element.getTitleElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "RequestGroup", "description", element.getDescriptionElement(), -1);
if (element.hasTextEquivalentElement())
composeString(t, "RequestGroup", "textEquivalent", element.getTextEquivalentElement(), -1);
for (int i = 0; i < element.getCode().size(); i++) composeCodeableConcept(t, "RequestGroup", "code", element.getCode().get(i), i);
for (int i = 0; i < element.getDocumentation().size(); i++) composeRelatedArtifact(t, "RequestGroup", "documentation", element.getDocumentation().get(i), i);
for (int i = 0; i < element.getCondition().size(); i++) composeRequestGroupRequestGroupActionConditionComponent(t, "RequestGroup", "condition", element.getCondition().get(i), i);
for (int i = 0; i < element.getRelatedAction().size(); i++) composeRequestGroupRequestGroupActionRelatedActionComponent(t, "RequestGroup", "relatedAction", element.getRelatedAction().get(i), i);
if (element.hasTiming())
composeType(t, "RequestGroup", "timing", element.getTiming(), -1);
for (int i = 0; i < element.getParticipant().size(); i++) composeReference(t, "RequestGroup", "participant", element.getParticipant().get(i), i);
if (element.hasType())
composeCoding(t, "RequestGroup", "type", element.getType(), -1);
if (element.hasGroupingBehaviorElement())
composeEnum(t, "RequestGroup", "groupingBehavior", element.getGroupingBehaviorElement(), -1);
if (element.hasSelectionBehaviorElement())
composeEnum(t, "RequestGroup", "selectionBehavior", element.getSelectionBehaviorElement(), -1);
if (element.hasRequiredBehaviorElement())
composeEnum(t, "RequestGroup", "requiredBehavior", element.getRequiredBehaviorElement(), -1);
if (element.hasPrecheckBehaviorElement())
composeEnum(t, "RequestGroup", "precheckBehavior", element.getPrecheckBehaviorElement(), -1);
if (element.hasCardinalityBehaviorElement())
composeEnum(t, "RequestGroup", "cardinalityBehavior", element.getCardinalityBehaviorElement(), -1);
if (element.hasResource())
composeReference(t, "RequestGroup", "resource", element.getResource(), -1);
for (int i = 0; i < element.getAction().size(); i++) composeRequestGroupRequestGroupActionComponent(t, "RequestGroup", "action", element.getAction().get(i), i);
}
use of org.hl7.fhir.dstu3.model.RequestGroup in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeRequestGroup.
protected void composeRequestGroup(Complex parent, String parentType, String name, RequestGroup element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "RequestGroup", name, element, index);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "RequestGroup", "identifier", element.getIdentifier().get(i), i);
for (int i = 0; i < element.getInstantiatesCanonical().size(); i++) composeCanonical(t, "RequestGroup", "instantiatesCanonical", element.getInstantiatesCanonical().get(i), i);
for (int i = 0; i < element.getInstantiatesUri().size(); i++) composeUri(t, "RequestGroup", "instantiatesUri", element.getInstantiatesUri().get(i), i);
for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "RequestGroup", "basedOn", element.getBasedOn().get(i), i);
for (int i = 0; i < element.getReplaces().size(); i++) composeReference(t, "RequestGroup", "replaces", element.getReplaces().get(i), i);
if (element.hasGroupIdentifier())
composeIdentifier(t, "RequestGroup", "groupIdentifier", element.getGroupIdentifier(), -1);
if (element.hasStatusElement())
composeEnum(t, "RequestGroup", "status", element.getStatusElement(), -1);
if (element.hasIntentElement())
composeEnum(t, "RequestGroup", "intent", element.getIntentElement(), -1);
if (element.hasPriorityElement())
composeEnum(t, "RequestGroup", "priority", element.getPriorityElement(), -1);
if (element.hasCode())
composeCodeableConcept(t, "RequestGroup", "code", element.getCode(), -1);
if (element.hasSubject())
composeReference(t, "RequestGroup", "subject", element.getSubject(), -1);
if (element.hasEncounter())
composeReference(t, "RequestGroup", "encounter", element.getEncounter(), -1);
if (element.hasAuthoredOnElement())
composeDateTime(t, "RequestGroup", "authoredOn", element.getAuthoredOnElement(), -1);
if (element.hasAuthor())
composeReference(t, "RequestGroup", "author", element.getAuthor(), -1);
for (int i = 0; i < element.getReasonCode().size(); i++) composeCodeableConcept(t, "RequestGroup", "reasonCode", element.getReasonCode().get(i), i);
for (int i = 0; i < element.getReasonReference().size(); i++) composeReference(t, "RequestGroup", "reasonReference", element.getReasonReference().get(i), i);
for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "RequestGroup", "note", element.getNote().get(i), i);
for (int i = 0; i < element.getAction().size(); i++) composeRequestGroupRequestGroupActionComponent(t, "RequestGroup", "action", element.getAction().get(i), i);
}
Aggregations