Search in sources :

Example 51 with Group

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

the class GroupTranslatorImplTest method shouldTranslateGroupTypeToAlwaysPerson.

@Test
public void shouldTranslateGroupTypeToAlwaysPerson() {
    Cohort cohort = mock(Cohort.class);
    Group group = groupTranslator.toFhirResource(cohort);
    assertThat(group, notNullValue());
    assertThat(group.getType(), is(Group.GroupType.PERSON));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Test(org.junit.Test)

Example 52 with Group

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

the class GroupTranslatorImplTest method shouldTranslateFHIRGroupMembersToOpenMRSCohortMembers.

@Test
@Ignore
public void shouldTranslateFHIRGroupMembersToOpenMRSCohortMembers() {
    Group group = mock(Group.class);
    GroupMember groupMember = mock(GroupMember.class);
    Reference memberRef = mock(Reference.class);
    Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
    when(group.hasMember()).thenReturn(true);
    when(group.getMember()).thenReturn(Arrays.asList(groupMemberComponent, groupMemberComponent));
    when(groupMember.hasEntity()).thenReturn(true);
    when(groupMember.getEntity()).thenReturn(memberRef);
    // when(memberRef.getReference()).thenReturn("ref-xxx");
    when(groupMemberTranslator.toOpenmrsType(groupMember)).thenReturn(1);
    Cohort cohort = groupTranslator.toOpenmrsType(group);
    assertThat(cohort, notNullValue());
    assertThat(cohort.getMemberIds().isEmpty(), is(false));
    assertThat(cohort.getMemberIds(), hasSize(1));
    assertThat(cohort.getMemberIds().iterator().next(), is(1));
}
Also used : Group(org.hl7.fhir.r4.model.Group) GroupMember(org.openmrs.module.fhir2.model.GroupMember) Cohort(org.openmrs.Cohort) Reference(org.hl7.fhir.r4.model.Reference) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 53 with Group

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

the class GroupTranslatorImplTest method shouldTranslateNameToNameFHIRType.

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

Example 54 with Group

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

the class GroupTranslatorImplTest method shouldTranslateActiveFHIRTypeToIsVoidedOpenMRSType.

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

Example 55 with Group

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

the class BaseGroupTranslatorTest method shouldTranslateManagingEntityToCreatorOpenMRSType.

@Test
public void shouldTranslateManagingEntityToCreatorOpenMRSType() {
    User user = mock(User.class);
    Reference practitionerRef = mock(Reference.class);
    when(practitionerReferenceTranslator.toOpenmrsType(practitionerRef)).thenReturn(user);
    group.setManagingEntity(practitionerRef);
    Cohort result = baseGroupTranslator.toOpenmrsType(cohort, group);
    assertThat(result, notNullValue());
    assertThat(result.getCreator(), notNullValue());
    assertThat(result.getCreator(), is(user));
}
Also used : User(org.openmrs.User) Cohort(org.openmrs.Cohort) Reference(org.hl7.fhir.r4.model.Reference) 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