use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerTest method transformBeneficiaryWithIncludeAddressFieldsAllOptEmpty.
/**
* Notes for reviewer: for header related coverage, do not test on the combination of headers
* values if there is no correlation between the headers, hence removed includeAddressFields
* header tests out of includeIdentifiers header tests to speed up tests and keep the same level
* of coverage at the same time.
*/
/**
* Verifies that {@link gov.cms.bfd.server.war.stu3.providers.BeneficiaryTransformer} works
* correctly when passed a {@link Beneficiary} where all {@link Optional} fields are set to {@link
* Optional#empty()} and includeAddressFields header take all possible values.
*/
@Test
public void transformBeneficiaryWithIncludeAddressFieldsAllOptEmpty() {
List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
Beneficiary beneficiary = parsedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
TransformerTestUtils.setAllOptionalsToEmpty(beneficiary);
RequestHeaders requestHeader = getRHwithIncldAddrFldHdr("true");
Patient patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
requestHeader = getRHwithIncldAddrFldHdr("false");
patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
requestHeader = getRHwithIncldAddrFldHdr("");
patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
requestHeader = RequestHeaders.getHeaderWrapper();
patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class SNFClaimTransformerV2Test method shouldReferenceCoverageInInsurance.
/**
* Insurance
*/
@Test
public void shouldReferenceCoverageInInsurance() {
// Only one insurance object
assertEquals(1, eob.getInsurance().size());
InsuranceComponent insurance = eob.getInsuranceFirstRep();
InsuranceComponent compare = new InsuranceComponent().setCoverage(new Reference().setReference("Coverage/part-a-567834"));
assertTrue(compare.equalsDeep(insurance));
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method mapEobCommonClaimHeaderData.
/**
* Transforms the common group level header fields between all claim types
*
* @param eob the {@link ExplanationOfBenefit} to modify
* @param claimId CLM_ID
* @param beneficiaryId BENE_ID
* @param claimType {@link ClaimTypeV2} to process
* @param claimGroupId CLM_GRP_ID
* @param coverageType {@link MedicareSegment}
* @param dateFrom CLM_FROM_DT || SRVC_DT (For Part D Events)
* @param dateThrough CLM_THRU_DT || SRVC_DT (For Part D Events)
* @param paymentAmount CLM_PMT_AMT
* @param finalAction FINAL_ACTION
*/
static void mapEobCommonClaimHeaderData(ExplanationOfBenefit eob, String claimId, String beneficiaryId, ClaimTypeV2 claimType, String claimGroupId, MedicareSegment coverageType, Optional<LocalDate> dateFrom, Optional<LocalDate> dateThrough, Optional<BigDecimal> paymentAmount, char finalAction) {
// Claim Type + Claim ID => ExplanationOfBenefit.id
eob.setId(buildEobId(claimType, claimId));
// Current timestamp => Created
eob.setCreated(new Date());
// "claim" => ExplanationOfBenefit.use
eob.setUse(Use.CLAIM);
if (claimType.equals(ClaimTypeV2.PDE)) {
// PDE_ID => ExplanationOfBenefit.identifier
eob.addIdentifier(createClaimIdentifier(CcwCodebookVariable.PDE_ID, claimId));
} else {
// CLM_ID => ExplanationOfBenefit.identifier
eob.addIdentifier(createClaimIdentifier(CcwCodebookVariable.CLM_ID, claimId));
}
// CLM_GRP_ID => ExplanationOfBenefit.identifier
eob.addIdentifier().setSystem(TransformerConstants.IDENTIFIER_SYSTEM_BBAPI_CLAIM_GROUP_ID).setValue(claimGroupId).setType(createC4BBClaimCodeableConcept());
// BENE_ID + Coverage Type => ExplanationOfBenefit.insurance.coverage (ref)
eob.addInsurance().setCoverage(referenceCoverage(beneficiaryId, coverageType));
// BENE_ID => ExplanationOfBenefit.patient (reference)
eob.setPatient(referencePatient(beneficiaryId));
// "insurer" => ExplanationOfBenefit.insurer
eob.setInsurer(new Reference().setIdentifier(new Identifier().setValue("CMS")));
// "outcome" => ExplanationOfBenefit.outcome
eob.setOutcome(RemittanceOutcome.COMPLETE);
// FINAL_ACTION => ExplanationOfBenefit.status
switch(finalAction) {
case 'F':
eob.setStatus(ExplanationOfBenefitStatus.ACTIVE);
break;
case 'N':
eob.setStatus(ExplanationOfBenefitStatus.CANCELLED);
break;
default:
// unknown final action value
throw new BadCodeMonkeyException();
}
// CLM_THRU_DT || SRVC_DT (For Part D Events) => ExplanationOfBenefit.billablePeriod.end
if (dateFrom.isPresent()) {
validatePeriodDates(dateFrom, dateThrough);
setPeriodStart(eob.getBillablePeriod(), dateFrom.get());
setPeriodEnd(eob.getBillablePeriod(), dateThrough.get());
}
// CLM_PMT_AMT => ExplanationOfBenefit.payment.amount
if (paymentAmount.isPresent()) {
eob.getPayment().setAmount(createMoney(paymentAmount));
}
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method createBundle.
/**
* Create a bundle from the entire search result
*
* @param paging contains the {@link OffsetLinkBuilder} information
* @param resources a list of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, of which a portion or all will be added to the bundle based on the paging values
* @param transactionTime date for the bundle
* @return Returns a {@link Bundle} of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or
* {@link Patient}s, which may contain multiple matching resources, or may also be empty.
*/
public static Bundle createBundle(OffsetLinkBuilder paging, List<IBaseResource> resources, Instant transactionTime) {
Bundle bundle = new Bundle();
if (paging.isPagingRequested()) {
/*
* FIXME: Due to a bug in HAPI-FHIR described here
* https://github.com/jamesagnew/hapi-fhir/issues/1074 paging for count=0 is not working
* correctly.
*/
int endIndex = Math.min(paging.getStartIndex() + paging.getPageSize(), resources.size());
List<IBaseResource> resourcesSubList = resources.subList(paging.getStartIndex(), endIndex);
bundle = TransformerUtilsV2.addResourcesToBundle(bundle, resourcesSubList);
paging.setTotal(resources.size()).addLinks(bundle);
} else {
bundle = TransformerUtilsV2.addResourcesToBundle(bundle, resources);
}
/*
* Dev Note: the Bundle's lastUpdated timestamp is the known last update time for the whole
* database. Because the filterManager's tracking of this timestamp is lazily updated for
* performance reason, the resources of the bundle may be after the filter manager's version of
* the timestamp.
*/
Instant maxBundleDate = resources.stream().map(r -> r.getMeta().getLastUpdated().toInstant()).filter(Objects::nonNull).max(Instant::compareTo).orElse(transactionTime);
bundle.getMeta().setLastUpdated(transactionTime.isAfter(maxBundleDate) ? Date.from(transactionTime) : Date.from(maxBundleDate));
bundle.setTotal(resources.size());
return bundle;
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method createBundle.
/**
* Create a bundle from the entire search result
*
* @param resources a list of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, all of which will be added to the bundle
* @param paging contains the {@link LinkBuilder} information to add to the bundle
* @param transactionTime date for the bundle
* @return Returns a {@link Bundle} of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or
* {@link Patient}s, which may contain multiple matching resources, or may also be empty.
*/
public static Bundle createBundle(List<IBaseResource> resources, LinkBuilder paging, Instant transactionTime) {
Bundle bundle = new Bundle();
TransformerUtilsV2.addResourcesToBundle(bundle, resources);
paging.addLinks(bundle);
bundle.setTotalElement(paging.isPagingRequested() ? new UnsignedIntType() : new UnsignedIntType(resources.size()));
/*
* Dev Note: the Bundle's lastUpdated timestamp is the known last update time for the whole
* database. Because the filterManager's tracking of this timestamp is lazily updated for
* performance reason, the resources of the bundle may be after the filter manager's version of
* the timestamp.
*/
Instant maxBundleDate = resources.stream().map(r -> r.getMeta().getLastUpdated().toInstant()).filter(Objects::nonNull).max(Instant::compareTo).orElse(transactionTime);
bundle.getMeta().setLastUpdated(transactionTime.isAfter(maxBundleDate) ? Date.from(transactionTime) : Date.from(maxBundleDate));
return bundle;
}
Aggregations