Search in sources :

Example 86 with org.hl7.fhir.r5.model

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

the class ConditionTranslatorImplTest method shouldTranslateConditionConceptToFhirType.

@Test
public void shouldTranslateConditionConceptToFhirType() {
    Concept concept = new Concept();
    concept.setUuid(CONCEPT_UUID);
    concept.setConceptId(CODE);
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = new Coding();
    coding.setCode(CODE.toString());
    coding.setSystem(SYSTEM);
    codeableConcept.addCoding(coding);
    openmrsCondition.setValueCoded(concept);
    when(conceptTranslator.toFhirResource(concept)).thenReturn(codeableConcept);
    org.hl7.fhir.r4.model.Condition condition = conditionTranslator.toFhirResource(openmrsCondition);
    assertThat(condition, notNullValue());
    assertThat(condition.getCode(), notNullValue());
    assertThat(condition.getCode().getCoding(), not(Collections.emptyList()));
    assertThat(condition.getCode().getCoding().get(0).getCode(), equalTo(CODE.toString()));
    assertThat(condition.getCode().getCoding().get(0).getSystem(), equalTo(SYSTEM));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) Coding(org.hl7.fhir.r4.model.Coding) Condition(org.hl7.fhir.r4.model.Condition) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 87 with org.hl7.fhir.r5.model

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

the class MedicationTranslatorImplTest method toFhirResource_shouldTranslateOpenMrsDateChangedToLastUpdatedDate.

@Test
public void toFhirResource_shouldTranslateOpenMrsDateChangedToLastUpdatedDate() {
    drug.setDateChanged(new Date());
    org.hl7.fhir.r4.model.Medication medication = medicationTranslator.toFhirResource(drug);
    assertThat(medication, notNullValue());
    assertThat(medication.getMeta().getLastUpdated(), DateMatchers.sameDay(new Date()));
}
Also used : Medication(org.hl7.fhir.r4.model.Medication) Date(java.util.Date) Test(org.junit.Test)

Example 88 with org.hl7.fhir.r5.model

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

the class LocationAddressTranslatorImplTest method shouldTranslateLocationPostalCodeToAddressCode.

@Test
public void shouldTranslateLocationPostalCodeToAddressCode() {
    omrsLocation.setPostalCode(POSTAL_CODE);
    org.hl7.fhir.r4.model.Address address = translator.toFhirResource(omrsLocation);
    assertThat(address, notNullValue());
    assertThat(address.getPostalCode(), notNullValue());
    assertThat(address.getPostalCode(), equalTo(POSTAL_CODE));
}
Also used : Address(org.hl7.fhir.r4.model.Address) Test(org.junit.Test)

Example 89 with org.hl7.fhir.r5.model

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

the class LocationAddressTranslatorImplTest method shouldTranslateAddressPostalCodeToLocationPostalCode.

@Test
public void shouldTranslateAddressPostalCodeToLocationPostalCode() {
    org.hl7.fhir.r4.model.Address address = new Address();
    address.setPostalCode(POSTAL_CODE);
    omrsLocation = translator.toOpenmrsType(new Location(), address);
    assertThat(omrsLocation, notNullValue());
    assertThat(omrsLocation.getPostalCode(), notNullValue());
    assertThat(omrsLocation.getPostalCode(), equalTo(POSTAL_CODE));
}
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 90 with org.hl7.fhir.r5.model

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

the class LocationAddressTranslatorImplTest method shouldTranslateAddressCountryToLocationCountry.

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

Aggregations

Test (org.junit.jupiter.api.Test)435 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)289 ArrayList (java.util.ArrayList)112 FHIRException (org.hl7.fhir.exceptions.FHIRException)111 IOException (java.io.IOException)84 List (java.util.List)73 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)68 FileOutputStream (java.io.FileOutputStream)66 File (java.io.File)61 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 InputStream (java.io.InputStream)55 TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 Bundle (org.hl7.fhir.dstu3.model.Bundle)49 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Collectors (java.util.stream.Collectors)48 Arrays (java.util.Arrays)46