use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class SamhsaMatcherR4FromClaimTransformerV2Test method verifySamhsaMatcherForProcedureIcd.
/**
* Verify SAMHSA matcher for ICD item with the given system, code and if the expectation is that
* there should be a match for this combination.
*
* @param system the system value
* @param code the code
* @param shouldMatch if the matcher should match on this combination
*/
private void verifySamhsaMatcherForProcedureIcd(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
// Set diagnosis to empty so we dont check it for matches
for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
ArrayList<Coding> codingList = new ArrayList<>();
codeableConcept.setCoding(codingList);
diagnosisComponent.setPackageCode(null);
}
// Set procedure
for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
ArrayList<Coding> codingList = new ArrayList<>();
codingList.add(new Coding().setSystem(system).setCode(code));
codeableConcept.setCoding(codingList);
}
// Set item coding to non-SAMHSA so we dont check it for matches
List<Coding> codings = new ArrayList<>();
Coding coding = new Coding();
coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
coding.setCode(NON_SAMHSA_HCPCS_CODE);
codings.add(coding);
modifiedEob.getItem().get(0).getProductOrService().setCoding(codings);
assertEquals(shouldMatch, samhsaMatcherV2.test(modifiedEob));
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class TransformerTestUtilsV2 method findAdjudicationByCategoryAndAmount.
/**
* Finds an {@link AdjudicationComponent} using a code in the category and value in amount
*
* @param code
* @param amount
* @param components
* @return
*/
static AdjudicationComponent findAdjudicationByCategoryAndAmount(String code, BigDecimal amount, List<AdjudicationComponent> components) {
final BigDecimal amt = amount.setScale(2, RoundingMode.HALF_DOWN);
Optional<AdjudicationComponent> adjudication = components.stream().filter(cmp -> (amt.equals(cmp.getAmount().getValue()))).filter(cmp -> cmp.getCategory().getCoding().stream().filter(c -> code.equals(c.getCode())).count() > 0).findFirst();
assertTrue(adjudication.isPresent());
return adjudication.get();
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForSamhsaEobsWithExcludeSamhsaFalse.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} with <code>
* excludeSAMHSA=false</code> does not filter out SAMHSA-related claims.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForSamhsaEobsWithExcludeSamhsaFalse() throws FHIRException {
Beneficiary beneficiary = loadSampleAWithSamhsa();
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary.getBeneficiaryId()))).and(new StringClientParam("excludeSAMHSA").matches().value("false")).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
for (ClaimType claimType : ClaimType.values()) {
// Without filtering we expect one claim for each claim type.
assertEquals(1, filterToClaimType(searchResults, claimType).size());
}
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForNonSamhsaEobsWithExcludeSamhsaTrue.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} with <code>
* excludeSAMHSA=true</code> properly returns claims that are not SAMHSA-related.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForNonSamhsaEobsWithExcludeSamhsaTrue() throws FHIRException {
// Load the SAMPLE_A resources normally.
Beneficiary beneficiary = loadSampleA();
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary.getBeneficiaryId()))).and(new StringClientParam("excludeSAMHSA").matches().value("true")).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
for (ClaimType claimType : ClaimType.values()) {
// None of the claims are SAMHSA so we expect one record per claim type in the results.
assertEquals(1, filterToClaimType(searchResults, claimType).size(), String.format("Verify claims of type '%s' are present", claimType));
}
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatientWithPageSizeZero.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} works as expected for
* a {@link Patient} that does exist in the DB, with paging on a page size of 0.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsByExistingPatientWithPageSizeZero() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
/*
* FIXME: According the the FHIR spec, paging for _count=0 should not return any
* claim entries in the bundle, but instead just a total for the number of
* entries that match the search criteria. This functionality does no work
* currently (see https://github.com/jamesagnew/hapi-fhir/issues/1074) and so
* for now paging with _count=0 should behave as though paging was not
* requested.
*/
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).count(0).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
/*
* Verify the bundle contains a key for total and that the value matches the
* number of entries in the bundle
*/
assertEquals(loadedRecords.stream().filter(r -> !(r instanceof Beneficiary)).filter(r -> !(r instanceof BeneficiaryHistory)).filter(r -> !(r instanceof MedicareBeneficiaryIdHistory)).count(), searchResults.getTotal());
/*
* Verify that no paging links exist in the bundle.
*/
assertNull(searchResults.getLink(Constants.LINK_NEXT));
assertNull(searchResults.getLink(Constants.LINK_PREVIOUS));
assertNull(searchResults.getLink(Constants.LINK_FIRST));
assertNull(searchResults.getLink(Constants.LINK_LAST));
/*
* Verify that each of the expected claims (one for every claim type) is present
* and looks correct.
*/
CarrierClaim carrierClaim = loadedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
assertEquals(1, filterToClaimType(searchResults, ClaimType.CARRIER).size());
CarrierClaimTransformerTest.assertMatches(carrierClaim, filterToClaimType(searchResults, ClaimType.CARRIER).get(0), Optional.empty());
DMEClaim dmeClaim = loadedRecords.stream().filter(r -> r instanceof DMEClaim).map(r -> (DMEClaim) r).findFirst().get();
DMEClaimTransformerTest.assertMatches(dmeClaim, filterToClaimType(searchResults, ClaimType.DME).get(0), Optional.empty());
HHAClaim hhaClaim = loadedRecords.stream().filter(r -> r instanceof HHAClaim).map(r -> (HHAClaim) r).findFirst().get();
HHAClaimTransformerTest.assertMatches(hhaClaim, filterToClaimType(searchResults, ClaimType.HHA).get(0));
HospiceClaim hospiceClaim = loadedRecords.stream().filter(r -> r instanceof HospiceClaim).map(r -> (HospiceClaim) r).findFirst().get();
HospiceClaimTransformerTest.assertMatches(hospiceClaim, filterToClaimType(searchResults, ClaimType.HOSPICE).get(0));
InpatientClaim inpatientClaim = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
InpatientClaimTransformerTest.assertMatches(inpatientClaim, filterToClaimType(searchResults, ClaimType.INPATIENT).get(0));
OutpatientClaim outpatientClaim = loadedRecords.stream().filter(r -> r instanceof OutpatientClaim).map(r -> (OutpatientClaim) r).findFirst().get();
OutpatientClaimTransformerTest.assertMatches(outpatientClaim, filterToClaimType(searchResults, ClaimType.OUTPATIENT).get(0));
PartDEvent partDEvent = loadedRecords.stream().filter(r -> r instanceof PartDEvent).map(r -> (PartDEvent) r).findFirst().get();
PartDEventTransformerTest.assertMatches(partDEvent, filterToClaimType(searchResults, ClaimType.PDE).get(0));
SNFClaim snfClaim = loadedRecords.stream().filter(r -> r instanceof SNFClaim).map(r -> (SNFClaim) r).findFirst().get();
SNFClaimTransformerTest.assertMatches(snfClaim, filterToClaimType(searchResults, ClaimType.SNF).get(0));
}
Aggregations