use of org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent in project beneficiary-fhir-data by CMSgov.
the class CarrierClaimTransformerV2Test method shouldHaveSupportingInfoListForClaimReceivedDate2.
@Test
public void shouldHaveSupportingInfoListForClaimReceivedDate2() {
SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("info", eob.getSupportingInfo());
SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
sic.getSequence(), // Category
Arrays.asList(new Coding("http://terminology.hl7.org/CodeSystem/claiminformationcategory", "info", "Information"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/line_hct_hgb_rslt_num", "Hematocrit / Hemoglobin Test Results")));
compare.setValue(new Reference("#line-observation-6"));
assertTrue(compare.equalsDeep(sic));
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method addInformation.
/**
* Returns a new {@link SupportingInformationComponent} that has been added to the specified
* {@link ExplanationOfBenefit}.
*
* @param eob the {@link ExplanationOfBenefit} to modify
* @return the newly-added {@link SupportingInformationComponent} entry
*/
static SupportingInformationComponent addInformation(ExplanationOfBenefit eob) {
int maxSequence = eob.getSupportingInfo().stream().mapToInt(i -> i.getSequence()).max().orElse(0);
SupportingInformationComponent infoComponent = new SupportingInformationComponent();
infoComponent.setSequence(maxSequence + 1);
eob.getSupportingInfo().add(infoComponent);
return infoComponent;
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method addInformationWithCode.
/**
* Returns a new {@link SupportingInformationComponent} that has been added to the specified
* {@link ExplanationOfBenefit}. Unlike {@link #addInformation(ExplanationOfBenefit,
* CcwCodebookInterface)}, this also sets the {@link SupportingInformationComponent#getCode()}
* based on the values provided.
*
* @param eob the {@link ExplanationOfBenefit} to modify
* @param categoryVariable {@link CcwCodebookInterface} to map to {@link
* SupportingInformationComponent#getCategory()}
* @param codeSystemVariable the {@link CcwCodebookInterface} to map to the {@link
* Coding#getSystem()} used in the {@link SupportingInformationComponent#getCode()}
* @param codeValue the value to map to the {@link Coding#getCode()} used in the {@link
* SupportingInformationComponent#getCode()}
* @return the newly-added {@link SupportingInformationComponent} entry
*/
static SupportingInformationComponent addInformationWithCode(ExplanationOfBenefit eob, CcwCodebookInterface categoryVariable, CcwCodebookInterface codeSystemVariable, Optional<?> codeValue) {
SupportingInformationComponent infoComponent = addInformation(eob, categoryVariable);
CodeableConcept infoCode = new CodeableConcept().addCoding(createCoding(eob, codeSystemVariable, codeValue));
infoComponent.setCode(infoCode);
return infoComponent;
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method assertEobEquals.
/**
* Compares two ExplanationOfBenefit objects in detail while working around serialization issues
* like comparing "0" and "0.0" or creation differences like using "Quantity" vs "SimpleQuantity"
*
* @param expected the expected
* @param actual the actual
*/
private static void assertEobEquals(ExplanationOfBenefit expected, ExplanationOfBenefit actual) {
// ID in the bundle will have `ExplanationOfBenefit/` in front, so make sure the last bit
// matches up
assertTrue(actual.getId().endsWith(expected.getId()));
// Clean them out so we can do a deep compare later
actual.setId("");
expected.setId("");
// If there are any contained resources, they might have lastupdate times in them too
assertEquals(expected.getContained().size(), actual.getContained().size());
for (int i = 0; i < expected.getContained().size(); i++) {
Resource expectedContained = expected.getContained().get(i);
Resource actualContained = actual.getContained().get(i);
expectedContained.getMeta().setLastUpdated(null);
actualContained.getMeta().setLastUpdated(null);
// TODO: HAPI seems to be inserting the `#` in the ID of the contained element.
// This is incorrect according to the FHIR spec:
// https://build.fhir.org/references.html#contained
// This works around that problem
assertEquals("#" + expectedContained.getId(), actualContained.getId());
expectedContained.setId("");
actualContained.setId("");
}
// Dates are not easy to compare so just make sure they are there
assertNotNull(actual.getMeta().getLastUpdated());
// We compared all of meta that we care about so get it out of the way
expected.getMeta().setLastUpdated(null);
actual.getMeta().setLastUpdated(null);
// Created is required, but can't be compared
assertNotNull(actual.getCreated());
expected.setCreated(null);
actual.setCreated(null);
// Extensions may have `valueMoney` elements
assertEquals(expected.getExtension().size(), actual.getExtension().size());
for (int i = 0; i < expected.getExtension().size(); i++) {
Extension expectedEx = expected.getExtension().get(i);
Extension actualEx = actual.getExtension().get(i);
// We have to deal with Money objects separately
if (expectedEx.hasValue() && expectedEx.getValue() instanceof Money) {
assertTrue(actualEx.getValue() instanceof Money);
assertCurrencyEquals((Money) expectedEx.getValue(), (Money) actualEx.getValue());
// Now remove since we validated so we can compare the rest directly
expectedEx.setValue(null);
actualEx.setValue(null);
}
}
// SupportingInfo can have `valueQuantity` that has the 0 vs 0.0 issue
assertEquals(expected.getSupportingInfo().size(), actual.getSupportingInfo().size());
for (int i = 0; i < expected.getSupportingInfo().size(); i++) {
SupportingInformationComponent expectedSup = expected.getSupportingInfo().get(i);
SupportingInformationComponent actualSup = actual.getSupportingInfo().get(i);
// We have to deal with Money objects separately
if (expectedSup.hasValueQuantity()) {
assertTrue(actualSup.hasValueQuantity());
assertEquals(expectedSup.getValueQuantity().getValue().floatValue(), actualSup.getValueQuantity().getValue().floatValue(), 0.0);
// Now remove since we validated so we can compare the rest directly
expectedSup.setValue(null);
actualSup.setValue(null);
}
}
// line items
assertEquals(expected.getItem().size(), actual.getItem().size());
for (int i = 0; i < expected.getItem().size(); i++) {
ItemComponent expectedItem = expected.getItem().get(i);
ItemComponent actualItem = actual.getItem().get(i);
// Compare value directly because SimpleQuantity vs Quantity can't be compared
assertEquals(expectedItem.getQuantity().getValue().floatValue(), actualItem.getQuantity().getValue().floatValue(), 0.0);
expectedItem.setQuantity(null);
actualItem.setQuantity(null);
assertEquals(expectedItem.getAdjudication().size(), actualItem.getAdjudication().size());
for (int j = 0; j < expectedItem.getAdjudication().size(); j++) {
AdjudicationComponent expectedAdj = expectedItem.getAdjudication().get(j);
AdjudicationComponent actualAdj = actualItem.getAdjudication().get(j);
// Here is where we start getting into trouble with "0" vs "0.0", so we do this manually
if (expectedAdj.hasAmount()) {
assertNotNull(actualAdj.getAmount());
assertCurrencyEquals(expectedAdj.getAmount(), actualAdj.getAmount());
} else {
// If expected doesn't have an amount, actual shouldn't
assertFalse(actualAdj.hasAmount());
}
// We just checked manually, so null them out and check the rest of the fields
expectedAdj.setAmount(null);
actualAdj.setAmount(null);
}
}
// Total has the same problem with values
assertEquals(expected.getTotal().size(), actual.getTotal().size());
for (int i = 0; i < expected.getTotal().size(); i++) {
TotalComponent expectedTot = expected.getTotal().get(i);
TotalComponent actualTot = actual.getTotal().get(i);
if (expectedTot.hasAmount()) {
assertNotNull(actualTot.getAmount());
assertCurrencyEquals(expectedTot.getAmount(), actualTot.getAmount());
} else {
// If expected doesn't have an amount, actual shouldn't
assertFalse(actualTot.hasAmount());
}
expectedTot.setAmount(null);
actualTot.setAmount(null);
}
// Benefit Balance Financial components
assertEquals(expected.getBenefitBalance().size(), actual.getBenefitBalance().size());
for (int i = 0; i < expected.getBenefitBalance().size(); i++) {
BenefitBalanceComponent expectedBen = expected.getBenefitBalance().get(i);
BenefitBalanceComponent actualBen = actual.getBenefitBalance().get(i);
assertEquals(expectedBen.getFinancial().size(), actualBen.getFinancial().size());
for (int j = 0; j < expectedBen.getFinancial().size(); j++) {
BenefitComponent expectedFinancial = expectedBen.getFinancial().get(j);
BenefitComponent actualFinancial = actualBen.getFinancial().get(j);
// Are we dealing with Money?
if (expectedFinancial.hasUsedMoney()) {
assertNotNull(actualFinancial.getUsedMoney());
assertCurrencyEquals(expectedFinancial.getUsedMoney(), actualFinancial.getUsedMoney());
// Clean up
expectedFinancial.setUsed(null);
actualFinancial.setUsed(null);
}
}
}
// As does payment
if (expected.hasPayment()) {
assertTrue(actual.hasPayment());
assertCurrencyEquals(expected.getPayment().getAmount(), actual.getPayment().getAmount());
} else {
// If expected doesn't have an amount, actual shouldn't
assertFalse(actual.hasPayment());
}
expected.getPayment().setAmount(null);
actual.getPayment().setAmount(null);
// Now for the grand finale, we can do an `equalsDeep` on the rest
assertTrue(expected.equalsDeep(actual));
}
use of org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent in project beneficiary-fhir-data by CMSgov.
the class TransformerTestUtils method assertInformationPeriodEquals.
/**
* @param expectedCategorySystem the expected value for {@link
* SupportingInformationComponent#getCategory()}'s {@link Coding#getSystem()}
* @param expectedCategoryCodeVariable the expected {@link CcwCodebookVariable} for {@link
* SupportingInformationComponent#getCategory()}'s {@link Coding#getCode()}
* @param expectedFromDate the expected {@link
* SupportingInformationComponent#getTimingPeriod().getStartElement()}
* @param expectedThruDate the expected {@link
* SupportingInformationComponent#getTimingPeriod().getEndElement()}
* @param actuals the actual {@link SupportingInformationComponent}s to verify
*/
static void assertInformationPeriodEquals(String expectedCategorySystem, CcwCodebookVariable expectedCategoryCodeVariable, LocalDate expectedFromDate, LocalDate expectedThruDate, List<SupportingInformationComponent> actuals) {
String expectedCategoryCode = CCWUtils.calculateVariableReferenceUrl(expectedCategoryCodeVariable);
Optional<SupportingInformationComponent> supportingInformationComponent = actuals.stream().filter(a -> isCodeInConcept(a.getCategory(), expectedCategorySystem, expectedCategoryCode)).findAny();
assertTrue(supportingInformationComponent.isPresent());
try {
assertDateEquals(expectedFromDate, supportingInformationComponent.get().getTimingPeriod().getStartElement());
assertDateEquals(expectedThruDate, supportingInformationComponent.get().getTimingPeriod().getEndElement());
} catch (FHIRException e) {
throw new BadCodeMonkeyException(e);
}
}
Aggregations