use of org.hl7.fhir.dstu2016may.model.IntegerType in project cqf-ruler by DBCG.
the class MultitenantServerR4IT method testCreateAndReadInTenantA.
@Test
public void testCreateAndReadInTenantA() {
// Create tenant A
ourClientTenantInterceptor.setTenantId("DEFAULT");
ourClient.operation().onServer().named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION).withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(1)).andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-A")).execute();
ourClientTenantInterceptor.setTenantId("TENANT-A");
Patient pt = new Patient();
pt.addName().setFamily("Family A");
ourClient.create().resource(pt).execute().getId();
Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
assertEquals(1, searchResult.getEntry().size());
Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
assertEquals("Family A", pt2.getName().get(0).getFamily());
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project cqf-ruler by DBCG.
the class MultitenantServerR4IT method testCreateAndReadInTenantB.
@Test
public void testCreateAndReadInTenantB() {
// Create tenant A
ourClientTenantInterceptor.setTenantId("DEFAULT");
ourClient.operation().onServer().named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION).withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(2)).andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-B")).execute();
ourClientTenantInterceptor.setTenantId("TENANT-B");
Patient pt = new Patient();
pt.addName().setFamily("Family B");
ourClient.create().resource(pt).execute().getId();
Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
assertEquals(1, searchResult.getEntry().size());
Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
assertEquals("Family B", pt2.getName().get(0).getFamily());
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverter method toCohortParameter.
public static Parameter toCohortParameter(Extension extension) {
Parameter parameter;
Type extensionValue = extension.getValue();
if (extensionValue instanceof Base64BinaryType) {
parameter = new StringParameter(((Base64BinaryType) extensionValue).asStringValue());
} else if (extensionValue instanceof BooleanType) {
parameter = new BooleanParameter(((BooleanType) extensionValue).booleanValue());
} else if (extensionValue instanceof DateType) {
parameter = new DateParameter(((DateType) extensionValue).asStringValue());
} else if (extensionValue instanceof DateTimeType) {
parameter = convertDateTimeType((DateTimeType) extensionValue);
} else if (extensionValue instanceof DecimalType) {
parameter = new DecimalParameter(((DecimalType) extensionValue).getValueAsString());
} else if (extensionValue instanceof InstantType) {
parameter = new DatetimeParameter(((InstantType) extensionValue).getValueAsString());
} else if (extensionValue instanceof IntegerType) {
parameter = new IntegerParameter(((IntegerType) extensionValue).getValue());
} else if (extensionValue instanceof StringType) {
parameter = new StringParameter(((StringType) extensionValue).getValue());
} else if (extensionValue instanceof TimeType) {
parameter = new TimeParameter(((TimeType) extensionValue).asStringValue());
} else if (extensionValue instanceof UriType) {
parameter = new StringParameter(((UriType) extensionValue).getValue());
} else if (extensionValue instanceof Coding) {
parameter = convertCoding((Coding) extensionValue);
} else if (extensionValue instanceof CodeableConcept) {
parameter = convertCodeableConcept((CodeableConcept) extensionValue);
} else if (extensionValue instanceof Period) {
Period castValue = (Period) extensionValue;
parameter = new IntervalParameter(convertDateTimeType(castValue.getStartElement()), true, convertDateTimeType(castValue.getEndElement()), true);
} else if (extensionValue instanceof Quantity) {
parameter = convertQuantity((Quantity) extensionValue);
} else if (extensionValue instanceof Range) {
Range castValue = (Range) extensionValue;
parameter = new IntervalParameter(convertQuantity(castValue.getLow()), true, convertQuantity(castValue.getHigh()), true);
} else if (extensionValue instanceof Ratio) {
Ratio castValue = (Ratio) extensionValue;
parameter = new RatioParameter().setDenominator(convertQuantity(castValue.getDenominator())).setNumerator(convertQuantity(castValue.getNumerator()));
} else {
throw new UnsupportedFhirTypeException(extensionValue);
}
return parameter;
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___java_overrides_overwrite_measure_params.
@Test
public void measure_report_generated___java_overrides_overwrite_measure_params() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
String duplicateParamName = "duplicateParam";
int fhirMeasureIntValue = 10;
int javaParameterIntValue = 99;
measure.addExtension(createParameterExtension(duplicateParamName, new IntegerType(fhirMeasureIntValue)));
mockFhirResourceRetrieval(measure);
Map<String, Parameter> parameterMap = new HashMap<>();
parameterMap.put(duplicateParamName, new IntegerParameter(javaParameterIntValue));
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameterMap);
assertNotNull(report);
// Make sure report only contained one entry for the duplicate parameter
List<Type> filteredReportParams = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).filter(x -> x.getName().equals(duplicateParamName)).map(x -> x.getExtensionByUrl(PARAMETER_VALUE_URL).getValue()).collect(Collectors.toList());
assertEquals(1, filteredReportParams.size());
// Sanity check input parameter values were different before checking for correct value
assertNotEquals(fhirMeasureIntValue, javaParameterIntValue);
assertEquals(javaParameterIntValue, ((IntegerType) filteredReportParams.get(0)).getValue().intValue());
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project quality-measure-and-cohort-service by Alvearie.
the class MeasureSupplementalDataEvaluationTest method testProcessAccumulators_multiplePatients.
@Test
public void testProcessAccumulators_multiplePatients() {
Map<String, Map<String, Integer>> initialAccumulators = new HashMap<>();
Map<String, Integer> initialMale = new HashMap<>();
initialMale.put(MALE_CODE, 1);
initialAccumulators.put(MeasureSupplementalDataEvaluation.SDE_SEX, initialMale);
Map<String, Map<String, Integer>> sdeAccumulators = getSexSDEAccumulatorsWithInitialAccumulators(initialAccumulators);
MeasureReport report = new MeasureReport();
MeasureSupplementalDataEvaluation.processAccumulators(report, sdeAccumulators, false, new ArrayList<>());
assertNotNull(report);
// EvaluatedResource should contain a reference to an observation record created for supplemental data
assertEquals(1, report.getEvaluatedResource().size());
// The observation record mentioned previously should exist within the contained resources of the measure report
assertEquals(1, report.getContained().size());
assertTrue(report.getContained().get(0) instanceof Observation);
Observation obs = (Observation) report.getContained().get(0);
// For a multiple patients, the code of the observation should be the supplemental data text
assertEquals(MALE_CODE, obs.getCode().getCoding().get(0).getCode());
// For a multiple patients, the value of the observation should be the result of the appropriate define
assertTrue(obs.getValue() instanceof IntegerType);
assertEquals("2", ((IntegerType) obs.getValue()).getValueAsString());
// Within the observation, there should be 1 extension, with two further nested extensions
Extension obsExt = obs.getExtensionByUrl(MeasureSupplementalDataEvaluation.CQF_MEASUREINFO_URL);
assertNotNull(obsExt);
assertEquals(2, obsExt.getExtension().size());
Extension measureNestedExt = obsExt.getExtensionByUrl(MeasureSupplementalDataEvaluation.MEASURE);
assertTrue(measureNestedExt.getValue() instanceof CanonicalType);
assertEquals(MeasureSupplementalDataEvaluation.CQFMEASURES_URL + report.getMeasure(), ((CanonicalType) measureNestedExt.getValue()).asStringValue());
Extension populationNestedExt = obsExt.getExtensionByUrl(MeasureSupplementalDataEvaluation.POPULATION_ID);
assertEquals(MeasureSupplementalDataEvaluation.SDE_SEX, ((StringType) populationNestedExt.getValue()).asStringValue());
}
Aggregations