builder
The one place an EHR backend is chosen: building an EHR config's service.
Backends, and bitfount.federated.types that names their configs, are imported
inside the functions that need them. So loading service/ loads no backend
(test_service_modules_load_no_backend), and a backend can import service/
without an import cycle.
Module
Functions
build_ehr_data_service
def build_ehr_data_service( ehr_config: EHRConfig, *, ehr_secrets: RefreshableJWT | None = None, knowledge_store: KnowledgeStore | None = None, bitfount_session: BitfountSession | None = None,) ‑> EHRDataService:Build the service for one EHR connection.
A NextGen config gets NextGenEHRDataService, which authenticates through
SMART on FHIR with bitfount_session and keeps no knowledge store. Any
other config whose provider ends in r4 gets FHIRR4EHRService. Each
ignores the arguments only the other uses.
Arguments
ehr_config: The EHR's config.ehr_secrets: JWT secrets for a FHIR R4 EHR, from the pod's secrets.knowledge_store: Where a FHIR R4 connection keeps its findings about the server (seeknowledge_store_for); in memory when not given.bitfount_session: The Bitfount session a NextGen connection authenticates with.
Raises
ValueError: If no backend serves the config's provider, if a NextGen config comes withoutbitfount_session, or asFHIRR4EHRServiceraises it.
is_fhir_r4_provider
def is_fhir_r4_provider(provider: str | None) ‑> bool:Whether a provider is served by the FHIR R4 backend: it ends in r4.
Arguments
provider: The provider string from the EHR config.
knowledge_store_for
def knowledge_store_for( cache: CacheProtocol | None, ehr_config: EHRConfig,) ‑> KnowledgeStore | None:Where a connection to this EHR keeps its findings, if anywhere.
Only the FHIR R4 backend keeps findings. Its store is the pod cache, keyed
by the server's identity (ehr_server_key), so every process on the pod
talking to the same EHR shares what is learned about it.
Arguments
cache: The pod's background cache, orNonewhere there is none (the CLI, tests).ehr_config: The EHR's config.
Returns
A pod-cache store for a FHIR R4 EHR on a pod; None without a cache,
for NextGen, or for a provider no backend serves (the builder raises
for that). The backend is decided as build_ehr_data_service decides
it.
nextgen_urls
def nextgen_urls(ehr_config: NextGenEHRConfig) ‑> NextGenURLs:A NextGen config's endpoints, defaulting each the config leaves unset.
An unset (or empty) base_url is NextGen's production FHIR URL, and an
unset enterprise_url its production Enterprise URL.
Arguments
ehr_config: The NextGen EHR's config.
unsupported_provider_error
def unsupported_provider_error(provider: str | None) ‑> ValueError:The error for a provider no backend, or not the backend asked, serves.
Arguments
provider: The provider string from the EHR config.
Classes
NextGenURLs
class NextGenURLs(fhir_url: ForwardRef('str'), enterprise_url: ForwardRef('str')):A NextGen EHR's two endpoints, NextGen's own where the config sets none.
Arguments
fhir_url: The NextGen FHIR API's base URL.enterprise_url: The NextGen Enterprise API's base URL.
Variables
enterprise_url : str- Alias for field number 1
fhir_url : str- Alias for field number 0