use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForSamhsaEobsWithExcludeSamhsaTrue.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.R4ExplanationOfBenefitResourceProvider#findByPatient} with
* <code>excludeSAMHSA=true</code> properly filters out SAMHSA-related claims.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForSamhsaEobsWithExcludeSamhsaTrue() throws FHIRException {
Beneficiary beneficiary = loadSampleAWithSamhsa();
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtilsV2.buildPatientId(beneficiary.getBeneficiaryId()))).and(new StringClientParam(EXCLUDE_SAMHSA_PARAM).matches().value("true")).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
for (ClaimTypeV2 claimType : ClaimTypeV2.values()) {
/*
* SAMHSA fields are present on all claim types except for PDE so we should not
* get any claims back in the results except for PDE.
*/
if (claimType == ClaimTypeV2.PDE) {
assertEquals(1, filterToClaimType(searchResults, claimType).size());
} else {
assertEquals(0, filterToClaimType(searchResults, claimType).size());
}
}
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatientAndType.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#findByPatient(ca.uhn.fhir.rest.param.ReferenceParam)}
* works as expected for a {@link Patient} that does exist in the DB, with filtering by claim
* type.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsByExistingPatientAndType() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtilsV2.buildPatientId(beneficiary))).where(new TokenClientParam("type").exactly().code(ClaimTypeV2.PDE.name())).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 PartDEvent)).filter(r -> !(r instanceof BeneficiaryHistory)).count(), searchResults.getTotal());
PartDEvent partDEvent = loadedRecords.stream().filter(r -> r instanceof PartDEvent).map(r -> (PartDEvent) r).findFirst().get();
// Compare result to transformed EOB
assertEobEquals(PartDEventTransformerV2.transform(PipelineTestUtils.get().getPipelineApplicationState().getMetrics(), partDEvent, Optional.of(false)), filterToClaimType(searchResults, ClaimTypeV2.PDE).get(0));
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatient.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#findByPatient} works
* as expected for a {@link Patient} that does exist in the DB.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsByExistingPatient() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtilsV2.buildPatientId(beneficiary))).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.
*/
assertEachEob(searchResults, loadedRecords);
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method testLastUpdatedUrls.
/**
* Test the set of lastUpdated values
*
* @param fhirClient to use
* @param id the bene id to use
* @param urls is a list of lastUpdate values to test to find
* @param expectedValue number of matches
*/
private void testLastUpdatedUrls(IGenericClient fhirClient, String id, List<String> urls, int expectedValue) {
// Search for each lastUpdated value
for (String lastUpdatedValue : urls) {
Bundle searchResults = fetchWithLastUpdated(fhirClient, id, lastUpdatedValue);
assertEquals(expectedValue, searchResults.getTotal(), String.format("Expected %s to filter resources correctly", lastUpdatedValue));
}
}
use of org.hl7.fhir.utilities.graphql.Value in project beneficiary-fhir-data by CMSgov.
the class SamhsaMatcherR4FromClaimTransformerV2Test method verifySamhsaMatcherForDiagnosisIcd.
/**
* 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 verifySamhsaMatcherForDiagnosisIcd(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
// Set diagnosis
for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
ArrayList<Coding> codingList = new ArrayList<>();
codingList.add(new Coding().setSystem(system).setCode(code));
codeableConcept.setCoding(codingList);
diagnosisComponent.setPackageCode(null);
}
// Set procedure to empty so we dont check it for matches
for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
ArrayList<Coding> codingList = new ArrayList<>();
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));
}
Aggregations