knowledge_store
What has been learned about an EHR server, kept as findings.
Attributes:
FindingKind: What a finding is about. type_unsupported: the server does
not serve the resource type. param_refused: the server refused a
search param with a 4xx. code_refused: the server refused a code
search value with a 400 naming it. param_inferred: a search param
was blamed for a timeout or a 5xx the server never confirmed was about
the param; rechecked when due. search_unresponsive: a search kept
timing out and is given up on until its recheck is due.
acuity_in_documents: the server's visual acuity is in patients'
documents, not in Observations, so the acuity code searches are
skipped; kept under Observation with an empty subject, and lapses
like a confirmed finding.
Classes
Finding
class Finding( kind: FindingKind, resource_type: str, subject: str = '', detail: str | None = None, wait_seconds: float | None = None, due_at: float | None = None,):One thing learned about an EHR server.
Arguments
kind: What the finding is about.resource_type: The resource type it concerns.subject: The param name, thecodesearch value as sent, the search's filters as canonical JSON, or empty for a whole resource type.detail: A short reason, such as an HTTP status.wait_seconds: For a finding that is rechecked, how long the current wait is.due_at: When the finding is next tested or, for a confirmed finding, lapses, in seconds since the epoch (UTC).
Variables
-
detail : str | None
-
due_at : float | None
-
kind : Literal['type_unsupported', 'param_refused', 'code_refused', 'param_inferred', 'search_unresponsive', 'acuity_in_documents']
-
resource_type : str
-
subject : str
-
wait_seconds : float | None
InMemoryKnowledgeStore
class InMemoryKnowledgeStore():A KnowledgeStore that lives as long as the object.
Methods
findings
def findings( self, kind: FindingKind | None = None,) ‑> list[Finding]:Every finding, or every finding of one kind.
Arguments
kind: The kind to list, orNonefor all.
get
def get( self, kind: FindingKind, resource_type: str, subject: str = '',) ‑> Finding | None:The finding under a key, or None.
Arguments
kind: What the finding is about.resource_type: The resource type it concerns.subject: Its subject (seeFinding.subject).
put
def put(self, finding: Finding) ‑> None:Store a finding, replacing any under the same key.
Arguments
finding: The finding.
remove
def remove(self, kind: FindingKind, resource_type: str, subject: str = '') ‑> None:Forget the finding under a key, if there is one.
Arguments
kind: What the finding is about.resource_type: The resource type it concerns.subject: Its subject (seeFinding.subject).
remove_if_unchanged
def remove_if_unchanged(self, finding: Finding) ‑> None:Forget a finding, unless another has been stored under its key since.
Arguments
finding: The finding as it was read.
KnowledgeStore
class KnowledgeStore(*args, **kwargs):Holds findings about one EHR server, one per (kind, resource_type, subject).
Ancestors
Methods
findings
def findings( self, kind: FindingKind | None = None,) ‑> list[Finding]:Every finding, or every finding of one kind.
Arguments
kind: The kind to list, orNonefor all.
get
def get( self, kind: FindingKind, resource_type: str, subject: str = '',) ‑> Finding | None:The finding under a key, or None.
Arguments
kind: What the finding is about.resource_type: The resource type it concerns.subject: Its subject (seeFinding.subject).
put
def put(self, finding: Finding) ‑> None:Store a finding, replacing any under the same key.
Arguments
finding: The finding.
remove
def remove(self, kind: FindingKind, resource_type: str, subject: str = '') ‑> None:Forget the finding under a key, if there is one.
Arguments
kind: What the finding is about.resource_type: The resource type it concerns.subject: Its subject (seeFinding.subject).
remove_if_unchanged
def remove_if_unchanged(self, finding: Finding) ‑> None:Forget a finding, unless another has been stored under its key since.
For a finding that has lapsed: a newer finding under the same key, such as one another process stored, is kept.
Arguments
finding: The finding as it was read.