Search in sources :

Example 76 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.

the class MeasureSupplementalDataEvaluationTest method testProcessAccumulators_notSDESex.

@Test
public void testProcessAccumulators_notSDESex() {
    /* 
		 * Jill - I don't like how this part of the code works.  The code grabs everything after (and including) the "-", 
		 * and then looks for that to exist as an extension on the Patient resource.  This works for race and ethnicity 
		 * on the US-core patient profile, but since we already calculated this in the populate SDE accumulator method
		 * the only reason it's "recalculating" is because the system and display aren't on the passed in map.
		 * Plus, it's coded assuming there is a list of extensions within the extension (which is how US-Core handles race and eth) 
		 * and it magically grabs the first one... so if you have multiple this doesn't match all of them.
		*/
    Code white = new Code();
    white.setCode(WHITE_CODE);
    Map<String, Map<String, Integer>> sdeAccumulators = getSDEAccumulators(SDE_RACE, null, white, new HashMap<>());
    MeasureReport report = new MeasureReport();
    Patient mockPatient = mockPatient();
    Extension raceExtension = new Extension();
    // This can be anything as long as it includes "-race"
    raceExtension.setUrl("something-race");
    // This example was stolen from https://www.hl7.org/fhir/us/core/Patient-example.xml.html
    Extension valueExtension = new Extension();
    valueExtension.setUrl("ombCategory");
    valueExtension.setValue(getWhiteCoding());
    raceExtension.setExtension(Arrays.asList(valueExtension));
    Mockito.when(mockPatient.getExtension()).thenReturn(Arrays.asList(raceExtension));
    MeasureSupplementalDataEvaluation.processAccumulators(report, sdeAccumulators, true, Arrays.asList(mockPatient));
    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 single patient, the code of the observation should be the supplemental data text
    assertEquals(SDE_RACE, obs.getCode().getText());
    // For a single patient, the value of the observation should be the result of the appropriate define
    assertTrue(obs.getValue() instanceof CodeableConcept);
    assertEquals(WHITE_CODE, ((CodeableConcept) obs.getValue()).getCoding().get(0).getCode());
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Observation(org.hl7.fhir.r4.model.Observation) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Code(org.opencds.cqf.cql.engine.runtime.Code) HashMap(java.util.HashMap) Map(java.util.Map) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 77 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method makeCoding.

private Coding makeCoding(String system, String value, String display, String version) {
    Coding coding = new Coding();
    coding.setSystem(system);
    coding.setCode(value);
    coding.setDisplay(display);
    coding.setVersion(version);
    return coding;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding)

Example 78 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.

the class R4RestFhirTerminologyProvider method lookup.

/**
 * This is a small patch to the OSS implementation to use named-parameter lookup on
 * the operation response instead of just assuming a positional location.
 */
@Override
public Code lookup(Code code, CodeSystemInfo codeSystem) throws ResourceNotFoundException {
    Parameters respParam = fhirClient.operation().onType(CodeSystem.class).named("lookup").withParameter(Parameters.class, "code", new CodeType(code.getCode())).andParameter("system", new UriType(codeSystem.getId())).execute();
    StringType display = (StringType) respParam.getParameter("display");
    if (display != null) {
        code.withDisplay(display.getValue());
    }
    return code.withSystem(codeSystem.getId());
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) CodeType(org.hl7.fhir.r4.model.CodeType) UriType(org.hl7.fhir.r4.model.UriType)

Example 79 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.

the class IdentifierBuilderTest method testBuilder.

@Test
public void testBuilder() {
    String system = "TEST SYSTEM";
    String code = "TEST CODE";
    String display = "TEST DISPLAY";
    String value = "TEST VALUE";
    Coding coding = new Coding(system, code, display);
    CodeableConcept type = new CodeableConcept(coding);
    Period period = new Period();
    period.setStart(new Date());
    period.setEnd(new Date());
    Reference assigner = new Reference("TEST REFERENCE");
    Identifier identifier = new IdentifierBuilder().buildUse(IdentifierUse.OFFICIAL).buildSystem(system).buildType(type).buildPeriod(period).buildValue(value).buildAssigner(assigner).build();
    assertEquals(IdentifierUse.OFFICIAL, identifier.getUse());
    assertEquals(system, identifier.getSystem());
    assertEquals(type, identifier.getType());
    assertEquals(period, identifier.getPeriod());
    assertEquals(value, identifier.getValue());
    assertEquals(assigner, identifier.getAssigner());
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 80 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.

the class RestFhirRetrieveProviderTest method makeValueSet.

protected ValueSet makeValueSet(String name, String system, String... codes) {
    ValueSet vs = new ValueSet();
    vs.setId(name);
    vs.setName(name);
    vs.setUrl("http://somewhere.com/fhir/ValueSet/" + name);
    vs.setVersion("1.0.0");
    for (String code : codes) {
        vs.getExpansion().addContains().setSystem(system).setCode(code);
    }
    return vs;
}
Also used : ValueSet(org.hl7.fhir.r4.model.ValueSet)

Aggregations

Test (org.junit.jupiter.api.Test)92 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)75 ArrayList (java.util.ArrayList)70 Coding (org.hl7.fhir.r4.model.Coding)70 Identifier (org.hl7.fhir.r4.model.Identifier)62 FHIRException (org.hl7.fhir.exceptions.FHIRException)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)45 Resource (org.hl7.fhir.r4.model.Resource)45 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)38 Test (org.junit.Test)37 Coding (org.hl7.fhir.dstu3.model.Coding)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)32 HashMap (java.util.HashMap)30 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)28 List (java.util.List)27 IOException (java.io.IOException)26 Bundle (org.hl7.fhir.r4.model.Bundle)26 Patient (org.hl7.fhir.r4.model.Patient)25 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)24 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)21