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());
}
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());
}
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))));
}
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);
}
}
}
}
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));
}
Aggregations