Skip to content

Instantly share code, notes, and snippets.

@htlin222
Created February 29, 2024 09:02
Show Gist options
  • Save htlin222/05d486935a408e291892cebb2ac43e96 to your computer and use it in GitHub Desktop.
Save htlin222/05d486935a408e291892cebb2ac43e96 to your computer and use it in GitHub Desktop.
A short script to demonstrate object-oriented programming (OOP) in clinical practice
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: patient_oop
# description: A short script to demonstrate object-oriented programming (OOP) in clinical practice
# date: "2024-02-29"
# author: Hsieh-Ting Lin, the Lizard 🦎
class Patient:
def __init__(self, age, sex, comorbidities, history, treatments, current_admission):
self.age = age
self.sex = sex
self.comorbidities = comorbidities
self.history = history
self.treatments = treatments
self.current_admission = current_admission
self.symptoms = []
self.PET_CT = {}
self.post_treatment_symptoms = []
self.current_symptoms = {}
self.recent_symptom_absence = {}
def add_symptom(self, date, description, location=None, size=None, diagnosis=None):
symptom = {
"date": date,
"description": description,
"location": location,
"size": size,
"diagnosis": diagnosis,
}
self.symptoms.append(symptom)
def set_PET_CT(self, date, findings):
self.PET_CT = {"date": date, "findings": findings}
def add_post_treatment_symptom(
self,
treatment,
date,
symptoms,
duration=None,
outcome=None,
treatment_received=None,
):
post_treatment_symptom = {
"treatment": treatment,
"date": date,
"symptoms": symptoms,
"duration": duration,
"outcome": outcome,
"treatment_received": treatment_received,
}
self.post_treatment_symptoms.append(post_treatment_symptom)
def set_current_symptoms(self, description, intensity, effect, pain_relief):
self.current_symptoms = {
"description": description,
"intensity": intensity,
"effect": effect,
"pain_relief": pain_relief,
}
def set_recent_symptom_absence(self, duration, absent_symptoms):
self.recent_symptom_absence = {
"duration": duration,
"absent_symptoms": absent_symptoms,
}
# Example usage
patient = Patient(
age=65,
sex="Female",
comorbidities=[
"HTN",
"gastric ulcer",
"chronic H. pylori gastritis s/p eradication therapy but no test of clearance",
],
history=[
"zoster in 2024/01/28",
"appendicitis s/p appendectomy c/w peritonitis",
"stage III follicular lymphoma",
],
treatments=[
"excision of right neck level IIa lymphadenopathy on 2023/11/03",
"R-CHOP*1 on 2024/01/09",
],
current_admission="admitted for #2 R-CHOP",
)
# Adding symptoms
patient.add_symptom(
date="2023-09",
description="palpated a mass in right submandibular gland tumor 3*2.5 cm",
location="right submandibular gland",
size="3*2.5 cm",
)
patient.add_symptom(
date="2023-10",
description="right neck lymph node(level II) excisional biopsy revealed FOLLICULAR LYMPHOMA, low-grade",
diagnosis="FOLLICULAR LYMPHOMA, low-grade",
)
# Setting PET CT
patient.set_PET_CT(
date="2023-11-10",
findings="abnormal focal increased uptake of FDG in the bilateral neck, axillary, left supraclavicular, gastrohepatic, left pelvic regions and liver",
)
# Adding post-treatment symptoms
patient.add_post_treatment_symptom(
treatment="1st R-CHOP",
date="2024-01-09",
symptoms=["dizziness", "nausea"],
duration="first few days",
outcome="subsided spontaneously",
)
patient.add_post_treatment_symptom(
date="2024-01-28",
symptoms=[
"skin rash over the left posterior neck and the great thenar of the left hand"
],
treatment="Valacyclovir PO 500mg TID for 7 days, regular Wontran, PRN morphine for pain control",
)
# Setting current symptoms
patient.set_current_symptoms(
description="left upper limb throbbing pain",
intensity="6/10",
effect="sometimes made her unable to fall asleep",
pain_relief="decreased to 1-2/10 after tramadol",
)
# Setting recent symptom absence
patient.set_recent_symptom_absence(
duration="past 1 week",
absent_symptoms=[
"fever",
"chills",
"dyspnea",
"cough",
"sputum",
"abdominal pain",
"diarrhea",
"dyuria",
"n/v",
"frequency",
"urgency",
"flank pain",
"headache",
],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment