GithubHelp home page GithubHelp logo

biostats_ehr's Introduction

ehr-utils

The ehr-utils library provides some simple analytical capabilities for EHR data.

Modules

  • ehr_analysis provides four simple analytical capabilities for EHR data and two class(Patient and Lab), including functions that are able to:
  1. Read and parse the data files to store data into a SQLite database
  2. Return the age in years of a given patient
  3. Indicate a patient's situation based on a test result
  4. Compute the age of a given patient when their earliest lab was recorded

Installation

Feel free to copy ehr_analysis.py.

Usage

The ehr_analysis contains two classes and one function.

  1. Read and parse the data files

    This function takes both patient and lab file names, or the path to those files (string), inserts data in those files into a SQLite database, and produces two lists in a tuple format that contain patients' basic information(Patient class) and relevant lab data(Lab class), respectively.

    Example usage:

from ehr_analysis import parse_data

  def test_Patient_class() -> None:
  """Test the parse_data() Patient has the correct attributes."""
      with fake_files(temp_patient, temp_lab) as (patient, lab):
          patient, labs = parse_data(patient, lab)
      assert patient[0].id == "1"
      assert patient[0].gender == "F"
      assert patient[0].dob == "1947-01-01 00:00:00.000000"
      assert patient[0].race == "white"


  def test_Lab_class() -> None:
      """Test the parse_data() Lab has the correct attributes."""
      with fake_files(temp_patient, temp_lab) as (patient, lab):
          patient, labs = parse_data(patient, lab)
      assert labs[0].patient_id == "1"
      assert labs[0].lab_name == "HDL"
      assert labs[0].lab_value == "50"
      assert labs[0].lab_units == "mg/dL"
      assert labs[0].lab_date == "1980-01-01 00:00:00.000000"
  1. Return the age in years of a given patient

    This is a property of the class Patient, which returns the age in years of the given patient.

    Example usage:

    from ehr_analysis import patient_age
    
    def test_patient_age() -> None:
    """test whether the Patient age property returns the correct age"""
    lab1 = Lab(
        patient_id="1",
    )
    patient1 = Patient(
        id="1",
    )
    assert patient1.age == 76
    
  2. Indicate a patient's situation based on a test result

    This is a property of the class Patient, which takes a lab name (string), an operator (string), and a value of that lab result (float), returns a boolean indicating whether the patient has ever had a test with value above (">") or below ("<") the given level.

    Example usage:

    from ehr_analysis import patient_is_sick
    
    def test_is_sick() -> None:
    """Test whether the is_sick method returns the correct boolean value"""
    lab1 = Lab(
        patient_id="1",
    )
    patient1 = Patient(
        id="1",
    )
    assert patient1.is_sick("HDL", ">", 30) is True
    
  3. Compute the age of a given patient when their earliest lab was recorded

    This is a method of the class Patient, which returns the age in years (int) of a given patient when their earliest lab was recorded.

    Example usage:

    from ehr_analysis import patient_is_sick
    
    def test_earliest_admission() -> None:
    """Test whether the earliest_admission property returns the correct age"""
    patient1 = Patient(
        id="1",
    )
    assert patient1.earliest_admission == 33
    

Development

We welcome contributions! Before opening a pull request, please confirm that existing regression tests pass:

python -m pytest tests/

biostats_ehr's People

Contributors

xquanl avatar patrickkwang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.