use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientByLogicalId.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.PatientResourceProvider#searchByLogicalId(ca.uhn.fhir.rest.param.TokenParam)}
* works as expected for a {@link Patient} that does exist in the DB.
*/
@Test
public void searchForExistingPatientByLogicalId() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = createFhirClient();
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.RES_ID.exactly().systemAndIdentifier(null, beneficiary.getBeneficiaryId())).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
/*
* Verify that no paging links exist within the bundle.
*/
assertNull(searchResults.getLink(Constants.LINK_FIRST));
assertNull(searchResults.getLink(Constants.LINK_NEXT));
assertNull(searchResults.getLink(Constants.LINK_PREVIOUS));
assertNull(searchResults.getLink(Constants.LINK_LAST));
assertEquals(1, searchResults.getTotal());
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
BeneficiaryTransformerTest.assertMatches(beneficiary, patientFromSearchResult, getRHwithIncldAddrFldHdr("false"));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientByMbiHashIncludeIdentifiersFalse.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.PatientResourceProvider#searchByIdentifier(ca.uhn.fhir.rest.param.TokenParam)}
* works as expected for a {@link Patient} that does exist in the DB, including identifiers to
* return the unhashed HICN and MBI.
*/
@Test
public void searchForExistingPatientByMbiHashIncludeIdentifiersFalse() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = createFhirClient("false", "true");
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH, beneficiary.getMbiHash().get())).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
/*
* Ensure the unhashed values for HICN and MBI are *not* present.
*/
Boolean hicnUnhashedPresent = false;
Boolean mbiUnhashedPresent = false;
Iterator<Identifier> identifiers = patientFromSearchResult.getIdentifier().iterator();
while (identifiers.hasNext()) {
Identifier identifier = identifiers.next();
if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_BENE_HICN_UNHASHED))
hicnUnhashedPresent = true;
if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED))
mbiUnhashedPresent = true;
}
assertFalse(hicnUnhashedPresent);
assertFalse(mbiUnhashedPresent);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientByHicnHash.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.PatientResourceProvider#searchByIdentifier(ca.uhn.fhir.rest.param.TokenParam)}
* works as expected for a {@link Patient} that does exist in the DB.
*/
@Test
public void searchForExistingPatientByHicnHash() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = createFhirClient();
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_HICN_HASH, beneficiary.getHicn())).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
/*
* Verify that no paging links exist within the bundle.
*/
assertNull(searchResults.getLink(Constants.LINK_FIRST));
assertNull(searchResults.getLink(Constants.LINK_NEXT));
assertNull(searchResults.getLink(Constants.LINK_PREVIOUS));
assertNull(searchResults.getLink(Constants.LINK_LAST));
assertEquals(1, searchResults.getTotal());
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
BeneficiaryTransformerTest.assertMatches(beneficiary, patientFromSearchResult, getRHwithIncldAddrFldHdr("false"));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchByPartDContractWithoutYear.
/**
* Verifies that {@link
* PatientResourceProvider#searchByCoverageContract(ca.uhn.fhir.rest.param.TokenParam,
* ca.uhn.fhir.rest.param.TokenParam, String, ca.uhn.fhir.rest.api.server.RequestDetails)} works
* as expected, when no year is specified (hopefully causing it to substitute the current year).
*/
@Test
public void searchByPartDContractWithoutYear() {
/*
* TODO Once AB2D has switched to always specifying the year, this needs to become an invalid
* request and this test will need to be updated to reflect that, then.
*/
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
IGenericClient fhirClient = createFhirClientWithIncludeIdentifiersMbi();
// First, adjust the bene's reference year in the DB.
ServerTestUtils.get().doTransaction((entityManager) -> {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BeneficiaryMonthly> select = builder.createQuery(BeneficiaryMonthly.class);
select.from(BeneficiaryMonthly.class);
List<BeneficiaryMonthly> beneMonthlys = entityManager.createQuery(select).getResultList();
for (BeneficiaryMonthly beneMonthly : beneMonthlys) {
LocalDate yearMonth = beneMonthly.getYearMonth();
CriteriaUpdate<BeneficiaryMonthly> update = builder.createCriteriaUpdate(BeneficiaryMonthly.class);
Root<BeneficiaryMonthly> beneMonthlyRoot = update.from(BeneficiaryMonthly.class);
update.set(BeneficiaryMonthly_.yearMonth, LocalDate.of(Year.now().getValue(), yearMonth.getMonthValue(), yearMonth.getDayOfMonth()));
update.where(builder.equal(beneMonthlyRoot.get(BeneficiaryMonthly_.parentBeneficiary), beneMonthly.getParentBeneficiary()), builder.equal(beneMonthlyRoot.get(BeneficiaryMonthly_.yearMonth), yearMonth));
entityManager.createQuery(update).executeUpdate();
}
});
// Should return a single match
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(new TokenClientParam("_has:Coverage.extension").exactly().systemAndIdentifier(CCWUtils.calculateVariableReferenceUrl(CcwCodebookVariable.PTDCNTRCT01), "S4607")).returnBundle(Bundle.class).execute();
// Verify that it found the expected bene.
assertNotNull(searchResults);
assertEquals(1, searchResults.getEntry().size());
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
Beneficiary expectedBene = (Beneficiary) loadedRecords.get(0);
assertEquals(expectedBene.getBeneficiaryId(), patientFromSearchResult.getIdElement().getIdPart());
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientByLogicalIdIncludeIdentifiersTrue.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.PatientResourceProvider#searchByLogicalId(ca.uhn.fhir.rest.param.TokenParam)}
* works as expected for a {@link Patient} that does exist in the DB, including identifiers to
* return the unhashed HICN and MBI.
*/
@Test
public void searchForExistingPatientByLogicalIdIncludeIdentifiersTrue() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = createFhirClient("true", "true");
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.RES_ID.exactly().systemAndIdentifier(null, beneficiary.getBeneficiaryId())).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
/*
* Ensure the unhashed values for HICN and MBI are present.
*/
Boolean hicnUnhashedPresent = false;
Boolean mbiUnhashedPresent = false;
Iterator<Identifier> identifiers = patientFromSearchResult.getIdentifier().iterator();
while (identifiers.hasNext()) {
Identifier identifier = identifiers.next();
if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_BENE_HICN_UNHASHED))
hicnUnhashedPresent = true;
if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED))
mbiUnhashedPresent = true;
}
assertTrue(hicnUnhashedPresent);
assertTrue(mbiUnhashedPresent);
}
Aggregations