use of org.hl7.fhir.r4.model.ActivityDefinition 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.ActivityDefinition in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveDiagnosticReport.
private DiagnosticReport resolveDiagnosticReport(ActivityDefinition activityDefinition, String patientId) {
DiagnosticReport diagnosticReport = new DiagnosticReport();
diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.UNKNOWN);
diagnosticReport.setSubject(new Reference(patientId));
if (activityDefinition.hasCode()) {
diagnosticReport.setCode(activityDefinition.getCode());
} else {
throw new ActivityDefinitionApplyException("Missing required ActivityDefinition.code property for DiagnosticReport");
}
if (activityDefinition.hasRelatedArtifact()) {
List<Attachment> presentedFormAttachments = new ArrayList<>();
for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
Attachment attachment = new Attachment();
if (artifact.hasUrl()) {
attachment.setUrl(artifact.getUrl());
}
if (artifact.hasDisplay()) {
attachment.setTitle(artifact.getDisplay());
}
presentedFormAttachments.add(attachment);
}
diagnosticReport.setPresentedForm(presentedFormAttachments);
}
return diagnosticReport;
}
use of org.hl7.fhir.r4.model.ActivityDefinition in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveMedicationRequest.
private MedicationRequest resolveMedicationRequest(ActivityDefinition activityDefinition, String patientId) throws ActivityDefinitionApplyException {
// intent, medication, and subject are required
MedicationRequest medicationRequest = new MedicationRequest();
medicationRequest.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
medicationRequest.setSubject(new Reference(patientId));
if (activityDefinition.hasProduct()) {
medicationRequest.setMedication(activityDefinition.getProduct());
} else {
throw new ActivityDefinitionApplyException("Missing required product property");
}
if (activityDefinition.hasDosage()) {
medicationRequest.setDosageInstruction(activityDefinition.getDosage());
}
if (activityDefinition.hasBodySite()) {
throw new ActivityDefinitionApplyException("BodySite does not map to " + activityDefinition.getKind());
}
if (activityDefinition.hasCode()) {
throw new ActivityDefinitionApplyException("Code does not map to " + activityDefinition.getKind());
}
if (activityDefinition.hasQuantity()) {
throw new ActivityDefinitionApplyException("Quantity does not map to " + activityDefinition.getKind());
}
return medicationRequest;
}
use of org.hl7.fhir.r4.model.ActivityDefinition in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveCommunication.
private Communication resolveCommunication(ActivityDefinition activityDefinition, String patientId) {
Communication communication = new Communication();
communication.setStatus(Communication.CommunicationStatus.UNKNOWN);
communication.setSubject(new Reference(patientId));
if (activityDefinition.hasCode()) {
communication.setReasonCode(Collections.singletonList(activityDefinition.getCode()));
}
if (activityDefinition.hasRelatedArtifact()) {
for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
if (artifact.hasUrl()) {
Attachment attachment = new Attachment().setUrl(artifact.getUrl());
if (artifact.hasDisplay()) {
attachment.setTitle(artifact.getDisplay());
}
Communication.CommunicationPayloadComponent payload = new Communication.CommunicationPayloadComponent();
payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
communication.setPayload(Collections.singletonList(payload));
}
// TODO - other relatedArtifact types
}
}
return communication;
}
use of org.hl7.fhir.r4.model.ActivityDefinition in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveProcedure.
private Procedure resolveProcedure(ActivityDefinition activityDefinition, String patientId) {
Procedure procedure = new Procedure();
// TODO - set the appropriate status
procedure.setStatus(Procedure.ProcedureStatus.UNKNOWN);
procedure.setSubject(new Reference(patientId));
if (activityDefinition.hasCode()) {
procedure.setCode(activityDefinition.getCode());
}
if (activityDefinition.hasBodySite()) {
procedure.setBodySite(activityDefinition.getBodySite());
}
return procedure;
}
Aggregations