use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toFhirResource_shouldAddProvenanceResources.
@Test
public void toFhirResource_shouldAddProvenanceResources() {
FhirTask task = new FhirTask();
task.setUuid(TASK_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(task)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(task)).thenReturn(provenance);
org.hl7.fhir.r4.model.Task result = taskTranslator.toFhirResource(task);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), greaterThanOrEqualTo(2));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class ConditionTranslatorImplTest method shouldTranslateOpenMrsConditionOnsetDateToFhirType.
@Test
public void shouldTranslateOpenMrsConditionOnsetDateToFhirType() {
openmrsCondition.setObsDatetime(new Date());
org.hl7.fhir.r4.model.Condition condition = conditionTranslator.toFhirResource(openmrsCondition);
assertThat(condition, notNullValue());
assertThat(condition.getOnsetDateTimeType().getValue(), notNullValue());
assertThat(condition.getOnsetDateTimeType().getValue(), DateMatchers.sameDay(new Date()));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class ConditionTranslatorImplTest method shouldAddProvenanceToConditionResource.
@Test
public void shouldAddProvenanceToConditionResource() {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(openmrsCondition)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(openmrsCondition)).thenReturn(provenance);
org.hl7.fhir.r4.model.Condition result = conditionTranslator.toFhirResource(openmrsCondition);
List<Resource> resources = result.getContained();
assertThat(resources, Matchers.notNullValue());
assertThat(resources, Matchers.not(empty()));
assertThat(resources.stream().findAny().isPresent(), CoreMatchers.is(true));
assertThat(resources.stream().findAny().get().isResource(), CoreMatchers.is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), Matchers.equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class ConditionTranslatorImplTest method shouldTranslateConditionDateCreatedToRecordedDateFhirType.
@Test
public void shouldTranslateConditionDateCreatedToRecordedDateFhirType() {
openmrsCondition.setDateCreated(new Date());
org.hl7.fhir.r4.model.Condition condition = conditionTranslator.toFhirResource(openmrsCondition);
assertThat(condition, notNullValue());
assertThat(condition.getRecordedDate(), notNullValue());
assertThat(condition.getRecordedDate(), DateMatchers.sameDay(new Date()));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class ConditionTranslatorImplTest 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);
openmrsCondition.setValueCoded(concept);
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));
}
Aggregations