use of org.hl7.fhir.r4b.model.DateType in project beneficiary-fhir-data by CMSgov.
the class FissClaimResponseTransformerV2 method getExtension.
private static List<Extension> getExtension(PreAdjFissClaim claimGroup) {
List<Extension> extensions = new ArrayList<>();
extensions.add(new Extension(BBCodingSystems.FISS.CURR_STATUS).setValue(new Coding(BBCodingSystems.FISS.CURR_STATUS, "" + claimGroup.getCurrStatus(), null)));
if (claimGroup.getReceivedDate() != null) {
extensions.add(new Extension(BBCodingSystems.FISS.RECD_DT_CYMD).setValue(new DateType(localDateToDate(claimGroup.getReceivedDate()))));
}
if (claimGroup.getCurrTranDate() != null) {
extensions.add(new Extension(BBCodingSystems.FISS.CURR_TRAN_DT_CYMD));
}
return List.copyOf(extensions);
}
use of org.hl7.fhir.r4b.model.DateType in project beneficiary-fhir-data by CMSgov.
the class PartDEventTransformerV2Test method shouldHaveLineItemServicedDate.
@Test
public void shouldHaveLineItemServicedDate() {
DateType servicedDate = eob.getItemFirstRep().getServicedDateType();
DateType compare = new DateType("2015-05-12");
assertEquals(servicedDate.toString(), compare.toString());
}
use of org.hl7.fhir.r4b.model.DateType in project openmrs-module-fhir2 by openmrs.
the class BirthDateTranslatorImpl method toFhirResource.
@Override
public DateType toFhirResource(@Nonnull Person person) {
if (person.getBirthdate() == null) {
return null;
}
if (person.getBirthdateEstimated() != null && person.getBirthdateEstimated()) {
DateType dateType = new DateType();
LocalDate now = LocalDate.now();
LocalDate birthDate = Instant.ofEpochMilli(person.getBirthdate().getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
// "infant" and "child"
if (Period.between(birthDate, now).getYears() > 5) {
dateType.setValue(person.getBirthdate(), TemporalPrecisionEnum.YEAR);
} else {
dateType.setValue(person.getBirthdate(), TemporalPrecisionEnum.MONTH);
}
return dateType;
}
return new DateType(person.getBirthdate());
}
use of org.hl7.fhir.r4b.model.DateType in project openmrs-module-fhir2 by openmrs.
the class PersonTranslatorImplTest method shouldTranslateToOpenMRSBirthDate.
@Test
public void shouldTranslateToOpenMRSBirthDate() {
org.hl7.fhir.r4.model.Person openMRSPerson = new org.hl7.fhir.r4.model.Person();
Date date = new Date();
DateType dateType = new DateType();
// for TemporalPrecisionEnum.DAY
dateType.setValue(date, TemporalPrecisionEnum.DAY);
openMRSPerson.setBirthDateElement(dateType);
Person result = personTranslator.toOpenmrsType(openMRSPerson);
assertThat(result, notNullValue());
assertThat(result.getBirthdateEstimated(), equalTo(false));
assertThat(result.getBirthdate(), equalTo(date));
// for TemporalPrecisionEnum.Month
dateType.setValue(date, TemporalPrecisionEnum.MONTH);
openMRSPerson.setBirthDateElement(dateType);
result = personTranslator.toOpenmrsType(openMRSPerson);
assertThat(result, notNullValue());
assertThat(result.getBirthdateEstimated(), equalTo(true));
assertThat(result.getBirthdate(), equalTo(date));
// for TemporalPrecisionEnum.YEAR
dateType.setValue(date, TemporalPrecisionEnum.YEAR);
openMRSPerson.setBirthDateElement(dateType);
result = personTranslator.toOpenmrsType(openMRSPerson);
assertThat(result, notNullValue());
assertThat(result.getBirthdateEstimated(), equalTo(true));
assertThat(result.getBirthdate(), equalTo(date));
}
use of org.hl7.fhir.r4b.model.DateType in project openmrs-module-fhir2 by openmrs.
the class PersonTranslatorImplTest method shouldTranslateToFhirBirthDate.
@Test
public void shouldTranslateToFhirBirthDate() {
Person person = new Person();
Calendar calendar = Calendar.getInstance();
DateType dateType = new DateType();
// when birthdate more than 5 year
calendar.set(2000, Calendar.AUGUST, 12);
person.setBirthdateEstimated(true);
person.setBirthdate(calendar.getTime());
org.hl7.fhir.r4.model.Person result = personTranslator.toFhirResource(person);
assertThat(result, notNullValue());
assertThat(result.getBirthDateElement().getPrecision(), equalTo(TemporalPrecisionEnum.YEAR));
assertThat(result.getBirthDateElement().getYear(), equalTo(2000));
// when birthDate less then 5 year
Date date = new Date();
person.setBirthdate(date);
dateType.setValue(date, TemporalPrecisionEnum.MONTH);
result = personTranslator.toFhirResource(person);
assertThat(result, notNullValue());
assertThat(result.getBirthDateElement().getPrecision(), equalTo(TemporalPrecisionEnum.MONTH));
assertThat(result.getBirthDateElement().getYear(), equalTo(dateType.getYear()));
assertThat(result.getBirthDateElement().getMonth(), equalTo(dateType.getMonth()));
}
Aggregations