use of org.hl7.fhir.r4.model.CommunicationRequest 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;
}
use of org.hl7.fhir.r4.model.CommunicationRequest in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveActivityDefinition.
// For library use
public Resource resolveActivityDefinition(ActivityDefinition activityDefinition, String patientId, String practitionerId, String organizationId, RequestDetails theRequest) throws FHIRException {
Resource result = newResource(activityDefinition.getKind().toCode());
switch(result.fhirType()) {
case "ServiceRequest":
result = resolveServiceRequest(activityDefinition, patientId, practitionerId, organizationId);
break;
case "MedicationRequest":
result = resolveMedicationRequest(activityDefinition, patientId);
break;
case "SupplyRequest":
result = resolveSupplyRequest(activityDefinition, practitionerId, organizationId);
break;
case "Procedure":
result = resolveProcedure(activityDefinition, patientId);
break;
case "DiagnosticReport":
result = resolveDiagnosticReport(activityDefinition, patientId);
break;
case "Communication":
result = resolveCommunication(activityDefinition, patientId);
break;
case "CommunicationRequest":
result = resolveCommunicationRequest(activityDefinition, patientId);
break;
case "Task":
result = resolveTask(activityDefinition, patientId);
break;
}
for (ActivityDefinition.ActivityDefinitionDynamicValueComponent dynamicValue : activityDefinition.getDynamicValue()) {
// ActivityDefinition apply operation does not fail.
try {
if (dynamicValue.getExpression() != null) {
// Special case for setting a Patient reference
if ("Patient".equals(dynamicValue.getExpression().getExpression())) {
this.modelResolver.setValue(result, dynamicValue.getPath(), new Reference(patientId));
} else {
/*
* TODO: Passing the activityDefinition as context here because that's what will
* have the libraries, but perhaps the "context" here should be the result
* resource?
*/
Object value = expressionEvaluation.evaluateInContext(activityDefinition, dynamicValue.getExpression().getExpression(), patientId, theRequest);
if (value != null) {
logger.debug("dynamicValue value: {}", value);
if (value instanceof Boolean) {
value = new BooleanType((Boolean) value);
} else if (value instanceof DateTime) {
value = Date.from(((DateTime) value).getDateTime().toInstant());
} else if (value instanceof String) {
value = new StringType((String) value);
}
this.modelResolver.setValue(result, dynamicValue.getPath(), value);
} else {
logger.warn("WARNING: ActivityDefinition has null value for path: {}", dynamicValue.getPath());
}
}
}
} catch (Exception e) {
logger.error("ERROR: ActivityDefinition dynamicValue {} could not be applied and threw exception {}", dynamicValue.getPath(), e.toString());
logger.error(e.toString());
}
}
return result;
}
use of org.hl7.fhir.r4.model.CommunicationRequest in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCommunicationRequestCommunicationRequestPayloadComponent.
protected void composeCommunicationRequestCommunicationRequestPayloadComponent(Complex parent, String parentType, String name, CommunicationRequest.CommunicationRequestPayloadComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "payload", name, element, index);
if (element.hasContent())
composeType(t, "CommunicationRequest", "content", element.getContent(), -1);
}
use of org.hl7.fhir.r4.model.CommunicationRequest in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCommunicationRequestCommunicationRequestRequesterComponent.
protected void composeCommunicationRequestCommunicationRequestRequesterComponent(Complex parent, String parentType, String name, CommunicationRequest.CommunicationRequestRequesterComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "requester", name, element, index);
if (element.hasAgent())
composeReference(t, "CommunicationRequest", "agent", element.getAgent(), -1);
if (element.hasOnBehalfOf())
composeReference(t, "CommunicationRequest", "onBehalfOf", element.getOnBehalfOf(), -1);
}
use of org.hl7.fhir.r4.model.CommunicationRequest in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCommunicationRequest.
protected void composeCommunicationRequest(Complex parent, String parentType, String name, CommunicationRequest element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "CommunicationRequest", name, element, index);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "CommunicationRequest", "identifier", element.getIdentifier().get(i), i);
if (element.hasCategory())
composeCodeableConcept(t, "CommunicationRequest", "category", element.getCategory(), -1);
if (element.hasSender())
composeReference(t, "CommunicationRequest", "sender", element.getSender(), -1);
for (int i = 0; i < element.getRecipient().size(); i++) composeReference(t, "CommunicationRequest", "recipient", element.getRecipient().get(i), i);
for (int i = 0; i < element.getPayload().size(); i++) composeCommunicationRequestCommunicationRequestPayloadComponent(t, "CommunicationRequest", "payload", element.getPayload().get(i), i);
for (int i = 0; i < element.getMedium().size(); i++) composeCodeableConcept(t, "CommunicationRequest", "medium", element.getMedium().get(i), i);
if (element.hasRequester())
composeReference(t, "CommunicationRequest", "requester", element.getRequester(), -1);
if (element.hasStatusElement())
composeEnum(t, "CommunicationRequest", "status", element.getStatusElement(), -1);
if (element.hasEncounter())
composeReference(t, "CommunicationRequest", "encounter", element.getEncounter(), -1);
if (element.hasScheduled())
composeType(t, "CommunicationRequest", "scheduled", element.getScheduled(), -1);
for (int i = 0; i < element.getReason().size(); i++) composeCodeableConcept(t, "CommunicationRequest", "reason", element.getReason().get(i), i);
if (element.hasRequestedOnElement())
composeDateTime(t, "CommunicationRequest", "requestedOn", element.getRequestedOnElement(), -1);
if (element.hasSubject())
composeReference(t, "CommunicationRequest", "subject", element.getSubject(), -1);
if (element.hasPriority())
composeCodeableConcept(t, "CommunicationRequest", "priority", element.getPriority(), -1);
}
Aggregations