Search in sources :

Example 51 with DateType

use of org.hl7.fhir.r4.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);
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) DateType(org.hl7.fhir.r4.model.DateType)

Example 52 with DateType

use of org.hl7.fhir.r4.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());
}
Also used : DateType(org.hl7.fhir.r4.model.DateType) Test(org.junit.jupiter.api.Test)

Example 53 with DateType

use of org.hl7.fhir.r4.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());
}
Also used : DateType(org.hl7.fhir.r4.model.DateType) LocalDate(java.time.LocalDate)

Example 54 with DateType

use of org.hl7.fhir.r4.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));
}
Also used : Person(org.openmrs.Person) DateType(org.hl7.fhir.r4.model.DateType) Date(java.util.Date) Test(org.junit.Test)

Example 55 with DateType

use of org.hl7.fhir.r4.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()));
}
Also used : Calendar(java.util.Calendar) Person(org.openmrs.Person) DateType(org.hl7.fhir.r4.model.DateType) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateType (org.hl7.fhir.r4.model.DateType)36 Test (org.junit.jupiter.api.Test)21 Date (java.util.Date)17 Coding (org.hl7.fhir.r4.model.Coding)15 Test (org.junit.Test)11 SupportingInformationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)10 DateType (org.hl7.fhir.r4b.model.DateType)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 ArrayList (java.util.ArrayList)8 DateType (org.hl7.fhir.r5.model.DateType)8 DateType (org.hl7.fhir.dstu3.model.DateType)7 Extension (org.hl7.fhir.r4.model.Extension)6 Calendar (java.util.Calendar)5 DisplayName (org.junit.jupiter.api.DisplayName)5 InvalidRifValueException (gov.cms.bfd.model.rif.parse.InvalidRifValueException)4 DateType (org.hl7.fhir.dstu2016may.model.DateType)4 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)4 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)4 Patient (org.hl7.fhir.r4.model.Patient)4 Reference (org.hl7.fhir.r4.model.Reference)4