Skip to content

Commit

Permalink
updated the structure plus seperation of add and update pages
Browse files Browse the repository at this point in the history
  • Loading branch information
yashar2028 committed Jan 5, 2025
1 parent be79e5e commit 1755af2
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 8 deletions.
20 changes: 13 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def add_patient():
flash(f"An error occurred while adding information: {str(e)}")
return redirect(url_for("dashboard"))

return render_template("add_patient.html", immunization_status=[])
return render_template("add_patient.html")


@app.route('/dashboard/view-patient')
Expand Down Expand Up @@ -368,11 +368,16 @@ def update_patient():
flash("In order to edit patient and access your dashboard you need to login.")
return redirect(url_for('login'))

email = request.args.get('patient_email') # For incoming GET request we need args.get
patient = Patient.query.filter_by(email=email).first()

patient_id = patient.patient_id
patient_med_info = PatientMedInfo.query.filter_by(patient_id=patient_id).first()
email = request.args.get('patient_email') # For incoming GET request we need args.get (update button in patient list).
email_from_update_post = request.form.get("email") # For incoming POST request (update button in update-patient)
if email:
patient = Patient.query.filter_by(email=email).first()
patient_id = patient.patient_id
patient_med_info = PatientMedInfo.query.filter_by(patient_id=patient_id).first()
elif email_from_update_post:
patient = Patient.query.filter_by(email=email_from_update_post).first()
patient_id = patient.patient_id
patient_med_info = PatientMedInfo.query.filter_by(patient_id=patient_id).first()

if request.method == "POST":
# Direct Information
Expand Down Expand Up @@ -425,6 +430,7 @@ def update_patient():
patient_med_info.ros = request.form['ros'] if 'ros' in request.form else patient_med_info.ros

try:
patient_med_info.immunization_status = json.dumps(request.form.getlist('immunization-status'))
db.session.commit()
flash("Patient information was successfully edited.")
return redirect(url_for("dashboard"))
Expand All @@ -435,7 +441,7 @@ def update_patient():

stored_immunization_status = json.loads(patient_med_info.immunization_status) # Deserialized the stored immunization_status for use in the template.

return render_template("add_patient.html", doctor_email=patient.responsible_doctor, admission_date=patient.admission_date,
return render_template("update_patient.html", doctor_email=patient.responsible_doctor, admission_date=patient.admission_date,
firstname=patient.first_name, lastname=patient.last_name, patient_email=patient.email,
address=patient.address, insurance_number=patient.insurance_number, phone_number=patient.phone_number,
gender=patient.gender, race=patient.race, age=patient.age, family_status=patient.family_status, occupation=patient.occupation,
Expand Down
2 changes: 1 addition & 1 deletion templates/add_patient.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ <h2>Add Patient</h2>
</fieldset>
</div>
<div style="display: flex; justify-content: flex-end; margin-top: 20px;">
<button type="submit">Submit</button>
<button type="submit" onclick="submitForm('add')">Submit</button>
</div>
</form>
</section>
Expand Down
252 changes: 252 additions & 0 deletions templates/update_patient.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Patient Information Form</title>
<link href="../static/style-css-method.css" rel="stylesheet">
<style>
/* General Styling */
.container {
display: flex;
flex-wrap: wrap;
gap: 20px;
width: 100%;
max-width: 1200px;
margin: auto;
}

fieldset {
border: 1px solid #ccc;
border-radius: 8px;
padding: 20px;
flex: 0 1 calc(48% - 20px);
box-sizing: border-box;
}

legend {
font-weight: bold;
}

label {
display: block;
margin-bottom: 10px;
font-size: 14px;
}

input, select, textarea {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
box-sizing: border-box;
}

textarea {
resize: none;
}

.checkbox-group {
display: flex;
flex-direction: column;
gap: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
fieldset {
flex: 0 1 100%;
}
}
</style>
</head>
<body>
<div class="sidebar">
<a href="#" class="navbar-brand">Medical Portal</a>
<ul class="navbar-nav">
<li class="nav-item"><a href="../" class="nav-link">Home</a></li>
<li class="nav-item"><a href="../dashboard/view-patient" class="nav-link">Patients list</a></li>
</ul>
</div>

<div class="main-content">
<section class="hero">
<h2>Add Patient</h2>
<form action="{{ url_for('update_patient') }}" method="POST">
<div class="container">
<!-- Doctor Details -->
<fieldset>
<legend>Doctor Details</legend>
<label for="doctor-email">Doctor E-mail:</label>
<textarea id="doctor-email" name="doctor_email">{{doctor_email}}</textarea>

<label for="admission-date">Admission Date:</label>
<input type="date" id="admission-date" name="admission-date" value="{{ admission_date }}">
</fieldset>

<!-- Patient Basic Information -->
<fieldset>
<legend>Patient Basic Information</legend>
<label for="first-name">First Name:</label>
<input type="text" id="first-name" name="first-name" value="{{ firstname }}">

<label for="last-name">Last Name:</label>
<input type="text" id="last-name" name="last-name" value="{{ lastname }}">

<label for="insurance-number">Insurance Number:</label>
<input type="text" id="insurance-number" name="insurance-number" value="{{ insurance_number }}">

<label for="phone-number">Phone Number:</label>
<input type="tel" id="phone-number" name="phone-number" value="{{ phone_number }}">

<label for="address">Address:</label>
<textarea id="address" name="address" rows="3">{{address}}</textarea>

<label for="email">E-mail:</label>
<textarea id="email" name="email">{{patient_email}}</textarea>
</fieldset>

<!-- Demographic Information -->
<fieldset>
<legend>Demographic Information</legend>
<label for="gender">Gender:</label>
<select id="gender" name="gender">
<option value="male" {% if gender == 'male' %}selected{% endif %}>Male</option>
<option value="female" {% if gender == 'female' %}selected{% endif %}>Female</option>
<option value="other" {% if gender == 'other' %}selected{% endif %}>Other</option>
</select>

<label for="age">Age:</label>
<input type="number" id="age" name="age" value="{{ age }}">

<label for="race">Race:</label>
<input type="text" id="race" name="race" value="{{ race }}">

<label for="family-status">Family Status:</label>
<input type="text" id="family-status" name="family-status" value="{{ family_status }}">

<label for="occupation">Occupation:</label>
<input type="text" id="occupation" name="occupation" value="{{ occupation }}">

<label for="height">Height:</label>
<input type="text" id="height" name="height" value="{{ height }}">

<label for="weight">Weight:</label>
<input type="text" id="weight" name="weight" value="{{ weight }}">
</fieldset>

<!-- Vital Signs -->
<fieldset>
<legend>Vital Signs</legend>
<label for="core-temp">Core Temperature:</label>
<input type="text" id="core-temp" name="core-temp" value="{{ core_temp }}">

<label for="heart-rate">Heart Rate:</label>
<input type="text" id="heart-rate" name="heart-rate" value="{{ heart_rate }}">

<label for="respiratory-rate">Respiratory Rate:</label>
<input type="text" id="respiratory-rate" name="respiratory-rate" value="{{ respiratory_rate }}">

<label for="blood-oxygen">Blood Oxygen:</label>
<input type="text" id="blood-oxygen" name="blood-oxygen" value="{{ blood_oxygen }}">

<label for="blood-pressure">Blood Pressure:</label>
<input type="text" id="blood-pressure" name="blood-pressure" value="{{ blood_pressure }}">
</fieldset>

<!-- Immunization Status -->
<fieldset>
<legend>Immunization Status</legend>
<div class="checkbox-group">
<label><input type="checkbox" name="immunization-status" value="Hepatitis A" {% if 'Hepatitis A' in immunization_status %}checked{% endif %}> Hepatitis A</label>
<label><input type="checkbox" name="immunization-status" value="Hepatitis B" {% if 'Hepatitis B' in immunization_status %}checked{% endif %}> Hepatitis B</label>
<label><input type="checkbox" name="immunization-status" value="HPV" {% if 'HPV' in immunization_status %}checked{% endif %}> HPV</label>
<label><input type="checkbox" name="immunization-status" value="Flu" {% if 'Flu' in immunization_status %}checked{% endif %}> Flu</label>
<label><input type="checkbox" name="immunization-status" value="Yellow Fever" {% if 'Yellow Fever' in immunization_status %}checked{% endif %}> Yellow Fever</label>
</div>
</fieldset>

<!-- Medical History -->
<fieldset>
<legend>Medical History</legend>
<label for="disease-history">Disease History:</label>
<textarea id="disease-history" name="disease-history" rows="4">{{disease_history}}</textarea>

<label for="family-history">Family History:</label>
<textarea id="family-history" name="family-history" rows="3">{{family_history}}</textarea>
</fieldset>

<!-- Laboratory Test Results -->
<fieldset>
<legend>Laboratory Test Results</legend>
<label for="wbc">WBC K/μl:</label>
<input type="text" id="wbc" name="wbc" value="{{ wbc }}">
<label for="rbc">RBC million/mm3:</label>
<input type="text" id="rbc" name="rbc" value="{{ rbc }}">
<label for="hco3">HCO3 mEq/L:</label>
<input type="text" id="hco3" name="hco3" value="{{ hco3 }}">
<label for="glucose">Glucose mg/dL:</label>
<input type="text" id="glucose" name="glucose" value="{{ glucose }}">
</fieldset>

<!-- Allergies and Habits -->
<fieldset>
<legend>Allergies and Habits</legend>
<label for="food-allergy">Food Allergy:</label>
<textarea id="food-allergy" name="food-allergy" rows="3">{{food_allergy}}</textarea>
<label for="medication-allergy">Medication Allergy:</label>
<textarea id="medication-allergy" name="medication-allergy" rows="3">{{medication_allergy}}</textarea>
<label for="other-allergy">Other Allergy:</label>
<textarea id="other-allergy" name="other-allergy" rows="3">{{other_allergies}}</textarea>

<label>Smoking History:</label>
<div>
<label><input type="radio" name="smoking-history" value="yes" {% if smoking_history == 'yes' %}checked{% endif %}> Yes</label>
<label><input type="radio" name="smoking-history" value="no" {% if smoking_history == 'no' %}checked{% endif %}> No</label>
</div>

<label>Alcohol History:</label>
<div>
<label><input type="radio" name="alcohol-history" value="yes" {% if alcohol_history == 'yes' %}checked{% endif %}> Yes</label>
<label><input type="radio" name="alcohol-history" value="no" {% if alcohol_history == 'no' %}checked{% endif %}> No</label>
</div>
</fieldset>

<!-- Review of Systems (ROS) -->
<fieldset>
<legend>Review of Systems (ROS)</legend>
<textarea id="general" name="ros" rows="3">{{ros}}</textarea>
</fieldset>

<!-- Medication History -->
<fieldset>
<legend>Medication History</legend>
<label for="current_med_name">Current Medication:</label>
<textarea id="current_med_name" name="current_med_name" rows="3">{{current_med_name}}</textarea>
<label for="current_med_frequency">Medication Frequency:</label>
<textarea id="current_med_frequency" name="current_med_frequency" rows="3">{{current_med_frequency}}</textarea>
<label for="current_med_dosage">Medication Dosage:</label>
<textarea id="current_med_dosage" name="current_med_dosage" rows="3">{{current_med_dosage}}</textarea>
<label for="past-medication">Past Medication:</label>
<textarea id="past-medication" name="past-medication" rows="3">{{past_medication}}</textarea>
</fieldset>

<!-- History of Present Illness -->
<fieldset>
<legend>History Of Present Illness</legend>
<label for="chief-complaint">Chief Complaint:</label>
<textarea id="chief-complaint" name="chief-complaint" rows="3">{{cc}}</textarea>
<label for="soap-notes">SOAP Notes:</label>
<textarea id="soap-notes" name="soap-notes" rows="3">{{soap}}</textarea>
</fieldset>
</div>
<div style="display: flex; justify-content: flex-end; margin-top: 20px;">
<button type="submit" onclick="submitForm('update')">Update</button>
</div>
</form>
</section>
</div>
</body>
</html>

0 comments on commit 1755af2

Please sign in to comment.