Search in sources :

Example 26 with Organization

use of org.hl7.fhir.r4.model.Organization 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.buildInstantiatesCanonical(planDefinition.getUrl()).buildSubject(new Reference(patientId)).buildStatus(CarePlan.CarePlanStatus.DRAFT);
    if (encounterId != null)
        builder.buildEncounter(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(session, theRequest));
}
Also used : CarePlan(org.hl7.fhir.r4.model.CarePlan) CarePlanBuilder(org.opencds.cqf.ruler.cr.r4.builder.CarePlanBuilder) Reference(org.hl7.fhir.r4.model.Reference) RequestGroupBuilder(org.opencds.cqf.ruler.cr.r4.builder.RequestGroupBuilder) PlanDefinition(org.hl7.fhir.r4.model.PlanDefinition) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 27 with Organization

use of org.hl7.fhir.r4.model.Organization 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 28 with Organization

use of org.hl7.fhir.r4.model.Organization in project cqf-ruler by DBCG.

the class CareGapsProviderIT method testPractitionerAndOrganization.

@Test
public void testPractitionerAndOrganization() throws Exception {
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType(periodStartValid));
    params.addParameter().setName("periodEnd").setValue(new StringType(periodEndValid));
    params.addParameter().setName("status").setValue(new StringType(statusValid));
    params.addParameter().setName("measureId").setValue(new StringType(measureIdValid));
    params.addParameter().setName("organization").setValue(new StringType(organizationValid));
    params.addParameter().setName("practitioner").setValue(new StringType(practitionerValid));
    assertThrows(InternalErrorException.class, () -> {
        getClient().operation().onType(Measure.class).named("$care-gaps").withParameters(params).useHttpGet().returnResourceType(Parameters.class).execute();
    });
// TODO: implement practitioner and organization
// assertDoesNotThrow(() -> {
// getClient().operation().onType(Measure.class).named("$care-gaps")
// .withParameters(params)
// .useHttpGet()
// .returnResourceType(Parameters.class)
// .execute();
// });
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Measure(org.hl7.fhir.r4.model.Measure) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 29 with Organization

use of org.hl7.fhir.r4.model.Organization in project cqf-ruler by DBCG.

the class CareGapsProvider method patientReports.

// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
private Parameters.ParametersParameterComponent patientReports(RequestDetails requestDetails, String periodStart, String periodEnd, Patient patient, List<String> status, List<Measure> measures, String organization) {
    // TODO: add organization to report, if it exists.
    Composition composition = getComposition(patient);
    List<DetectedIssue> detectedIssues = new ArrayList<>();
    Map<String, Resource> evaluatedResources = new HashMap<>();
    List<MeasureReport> reports = getReports(requestDetails, periodStart, periodEnd, patient, status, measures, composition, detectedIssues, evaluatedResources);
    if (reports.isEmpty()) {
        return null;
    }
    return initializePatientParameter(patient).setResource(addBundleEntries(requestDetails.getFhirServerBase(), composition, detectedIssues, reports, evaluatedResources));
}
Also used : Composition(org.hl7.fhir.r4.model.Composition) DetectedIssue(org.hl7.fhir.r4.model.DetectedIssue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Resource(org.hl7.fhir.r4.model.Resource) MeasureReport(org.hl7.fhir.r4.model.MeasureReport)

Example 30 with Organization

use of org.hl7.fhir.r4.model.Organization in project summary-care-record-api by NHSDigital.

the class AgentPersonMapper method mapOrganization.

private Organization mapOrganization(Node agentPerson) {
    Organization org;
    Optional<Node> orgNode = xmlUtils.detachOptionalNodeByXPath(agentPerson, ORG_XPATH);
    Optional<Node> orgSdsNode = xmlUtils.detachOptionalNodeByXPath(agentPerson, ORG_SDS_XPATH);
    if (orgNode.isPresent()) {
        org = organisationMapper.mapOrganization(orgNode.get());
    } else if (orgSdsNode.isPresent()) {
        org = organisationSdsMapper.mapOrganizationSds(orgSdsNode.get());
    } else {
        org = new Organization();
        org.setId(randomUUID());
    }
    org.setTelecom(mapContactPoints(agentPerson));
    xmlUtils.getOptionalValueByXPath(agentPerson, ADDRESS_XPATH).ifPresent(val -> org.addAddress(new Address().setText(val)));
    return org;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Address(org.hl7.fhir.r4.model.Address) Node(org.w3c.dom.Node)

Aggregations

Test (org.junit.jupiter.api.Test)101 Organization (org.hl7.fhir.dstu3.model.Organization)90 Organization (org.hl7.fhir.r4.model.Organization)69 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)41 Resource (org.hl7.fhir.r4.model.Resource)38 ArrayList (java.util.ArrayList)34 List (java.util.List)33 Reference (org.hl7.fhir.r4.model.Reference)33 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.dstu3.model.Bundle)27 UUID (java.util.UUID)26 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)25 Patient (org.hl7.fhir.r4.model.Patient)25 IdType (org.hl7.fhir.dstu3.model.IdType)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 Coding (org.hl7.fhir.r4.model.Coding)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)16