use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ConditionTranslatorImpl_2_2Test method shouldTranslateConditionConceptToFhirType.
@Test
public void shouldTranslateConditionConceptToFhirType() {
Concept concept = new Concept();
concept.setUuid(CONCEPT_UUID);
concept.setConceptId(CODE);
CodeableConcept codeableConcept = new CodeableConcept();
Coding coding = new Coding();
coding.setCode(CODE.toString());
coding.setSystem(SYSTEM);
codeableConcept.addCoding(coding);
CodedOrFreeText conceptCodeOrFreeText = new CodedOrFreeText();
conceptCodeOrFreeText.setCoded(concept);
openmrsCondition.setCondition(conceptCodeOrFreeText);
when(conceptTranslator.toFhirResource(concept)).thenReturn(codeableConcept);
org.hl7.fhir.r4.model.Condition condition = conditionTranslator.toFhirResource(openmrsCondition);
assertThat(condition, notNullValue());
assertThat(condition.getCode(), notNullValue());
assertThat(condition.getCode().getCoding(), not(Collections.emptyList()));
assertThat(condition.getCode().getCoding().get(0).getCode(), equalTo(CODE.toString()));
assertThat(condition.getCode().getCoding().get(0).getSystem(), equalTo(SYSTEM));
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderIntegrationTest method shouldReturnExistingObservationAsJson.
@Test
public void shouldReturnExistingObservationAsJson() throws Exception {
MockHttpServletResponse response = get("/Observation/" + OBS_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Observation observation = readResponse(response);
assertThat(observation, notNullValue());
assertThat(observation.getIdElement().getIdPart(), equalTo(OBS_UUID));
// verify expected codings
assertThat(observation.getCode().getCoding(), hasItem(allOf(hasProperty("system", nullValue()), hasProperty("code", equalTo(OBS_CONCEPT_UUID)))));
assertThat(observation.getCode().getCoding(), hasItem(allOf(hasProperty("system", equalTo(CIEL_SYSTEM_URI)), hasProperty("code", equalTo(OBS_CONCEPT_CIEL_ID)))));
assertThat(observation.getCode().getCodingFirstRep().getDisplay(), equalTo(OBS_CONCEPT_DISPLAY_NAME));
// verify expected value
assertThat(observation.getValueQuantity(), notNullValue());
assertThat(observation.getValueQuantity().getValue(), equalTo(OBS_CONCEPT_VALUE));
// verify reference ranges
assertThat(observation.getReferenceRange(), notNullValue());
assertThat(observation.getReferenceRange(), not(empty()));
assertThat(observation.getReferenceRange(), hasItem(hasProperty("low", hasProperty("value", equalTo(OBS_LOW_REFERENCE_RANGE)))));
assertThat(observation.getReferenceRange(), hasItem(hasProperty("high", hasProperty("value", equalTo(OBS_HIGH_REFERENCE_RANGE)))));
// verify expected patient
assertThat(observation.getSubject(), notNullValue());
assertThat(observation.getSubject().getReference(), containsString("Patient/"));
assertThat(observation.getSubject().getReference(), endsWith("/" + OBS_PATIENT_UUID));
// verify expected encounter
assertThat(observation.getContext(), notNullValue());
assertThat(observation.getContext().getReference(), endsWith("/" + OBS_ENCOUNTER_UUID));
assertThat(observation, validResource());
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderIntegrationTest method shouldReturnExistingObservationAsXML.
@Test
public void shouldReturnExistingObservationAsXML() throws Exception {
MockHttpServletResponse response = get("/Observation/" + OBS_UUID).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Observation observation = readResponse(response);
assertThat(observation, notNullValue());
assertThat(observation.getIdElement().getIdPart(), equalTo(OBS_UUID));
// verify expected codings
assertThat(observation.getCode().getCoding(), hasItem(allOf(hasProperty("system", nullValue()), hasProperty("code", equalTo(OBS_CONCEPT_UUID)))));
assertThat(observation.getCode().getCoding(), hasItem(allOf(hasProperty("system", equalTo(CIEL_SYSTEM_URN)), hasProperty("code", equalTo(OBS_CONCEPT_CIEL_ID)))));
assertThat(observation.getCode().getCodingFirstRep().getDisplay(), equalTo(OBS_CONCEPT_DISPLAY_NAME));
// verify expected value
assertThat(observation.getValueQuantity(), notNullValue());
assertThat(observation.getValueQuantity().getValue(), equalTo(OBS_CONCEPT_VALUE));
// verify reference ranges
assertThat(observation.getReferenceRange(), notNullValue());
assertThat(observation.getReferenceRange(), not(empty()));
assertThat(observation.getReferenceRange(), hasItem(hasProperty("low", hasProperty("value", equalTo(OBS_LOW_REFERENCE_RANGE)))));
assertThat(observation.getReferenceRange(), hasItem(hasProperty("high", hasProperty("value", equalTo(OBS_HIGH_REFERENCE_RANGE)))));
// verify expected patient
assertThat(observation.getSubject(), notNullValue());
assertThat(observation.getSubject().getType(), equalTo("Patient"));
assertThat(observation.getSubject().getReference(), endsWith("/" + OBS_PATIENT_UUID));
// verify expected encounter
assertThat(observation.getEncounter(), notNullValue());
assertThat(observation.getEncounter().getReference(), endsWith("/" + OBS_ENCOUNTER_UUID));
assertThat(observation, validResource());
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project Gravity-SDOH-Exchange-RI by FHIR.
the class OrganizationToDtoConverter method convert.
@Override
public OrganizationDto convert(Organization org) {
String orgId = org.getIdElement().getIdPart();
OrganizationDto orgDto = new OrganizationDto(orgId);
orgDto.setName(org.getName());
// We are interested only in CBO/CP types. Other are ignored.
Coding coding = FhirUtil.findCoding(org.getType(), OrganizationTypeCode.SYSTEM);
if (coding == null) {
orgDto.getErrors().add(String.format("Organization with id '%s' has no coding with system '%s' within a 'type' property. Such organizations " + "are " + "not expected in this context.", orgId, OrganizationTypeCode.SYSTEM));
} else {
try {
orgDto.setType(OrganizationTypeCode.fromCode(coding.getCode()));
} catch (FHIRException exc) {
orgDto.getErrors().add(String.format("OrganizationTypeCode code '%s' cannot be resolved for Organization with id '%s'.", coding.getCode(), orgId));
}
}
return orgDto;
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskValidator method validate.
public List<String> validate(Task task) {
List<String> errors = new ArrayList<>();
if (task.hasIdentifier() && task.getIdentifier().size() != 1) {
errors.add("Task.identifier is not valid.");
}
if (!task.getIntent().equals(Task.TaskIntent.ORDER)) {
errors.add(String.format("Task.intent has wrong value. Supported value is '%s'.", Task.TaskIntent.ORDER.toCode()));
}
TaskCode taskCode = TaskCode.FULFILL;
if (task.getCode().getCoding().stream().noneMatch(coding -> taskCode.getSystem().equals(coding.getSystem()) && taskCode.toCode().equals(coding.getCode()) && taskCode.getDisplay().equals(coding.getDisplay()))) {
errors.add(String.format("Task.code has no coding with system '%s' and code '%s'.", taskCode.getSystem(), taskCode.toCode()));
}
if (!task.hasFocus()) {
errors.add("Task.focus is missing.");
}
if (!task.hasFor()) {
errors.add("Task.for is missing.");
}
if (task.hasFor() && !task.getFor().getReferenceElement().getResourceType().equals(Patient.class.getSimpleName())) {
errors.add(String.format("Task.for reference is invalid. Supported reference is '%s'.", Patient.class.getSimpleName()));
}
if (task.hasRequester() && !task.getRequester().getReferenceElement().getResourceType().equals(Organization.class.getSimpleName())) {
errors.add(String.format("Task.requester reference is invalid. Supported reference is '%s'.", Organization.class.getSimpleName()));
}
if (task.hasOwner() && !task.getOwner().getReferenceElement().getResourceType().equals(Organization.class.getSimpleName())) {
errors.add(String.format("Task.owner reference is invalid. Supported reference is '%s'.", Organization.class.getSimpleName()));
}
return errors;
}
Aggregations