Search in sources :

Example 96 with Reference

use of org.hl7.fhir.dstu2.model.Reference in project cqf-ruler by DBCG.

the class Session method applyPlanDefinition.

@Operation(name = "$apply", idempotent = true, type = PlanDefinition.class)
public CarePlan applyPlanDefinition(RequestDetails theRequest, @IdParam IdType theId, @OperationParam(name = "patient") String patientId, @OperationParam(name = "encounter") String encounterId, @OperationParam(name = "practitioner") String practitionerId, @OperationParam(name = "organization") String organizationId, @OperationParam(name = "userType") String userType, @OperationParam(name = "userLanguage") String userLanguage, @OperationParam(name = "userTaskContext") String userTaskContext, @OperationParam(name = "setting") String setting, @OperationParam(name = "settingContext") String settingContext) throws IOException, FHIRException {
    PlanDefinition planDefinition = this.planDefinitionDao.read(theId);
    if (planDefinition == null) {
        throw new IllegalArgumentException("Couldn't find PlanDefinition " + theId);
    }
    logger.info("Performing $apply operation on PlanDefinition/{}", theId);
    CarePlanBuilder builder = new CarePlanBuilder();
    builder.buildDefinition(new Reference(planDefinition.getIdElement().getIdPart())).buildSubject(new Reference(patientId)).buildStatus(CarePlan.CarePlanStatus.DRAFT);
    if (encounterId != null)
        builder.buildContext(new Reference(encounterId));
    if (practitionerId != null)
        builder.buildAuthor(new Reference(practitionerId));
    if (organizationId != null)
        builder.buildAuthor(new Reference(organizationId));
    if (userLanguage != null)
        builder.buildLanguage(userLanguage);
    // Each Group of actions shares a RequestGroup
    RequestGroupBuilder requestGroupBuilder = new RequestGroupBuilder().buildStatus().buildIntent();
    Session session = new Session(planDefinition, builder, patientId, encounterId, practitionerId, organizationId, userType, userLanguage, userTaskContext, setting, settingContext, requestGroupBuilder);
    return (CarePlan) ContainedHelper.liftContainedResourcesToParent(resolveActions(theRequest, session));
}
Also used : CarePlan(org.hl7.fhir.dstu3.model.CarePlan) CarePlanBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.CarePlanBuilder) Reference(org.hl7.fhir.dstu3.model.Reference) RequestGroupBuilder(org.opencds.cqf.ruler.cr.dstu3.builder.RequestGroupBuilder) PlanDefinition(org.hl7.fhir.dstu3.model.PlanDefinition) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 97 with Reference

use of org.hl7.fhir.dstu2.model.Reference in project cqf-ruler by DBCG.

the class SubmitDataProviderIT method testSubmitDataNoId.

@Test
public void testSubmitDataNoId() {
    // Create a MR and a resource
    MeasureReport mr = newResource(MeasureReport.class).setMeasure(new Reference("Measure/123"));
    Observation obs = newResource(Observation.class).setValue(new StringType("ABC"));
    // Submit it
    mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "123"), mr, Lists.newArrayList(obs));
    // Check if they made it to the db
    Observation savedObs = search(Observation.class, Searches.all()).single();
    assertNotNull(savedObs);
    assertEquals("ABC", savedObs.getValue().primitiveValue());
    MeasureReport savedMr = search(MeasureReport.class, Searches.all()).single();
    assertNotNull(savedMr);
    assertEquals("Measure/123", savedMr.getMeasure().getReference());
}
Also used : StringType(org.hl7.fhir.dstu3.model.StringType) SystemRequestDetails(ca.uhn.fhir.jpa.partition.SystemRequestDetails) Reference(org.hl7.fhir.dstu3.model.Reference) Observation(org.hl7.fhir.dstu3.model.Observation) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) DaoIntegrationTest(org.opencds.cqf.ruler.test.DaoIntegrationTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 98 with Reference

use of org.hl7.fhir.dstu2.model.Reference 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;
}
Also used : StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) CommunicationRequest(org.hl7.fhir.dstu3.model.CommunicationRequest)

Example 99 with Reference

use of org.hl7.fhir.dstu2.model.Reference 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;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact)

Example 100 with Reference

use of org.hl7.fhir.dstu2.model.Reference 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;
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Reference(org.hl7.fhir.dstu3.model.Reference)

Aggregations

Reference (org.hl7.fhir.r4.model.Reference)363 Test (org.junit.Test)305 ArrayList (java.util.ArrayList)210 Reference (org.hl7.fhir.dstu3.model.Reference)156 Reference (io.adminshell.aas.v3.model.Reference)118 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)91 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)85 Resource (org.hl7.fhir.r4.model.Resource)85 Test (org.junit.jupiter.api.Test)85 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)84 List (java.util.List)84 Bundle (org.hl7.fhir.r4.model.Bundle)82 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)80 Coding (org.hl7.fhir.r4.model.Coding)76 Observation (org.hl7.fhir.r4.model.Observation)69 FHIRException (org.hl7.fhir.exceptions.FHIRException)67 Date (java.util.Date)62 Identifier (org.hl7.fhir.r4.model.Identifier)58 Collectors (java.util.stream.Collectors)53 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)49