Search in sources :

Example 46 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class FhirGroupServiceImplTest method shouldDeleteGroup.

@Test
public void shouldDeleteGroup() {
    Group group = new Group();
    group.setId(COHORT_UUID);
    when(dao.delete(COHORT_UUID)).thenReturn(cohort);
    when(translator.toFhirResource(cohort)).thenReturn(group);
    Group result = groupService.delete(COHORT_UUID);
    assertThat(result, notNullValue());
    assertThat(result.getId(), equalTo(COHORT_UUID));
    assertThat(result.getActive(), is(false));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Test(org.junit.Test)

Example 47 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupTranslatorImplTest method shouldUpdateIsVoidedOpenMRSType.

@Test
public void shouldUpdateIsVoidedOpenMRSType() {
    Cohort cohort = new Cohort();
    cohort.setVoided(false);
    Group group = mock(Group.class);
    when(group.hasActive()).thenReturn(true);
    when(group.getActive()).thenReturn(false);
    Cohort updateCohort = groupTranslator.toOpenmrsType(cohort, group);
    assertThat(updateCohort, notNullValue());
    assertThat(updateCohort.getVoided(), is(true));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Test(org.junit.Test)

Example 48 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupTranslatorImplTest method shouldTranslateUuidToIdFHIRType.

@Test
public void shouldTranslateUuidToIdFHIRType() {
    Cohort cohort = mock(Cohort.class);
    when(cohort.getUuid()).thenReturn(COHORT_UUID);
    Group group = groupTranslator.toFhirResource(cohort);
    assertThat(group, notNullValue());
    assertThat(group.getId(), is(COHORT_UUID));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Test(org.junit.Test)

Example 49 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupTranslatorImplTest method shouldTranslateCreatorToManagingEntityFHIRType.

@Test
public void shouldTranslateCreatorToManagingEntityFHIRType() {
    User user = mock(User.class);
    Cohort cohort = new Cohort();
    cohort.setUuid(COHORT_UUID);
    cohort.setName(COHORT_NAME);
    cohort.setCreator(user);
    Reference practitionerRef = mock(Reference.class);
    when(practitionerReferenceTranslator.toFhirResource(user)).thenReturn(practitionerRef);
    Group result = groupTranslator.toFhirResource(cohort);
    assertThat(result, notNullValue());
    assertThat(result.hasManagingEntity(), is(true));
    assertThat(result.getManagingEntity(), is(practitionerRef));
}
Also used : Group(org.hl7.fhir.r4.model.Group) User(org.openmrs.User) Cohort(org.openmrs.Cohort) Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.Test)

Example 50 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupTranslatorImplTest method shouldTranslateCohortMembersToFHIRGroupMembers.

@Test
@Ignore
public void shouldTranslateCohortMembersToFHIRGroupMembers() {
    Cohort cohort = mock(Cohort.class);
    Reference patientReference = mock(Reference.class);
    Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
    when(cohort.getMemberIds()).thenReturn(new HashSet<>(Arrays.asList(1, 2, 3)));
    // when(groupMemberTranslator.toFhirResource(anyInt())).thenReturn(new GroupMember(groupMemberComponent.getEntity()));
    when(groupMemberComponent.hasEntity()).thenReturn(true);
    when(groupMemberComponent.getEntity()).thenReturn(patientReference);
    Group group = groupTranslator.toFhirResource(cohort);
    assertThat(group, notNullValue());
    assertThat(group.hasMember(), is(true));
    assertThat(group.getMemberFirstRep().hasEntity(), is(true));
    assertThat(group.getMemberFirstRep().getEntity(), is(patientReference));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Reference(org.hl7.fhir.r4.model.Reference) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)106 Group (org.hl7.fhir.r4.model.Group)74 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)59 ArrayList (java.util.ArrayList)57 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)50 Group (org.hl7.fhir.dstu3.model.Group)44 FHIRException (org.hl7.fhir.exceptions.FHIRException)37 Cohort (org.openmrs.Cohort)32 Test (org.junit.jupiter.api.Test)29 InputStream (java.io.InputStream)21 Reference (org.hl7.fhir.r4.model.Reference)21 List (java.util.List)16 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)16 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)16 Coding (org.hl7.fhir.r4.model.Coding)16 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)15 IOException (java.io.IOException)13 IdType (org.hl7.fhir.dstu3.model.IdType)13 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13