use of org.hl7.fhir.r5.model in project elexis-server by elexis.
the class PractitionerRoleTest method getPractitionerRole.
@Test
public void getPractitionerRole() {
// search by role
Bundle results = client.search().forResource(PractitionerRole.class).where(PractitionerRole.ROLE.exactly().systemAndCode(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.getSystem(), org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.toCode())).returnBundle(Bundle.class).execute();
assertNotNull(results);
List<BundleEntryComponent> entries = results.getEntry();
assertFalse(entries.isEmpty());
PractitionerRole practitionerRole = (PractitionerRole) entries.get(0).getResource();
List<CodeableConcept> roles = practitionerRole.getCode();
boolean doctorRoleFound = false;
for (CodeableConcept role : roles) {
List<Coding> codings = role.getCoding();
for (Coding coding : codings) {
if (coding.getSystem().equals(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.getSystem()) && coding.getCode().equals(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.toCode())) {
doctorRoleFound = true;
}
}
}
assertTrue(doctorRoleFound);
}
use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.
the class GroupFhirResourceProviderTest method shouldThrowMethodNotAllowedIfGroupToUpdateDoesNotExist.
@Test(expected = MethodNotAllowedException.class)
public void shouldThrowMethodNotAllowedIfGroupToUpdateDoesNotExist() {
org.hl7.fhir.r4.model.Group wrongGroup = new org.hl7.fhir.r4.model.Group();
wrongGroup.setId(BAD_COHORT_UUID);
when(fhirGroupService.update(eq(BAD_COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))).thenThrow(MethodNotAllowedException.class);
resourceProvider.updateGroup(new IdType().setValue(BAD_COHORT_UUID), wrongGroup);
}
use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.
the class GroupFhirResourceProviderTest method shouldUpdateExistingGroup.
@Test
public void shouldUpdateExistingGroup() {
Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
group.setActual(false);
group.addMember(groupMemberComponent);
when(fhirGroupService.update(eq(COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group);
MethodOutcome result = resourceProvider.updateGroup(new IdType().setValue(COHORT_UUID), group);
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.R4));
}
use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method shouldAddProvenanceResources.
@Test
public void shouldAddProvenanceResources() {
Obs obs = new Obs();
obs.setUuid(OBS_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(obs)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(obs)).thenReturn(provenance);
org.hl7.fhir.r4.model.Observation result = observationTranslator.toFhirResource(obs);
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 PatientTranslatorImplTest method shouldNotAddUpdateProvenanceIfDateChangedAndChangedByAreBothNull.
@Test
public void shouldNotAddUpdateProvenanceIfDateChangedAndChangedByAreBothNull() {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
org.openmrs.Patient patient = new org.openmrs.Patient();
patient.setUuid(PATIENT_UUID);
patient.setDateChanged(null);
patient.setChangedBy(null);
when(provenanceTranslator.getCreateProvenance(patient)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(patient)).thenReturn(null);
org.hl7.fhir.r4.model.Patient result = patientTranslator.toFhirResource(patient);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), equalTo(1));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
Aggregations