use of ca.uhn.hl7v2.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));
}
use of ca.uhn.hl7v2.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));
}
use of ca.uhn.hl7v2.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));
}
use of ca.uhn.hl7v2.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));
}
use of ca.uhn.hl7v2.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));
}
Aggregations