Module dbops.insurance_providers
selects and updates for records in common_db.shared.insurance_providers
Functions
def select_insurance_provider(insurance_entry: dict[str, Any]) ‑> InsuranceRecord
-
given an extracted patient_info->'insurance' entry, find matches from common_db.shared.insurance_providers.
Args
insurance_entry
:dict[str, Any]
- a patient_info->'insurance' entry from an extracted case
Returns
InsuranceRecord
- the matching record from insurance_providers (no result is returned if more than one match is discovered.)
def update_insurance_provider(ins_record: InsuranceRecord) ‑> bool
-
insert provider info into facility table if not already present. if provider with supplied npi exists, update lastReferenceDate
Classes
class InsuranceData (company: str = '', plan: str = '', phone: str = '', address: dict[str, str] = <factory>, insuranceID: str = '')
-
Represents the json content contained in the insurance_data column
Attributes
company
:str
- insurance company i.e. a "payor"
plan
:str
- insurance plan
phone
:str
- phone number for payor/plan above
address
:dict[str, str]
- keys street1, street2, city, state, zip
insuranceID
:str
- id for this row (if returned from DB)
Class variables
var address : dict[str, str]
var company : str
var insuranceID : str
var phone : str
var plan : str
Static methods
def from_entry(entry: dict[str, Any]) ‑> InsuranceData
-
create an 'as extracted' InsuranceData object from an entry in patient_info->'insurance' on an extracted case
Args
entry
:dict[str, Any]
- a patient_info->'insurance' entry
Returns
InsuranceData
- an InsuranceData instance representing the plan in the extracted entry
Methods
def fuzzy_name(self) ‑> str
-
returns company, plan, the first numerical value in address.street1 or all of street1 if no number is found, and the zip as extracted and joined with a space as separator.
class InsuranceRecord (insurance_id: str = '', insurance_data: InsuranceData = <factory>)
-
representation of a single row from common_db.shared.insurance_providers
Attributes
insurance_id
:str
- internal numerical identifier for this insurance
insurance_data
:InsuranceData
- content of the insurance_data column
Class variables
var insurance_data : InsuranceData
var insurance_id : str
Static methods
def from_entry(entry: dict[str, Any]) ‑> InsuranceRecord
-
given an entry in an extracted case dictionary, return an InsuranceRecord instance
Args
entry
:dict[str, Any]
- entry in patient_info->'insurance' of an extracted case
Returns
InsuranceRecord
- representative InsuranceRecord instance
def from_query(result_tuple: tuple[int, dict[str, Any]]) ‑> InsuranceRecord
-
given a result tuple from select_insurance_providers, return an InsuranceRecord instance
Args
result_tuple
:tuple[str, dict[str, Any], dict[str, list]]
- single row from a query result
Returns
InsuranceRecord
- InsuranceRecord instance
Instance variables
prop conf : float
-
confidence value to assign for vStr values in to_dict() output
prop selected : bool
-
was this record selected from the DB (true) or constructed from an entry
prop updated : bool
-
was the insurance_meta updated for this record
Methods
def to_dict(self) ‑> dict[str, str | utilities.v_str.vStr | dict[str, utilities.v_str.vStr]]
-
returns self in dict form with vstr values having confidence 1.0 if match was found in shared.insurance_providers. otherwise, vstrs in output are assigned confidence 0.0.