use of org.hl7.fhir.r4.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;
}
use of org.hl7.fhir.r4.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;
}
use of org.hl7.fhir.r4.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);
}
use of org.hl7.fhir.r4.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;
}
use of org.hl7.fhir.r4.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;
}
Aggregations