Search in sources :

Example 81 with Practitioner

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

the class PractitionerTranslatorProviderImplTest method shouldTranslateFhirNameToPersonName.

@Test
public void shouldTranslateFhirNameToPersonName() {
    PersonName personName = new PersonName();
    personName.setGivenName(GIVEN_NAME);
    personName.setFamilyName(FAMILY_NAME);
    org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
    practitioner.addIdentifier(new Identifier().setValue("349023n23b-t"));
    HumanName name = practitioner.addName();
    name.addGiven(GIVEN_NAME);
    name.setFamily(FAMILY_NAME);
    when(nameTranslator.toOpenmrsType(name)).thenReturn(personName);
    Provider result = practitionerTranslator.toOpenmrsType(practitioner);
    assertThat(result, notNullValue());
    assertThat(result.getPerson().getGivenName(), equalTo(GIVEN_NAME));
    assertThat(result.getPerson().getFamilyName(), equalTo(FAMILY_NAME));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) Identifier(org.hl7.fhir.r4.model.Identifier) Practitioner(org.hl7.fhir.r4.model.Practitioner) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 82 with Practitioner

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

the class PractitionerTranslatorProviderImplTest method shouldTranslateFhirPractitionerIdToUuid.

@Test
public void shouldTranslateFhirPractitionerIdToUuid() {
    org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
    practitioner.setId(PRACTITIONER_UUID);
    practitioner.addIdentifier(new Identifier().setValue("349023n23b-t"));
    Provider result = practitionerTranslator.toOpenmrsType(practitioner);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), equalTo(PRACTITIONER_UUID));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Identifier(org.hl7.fhir.r4.model.Identifier) Practitioner(org.hl7.fhir.r4.model.Practitioner) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 83 with Practitioner

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

the class PractitionerTranslatorProviderImplTest method shouldTranslateFhirContactPointToPersonAttribute.

@Test
public void shouldTranslateFhirContactPointToPersonAttribute() {
    ProviderAttributeType attributeType = new ProviderAttributeType();
    attributeType.setName(PERSON_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
    ProviderAttribute providerAttribute = new ProviderAttribute();
    providerAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
    providerAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    providerAttribute.setAttributeType(attributeType);
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(PERSON_ATTRIBUTE_UUID);
    contactPoint.setValue(PERSON_ATTRIBUTE_VALUE);
    practitioner.addTelecom(contactPoint);
    when(telecomTranslator.toOpenmrsType(any(), any())).thenReturn(providerAttribute);
    Provider provider = practitionerTranslator.toOpenmrsType(practitioner);
    assertThat(provider, notNullValue());
    assertThat(provider.getAttributes(), notNullValue());
    assertThat(provider.getAttributes().size(), greaterThanOrEqualTo(1));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) ProviderAttribute(org.openmrs.ProviderAttribute) ProviderAttributeType(org.openmrs.ProviderAttributeType) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 84 with Practitioner

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

the class PractitionerTranslatorProviderImplTest method shouldReturnNullWhenProviderIsNull.

@Test
public void shouldReturnNullWhenProviderIsNull() {
    Practitioner practitioner = practitionerTranslator.toFhirResource(null);
    assertThat(practitioner, nullValue());
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Test(org.junit.Test)

Example 85 with Practitioner

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

the class BaseFhirProvenanceResourceTest method addAgent.

private Provenance.ProvenanceAgentComponent addAgent() {
    User user = new User();
    user.setUuid(PRACTITIONER_UUID);
    Practitioner practitioner = new Practitioner();
    practitioner.setId(PRACTITIONER_UUID);
    when(practitionerReferenceTranslator.toFhirResource(user)).thenReturn(createPractitionerReference());
    return new Provenance.ProvenanceAgentComponent().setType(addAgentType()).addRole(addAgentRole()).setWho(practitionerReferenceTranslator.toFhirResource(user));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Provenance(org.hl7.fhir.r4.model.Provenance) User(org.openmrs.User)

Aggregations

Test (org.junit.Test)185 Practitioner (org.hl7.fhir.r4.model.Practitioner)139 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)86 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)81 Test (org.junit.jupiter.api.Test)68 Practitioner (org.hl7.fhir.dstu3.model.Practitioner)62 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)59 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)54 StringParam (ca.uhn.fhir.rest.param.StringParam)54 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)52 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)37 Identifier (org.hl7.fhir.r4.model.Identifier)32 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)30 Resource (org.hl7.fhir.r4.model.Resource)30 ArrayList (java.util.ArrayList)25 Reference (org.hl7.fhir.r4.model.Reference)24 Bundle (org.hl7.fhir.r4.model.Bundle)22 Date (java.util.Date)21 List (java.util.List)21 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)20