use of org.hl7.fhir.dstu2.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));
}
use of org.hl7.fhir.dstu2.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()));
}
use of org.hl7.fhir.dstu2.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()));
}
use of org.hl7.fhir.dstu2.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()));
}
use of org.hl7.fhir.dstu2.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;
}
Aggregations