use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldAddPersonLinksToResultListWhenIncluded.
@Test
public void shouldAddPersonLinksToResultListWhenIncluded() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PERSON_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("Person:link:Patient"));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(resultList, not(empty()));
// included resource added as part of the result list
assertThat(resultList.size(), equalTo(2));
assertThat(((org.hl7.fhir.r4.model.Person) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(PERSON_UUID));
org.hl7.fhir.r4.model.Person returnedPerson = (org.hl7.fhir.r4.model.Person) resultList.iterator().next();
assertThat(resultList, hasItem(allOf(is(instanceOf(Patient.class)), hasProperty("id", equalTo(returnedPerson.getLinkFirstRep().getTarget().getReferenceElement().getIdPart())))));
}
use of org.hl7.fhir.r5.model 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.model 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.model 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.model 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()));
}
Aggregations