use of org.hl7.gravity.refimpl.sdohexchange.fhir.factory.ConsentPrepareBundleFactory in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConsentService method retrieveOrganization.
private Reference retrieveOrganization(UserDto userDto) {
Bundle bundle = new ConsentPrepareBundleFactory(userDto.getId()).createPrepareBundle();
Bundle consentResponseBundle = ehrClient.transaction().withBundle(bundle).execute();
Bundle consentBundle = FhirUtil.getFirstFromBundle(consentResponseBundle, Bundle.class);
PractitionerRole practitionerRole = FhirUtil.getFirstFromBundle(consentBundle, PractitionerRole.class);
Reference organization = practitionerRole.getOrganization();
if (organization == null) {
throw new ConsentCreateException("No Organization found for Consent creation.");
}
return organization;
}
Aggregations