Search in sources :

Example 26 with Group

use of ca.uhn.hl7v2.model.Group in project openmrs-module-fhir2 by openmrs.

the class BaseGroupTranslatorTest method setup.

@Before
public void setup() {
    baseGroupTranslator = new BaseGroupTranslator() {
    };
    baseGroupTranslator.setPractitionerReferenceTranslator(practitionerReferenceTranslator);
    cohort = new Cohort();
    cohort.setUuid(COHORT_UUID);
    cohort.setName(COHORT_NAME);
    group = new Group();
    group.setId(COHORT_UUID);
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Before(org.junit.Before)

Example 27 with Group

use of ca.uhn.hl7v2.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupFhirResourceProviderTest method getGroupByUuid_shouldReturnMatchingGroup.

@Test
public void getGroupByUuid_shouldReturnMatchingGroup() {
    when(fhirGroupService.get(COHORT_UUID)).thenReturn(group);
    IdType id = new IdType();
    id.setValue(COHORT_UUID);
    Group group = resourceProvider.getGroupByUuid(id);
    assertThat(group, notNullValue());
    assertThat(group.getId(), notNullValue());
    assertThat(group.getId(), equalTo(COHORT_UUID));
}
Also used : Group(org.hl7.fhir.r4.model.Group) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 28 with Group

use of ca.uhn.hl7v2.model.Group 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));
}
Also used : Group(org.hl7.fhir.r4.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 29 with Group

use of ca.uhn.hl7v2.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupFhirResourceProviderTest method shouldCreateNewGroup.

@Test
public void shouldCreateNewGroup() {
    when(fhirGroupService.create(any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group);
    MethodOutcome result = resourceProvider.createGroup(Group30_40.convertGroup(group));
    assertThat(result, notNullValue());
    assertThat(result.getCreated(), is(true));
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
    assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.DSTU3));
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 30 with Group

use of ca.uhn.hl7v2.model.Group in project openmrs-module-fhir2 by openmrs.

the class GroupFhirResourceProviderTest method shouldUpdateExistingGroup.

@Test
public void shouldUpdateExistingGroup() {
    org.hl7.fhir.r4.model.Group.GroupMemberComponent groupMemberComponent = mock(org.hl7.fhir.r4.model.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), Group30_40.convertGroup(group));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
    assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.DSTU3));
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)90 Group (org.hl7.fhir.r4.model.Group)74 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 Group (org.hl7.fhir.dstu3.model.Group)44 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)40 Cohort (org.openmrs.Cohort)30 InputStream (java.io.InputStream)20 ArrayList (java.util.ArrayList)16 Structure (ca.uhn.hl7v2.model.Structure)13 Test (org.junit.jupiter.api.Test)13 Group (ca.uhn.hl7v2.model.Group)12 UUID (java.util.UUID)12 Reference (org.hl7.fhir.r4.model.Reference)12 HL7Exception (ca.uhn.hl7v2.HL7Exception)11 List (java.util.List)10 IdType (org.hl7.fhir.dstu3.model.IdType)9 Message (ca.uhn.hl7v2.model.Message)7 Patient (org.hl7.fhir.dstu3.model.Patient)7 PatientEntity (gov.cms.dpc.common.entities.PatientEntity)6 ProviderEntity (gov.cms.dpc.common.entities.ProviderEntity)6