use of gov.cms.bfd.model.codebook.model.CcwCodebookInterface in project beneficiary-fhir-data by CMSgov.
the class TransformerTestUtils method assertAdjudicationReasonEquals.
/**
* @param expectedCategoryCode the {@link CcwCodebookVariable} for the {@link
* AdjudicationComponent#getCategory()} to find and verify
* @param expectedReasonCode the expected {@link Coding#getCode()} of the {@link
* AdjudicationComponent#getReason()} to find and verify
* @param actuals the actual {@link AdjudicationComponent}s to verify
*/
static void assertAdjudicationReasonEquals(CcwCodebookInterface ccwVariable, Optional<?> expectedReasonCode, List<AdjudicationComponent> actuals) {
CodeableConcept expectedCategory = TransformerUtils.createAdjudicationCategory(ccwVariable);
Optional<AdjudicationComponent> adjudication = actuals.stream().filter(a -> isCodeInConcept(a.getCategory(), expectedCategory.getCodingFirstRep().getSystem(), expectedCategory.getCodingFirstRep().getCode())).findAny();
assertEquals(expectedReasonCode.isPresent(), adjudication.isPresent());
if (expectedReasonCode.isPresent())
assertHasCoding(ccwVariable, expectedReasonCode, adjudication.get().getReason());
}
use of gov.cms.bfd.model.codebook.model.CcwCodebookInterface in project beneficiary-fhir-data by CMSgov.
the class TransformerTestUtils method assertHasBenefitComponent.
/**
* @param ccwVariable the {@link CcwCodebookVariable} matching the {@link
* BenefitComponent#getType()} to find
* @param eob the {@link ExplanationOfBenefit} to search
* @return the {@link BenefitComponent} that was found (if one wasn't, the method will instead
* fail with an {@link AssertionFailedError})
*/
private static BenefitComponent assertHasBenefitComponent(CcwCodebookInterface ccwVariable, ExplanationOfBenefit eob) {
// We only ever map one root EOB.benefitBalance.
BenefitBalanceComponent benefitBalanceComponent = eob.getBenefitBalanceFirstRep();
assertNotNull(benefitBalanceComponent);
Optional<BenefitComponent> benefitOptional = benefitBalanceComponent.getFinancial().stream().filter(bc -> isCodeInConcept(bc.getType(), TransformerConstants.CODING_BBAPI_BENEFIT_BALANCE_TYPE, CCWUtils.calculateVariableReferenceUrl(ccwVariable))).findFirst();
assertTrue(benefitOptional.isPresent());
return benefitOptional.get();
}
use of gov.cms.bfd.model.codebook.model.CcwCodebookInterface in project beneficiary-fhir-data by CMSgov.
the class TransformerTestUtils method assertAdjudicationAmountEquals.
/**
* @param ccwVariable the {@link CcwCodebookVariable} for the {@link
* AdjudicationComponent#getCategory()} to find and verify
* @param expectedAmount the expected {@link AdjudicationComponent#getAmount()}
* @param actuals the actual {@link AdjudicationComponent}s to verify
* @return the {@link AdjudicationComponent} that was found and verified
*/
static AdjudicationComponent assertAdjudicationAmountEquals(CcwCodebookInterface ccwVariable, BigDecimal expectedAmount, List<AdjudicationComponent> actuals) {
CodeableConcept expectedCategory = TransformerUtils.createAdjudicationCategory(ccwVariable);
Optional<AdjudicationComponent> adjudication = actuals.stream().filter(a -> isCodeInConcept(a.getCategory(), expectedCategory.getCodingFirstRep().getSystem(), expectedCategory.getCodingFirstRep().getCode())).findAny();
assertTrue(adjudication.isPresent());
assertEquivalent(expectedAmount, adjudication.get().getAmount().getValue());
return adjudication.get();
}
use of gov.cms.bfd.model.codebook.model.CcwCodebookInterface in project beneficiary-fhir-data by CMSgov.
the class TransformerTestUtils method assertQuantityUnitInfoEquals.
/**
* @param ccwVariableForQuantity the {@link CcwCodebookVariable} that was mapped to a {@link
* Quantity} {@link Extension}
* @param ccwVariableForUnit the {@link CcwCodebookVariable} that was mapped to a {@link Quantity}
* unit
* @param expectedUnitCode the expected {@link Quantity#getCode()} value
* @param actualElement the FHIR element to find and verify the {@link Extension} of
*/
static void assertQuantityUnitInfoEquals(CcwCodebookInterface ccwVariableForQuantity, CcwCodebookInterface ccwVariableForUnit, Object expectedUnitCode, IBaseHasExtensions actualElement) {
String expectedExtensionUrl = CCWUtils.calculateVariableReferenceUrl(ccwVariableForQuantity);
Optional<? extends IBaseExtension<?, ?>> actualExtension = actualElement.getExtension().stream().filter(e -> e.getUrl().equals(expectedExtensionUrl)).findFirst();
assertTrue(actualExtension.isPresent());
assertTrue(actualExtension.get().getValue() instanceof Quantity);
Quantity actualQuantity = (Quantity) actualExtension.get().getValue();
String expectedUnitCodeString;
if (expectedUnitCode instanceof String)
expectedUnitCodeString = (String) expectedUnitCode;
else if (expectedUnitCode instanceof Character)
expectedUnitCodeString = ((Character) expectedUnitCode).toString();
else
throw new BadCodeMonkeyException("Unsupported: " + expectedUnitCode);
assertEquals(expectedUnitCodeString, actualQuantity.getCode());
assertEquals(CCWUtils.calculateVariableReferenceUrl(ccwVariableForUnit), actualQuantity.getSystem());
}
Aggregations