Search in sources :

Example 96 with Person

use of org.hl7.fhir.dstu3.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method searchPeople_shouldReturnMatchingBundleOfPeopleByName.

@Test
public void searchPeople_shouldReturnMatchingBundleOfPeopleByName() {
    StringAndListParam nameParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(GIVEN_NAME)));
    when(fhirPersonService.searchForPeople(argThat(is(nameParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchPeople(nameParam, null, null, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 97 with Person

use of org.hl7.fhir.dstu3.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByCity.

@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByCity() {
    StringAndListParam cityParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
    when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), argThat(is(cityParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchPeople(null, null, null, cityParam, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 98 with Person

use of org.hl7.fhir.dstu3.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByPostalCode.

@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByPostalCode() {
    StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
    when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(postalCodeParam)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, postalCodeParam, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 99 with Person

use of org.hl7.fhir.dstu3.model.Person in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByUUID.

@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByUUID() {
    TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PERSON_UUID));
    when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(uuid)), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, null, uuid, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 100 with Person

use of org.hl7.fhir.dstu3.model.Person in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composePerson.

protected void composePerson(Complex parent, String parentType, String name, Person element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Person", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Person", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getName().size(); i++) composeHumanName(t, "Person", "name", element.getName().get(i), i);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "Person", "telecom", element.getTelecom().get(i), i);
    if (element.hasGenderElement())
        composeEnum(t, "Person", "gender", element.getGenderElement(), -1);
    if (element.hasBirthDateElement())
        composeDate(t, "Person", "birthDate", element.getBirthDateElement(), -1);
    for (int i = 0; i < element.getAddress().size(); i++) composeAddress(t, "Person", "address", element.getAddress().get(i), i);
    if (element.hasPhoto())
        composeAttachment(t, "Person", "photo", element.getPhoto(), -1);
    if (element.hasManagingOrganization())
        composeReference(t, "Person", "managingOrganization", element.getManagingOrganization(), -1);
    if (element.hasActiveElement())
        composeBoolean(t, "Person", "active", element.getActiveElement(), -1);
    for (int i = 0; i < element.getLink().size(); i++) composePersonPersonLinkComponent(t, "Person", "link", element.getLink().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

Test (org.junit.Test)181 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)54 Date (java.util.Date)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)48 Person (org.hl7.fhir.r4.model.Person)47 Person (model.Person)44 Person (com.google.api.services.people.v1.model.Person)38 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)32 Reference (org.hl7.fhir.r4.model.Reference)31 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)30 StringParam (ca.uhn.fhir.rest.param.StringParam)30 VCard (ezvcard.VCard)30 Person (org.openmrs.Person)29 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)23 List (java.util.List)22 Collectors (java.util.stream.Collectors)22 Person (org.hl7.fhir.dstu3.model.Person)22 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)22 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)21