Search in sources :

Example 91 with DateTimeType

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

the class PatientTranslatorImplTest method shouldTranslateDeathDateToDeceasedPatient.

@Test
public void shouldTranslateDeathDateToDeceasedPatient() {
    Patient patient = new Patient();
    patient.setDeceased(new DateTimeType(PATIENT_DEATH_DATE));
    org.openmrs.Patient result = patientTranslator.toOpenmrsType(patient);
    assertThat(result.getDead(), is(true));
    assertThat(result.getDeathDate(), equalTo(PATIENT_DEATH_DATE));
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.Test)

Example 92 with DateTimeType

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

the class ObservationEffectiveDatetimeTranslatorImplTest method toOpenmrsType_shouldTranslateDatetimeTypeToObsDatetime.

@Test
public void toOpenmrsType_shouldTranslateDatetimeTypeToObsDatetime() {
    DateTimeType dateTime = new DateTimeType();
    dateTime.setValue(new Date());
    Obs result = datetimeTranslator.toOpenmrsType(obs, dateTime);
    assertThat(result, notNullValue());
    assertThat(result.getObsDatetime(), DateMatchers.sameDay(new Date()));
}
Also used : Obs(org.openmrs.Obs) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Date(java.util.Date) Test(org.junit.Test)

Example 93 with DateTimeType

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

the class ObservationEffectiveDatetimeTranslatorImplTest method toFhirResource_shouldTranslateObsDatetimeToDatetimeType.

@Test
public void toFhirResource_shouldTranslateObsDatetimeToDatetimeType() {
    obs.setObsDatetime(new Date());
    Type datetimeType = datetimeTranslator.toFhirResource(obs);
    assertThat(datetimeType, notNullValue());
    assertThat(((DateTimeType) datetimeType).getValue(), notNullValue());
    assertThat(((DateTimeType) datetimeType).getValue(), DateMatchers.sameDay(new Date()));
}
Also used : Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) InstantType(org.hl7.fhir.r4.model.InstantType) Date(java.util.Date) Test(org.junit.Test)

Example 94 with DateTimeType

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

the class ConditionTranslatorImplTest method shouldTranslateFhirConditionOnsetToOpenMrsOnsetDate.

@Test
public void shouldTranslateFhirConditionOnsetToOpenMrsOnsetDate() {
    when(conceptService.getConceptByUuid(FhirConstants.CONDITION_OBSERVATION_CONCEPT_UUID)).thenReturn(concept);
    DateTimeType theDateTime = new DateTimeType();
    theDateTime.setValue(new Date());
    fhirCondition.setOnset(theDateTime);
    Obs condition = conditionTranslator.toOpenmrsType(fhirCondition);
    assertThat(condition, notNullValue());
    assertThat(condition.getObsDatetime(), notNullValue());
    assertThat(condition.getObsDatetime(), DateMatchers.sameDay(new Date()));
}
Also used : Obs(org.openmrs.Obs) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Date(java.util.Date) Test(org.junit.Test)

Example 95 with DateTimeType

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

the class ConditionTranslatorImpl_2_2 method toFhirResource.

@Override
public org.hl7.fhir.r4.model.Condition toFhirResource(@Nonnull Condition condition) {
    notNull(condition, "The Openmrs Condition object should not be null");
    org.hl7.fhir.r4.model.Condition fhirCondition = new org.hl7.fhir.r4.model.Condition();
    fhirCondition.setId(condition.getUuid());
    fhirCondition.setSubject(patientReferenceTranslator.toFhirResource(condition.getPatient()));
    fhirCondition.setClinicalStatus(clinicalStatusTranslator.toFhirResource(condition.getClinicalStatus()));
    fhirCondition.setVerificationStatus(verificationStatusTranslator.toFhirResource(condition.getVerificationStatus()));
    CodedOrFreeText codedOrFreeTextCondition = condition.getCondition();
    if (codedOrFreeTextCondition != null) {
        fhirCondition.setCode(conceptTranslator.toFhirResource(codedOrFreeTextCondition.getCoded()));
        if (codedOrFreeTextCondition.getNonCoded() != null) {
            Extension extension = new Extension();
            extension.setUrl(FhirConstants.OPENMRS_FHIR_EXT_NON_CODED_CONDITION);
            extension.setValue(new StringType(codedOrFreeTextCondition.getNonCoded()));
            fhirCondition.addExtension(extension);
        }
    }
    fhirCondition.setOnset(new DateTimeType().setValue(condition.getOnsetDate()));
    fhirCondition.setRecorder(practitionerReferenceTranslator.toFhirResource(condition.getCreator()));
    fhirCondition.setRecordedDate(condition.getDateCreated());
    fhirCondition.getMeta().setLastUpdated(condition.getDateChanged());
    fhirCondition.addContained(provenanceTranslator.getCreateProvenance(condition));
    fhirCondition.addContained(provenanceTranslator.getUpdateProvenance(condition));
    return fhirCondition;
}
Also used : Condition(org.openmrs.Condition) Extension(org.hl7.fhir.r4.model.Extension) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) StringType(org.hl7.fhir.r4.model.StringType) CodedOrFreeText(org.openmrs.CodedOrFreeText)

Aggregations

DateTimeType (org.hl7.fhir.r4.model.DateTimeType)65 Date (java.util.Date)28 Test (org.junit.Test)25 Coding (org.hl7.fhir.r4.model.Coding)23 DateTimeType (org.hl7.fhir.dstu3.model.DateTimeType)18 Period (org.hl7.fhir.r4.model.Period)18 ArrayList (java.util.ArrayList)17 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 Observation (org.hl7.fhir.r4.model.Observation)16 Test (org.junit.jupiter.api.Test)16 Patient (org.hl7.fhir.r4.model.Patient)14 DateTimeType (org.hl7.fhir.r4b.model.DateTimeType)14 HashMap (java.util.HashMap)13 DateTimeType (org.hl7.fhir.r5.model.DateTimeType)13 NotImplementedException (org.apache.commons.lang3.NotImplementedException)12 Reference (org.hl7.fhir.r4.model.Reference)12 List (java.util.List)11 Reference (org.hl7.fhir.dstu3.model.Reference)11 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 Resource (org.hl7.fhir.r4.model.Resource)11