Skip to main content

types

EHR types.

Module

Functions

dedupe_dataclass_list

def dedupe_dataclass_list(items: list[_T])> list[~_T]:

Remove duplicate dataclass instances from a list, preserving order.

Uses dataclasses.astuple() to create hashable representations for comparison. The first occurrence of each unique item is kept.

Arguments

  • items: A list of dataclass instances.

Returns A new list with duplicates removed, maintaining original order.

Classes

BodySite

class BodySite(    text: Optional[str] = None,    bodysite_coding_system: Optional[str] = None,    bodysite_coding_code: Optional[str] = None,    bodysite_coding_display: Optional[str] = None,):

Dataclass to describe BodySite related to a Condition/Procedure.

Variables

  • static bodysite_coding_code : Optional[str]
  • static bodysite_coding_display : Optional[str]
  • static bodysite_coding_system : Optional[str]
  • static text : Optional[str]

Condition

class Condition(    onset_datetime: Optional[datetime],    code_system: Optional[str],    code_code: Optional[str],    code_display: Optional[str],    code_text: Optional[str],    clinical_status: Optional[str],    bodysite: Optional[BodySite] = None,):

Dataclass to describe patient Condition.

Variables

  • static clinical_status : Optional[str]
  • static code_code : Optional[str]
  • static code_display : Optional[str]
  • static code_system : Optional[str]
  • static code_text : Optional[str]

DownloadedEHRDocumentInfo

class DownloadedEHRDocumentInfo(    *,    document_id: str,    document_date: str = '',    document_description: str = '',    extension: Optional[str] = '',    local_path: Path,):

Document Info for successfully downloaded documents from EHR.

Variables

Static methods


from_instance

def from_instance(instance: EHRDocumentInfo, **kwargs: Any)> Self:

Inherited from:

EHRDocumentInfo.from_instance :

Method to instantiate children class from parent class.

EHRAppointmentEncounter

class EHRAppointmentEncounter(    appointment_date: Optional[date],    location_name: Optional[str],    event_name: Optional[str],):

Class for Patient Appointment.

Variables

  • static event_name : Optional[str]
  • static location_name : Optional[str]

Methods


format_for_csv

def format_for_csv(self)> dict[str, str]:

Format into a readable dictionary for csv.

EHRDocumentInfo

class EHRDocumentInfo(    *,    document_id: str,    document_date: str = '',    document_description: str = '',    extension: Optional[str] = '',):

Document Information to facilitate download of EHR documents.

Variables

  • static document_date : str
  • static document_description : str
  • static document_id : str
  • static extension : Optional[str]

Static methods


from_instance

def from_instance(instance: EHRDocumentInfo, **kwargs: Any)> Self:

Method to instantiate children class from parent class.

FailedEHRDocumentInfo

class FailedEHRDocumentInfo(    *,    document_id: str,    document_date: str = '',    document_description: str = '',    extension: Optional[str] = '',    local_path: Optional[Path] = None,    failed_reason: str,):

Document Info for documents that failed an attempt to upload.

Variables

  • static failed_reason : str

Static methods


from_instance

def from_instance(instance: EHRDocumentInfo, **kwargs: Any)> Self:

Inherited from:

EHRDocumentInfo.from_instance :

Method to instantiate children class from parent class.

Observation

class Observation(    date: Optional[datetime],    code_system: Optional[str],    code_code: Optional[str],    code_display: Optional[str],    code_text: Optional[str],    value: Optional[float],    unit: Optional[str],):

Observation object from FHIR.

Variables

  • static code_code : Optional[str]
  • static code_display : Optional[str]
  • static code_system : Optional[str]
  • static code_text : Optional[str]
  • static unit : Optional[str]
  • static value : Optional[float]

Procedure

class Procedure(    performed_datetime: Optional[datetime],    code_system: Optional[str],    code_code: Optional[str],    code_display: Optional[str],    code_text: Optional[str],    bodysite: Optional[BodySite] = None,):

Dataclass to describe patient Procedure.

Variables

  • static code_code : Optional[str]
  • static code_display : Optional[str]
  • static code_system : Optional[str]
  • static code_text : Optional[str]

S3UploadedEHRDocumentInfo

class S3UploadedEHRDocumentInfo(    *,    document_id: str,    document_date: str = '',    document_description: str = '',    extension: Optional[str] = '',    local_path: Path,    s3_key: str,    upload_date: str,):

Document Info for documents successfully uploaded to S3.

Variables

  • static s3_key : str
  • static upload_date : str

Static methods


from_instance

def from_instance(instance: EHRDocumentInfo, **kwargs: Any)> Self:

Inherited from:

DownloadedEHRDocumentInfo.from_instance :

Method to instantiate children class from parent class.