Search in sources :

Example 96 with Encounter

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

the class EncounterTranslatorImplTest method toFhirResource_shouldTranslateLocationToEncounterDefaultClass.

@Test
public void toFhirResource_shouldTranslateLocationToEncounterDefaultClass() {
    omrsEncounter.setLocation(location);
    Encounter result = encounterTranslator.toFhirResource(omrsEncounter);
    assertThat(result, notNullValue());
    assertThat(result.getClass_(), notNullValue());
    assertThat(result.getClass_().getSystem(), is(FhirConstants.ENCOUNTER_CLASS_VALUE_SET_URI));
    assertThat(result.getClass_().getCode(), is("AMB"));
}
Also used : Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.Test)

Example 97 with Encounter

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

the class EncounterTranslatorImplTest method toFhirResource_shouldTranslateLocationToEncounterLocationWithCorrectReference.

@Test
public void toFhirResource_shouldTranslateLocationToEncounterLocationWithCorrectReference() {
    omrsEncounter.setLocation(location);
    Encounter.EncounterLocationComponent locationComponent = new Encounter.EncounterLocationComponent();
    Reference locationRef = new Reference();
    locationRef.setReference(LOCATION_URI);
    locationRef.setDisplay(TEST_LOCATION_NAME);
    locationComponent.setLocation(locationRef);
    when(encounterLocationTranslator.toFhirResource(location)).thenReturn(locationComponent);
    Encounter result = encounterTranslator.toFhirResource(omrsEncounter);
    assertThat(result, notNullValue());
    assertThat(result.getLocation(), notNullValue());
    assertThat(result.getLocation().size(), is(1));
    assertThat(result.getLocation().get(0).getLocation().getDisplay(), equalTo(TEST_LOCATION_NAME));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.Test)

Example 98 with Encounter

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

the class BaseReferenceHandlingTranslatorTest method shouldAddEncounterReference.

@Test
public void shouldAddEncounterReference() {
    Reference reference = referenceHandlingTranslator.createEncounterReference(encounter);
    assertThat(reference, notNullValue());
    assertThat(reference.getReference(), equalTo(ENCOUNTER_URI));
    assertThat(reference.getType(), equalTo(FhirConstants.ENCOUNTER));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.Test)

Example 99 with Encounter

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

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldConvertEncounter.

@Test
public void toFhirResource_shouldConvertEncounter() {
    Encounter encounter = new Encounter();
    Reference encounterReference = new Reference();
    fhirDiagnosticReport.setEncounter(encounter);
    when(encounterReferenceTranslator.toFhirResource(encounter)).thenReturn(encounterReference);
    DiagnosticReport result = translator.toFhirResource(fhirDiagnosticReport);
    assertThat(result.getEncounter(), equalTo(encounterReference));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Encounter(org.openmrs.Encounter) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Test(org.junit.Test)

Example 100 with Encounter

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

the class EncounterPeriodTranslatorImplTest method toOpenmrsObject_shouldMapPeriodStartToEncounterDatetime.

@Test
public void toOpenmrsObject_shouldMapPeriodStartToEncounterDatetime() {
    Date encounterDate = new java.util.Date();
    Encounter encounter = new Encounter();
    Period period = new Period();
    period.setStart(encounterDate);
    Encounter result = encounterPeriodTranslator.toOpenmrsType(encounter, period);
    assertThat(result, notNullValue());
    assertThat(result.getEncounterDatetime(), equalTo(encounterDate));
}
Also used : Encounter(org.openmrs.Encounter) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)238 Encounter (org.hl7.fhir.r4.model.Encounter)166 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)96 Test (org.junit.jupiter.api.Test)91 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)87 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)79 Reference (org.hl7.fhir.r4.model.Reference)71 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)66 ArrayList (java.util.ArrayList)61 Resource (org.hl7.fhir.r4.model.Resource)61 Bundle (org.hl7.fhir.r4.model.Bundle)60 Date (java.util.Date)56 Coding (org.hl7.fhir.r4.model.Coding)51 Encounter (org.hl7.fhir.dstu3.model.Encounter)50 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)49 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)43 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)41 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)37 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)37 Observation (org.hl7.fhir.r4.model.Observation)34