use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientWithNoHistoryIncludeIdentifiersTrue.
/**
* 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 searchForExistingPatientWithNoHistoryIncludeIdentifiersTrue() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
IGenericClient fhirClient = createFhirClient("true", "true");
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.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientByMbiHashIncludeIdentifiersTrue.
/**
* 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 searchForExistingPatientByMbiHashIncludeIdentifiersTrue() {
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.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 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);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class PatientResourceProviderIT method searchForExistingPatientByHicnHashIncludeIdentifiersTrue.
/**
* 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 searchForExistingPatientByHicnHashIncludeIdentifiersTrue() {
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.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_HICN_HASH, beneficiary.getHicn())).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);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerTest method transformBeneficiaryWithAllOptionalsEmpty.
/**
* Verifies that {@link gov.cms.bfd.server.war.stu3.providers.BeneficiaryTransformer} works
* correctly when passed a {@link Beneficiary} where all {@link Optional} fields are set to {@link
* Optional#empty()}.
*/
@Test
public void transformBeneficiaryWithAllOptionalsEmpty() {
List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
Beneficiary beneficiary = parsedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
TransformerTestUtils.setAllOptionalsToEmpty(beneficiary);
RequestHeaders requestHeader = getRHwithIncldIdntityHdr("");
Patient patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerTest method transformSampleARecordWithoutLastUpdated.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.BeneficiaryTransformer#transform(Beneficiary)} works as
* expected when run against the {@link StaticRifResource#SAMPLE_A_BENES} {@link Beneficiary} with
* a lastUpdated field not set.
*/
@Test
public void transformSampleARecordWithoutLastUpdated() {
Beneficiary beneficiary = loadSampleABeneficiary();
beneficiary.setLastUpdated(Optional.empty());
RequestHeaders requestHeader = getRHwithIncldIdntityHdr("");
Patient patient = BeneficiaryTransformer.transform(new MetricRegistry(), beneficiary, requestHeader);
assertMatches(beneficiary, patient, requestHeader);
}
Aggregations