use of org.alfresco.event.sdk.model.v1.model.Resource in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method findOrCreateContainedOrg.
/**
* Looks for an {@link Organization} with the given resource ID in {@link
* ExplanationOfBenefit#getContained()} or adds one if it doesn't exist
*
* @param eob the {@link ExplanationOfBenefit} to modify
* @param id The resource ID
* @return The found or new {@link Organization} resource
*/
static Resource findOrCreateContainedOrg(ExplanationOfBenefit eob, String id) {
Optional<Resource> org = eob.getContained().stream().filter(r -> r.getId() == id).findFirst();
// If it isn't there, add one
if (!org.isPresent()) {
org = Optional.of(new Organization().setId(id));
org.get().getMeta().addProfile(ProfileConstants.C4BB_ORGANIZATION_URL);
eob.getContained().add(org.get());
}
return org.get();
}
use of org.alfresco.event.sdk.model.v1.model.Resource in project beneficiary-fhir-data by CMSgov.
the class AbstractR4ResourceProvider method createBundleFor.
/**
* Creates a Bundle of resources for the given data using the given {@link ResourceTypeV2}.
*
* @param resourceTypes The {@link ResourceTypeV2} data to retrieve.
* @param mbi The mbi to look up associated data for.
* @param isHashed Denotes if the given mbi is hashed.
* @param lastUpdated Date range of desired lastUpdate values to retrieve data for.
* @param serviceDate Date range of the desired service date to retrieve data for.
* @return A Bundle with data found using the provided parameters.
*/
@VisibleForTesting
Bundle createBundleFor(Set<ResourceTypeV2<T>> resourceTypes, String mbi, boolean isHashed, boolean excludeSamhsa, DateRangeParam lastUpdated, DateRangeParam serviceDate) {
List<T> resources = new ArrayList<>();
for (ResourceTypeV2<T> type : resourceTypes) {
List<?> entities;
entities = claimDao.findAllByMbiAttribute(type.getEntityClass(), type.getEntityMbiRecordAttribute(), mbi, isHashed, lastUpdated, serviceDate, type.getEntityEndDateAttribute());
resources.addAll(entities.stream().filter(e -> !excludeSamhsa || hasNoSamhsaData(metricRegistry, e)).map(e -> type.getTransformer().transform(metricRegistry, e)).collect(Collectors.toList()));
}
Bundle bundle = new Bundle();
resources.forEach(c -> {
Bundle.BundleEntryComponent entry = bundle.addEntry();
entry.setResource((Resource) c);
});
return bundle;
}
use of org.alfresco.event.sdk.model.v1.model.Resource in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method addProviderSlice.
/**
* Looks up or adds a contained {@link Organization} object to the current {@link
* ExplanationOfBenefit}. This is used to store Identifier slices related to the Provider
* organization.
*
* @param eob The {@link ExplanationOfBenefit} to provider org details to
* @param type The {@link C4BBIdentifierType} of the identifier slice
* @param value The value of the identifier. If empty, this call is a no-op
*/
static void addProviderSlice(ExplanationOfBenefit eob, C4BBOrganizationIdentifierType type, Optional<String> value, Optional<Instant> lastUpdated) {
if (value.isPresent()) {
Resource providerResource = findOrCreateContainedOrg(eob, PROVIDER_ORG_ID);
// We are assuming that the contained resource with an id of "provider-org" is an Organization
if (!Organization.class.isInstance(providerResource)) {
throw new BadCodeMonkeyException();
}
Organization provider = (Organization) providerResource;
// Add the new Identifier to the Organization
Identifier id = new Identifier().setType(createCodeableConcept(type.getSystem(), type.toCode())).setValue(value.get());
// Certain types have specific systems
if (type == C4BBOrganizationIdentifierType.NPI) {
id.setSystem(TransformerConstants.CODING_NPI_US);
}
provider.addIdentifier(id);
// Set active to value of true
provider.setActive(true);
setLastUpdated(provider, lastUpdated);
// This gets updated for every call, but always set to the same value
eob.getProvider().setReference(PROVIDER_ORG_REFERENCE);
}
}
use of org.alfresco.event.sdk.model.v1.model.Resource in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method findOrCreateContainedObservation.
static Observation findOrCreateContainedObservation(ExplanationOfBenefit eob, String id) {
Optional<Resource> observation = eob.getContained().stream().filter(r -> r.getId() == id).findFirst();
// If it isn't there, add one
if (!observation.isPresent()) {
observation = Optional.of(new Observation().setId(id));
eob.getContained().add(observation.get());
}
// At this point `observation.get()` will always return
if (!Observation.class.isInstance(observation.get())) {
throw new BadCodeMonkeyException();
}
return (Observation) observation.get();
}
use of org.alfresco.event.sdk.model.v1.model.Resource in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForExistingInpatientClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for an {@link InpatientClaim}-derived {@link ExplanationOfBenefit} that does
* exist in the DB.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void readEobForExistingInpatientClaim() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
InpatientClaim claim = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
ExplanationOfBenefit eob = fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.INPATIENT, claim.getClaimId())).execute();
assertNotNull(eob);
// Compare result to transformed EOB
compareEob(ClaimTypeV2.INPATIENT, eob, loadedRecords);
}
Aggregations