Search in sources :

Example 61 with StringType

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

use of org.hl7.fhir.r4.model.StringType in project quality-measure-and-cohort-service by Alvearie.

the class R4RestFhirTerminologyProviderTest method lookupOperationSuccess.

@Test
public void lookupOperationSuccess() throws Exception {
    CodeSystemInfo info = new CodeSystemInfo();
    info.setId(TEST_SYSTEM);
    info.setVersion(TEST_SYSTEM_VERSION);
    Code code = new Code();
    code.setCode(TEST_CODE);
    code.setSystem(TEST_SYSTEM);
    code.setDisplay(TEST_DISPLAY);
    Parameters parameters = new Parameters();
    parameters.addParameter().setName("name").setValue(new StringType(code.getCode()));
    parameters.addParameter().setName("version").setValue(new StringType(info.getVersion()));
    parameters.addParameter().setName("display").setValue(new StringType(code.getDisplay()));
    mockFhirResourceRetrieval(post(urlEqualTo("/CodeSystem/$lookup?_format=json")), parameters);
    Code result = provider.lookup(code, info);
    assertNotNull(result);
    assertEquals(result.getSystem(), code.getSystem());
    assertEquals(result.getCode(), code.getCode());
    assertEquals(result.getDisplay(), code.getDisplay());
}
Also used : CodeSystemInfo(org.opencds.cqf.cql.engine.terminology.CodeSystemInfo) Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Code(org.opencds.cqf.cql.engine.runtime.Code) Test(org.junit.Test)

Example 63 with StringType

use of org.hl7.fhir.r4.model.StringType in project openmrs-module-fhir2 by openmrs.

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldUpdateInputTextValue.

@Test
public void toOpenmrsType_shouldUpdateInputTextValue() {
    Task task = new Task();
    Task.ParameterComponent input = new Task.ParameterComponent();
    CodeableConcept inputType = new CodeableConcept().setText("some text");
    String inputVal = "some input value";
    input.setType(inputType).setValue(new StringType(inputVal));
    Concept openmrsInputType = new Concept();
    openmrsInputType.setUuid(CONCEPT_UUID);
    task.setInput(Collections.singletonList(input));
    FhirTask openmrsTask = new FhirTask();
    openmrsTask.setUuid(TASK_UUID);
    openmrsTask.setInput(Collections.singleton(new FhirTaskInput()));
    when(conceptTranslator.toOpenmrsType(inputType)).thenReturn(openmrsInputType);
    FhirTask result = taskTranslator.toOpenmrsType(openmrsTask, task);
    assertThat(result.getInput(), not(empty()));
    assertThat(result.getInput(), hasItem(hasProperty("type", hasProperty("uuid", equalTo(CONCEPT_UUID)))));
    assertThat(result.getInput(), hasItem(hasProperty("valueText", equalTo(inputVal))));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) StringType(org.hl7.fhir.r4.model.StringType) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTaskInput(org.openmrs.module.fhir2.model.FhirTaskInput) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 64 with StringType

use of org.hl7.fhir.r4.model.StringType in project elexis-server by elexis.

the class ObservationTest method laboratoryObservations.

@Test
public void laboratoryObservations() throws FHIRException {
    // search by patient and category
    Bundle results = client.search().forResource(Observation.class).where(Observation.SUBJECT.hasId(AllTests.getTestDatabaseInitializer().getPatient().getId())).and(Condition.CATEGORY.exactly().code("laboratory")).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    assertFalse(results.getEntry().isEmpty());
    @SuppressWarnings("unchecked") List<Observation> observations = (List<Observation>) ((List<?>) results.getEntry().parallelStream().map(be -> be.getResource()).collect(Collectors.toList()));
    for (Observation observation : observations) {
        assertTrue(observation.hasEffectiveDateTimeType());
        assertTrue(observation.hasValue());
        assertNotNull(observation.getCode());
        List<Coding> coding = observation.getCode().getCoding();
        assertFalse(coding.isEmpty());
        for (Coding code : coding) {
            if (code.getCode().contains("NUMERIC")) {
                if (observation.hasValueQuantity()) {
                    Quantity quantityValue = observation.getValueQuantity();
                    assertNotNull(quantityValue);
                } else if (observation.hasValueStringType()) {
                    StringType stringValue = observation.getValueStringType();
                    assertNotNull(stringValue);
                    assertTrue(Character.isDigit(stringValue.toString().charAt(0)));
                } else {
                    fail("Unexpected vaue type" + observation.getValue());
                }
                List<ObservationReferenceRangeComponent> refs = observation.getReferenceRange();
                assertFalse(refs.isEmpty());
            } else if (code.getCode().contains("TEXT")) {
                StringType stringValue = observation.getValueStringType();
                assertNotNull(stringValue);
            }
        }
    }
}
Also used : TransientCoding(ch.elexis.core.findings.util.model.TransientCoding) Coding(org.hl7.fhir.r4.model.Coding) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) ObservationReferenceRangeComponent(org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent) Observation(org.hl7.fhir.r4.model.Observation) IObservation(ch.elexis.core.findings.IObservation) Quantity(org.hl7.fhir.r4.model.Quantity) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 65 with StringType

use of org.hl7.fhir.r4.model.StringType in project openmrs-module-fhir2 by openmrs.

the class ObservationValueTranslatorImplTest method toFhirResource_shouldConvertObsWithTextValueToString.

@Test
public void toFhirResource_shouldConvertObsWithTextValueToString() {
    obs.setValueText(OBS_STRING);
    Type result = obsValueTranslator.toFhirResource(obs);
    assertThat(result, notNullValue());
    assertThat(result, instanceOf(StringType.class));
    assertThat(((StringType) result).getValue(), equalTo(OBS_STRING));
}
Also used : Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) StringType(org.hl7.fhir.r4.model.StringType) IntegerType(org.hl7.fhir.r4.model.IntegerType) BooleanType(org.hl7.fhir.r4.model.BooleanType) StringType(org.hl7.fhir.r4.model.StringType) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Aggregations

StringType (org.hl7.fhir.r4.model.StringType)158 ArrayList (java.util.ArrayList)77 Test (org.junit.jupiter.api.Test)77 StringType (org.hl7.fhir.dstu3.model.StringType)65 Parameters (org.hl7.fhir.r4.model.Parameters)62 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)62 StringType (org.hl7.fhir.r5.model.StringType)61 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)58 StringType (org.hl7.fhir.r4b.model.StringType)45 FHIRException (org.hl7.fhir.exceptions.FHIRException)43 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 HashMap (java.util.HashMap)28 StringType (org.hl7.fhir.dstu2.model.StringType)27 StringType (org.hl7.fhir.dstu2016may.model.StringType)26 Coding (org.hl7.fhir.r4.model.Coding)26 Extension (org.hl7.fhir.r4.model.Extension)25 Measure (org.hl7.fhir.r4.model.Measure)23 Test (org.junit.Test)23 Base (org.hl7.fhir.r5.model.Base)20 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19