use of ca.uhn.fhir.rest.param.TokenAndListParam in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProvider method parseTypeParam.
/**
* @param type a {@link TokenAndListParam} for the "type" field in a search
* @return The {@link ClaimType}s to be searched, as computed from the specified "type" {@link
* TokenAndListParam} search param
*/
static Set<ClaimType> parseTypeParam(TokenAndListParam type) {
if (type == null)
type = new TokenAndListParam().addAnd(new TokenOrListParam().add(TransformerConstants.CODING_SYSTEM_BBAPI_EOB_TYPE, null));
/*
* This logic kinda' stinks, but HAPI forces us to handle some odd query
* formulations, e.g. (in postfix notation):
* "and(or(claimType==FOO, claimType==BAR), or(claimType==FOO))".
*/
Set<ClaimType> claimTypes = new HashSet<ClaimType>(Arrays.asList(ClaimType.values()));
for (TokenOrListParam typeToken : type.getValuesAsQueryTokens()) {
/*
* Each OR entry is additive: we start with an empty set and add every (valid)
* ClaimType that's encountered.
*/
Set<ClaimType> claimTypesInner = new HashSet<ClaimType>();
for (TokenParam codingToken : typeToken.getValuesAsQueryTokens()) {
if (codingToken.getModifier() != null)
throw new IllegalArgumentException();
/*
* Per the FHIR spec (https://www.hl7.org/fhir/search.html), there are lots of
* edge cases here: we could have null or wildcard or exact system, we can have
* an exact or wildcard code. All of those need to be handled carefully -- see
* the spec for details.
*/
Optional<ClaimType> claimType = codingToken.getValue() != null ? ClaimType.parse(codingToken.getValue().toLowerCase()) : Optional.empty();
if (codingToken.getSystem() != null && codingToken.getSystem().equals(TransformerConstants.CODING_SYSTEM_BBAPI_EOB_TYPE) && !claimType.isPresent()) {
claimTypesInner.addAll(Arrays.asList(ClaimType.values()));
} else if (codingToken.getSystem() == null || codingToken.getSystem().equals(TransformerConstants.CODING_SYSTEM_BBAPI_EOB_TYPE)) {
if (claimType.isPresent())
claimTypesInner.add(claimType.get());
}
}
/*
* All multiple AND parameters will do is reduce the number of possible matches.
*/
claimTypes.retainAll(claimTypesInner);
}
return claimTypes;
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForEobsIncludeTaxNumbersHandling.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient(ReferenceParam,
* TokenAndListParam, String, String, DateRangeParam, DateRangeParam, RequestDetails)} handles the
* {@link ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS} header properly.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsIncludeTaxNumbersHandling() 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();
CarrierClaim carrierClaim = loadedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
DMEClaim dmeClaim = loadedRecords.stream().filter(r -> r instanceof DMEClaim).map(r -> (DMEClaim) r).findFirst().get();
Bundle searchResults;
ExplanationOfBenefit carrierEob;
ExplanationOfBenefit dmeEob;
// Run the search without requesting tax numbers.
searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
// Verify that tax numbers aren't present for carrier claims.
carrierEob = filterToClaimType(searchResults, ClaimType.CARRIER).get(0);
assertNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(carrierClaim.getLines().get(0).getProviderTaxNumber(), carrierEob.getCareTeam()));
// Verify that tax numbers aren't present for DME claims.
dmeEob = filterToClaimType(searchResults, ClaimType.DME).get(0);
assertNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(dmeClaim.getLines().get(0).getProviderTaxNumber(), dmeEob.getCareTeam()));
RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(CommonHeaders.HEADER_NAME_INCLUDE_TAX_NUMBERS, "true");
fhirClient = ServerTestUtils.get().createFhirClientWithHeaders(requestHeader);
searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
// Verify that tax numbers are present for carrier claims.
carrierEob = filterToClaimType(searchResults, ClaimType.CARRIER).get(0);
assertNotNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(carrierClaim.getLines().get(0).getProviderTaxNumber(), carrierEob.getCareTeam()));
// Verify that tax numbers are present for DME claims.
dmeEob = filterToClaimType(searchResults, ClaimType.DME).get(0);
assertNotNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(dmeClaim.getLines().get(0).getProviderTaxNumber(), dmeEob.getCareTeam()));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnEmptyListByMismatchingUuidAndLastUpdated.
@Test
public void searchForObsConditions_shouldReturnEmptyListByMismatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(EXISTING_OBS_CONDITION_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_VOIDED).setLowerBound(DATE_VOIDED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnMultipleConditionsByCodeListAndNoSystem.
@Test
public void searchForObsConditions_shouldReturnMultipleConditionsByCodeListAndNoSystem() {
TokenAndListParam listParam = new TokenAndListParam();
listParam.addValue(new TokenOrListParam().add(new TokenParam(CONCEPT_ID_1)).add(new TokenParam(CONCEPT_ID_2)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, listParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList.size(), equalTo(2));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMatchingUuidAndLastUpdated.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(EXISTING_OBS_CONDITION_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CREATED).setLowerBound(DATE_CREATED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(EXISTING_OBS_CONDITION_UUID));
}
Aggregations