Search in sources :

Example 76 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationAddressTranslatorImplTest method shouldTranslateLocationCountryToAddressCountry.

@Test
public void shouldTranslateLocationCountryToAddressCountry() {
    omrsLocation.setCountry(COUNTRY);
    org.hl7.fhir.r4.model.Address address = translator.toFhirResource(omrsLocation);
    assertThat(address, notNullValue());
    assertThat(address.getCountry(), notNullValue());
    assertThat(address.getCountry(), equalTo(COUNTRY));
}
Also used : Address(org.hl7.fhir.r4.model.Address) Test(org.junit.Test)

Example 77 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationAddressTranslatorImplTest method shouldTranslateAddressStateToLocationState.

@Test
public void shouldTranslateAddressStateToLocationState() {
    org.hl7.fhir.r4.model.Address address = new Address();
    address.setState(STATE_PROVINCE);
    omrsLocation = translator.toOpenmrsType(new Location(), address);
    assertThat(omrsLocation, notNullValue());
    assertThat(omrsLocation.getStateProvince(), notNullValue());
    assertThat(omrsLocation.getStateProvince(), equalTo(STATE_PROVINCE));
}
Also used : Address(org.hl7.fhir.r4.model.Address) Address(org.hl7.fhir.r4.model.Address) Location(org.openmrs.Location) Test(org.junit.Test)

Example 78 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationTranslatorImplTest method shouldTranslateLocationAttributeToFhirContactPoint.

@Test
public void shouldTranslateLocationAttributeToFhirContactPoint() {
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(CONTACT_POINT_ID);
    contactPoint.setValue(CONTACT_POINT_VALUE);
    LocationAttribute locationAttribute = new LocationAttribute();
    locationAttribute.setUuid(LOCATION_ATTRIBUTE_UUID);
    locationAttribute.setValue(LOCATION_ATTRIBUTE_VALUE);
    LocationAttributeType attributeType = new LocationAttributeType();
    attributeType.setName(LOCATION_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(LOCATION_ATTRIBUTE_TYPE_UUID);
    locationAttribute.setAttributeType(attributeType);
    org.hl7.fhir.r4.model.Location location = locationTranslator.toFhirResource(new Location());
    assertThat(location, notNullValue());
    assertThat(location.getTelecom(), notNullValue());
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) LocationAttribute(org.openmrs.LocationAttribute) LocationAttributeType(org.openmrs.LocationAttributeType) Location(org.openmrs.Location) Test(org.junit.Test)

Example 79 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationTranslatorImplTest method toOpenmrsType_shouldTranslateFhirTagsToOpenmrsLocationTags.

@Test
public void toOpenmrsType_shouldTranslateFhirTagsToOpenmrsLocationTags() {
    LocationTag omrsTag = new LocationTag(LAB_TAG_NAME, LAB_TAG_DESCRIPTION);
    List<Coding> tags = new ArrayList<>();
    Coding tag = new Coding();
    tag.setCode(LAB_TAG_NAME);
    tag.setDisplay(LAB_TAG_DESCRIPTION);
    tags.add(tag);
    org.hl7.fhir.r4.model.Location fhirLocation = new org.hl7.fhir.r4.model.Location();
    fhirLocation.getMeta().setTag(tags);
    when(locationTagTranslator.toOpenmrsType(tag)).thenReturn(omrsTag);
    omrsLocation = locationTranslator.toOpenmrsType(fhirLocation);
    assertThat(omrsLocation.getTags(), notNullValue());
    assertThat(omrsLocation.getTags(), hasSize(greaterThanOrEqualTo(1)));
    assertThat(omrsLocation.getTags().iterator().next().getName(), is(LAB_TAG_NAME));
}
Also used : LocationTag(org.openmrs.LocationTag) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) Location(org.openmrs.Location) Test(org.junit.Test)

Example 80 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project elexis-server by elexis.

the class PractitionerRoleTest method getPractitionerRole.

@Test
public void getPractitionerRole() {
    // search by role
    Bundle results = client.search().forResource(PractitionerRole.class).where(PractitionerRole.ROLE.exactly().systemAndCode(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.getSystem(), org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.toCode())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    PractitionerRole practitionerRole = (PractitionerRole) entries.get(0).getResource();
    List<CodeableConcept> roles = practitionerRole.getCode();
    boolean doctorRoleFound = false;
    for (CodeableConcept role : roles) {
        List<Coding> codings = role.getCoding();
        for (Coding coding : codings) {
            if (coding.getSystem().equals(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.getSystem()) && coding.getCode().equals(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.toCode())) {
                doctorRoleFound = true;
            }
        }
    }
    assertTrue(doctorRoleFound);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) Bundle(org.hl7.fhir.r4.model.Bundle) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)427 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)104 ArrayList (java.util.ArrayList)101 IOException (java.io.IOException)78 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)65 List (java.util.List)64 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 FileOutputStream (java.io.FileOutputStream)59 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 File (java.io.File)57 InputStream (java.io.InputStream)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Bundle (org.hl7.fhir.dstu3.model.Bundle)48 MethodSource (org.junit.jupiter.params.provider.MethodSource)46 Arrays (java.util.Arrays)45 Collectors (java.util.stream.Collectors)45