Search in sources :

Example 26 with Group

use of org.hl7.fhir.dstu3.model.Group in project manifoldcf by apache.

the class ConfluenceClient method getUserGroups.

private List<Group> getUserGroups(final String username) throws Exception {
    long lastStart = 0;
    final long defaultSize = 50;
    final List<Group> groups = new ArrayList<Group>();
    if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
        final String groupsDesc = "groups of user " + username;
        Logging.connectors.debug(new MessageFormat("Starting from {0} and size {1} for {2}", Locale.ROOT).format(new Object[] { lastStart, defaultSize, groupsDesc }));
    }
    Boolean isLast = true;
    do {
        final ConfluenceResponse<Group> response = getUserGroups((int) lastStart, (int) defaultSize, username);
        int count = 0;
        for (final Group group : response.getResults()) {
            groups.add(group);
            count++;
        }
        lastStart += count;
        isLast = response.isLast();
        if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
            Logging.connectors.debug(new MessageFormat("New start {0} and size {1}", Locale.ROOT).format(new Object[] { lastStart, defaultSize }));
        }
    } while (!isLast);
    return groups;
}
Also used : Group(org.apache.manifoldcf.crawler.connectors.confluence.v6.model.Group) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) JSONObject(org.json.simple.JSONObject)

Example 27 with Group

use of org.hl7.fhir.dstu3.model.Group in project cqf-ruler by DBCG.

the class ParameterUser method getPatientListFromGroup.

// TODO: replace this with version from the evaluator?
default List<Patient> getPatientListFromGroup(String subjectGroupId) {
    List<Patient> patientList = new ArrayList<>();
    Group group = read(newId(subjectGroupId));
    if (group == null) {
        throw new IllegalArgumentException("Could not find Group: " + subjectGroupId);
    }
    group.getMember().forEach(member -> {
        Reference reference = member.getEntity();
        if (reference.getReferenceElement().getResourceType().equals("Patient")) {
            Patient patient = ensurePatient(reference.getReference());
            patientList.add(patient);
        } else if (reference.getReferenceElement().getResourceType().equals("Group")) {
            patientList.addAll(getPatientListFromGroup(reference.getReference()));
        } else {
            ourLog.info("Group member was not a Patient or a Group, so skipping. \n{}", reference.getReference());
        }
    });
    return patientList;
}
Also used : Group(org.hl7.fhir.r4.model.Group) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) Patient(org.hl7.fhir.r4.model.Patient)

Example 28 with Group

use of org.hl7.fhir.dstu3.model.Group in project cqf-ruler by DBCG.

the class MeasureDataProcessProviderIT method testMeasureReportExtractLineListData.

@Test
public void testMeasureReportExtractLineListData() throws IOException {
    String packagePrefix = "org/opencds/cqf/ruler/casereporting/r4/";
    loadResource(packagePrefix + "Patient-ra-patient01.json");
    loadResource(packagePrefix + "Patient-ra-patient02.json");
    loadResource(packagePrefix + "Patient-ra-patient03.json");
    loadResource(packagePrefix + "Group-ra-group00.json");
    loadResource(packagePrefix + "Group-ra-group01.json");
    loadResource(packagePrefix + "Group-ra-group02.json");
    loadResource(packagePrefix + "MeasureReport-ra-measurereport01.json");
    MeasureReport measureReport = getClient().read().resource(MeasureReport.class).withId("ra-measurereport01").execute();
    assertNotNull(measureReport);
    Parameters params = new Parameters();
    params.addParameter().setName("measureReport").setResource(measureReport);
    params.addParameter().setName("subjectList").setValue(null);
    Bundle returnBundle = getClient().operation().onType(MeasureReport.class).named("$extract-line-list-data").withParameters(params).returnResourceType(Bundle.class).execute();
    assertNotNull(returnBundle);
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) Bundle(org.hl7.fhir.r4.model.Bundle) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 29 with Group

use of org.hl7.fhir.dstu3.model.Group in project cqf-ruler by DBCG.

the class TransformProvider method transformObservations.

@Operation(name = "$transform", idempotent = false, type = Observation.class)
public Bundle transformObservations(@OperationParam(name = "observations") Bundle observationsBundle, @OperationParam(name = "conceptMapURL") String conceptMapURL) {
    if (null == observationsBundle) {
        throw new IllegalArgumentException("Unable to perform operation Observation$transform.  No Observation bundle passed in.");
    }
    if (null == conceptMapURL) {
        throw new IllegalArgumentException("Unable to perform operation Observation$transform.  No concept map url specified.");
    }
    String replaceCode = mySdcProperties.getTransform().getReplaceCode();
    // String username = mySdcProperties.getTransform().getUsername();
    // String password = mySdcProperties.getTransform().getPassword();
    String endpoint = mySdcProperties.getTransform().getEndpoint();
    IGenericClient client = Clients.forUrl(fhirContext, endpoint);
    ConceptMap transformConceptMap = client.read().resource(ConceptMap.class).withUrl(conceptMapURL).execute();
    if (null == transformConceptMap) {
        throw new IllegalArgumentException("Unable to perform operation Observation$transform.  Unable to get concept map.");
    }
    List<Observation> observations = BundleUtil.toListOfResources(fhirContext, observationsBundle).stream().filter(resource -> resource instanceof Observation).map(Observation.class::cast).collect(Collectors.toList());
    /**
     * TODO - There must be a more efficient way to loop through this, but so far I
     * have not come up with it.
     */
    transformConceptMap.getGroup().forEach(group -> {
        HashMap<String, ConceptMap.TargetElementComponent> codeMappings = new HashMap<>();
        String targetSystem = group.getTarget();
        group.getElement().forEach(codeElement -> {
            codeMappings.put(codeElement.getCode(), codeElement.getTarget().get(0));
        });
        observations.forEach(observation -> {
            if (observation.getValue().fhirType().equalsIgnoreCase("codeableconcept")) {
                String obsValueCode = observation.getValueCodeableConcept().getCoding().get(0).getCode();
                if (obsValueCode != null && codeMappings.get(observation.getValueCodeableConcept().getCoding().get(0).getCode()) != null) {
                    if (replaceCode != null) {
                        observation.getValueCodeableConcept().getCoding().get(0).setCode(codeMappings.get(obsValueCode).getCode());
                        observation.getValueCodeableConcept().getCoding().get(0).setDisplay(codeMappings.get(obsValueCode).getDisplay());
                        observation.getValueCodeableConcept().getCoding().get(0).setSystem(targetSystem);
                    } else {
                        Coding newCoding = new Coding();
                        newCoding.setSystem(targetSystem);
                        newCoding.setCode(codeMappings.get(obsValueCode).getCode());
                        newCoding.setDisplay(codeMappings.get(obsValueCode).getDisplay());
                        observation.getValueCodeableConcept().getCoding().add(newCoding);
                    }
                }
            }
        });
    });
    return observationsBundle;
}
Also used : HashMap(java.util.HashMap) Coding(org.hl7.fhir.dstu3.model.Coding) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Observation(org.hl7.fhir.dstu3.model.Observation) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 30 with Group

use of org.hl7.fhir.dstu3.model.Group in project cqf-ruler by DBCG.

the class TransformProvider method transformObservations.

@Operation(name = "$transform", idempotent = false, type = Observation.class)
public Bundle transformObservations(@OperationParam(name = "observations") Bundle observationsBundle, @OperationParam(name = "conceptMapURL") String conceptMapURL) {
    if (null == observationsBundle) {
        throw new IllegalArgumentException("Unable to perform operation Observation$transform.  No Observation bundle passed in.");
    }
    if (null == conceptMapURL) {
        throw new IllegalArgumentException("Unable to perform operation Observation$transform.  No concept map url specified.");
    }
    String replaceCode = mySdcProperties.getTransform().getReplaceCode();
    // String username = mySdcProperties.getTransform().getUsername();
    // String password = mySdcProperties.getTransform().getPassword();
    String endpoint = mySdcProperties.getTransform().getEndpoint();
    IGenericClient client = Clients.forUrl(fhirContext, endpoint);
    ConceptMap transformConceptMap = client.read().resource(ConceptMap.class).withUrl(conceptMapURL).execute();
    if (null == transformConceptMap) {
        throw new IllegalArgumentException("Unable to perform operation Observation$transform.  Unable to get concept map.");
    }
    List<Observation> observations = BundleUtil.toListOfResources(fhirContext, observationsBundle).stream().filter(resource -> resource instanceof Observation).map(Observation.class::cast).collect(Collectors.toList());
    /**
     * TODO - There must be a more efficient way to loop through this, but so far I
     * have not come up with it.
     */
    transformConceptMap.getGroup().forEach(group -> {
        HashMap<String, ConceptMap.TargetElementComponent> codeMappings = new HashMap<>();
        String targetSystem = group.getTarget();
        group.getElement().forEach(codeElement -> {
            codeMappings.put(codeElement.getCode(), codeElement.getTarget().get(0));
        });
        observations.forEach(observation -> {
            if (observation.getValue().fhirType().equalsIgnoreCase("codeableconcept")) {
                String obsValueCode = observation.getValueCodeableConcept().getCoding().get(0).getCode();
                if (obsValueCode != null && codeMappings.get(observation.getValueCodeableConcept().getCoding().get(0).getCode()) != null) {
                    if (replaceCode != null) {
                        observation.getValueCodeableConcept().getCoding().get(0).setCode(codeMappings.get(obsValueCode).getCode());
                        observation.getValueCodeableConcept().getCoding().get(0).setDisplay(codeMappings.get(obsValueCode).getDisplay());
                        observation.getValueCodeableConcept().getCoding().get(0).setSystem(targetSystem);
                    } else {
                        Coding newCoding = new Coding();
                        newCoding.setSystem(targetSystem);
                        newCoding.setCode(codeMappings.get(obsValueCode).getCode());
                        newCoding.setDisplay(codeMappings.get(obsValueCode).getDisplay());
                        observation.getValueCodeableConcept().getCoding().add(newCoding);
                    }
                }
            }
        });
    });
    return observationsBundle;
}
Also used : HashMap(java.util.HashMap) Coding(org.hl7.fhir.r4.model.Coding) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Observation(org.hl7.fhir.r4.model.Observation) ConceptMap(org.hl7.fhir.r4.model.ConceptMap) Operation(ca.uhn.fhir.rest.annotation.Operation)

Aggregations

Test (org.junit.Test)106 Group (org.hl7.fhir.r4.model.Group)74 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)59 ArrayList (java.util.ArrayList)57 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)50 Group (org.hl7.fhir.dstu3.model.Group)44 FHIRException (org.hl7.fhir.exceptions.FHIRException)37 Cohort (org.openmrs.Cohort)32 Test (org.junit.jupiter.api.Test)29 InputStream (java.io.InputStream)21 Reference (org.hl7.fhir.r4.model.Reference)21 List (java.util.List)16 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)16 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)16 Coding (org.hl7.fhir.r4.model.Coding)16 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)15 IOException (java.io.IOException)13 IdType (org.hl7.fhir.dstu3.model.IdType)13 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13