use of org.hl7.fhir.r4.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class PatientLinkBuilderTest method emptyPageTest.
@Test
public void emptyPageTest() {
PatientLinkBuilder paging = new PatientLinkBuilder(TEST_CONTRACT_URL + "&_count=10");
assertTrue(paging.isPagingRequested());
assertTrue(paging.isFirstPage());
assertEquals(10, paging.getPageSize());
Bundle bundle = new Bundle();
assertTrue(bundle.getLink().isEmpty());
paging.addLinks(bundle);
assertNotNull(bundle.getLink(Constants.LINK_SELF));
assertNotNull(bundle.getLink(Constants.LINK_FIRST));
}
use of org.hl7.fhir.r4.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForMissingPatientByHicnHash.
/**
* 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 not exist in the DB.
*/
@Test
public void searchForMissingPatientByHicnHash() {
IGenericClient fhirClient = createFhirClient();
// No data is loaded, so this should return 0 matches.
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_HICN_HASH, "1234")).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(0, searchResults.getTotal());
}
use of org.hl7.fhir.r4.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientWithNoHistory.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.PatientResourceProvider#searchByIdentifier(ca.uhn.fhir.rest.param.TokenParam)}
* works as expected for HICNs associated with {@link Beneficiary}s that have <strong>no</strong>
* {@link BeneficiaryHistory} records.
*/
@Test
public void searchForExistingPatientWithNoHistory() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
IGenericClient fhirClient = createFhirClient();
loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).forEach(h -> {
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_HICN_HASH, h.getHicn())).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(1, searchResults.getTotal());
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
assertEquals(h.getBeneficiaryId(), patientFromSearchResult.getIdElement().getIdPart());
});
}
use of org.hl7.fhir.r4.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForMissingPatientByMbiHash.
/**
* 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 not exist in the DB.
*/
@Test
public void searchForMissingPatientByMbiHash() {
IGenericClient fhirClient = createFhirClient();
// No data is loaded, so this should return 0 matches.
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH, "1234")).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(0, searchResults.getTotal());
}
use of org.hl7.fhir.r4.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForPatientByLogicalIdWithPaging.
/**
* 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, with paging.
*/
@Test
public void searchForPatientByLogicalIdWithPaging() {
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())).count(1).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(1, searchResults.getTotal());
/*
* Verify that only the first and last paging links exist, since there should
* only be one page.
*/
assertNotNull(searchResults.getLink(Constants.LINK_FIRST));
assertNull(searchResults.getLink(Constants.LINK_NEXT));
assertNull(searchResults.getLink(Constants.LINK_PREVIOUS));
assertNotNull(searchResults.getLink(Constants.LINK_LAST));
}
Aggregations