use of gov.cms.bfd.server.war.commons.RequestHeaders in project beneficiary-fhir-data by CMSgov.
the class EndpointJsonResponseComparatorV2IT method eobReadCarrierWithTaxNumbers.
/**
* @return the results of the {@link
* ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.dstu3.model.IdType)} operation for
* Carrier claims, with the {@link
* ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS} set to <code>true
* </code>
*/
public static String eobReadCarrierWithTaxNumbers() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = createFhirClientAndSetEncoding();
RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(CommonHeaders.HEADER_NAME_INCLUDE_TAX_NUMBERS, "true");
ExtraParamsInterceptor extraParamsInterceptor = new ExtraParamsInterceptor();
extraParamsInterceptor.setHeaders(requestHeader);
fhirClient.registerInterceptor(extraParamsInterceptor);
JsonInterceptor jsonInterceptor = createAndRegisterJsonInterceptor(fhirClient);
CarrierClaim carrClaim = loadedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.CARRIER, carrClaim.getClaimId())).execute();
return jsonInterceptor.getResponse();
}
use of gov.cms.bfd.server.war.commons.RequestHeaders in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerTest method transformBeneficiaryWithAllOptionalsEmpty.
/**
* 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()}.
*/
@Test
public void transformBeneficiaryWithAllOptionalsEmpty() {
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 = getRHwithIncldIdntityHdr("");
Patient patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
}
use of gov.cms.bfd.server.war.commons.RequestHeaders in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerTest method transformSampleARecordWithoutLastUpdated.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.BeneficiaryTransformer#transform(Beneficiary)} works as
* expected when run against the {@link StaticRifResource#SAMPLE_A_BENES} {@link Beneficiary} with
* a lastUpdated field not set.
*/
@Test
public void transformSampleARecordWithoutLastUpdated() {
Beneficiary beneficiary = loadSampleABeneficiary();
beneficiary.setLastUpdated(Optional.empty());
RequestHeaders requestHeader = getRHwithIncldIdntityHdr("");
Patient patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
}
use of gov.cms.bfd.server.war.commons.RequestHeaders in project beneficiary-fhir-data by CMSgov.
the class R4PatientResourceProviderIT method assertExistingPatientIncludeIdentifiersExpected.
/**
* Asserts that {@link
* gov.cms.bfd.server.war.r4.providers.R4PatientResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* contains expected/present identifiers for a {@link Patient}.
*
* @param includeIdentifiersValue header value
* @param expectingMbi true if expecting a MBI
* @param includeAddressValues header value
*/
public void assertExistingPatientIncludeIdentifiersExpected(boolean expectingMbi, RequestHeaders requestHeader) {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Patient expected = BeneficiaryTransformerV2.transform(PipelineTestUtils.get().getPipelineApplicationState().getMetrics(), beneficiary, requestHeader);
IGenericClient fhirClient = createFhirClient(requestHeader);
Patient patient = fhirClient.read().resource(Patient.class).withId(beneficiary.getBeneficiaryId()).execute();
// Because of how transform doesn't go through R4PatientResourceProvider, `expected` won't have
// the historical MBI data.
// Also, SAMPLE_A does not have mbi history (it used to); however, what used to be denoted as
// historical
// is not provided as the 'current' MBI identifier (no historical).
comparePatient(expected, patient);
/*
* Ensure the unhashed values for MBI are present.
*/
Boolean mbiUnhashedPresent = false;
Iterator<Identifier> identifiers = patient.getIdentifier().iterator();
while (identifiers.hasNext()) {
Identifier identifier = identifiers.next();
if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_BENE_ID)) {
mbiUnhashedPresent = true;
}
}
// Unhashed MBI should always be present in V2
assertTrue(mbiUnhashedPresent);
}
use of gov.cms.bfd.server.war.commons.RequestHeaders in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProvider method searchByCoverageContractAndYearMonth.
@Trace
private Bundle searchByCoverageContractAndYearMonth(// of relational search is more common.
TokenParam coverageId, LocalDate yearMonth, RequestDetails requestDetails) {
checkCoverageId(coverageId);
RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(requestDetails);
// requested.
if (!requestHeader.isMBIinIncludeIdentifiers() || requestHeader.isHICNinIncludeIdentifiers()) {
throw new InvalidRequestException(String.format("This endpoint requires the '%s: mbi' header.", CommonHeaders.HEADER_NAME_INCLUDE_IDENTIFIERS));
}
PatientLinkBuilder paging = new PatientLinkBuilder(requestDetails.getCompleteUrl());
Operation operation = new Operation(Operation.Endpoint.V1_PATIENT);
operation.setOption("by", "coverageContractForYearMonth");
requestHeader.getNVPairs().forEach((n, v) -> operation.setOption(n, v.toString()));
operation.publishOperationName();
List<Beneficiary> matchingBeneficiaries = fetchBeneficiariesByContractAndYearMonth(coverageId, yearMonth, paging);
boolean hasAnotherPage = matchingBeneficiaries.size() > paging.getPageSize();
if (hasAnotherPage) {
matchingBeneficiaries = matchingBeneficiaries.subList(0, paging.getPageSize());
paging = new PatientLinkBuilder(paging, hasAnotherPage);
}
List<IBaseResource> patients = matchingBeneficiaries.stream().map(b -> BeneficiaryTransformer.transform(metricRegistry, b, requestHeader)).collect(Collectors.toList());
Bundle bundle = TransformerUtils.createBundle(patients, paging, loadedFilterManager.getTransactionTime());
TransformerUtils.workAroundHAPIIssue1585(requestDetails);
return bundle;
}
Aggregations