Search in sources :

Example 81 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.

the class EncounterPeriodTranslatorImplTest method toOpenmrsObject_shouldNotTouchEncounterDatetimeIfPeriodHasNoStartOrEnd.

@Test
public void toOpenmrsObject_shouldNotTouchEncounterDatetimeIfPeriodHasNoStartOrEnd() {
    Date encounterDate = new java.util.Date();
    Encounter encounter = new Encounter();
    encounter.setEncounterDatetime(encounterDate);
    Period period = new Period();
    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)

Example 82 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.

the class EncounterReferenceTranslatorImplTest method toOpenmrsType_shouldReturnNullIfEncounterHasNoIdentifier.

@Test
public void toOpenmrsType_shouldReturnNullIfEncounterHasNoIdentifier() {
    Reference encounterReference = new Reference().setReference(FhirConstants.ENCOUNTER + "/" + ENCOUNTER_UUID).setType(FhirConstants.ENCOUNTER);
    Encounter result = encounterReferenceTranslator.toOpenmrsType(encounterReference);
    assertThat(result, nullValue());
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Encounter(org.openmrs.Encounter) Test(org.junit.Test)

Example 83 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.

the class EncounterReferenceTranslatorImplTest method toOpenmrsType_shouldConvertReferenceToEncounter.

@Test
public void toOpenmrsType_shouldConvertReferenceToEncounter() {
    Reference encounterReference = new Reference().setReference(FhirConstants.ENCOUNTER + "/" + ENCOUNTER_UUID).setType(FhirConstants.ENCOUNTER).setIdentifier(new Identifier().setValue(ENCOUNTER_UUID));
    Encounter encounter = new Encounter();
    encounter.setUuid(ENCOUNTER_UUID);
    when(dao.get(ENCOUNTER_UUID)).thenReturn(encounter);
    Encounter result = encounterReferenceTranslator.toOpenmrsType(encounterReference);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), equalTo(ENCOUNTER_UUID));
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Reference(org.hl7.fhir.r4.model.Reference) Encounter(org.openmrs.Encounter) Test(org.junit.Test)

Example 84 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.

the class EncounterTranslatorImplTest method toFhirResource_shouldTranslateToLastUpdatedDate.

@Test
public void toFhirResource_shouldTranslateToLastUpdatedDate() {
    omrsEncounter.setDateChanged(new Date());
    Encounter result = encounterTranslator.toFhirResource(omrsEncounter);
    assertThat(result, notNullValue());
    assertThat(result.getMeta().getLastUpdated(), DateMatchers.sameDay(new Date()));
}
Also used : Encounter(org.hl7.fhir.r4.model.Encounter) Date(java.util.Date) Test(org.junit.Test)

Example 85 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project openmrs-module-fhir2 by openmrs.

the class EncounterTranslatorImplTest method toFhirResource_shouldTranslateEncounterDatetimeToPeriod.

@Test
public void toFhirResource_shouldTranslateEncounterDatetimeToPeriod() {
    Date encounterDate = new java.util.Date();
    Period period = new Period();
    omrsEncounter.setEncounterDatetime(encounterDate);
    period.setStart(encounterDate);
    when(encounterPeriodTranslator.toFhirResource(ArgumentMatchers.any())).thenReturn(period);
    Encounter result = encounterTranslator.toFhirResource(omrsEncounter);
    assertThat(result, notNullValue());
    assertThat(result.getPeriod(), equalTo(period));
}
Also used : Period(org.hl7.fhir.r4.model.Period) Encounter(org.hl7.fhir.r4.model.Encounter) 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)100 Test (org.junit.jupiter.api.Test)93 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)64 Resource (org.hl7.fhir.r4.model.Resource)61 Bundle (org.hl7.fhir.r4.model.Bundle)60 Date (java.util.Date)57 Encounter (org.hl7.fhir.dstu3.model.Encounter)55 Coding (org.hl7.fhir.r4.model.Coding)51 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)49 Reference (org.hl7.fhir.dstu3.model.Reference)48 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)43 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)41 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)38 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)37