998 lines
50 KiB
HTML
998 lines
50 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Discharge Summary{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content" class="app-content">
|
|
<div class="container">
|
|
<ul class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'emr:dashboard' %}">EMR</a></li>
|
|
<li class="breadcrumb-item active">Discharge Summary</li>
|
|
</ul>
|
|
|
|
<div class="row align-items-center mb-3">
|
|
<div class="col">
|
|
<h1 class="page-header">Discharge Summary</h1>
|
|
<p class="text-muted">Comprehensive discharge documentation and care transition planning</p>
|
|
</div>
|
|
<div class="col-auto">
|
|
<div class="btn-group">
|
|
{% if discharge_summary %}
|
|
<button class="btn btn-primary" onclick="saveDischargeSummary()">
|
|
<i class="fa fa-save me-2"></i>Save Summary
|
|
</button>
|
|
<button class="btn btn-outline-secondary" onclick="printSummary()">
|
|
<i class="fa fa-print me-2"></i>Print
|
|
</button>
|
|
<button class="btn btn-outline-info" onclick="emailSummary()">
|
|
<i class="fa fa-envelope me-2"></i>Email
|
|
</button>
|
|
{% else %}
|
|
<button class="btn btn-primary" onclick="createDischargeSummary()">
|
|
<i class="fa fa-plus me-2"></i>Create Summary
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Patient Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Patient Information</h4>
|
|
<div class="card-tools">
|
|
<button class="btn btn-outline-primary btn-sm" onclick="selectPatient()">
|
|
<i class="fa fa-search me-1"></i>Select Patient
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
{% if patient %}
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<p><strong>Name:</strong> {{ patient.first_name }} {{ patient.last_name }}</p>
|
|
<p><strong>DOB:</strong> {{ patient.date_of_birth|date:"M d, Y" }}</p>
|
|
<p><strong>Age:</strong> {{ patient.age }}</p>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<p><strong>MRN:</strong> {{ patient.patient_id }}</p>
|
|
<p><strong>Gender:</strong> {{ patient.get_gender_display }}</p>
|
|
<p><strong>Phone:</strong> {{ patient.phone_primary|default:"Not provided" }}</p>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<p><strong>Address:</strong> {{ patient.address_line_1|default:"Not provided" }}</p>
|
|
<p><strong>Emergency Contact:</strong> {{ patient.emergency_contact_name|default:"Not provided" }}</p>
|
|
<p><strong>Insurance:</strong> {{ patient.primary_insurance|default:"Not provided" }}</p>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<p><strong>Admission Date:</strong> {{ admission.admission_date|date:"M d, Y g:i A"|default:"N/A" }}</p>
|
|
<p><strong>Discharge Date:</strong> {{ discharge.discharge_date|date:"M d, Y g:i A"|default:"Pending" }}</p>
|
|
<p><strong>Length of Stay:</strong> {{ length_of_stay|default:"Calculating..." }} days</p>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="text-center py-3">
|
|
<i class="fa fa-user fa-2x text-muted mb-2"></i>
|
|
<p class="text-muted">No patient selected. Please select a patient to create discharge summary.</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if patient %}
|
|
<!-- Discharge Summary Form -->
|
|
<form id="dischargeSummaryForm">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="patient_id" value="{{ patient.patient_id }}">
|
|
<input type="hidden" name="admission_id" value="{{ admission.id }}">
|
|
|
|
<!-- Admission Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Admission Information</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Admission Date & Time</label>
|
|
<input type="datetime-local" class="form-control" name="admission_date"
|
|
value="{{ admission.admission_date|date:'Y-m-d\TH:i' }}" readonly>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Discharge Date & Time</label>
|
|
<input type="datetime-local" class="form-control" name="discharge_date"
|
|
value="{{ discharge_summary.discharge_date|date:'Y-m-d\TH:i'|default:'' }}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Admitting Physician</label>
|
|
<input type="text" class="form-control" name="admitting_physician"
|
|
value="{{ admission.admitting_physician|default:'' }}">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Attending Physician</label>
|
|
<input type="text" class="form-control" name="attending_physician"
|
|
value="{{ discharge_summary.attending_physician|default:'' }}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Chief Complaint</label>
|
|
<textarea class="form-control" name="chief_complaint" rows="2">{{ discharge_summary.chief_complaint|default:'' }}</textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Clinical Summary -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Clinical Summary</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">History of Present Illness</label>
|
|
<textarea class="form-control" name="history_present_illness" rows="4">{{ discharge_summary.history_present_illness|default:'' }}</textarea>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Past Medical History</label>
|
|
<textarea class="form-control" name="past_medical_history" rows="3">{{ discharge_summary.past_medical_history|default:'' }}</textarea>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Allergies</label>
|
|
<textarea class="form-control" name="allergies" rows="2">{{ discharge_summary.allergies|default:patient.allergies|default:'' }}</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Social History</label>
|
|
<textarea class="form-control" name="social_history" rows="2">{{ discharge_summary.social_history|default:'' }}</textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Hospital Course -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Hospital Course</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Hospital Course Summary</label>
|
|
<textarea class="form-control" name="hospital_course" rows="6">{{ discharge_summary.hospital_course|default:'' }}</textarea>
|
|
<small class="form-text text-muted">Describe the patient's clinical course during hospitalization, including treatments, procedures, and response to therapy.</small>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Procedures Performed</label>
|
|
<textarea class="form-control" name="procedures_performed" rows="4">{{ discharge_summary.procedures_performed|default:'' }}</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Complications</label>
|
|
<textarea class="form-control" name="complications" rows="4">{{ discharge_summary.complications|default:'' }}</textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Diagnoses -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Diagnoses</h4>
|
|
<div class="card-tools">
|
|
<button type="button" class="btn btn-outline-primary btn-sm" onclick="addDiagnosis()">
|
|
<i class="fa fa-plus me-1"></i>Add Diagnosis
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Primary Diagnosis</label>
|
|
<input type="text" class="form-control" name="primary_diagnosis"
|
|
value="{{ discharge_summary.primary_diagnosis|default:'' }}">
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Secondary Diagnoses</label>
|
|
<div id="secondaryDiagnoses">
|
|
{% for diagnosis in secondary_diagnoses %}
|
|
<div class="input-group mb-2">
|
|
<input type="text" class="form-control" name="secondary_diagnoses[]" value="{{ diagnosis }}">
|
|
<button class="btn btn-outline-danger" type="button" onclick="removeDiagnosis(this)">
|
|
<i class="fa fa-times"></i>
|
|
</button>
|
|
</div>
|
|
{% endfor %}
|
|
{% if not secondary_diagnoses %}
|
|
<div class="input-group mb-2">
|
|
<input type="text" class="form-control" name="secondary_diagnoses[]" placeholder="Enter secondary diagnosis">
|
|
<button class="btn btn-outline-danger" type="button" onclick="removeDiagnosis(this)">
|
|
<i class="fa fa-times"></i>
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Discharge Medications -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Discharge Medications</h4>
|
|
<div class="card-tools">
|
|
<button type="button" class="btn btn-outline-primary btn-sm" onclick="addMedication()">
|
|
<i class="fa fa-plus me-1"></i>Add Medication
|
|
</button>
|
|
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="importCurrentMedications()">
|
|
<i class="fa fa-download me-1"></i>Import Current
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped" id="medicationsTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Medication</th>
|
|
<th>Dosage</th>
|
|
<th>Frequency</th>
|
|
<th>Route</th>
|
|
<th>Duration</th>
|
|
<th>Instructions</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for medication in discharge_medications %}
|
|
<tr>
|
|
<td><input type="text" class="form-control form-control-sm" name="medications[{{ forloop.counter0 }}][name]" value="{{ medication.name }}"></td>
|
|
<td><input type="text" class="form-control form-control-sm" name="medications[{{ forloop.counter0 }}][dosage]" value="{{ medication.dosage }}"></td>
|
|
<td><input type="text" class="form-control form-control-sm" name="medications[{{ forloop.counter0 }}][frequency]" value="{{ medication.frequency }}"></td>
|
|
<td><input type="text" class="form-control form-control-sm" name="medications[{{ forloop.counter0 }}][route]" value="{{ medication.route }}"></td>
|
|
<td><input type="text" class="form-control form-control-sm" name="medications[{{ forloop.counter0 }}][duration]" value="{{ medication.duration }}"></td>
|
|
<td><input type="text" class="form-control form-control-sm" name="medications[{{ forloop.counter0 }}][instructions]" value="{{ medication.instructions }}"></td>
|
|
<td>
|
|
<button type="button" class="btn btn-outline-danger btn-sm" onclick="removeMedicationRow(this)">
|
|
<i class="fa fa-times"></i>
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" class="text-center text-muted">No medications added. Click "Add Medication" to begin.</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Discharge Instructions -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Discharge Instructions</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Activity Level</label>
|
|
<select class="form-select" name="activity_level">
|
|
<option value="">Select activity level...</option>
|
|
<option value="bed_rest" {% if discharge_summary.activity_level == 'bed_rest' %}selected{% endif %}>Bed Rest</option>
|
|
<option value="limited" {% if discharge_summary.activity_level == 'limited' %}selected{% endif %}>Limited Activity</option>
|
|
<option value="moderate" {% if discharge_summary.activity_level == 'moderate' %}selected{% endif %}>Moderate Activity</option>
|
|
<option value="normal" {% if discharge_summary.activity_level == 'normal' %}selected{% endif %}>Normal Activity</option>
|
|
<option value="as_tolerated" {% if discharge_summary.activity_level == 'as_tolerated' %}selected{% endif %}>As Tolerated</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Diet</label>
|
|
<input type="text" class="form-control" name="diet"
|
|
value="{{ discharge_summary.diet|default:'' }}" placeholder="e.g., Regular, Low sodium, Diabetic">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Wound Care Instructions</label>
|
|
<textarea class="form-control" name="wound_care" rows="3">{{ discharge_summary.wound_care|default:'' }}</textarea>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Special Instructions</label>
|
|
<textarea class="form-control" name="special_instructions" rows="4">{{ discharge_summary.special_instructions|default:'' }}</textarea>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Warning Signs to Return</label>
|
|
<textarea class="form-control" name="warning_signs" rows="3">{{ discharge_summary.warning_signs|default:'' }}</textarea>
|
|
<small class="form-text text-muted">List symptoms or conditions that would require immediate medical attention.</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Follow-up Care -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Follow-up Care</h4>
|
|
<div class="card-tools">
|
|
<button type="button" class="btn btn-outline-primary btn-sm" onclick="addFollowUp()">
|
|
<i class="fa fa-plus me-1"></i>Add Follow-up
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div id="followUpAppointments">
|
|
{% for followup in follow_up_appointments %}
|
|
<div class="row mb-3 followup-row">
|
|
<div class="col-md-3">
|
|
<label class="form-label">Provider/Specialty</label>
|
|
<input type="text" class="form-control" name="followup_provider[]" value="{{ followup.provider }}">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label">Timeframe</label>
|
|
<input type="text" class="form-control" name="followup_timeframe[]" value="{{ followup.timeframe }}" placeholder="e.g., 1-2 weeks">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label">Phone</label>
|
|
<input type="text" class="form-control" name="followup_phone[]" value="{{ followup.phone }}">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label">Notes</label>
|
|
<input type="text" class="form-control" name="followup_notes[]" value="{{ followup.notes }}">
|
|
</div>
|
|
<div class="col-md-1">
|
|
<label class="form-label"> </label>
|
|
<button type="button" class="btn btn-outline-danger form-control" onclick="removeFollowUp(this)">
|
|
<i class="fa fa-times"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="row mb-3 followup-row">
|
|
<div class="col-md-3">
|
|
<label class="form-label">Provider/Specialty</label>
|
|
<input type="text" class="form-control" name="followup_provider[]" placeholder="e.g., Primary Care">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label">Timeframe</label>
|
|
<input type="text" class="form-control" name="followup_timeframe[]" placeholder="e.g., 1-2 weeks">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label">Phone</label>
|
|
<input type="text" class="form-control" name="followup_phone[]">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label">Notes</label>
|
|
<input type="text" class="form-control" name="followup_notes[]">
|
|
</div>
|
|
<div class="col-md-1">
|
|
<label class="form-label"> </label>
|
|
<button type="button" class="btn btn-outline-danger form-control" onclick="removeFollowUp(this)">
|
|
<i class="fa fa-times"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Discharge Disposition -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Discharge Disposition</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Discharge Disposition</label>
|
|
<select class="form-select" name="discharge_disposition">
|
|
<option value="">Select disposition...</option>
|
|
<option value="home" {% if discharge_summary.discharge_disposition == 'home' %}selected{% endif %}>Home</option>
|
|
<option value="home_health" {% if discharge_summary.discharge_disposition == 'home_health' %}selected{% endif %}>Home with Health Services</option>
|
|
<option value="skilled_nursing" {% if discharge_summary.discharge_disposition == 'skilled_nursing' %}selected{% endif %}>Skilled Nursing Facility</option>
|
|
<option value="rehabilitation" {% if discharge_summary.discharge_disposition == 'rehabilitation' %}selected{% endif %}>Rehabilitation Facility</option>
|
|
<option value="long_term_care" {% if discharge_summary.discharge_disposition == 'long_term_care' %}selected{% endif %}>Long-term Care</option>
|
|
<option value="hospice" {% if discharge_summary.discharge_disposition == 'hospice' %}selected{% endif %}>Hospice</option>
|
|
<option value="transfer" {% if discharge_summary.discharge_disposition == 'transfer' %}selected{% endif %}>Transfer to Another Hospital</option>
|
|
<option value="ama" {% if discharge_summary.discharge_disposition == 'ama' %}selected{% endif %}>Against Medical Advice</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Condition at Discharge</label>
|
|
<select class="form-select" name="condition_at_discharge">
|
|
<option value="">Select condition...</option>
|
|
<option value="stable" {% if discharge_summary.condition_at_discharge == 'stable' %}selected{% endif %}>Stable</option>
|
|
<option value="improved" {% if discharge_summary.condition_at_discharge == 'improved' %}selected{% endif %}>Improved</option>
|
|
<option value="unchanged" {% if discharge_summary.condition_at_discharge == 'unchanged' %}selected{% endif %}>Unchanged</option>
|
|
<option value="worse" {% if discharge_summary.condition_at_discharge == 'worse' %}selected{% endif %}>Worse</option>
|
|
<option value="critical" {% if discharge_summary.condition_at_discharge == 'critical' %}selected{% endif %}>Critical</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Discharge Summary Notes</label>
|
|
<textarea class="form-control" name="discharge_notes" rows="3">{{ discharge_summary.discharge_notes|default:'' }}</textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Provider Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Provider Information</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Discharging Physician</label>
|
|
<input type="text" class="form-control" name="discharging_physician"
|
|
value="{{ discharge_summary.discharging_physician|default:user.get_full_name }}">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Date Dictated</label>
|
|
<input type="date" class="form-control" name="date_dictated"
|
|
value="{{ discharge_summary.date_dictated|date:'Y-m-d'|default:today }}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Electronic Signature</label>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="electronically_signed"
|
|
{% if discharge_summary.electronically_signed %}checked{% endif %}>
|
|
<label class="form-check-label">
|
|
Electronically signed by {{ user.get_full_name }}
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Status</label>
|
|
<select class="form-select" name="status">
|
|
<option value="draft" {% if discharge_summary.status == 'draft' %}selected{% endif %}>Draft</option>
|
|
<option value="pending_review" {% if discharge_summary.status == 'pending_review' %}selected{% endif %}>Pending Review</option>
|
|
<option value="final" {% if discharge_summary.status == 'final' %}selected{% endif %}>Final</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<button type="button" class="btn btn-outline-secondary" onclick="saveDraft()">
|
|
<i class="fa fa-save me-2"></i>Save as Draft
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info" onclick="previewSummary()">
|
|
<i class="fa fa-eye me-2"></i>Preview
|
|
</button>
|
|
</div>
|
|
<div>
|
|
<button type="button" class="btn btn-warning" onclick="submitForReview()">
|
|
<i class="fa fa-check me-2"></i>Submit for Review
|
|
</button>
|
|
<button type="button" class="btn btn-success" onclick="finalizeSummary()">
|
|
<i class="fa fa-check-circle me-2"></i>Finalize Summary
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Patient Selection Modal -->
|
|
<div class="modal fade" id="patientSelectionModal" tabindex="-1">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Select Patient</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<input type="text" class="form-control" id="patientSearchInput" placeholder="Search by name, ID, or phone number...">
|
|
</div>
|
|
<div id="patientSearchResults">
|
|
<!-- Search results will be loaded here -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Preview Modal -->
|
|
<div class="modal fade" id="previewModal" tabindex="-1">
|
|
<div class="modal-dialog modal-xl">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Discharge Summary Preview</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div id="previewContent">
|
|
<!-- Preview content will be loaded here -->
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
<button type="button" class="btn btn-primary" onclick="printPreview()">Print</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
setupEventHandlers();
|
|
setupAutoSave();
|
|
});
|
|
|
|
function setupEventHandlers() {
|
|
// Patient search
|
|
$('#patientSearchInput').on('input', function() {
|
|
var query = $(this).val();
|
|
if (query.length >= 3) {
|
|
searchPatients(query);
|
|
}
|
|
});
|
|
|
|
// Form validation
|
|
$('#dischargeSummaryForm').on('submit', function(e) {
|
|
e.preventDefault();
|
|
saveDischargeSummary();
|
|
});
|
|
}
|
|
|
|
function setupAutoSave() {
|
|
// Auto-save every 5 minutes
|
|
setInterval(function() {
|
|
if ($('#dischargeSummaryForm').length) {
|
|
saveDraft(true); // Silent save
|
|
}
|
|
}, 300000); // 5 minutes
|
|
}
|
|
|
|
function selectPatient() {
|
|
$('#patientSelectionModal').modal('show');
|
|
}
|
|
|
|
function searchPatients(query) {
|
|
$.get('{% url "emr:patient_search_api" %}', {q: query}, function(data) {
|
|
var html = '';
|
|
|
|
if (data.patients.length === 0) {
|
|
html = '<div class="alert alert-info">No patients found matching "' + query + '"</div>';
|
|
} else {
|
|
html = '<div class="list-group">';
|
|
data.patients.forEach(function(patient) {
|
|
html += '<button type="button" class="list-group-item list-group-item-action" onclick="selectPatientForSummary(\'' + patient.patient_id + '\')">' +
|
|
'<div class="d-flex w-100 justify-content-between">' +
|
|
'<h6 class="mb-1">' + patient.first_name + ' ' + patient.last_name + '</h6>' +
|
|
'<small>' + patient.patient_id + '</small>' +
|
|
'</div>' +
|
|
'<p class="mb-1">DOB: ' + patient.date_of_birth + ' | Gender: ' + patient.gender + '</p>' +
|
|
'<small>Phone: ' + (patient.phone_primary || 'Not provided') + '</small>' +
|
|
'</button>';
|
|
});
|
|
html += '</div>';
|
|
}
|
|
|
|
$('#patientSearchResults').html(html);
|
|
});
|
|
}
|
|
|
|
function selectPatientForSummary(patientId) {
|
|
window.location.href = '{% url "emr:discharge_summary" %}?patient_id=' + patientId;
|
|
}
|
|
|
|
function createDischargeSummary() {
|
|
var patientId = '{{ patient.patient_id|default:"" }}';
|
|
if (!patientId) {
|
|
toastr.error('Please select a patient first');
|
|
return;
|
|
}
|
|
|
|
$.post('{% url "emr:create_discharge_summary" %}', {
|
|
patient_id: patientId,
|
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
|
}, function(data) {
|
|
if (data.success) {
|
|
toastr.success('Discharge summary created');
|
|
location.reload();
|
|
} else {
|
|
toastr.error('Failed to create discharge summary: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function addDiagnosis() {
|
|
var html = '<div class="input-group mb-2">' +
|
|
'<input type="text" class="form-control" name="secondary_diagnoses[]" placeholder="Enter secondary diagnosis">' +
|
|
'<button class="btn btn-outline-danger" type="button" onclick="removeDiagnosis(this)">' +
|
|
'<i class="fa fa-times"></i>' +
|
|
'</button>' +
|
|
'</div>';
|
|
$('#secondaryDiagnoses').append(html);
|
|
}
|
|
|
|
function removeDiagnosis(button) {
|
|
$(button).closest('.input-group').remove();
|
|
}
|
|
|
|
function addMedication() {
|
|
var rowCount = $('#medicationsTable tbody tr').length;
|
|
if ($('#medicationsTable tbody tr td[colspan]').length > 0) {
|
|
$('#medicationsTable tbody').empty();
|
|
rowCount = 0;
|
|
}
|
|
|
|
var html = '<tr>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + rowCount + '][name]"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + rowCount + '][dosage]"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + rowCount + '][frequency]"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + rowCount + '][route]"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + rowCount + '][duration]"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + rowCount + '][instructions]"></td>' +
|
|
'<td><button type="button" class="btn btn-outline-danger btn-sm" onclick="removeMedicationRow(this)"><i class="fa fa-times"></i></button></td>' +
|
|
'</tr>';
|
|
$('#medicationsTable tbody').append(html);
|
|
}
|
|
|
|
function removeMedicationRow(button) {
|
|
$(button).closest('tr').remove();
|
|
|
|
// If no rows left, show placeholder
|
|
if ($('#medicationsTable tbody tr').length === 0) {
|
|
$('#medicationsTable tbody').html('<tr><td colspan="7" class="text-center text-muted">No medications added. Click "Add Medication" to begin.</td></tr>');
|
|
}
|
|
}
|
|
|
|
function importCurrentMedications() {
|
|
var patientId = '{{ patient.patient_id|default:"" }}';
|
|
|
|
$.get('{% url "emr:get_current_medications" %}', {patient_id: patientId}, function(data) {
|
|
if (data.success) {
|
|
// Clear existing medications
|
|
$('#medicationsTable tbody').empty();
|
|
|
|
// Add current medications
|
|
data.medications.forEach(function(med, index) {
|
|
var html = '<tr>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + index + '][name]" value="' + med.name + '"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + index + '][dosage]" value="' + med.dosage + '"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + index + '][frequency]" value="' + med.frequency + '"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + index + '][route]" value="' + med.route + '"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + index + '][duration]"></td>' +
|
|
'<td><input type="text" class="form-control form-control-sm" name="medications[' + index + '][instructions]"></td>' +
|
|
'<td><button type="button" class="btn btn-outline-danger btn-sm" onclick="removeMedicationRow(this)"><i class="fa fa-times"></i></button></td>' +
|
|
'</tr>';
|
|
$('#medicationsTable tbody').append(html);
|
|
});
|
|
|
|
toastr.success('Current medications imported');
|
|
} else {
|
|
toastr.error('Failed to import medications: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function addFollowUp() {
|
|
var html = '<div class="row mb-3 followup-row">' +
|
|
'<div class="col-md-3">' +
|
|
'<label class="form-label">Provider/Specialty</label>' +
|
|
'<input type="text" class="form-control" name="followup_provider[]">' +
|
|
'</div>' +
|
|
'<div class="col-md-3">' +
|
|
'<label class="form-label">Timeframe</label>' +
|
|
'<input type="text" class="form-control" name="followup_timeframe[]" placeholder="e.g., 1-2 weeks">' +
|
|
'</div>' +
|
|
'<div class="col-md-2">' +
|
|
'<label class="form-label">Phone</label>' +
|
|
'<input type="text" class="form-control" name="followup_phone[]">' +
|
|
'</div>' +
|
|
'<div class="col-md-3">' +
|
|
'<label class="form-label">Notes</label>' +
|
|
'<input type="text" class="form-control" name="followup_notes[]">' +
|
|
'</div>' +
|
|
'<div class="col-md-1">' +
|
|
'<label class="form-label"> </label>' +
|
|
'<button type="button" class="btn btn-outline-danger form-control" onclick="removeFollowUp(this)">' +
|
|
'<i class="fa fa-times"></i>' +
|
|
'</button>' +
|
|
'</div>' +
|
|
'</div>';
|
|
$('#followUpAppointments').append(html);
|
|
}
|
|
|
|
function removeFollowUp(button) {
|
|
$(button).closest('.followup-row').remove();
|
|
}
|
|
|
|
function saveDraft(silent = false) {
|
|
var formData = $('#dischargeSummaryForm').serialize();
|
|
formData += '&status=draft';
|
|
|
|
$.post('{% url "emr:save_discharge_summary" %}', formData, function(data) {
|
|
if (data.success) {
|
|
if (!silent) {
|
|
toastr.success('Draft saved');
|
|
}
|
|
} else {
|
|
if (!silent) {
|
|
toastr.error('Failed to save draft: ' + data.error);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function saveDischargeSummary() {
|
|
var formData = $('#dischargeSummaryForm').serialize();
|
|
|
|
$.post('{% url "emr:save_discharge_summary" %}', formData, function(data) {
|
|
if (data.success) {
|
|
toastr.success('Discharge summary saved');
|
|
} else {
|
|
toastr.error('Failed to save discharge summary: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function submitForReview() {
|
|
var formData = $('#dischargeSummaryForm').serialize();
|
|
formData += '&status=pending_review';
|
|
|
|
$.post('{% url "emr:save_discharge_summary" %}', formData, function(data) {
|
|
if (data.success) {
|
|
toastr.success('Discharge summary submitted for review');
|
|
location.reload();
|
|
} else {
|
|
toastr.error('Failed to submit for review: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function finalizeSummary() {
|
|
if (confirm('Are you sure you want to finalize this discharge summary? This action cannot be undone.')) {
|
|
var formData = $('#dischargeSummaryForm').serialize();
|
|
formData += '&status=final';
|
|
|
|
$.post('{% url "emr:save_discharge_summary" %}', formData, function(data) {
|
|
if (data.success) {
|
|
toastr.success('Discharge summary finalized');
|
|
location.reload();
|
|
} else {
|
|
toastr.error('Failed to finalize summary: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function previewSummary() {
|
|
var formData = $('#dischargeSummaryForm').serialize();
|
|
|
|
$.post('{% url "emr:preview_discharge_summary" %}', formData, function(data) {
|
|
if (data.success) {
|
|
$('#previewContent').html(data.html);
|
|
$('#previewModal').modal('show');
|
|
} else {
|
|
toastr.error('Failed to generate preview: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function printSummary() {
|
|
var patientId = '{{ patient.patient_id|default:"" }}';
|
|
window.open('{% url "emr:print_discharge_summary" %}?patient_id=' + patientId, '_blank');
|
|
}
|
|
|
|
function printPreview() {
|
|
var printWindow = window.open('', '_blank');
|
|
printWindow.document.write('<html><head><title>Discharge Summary</title>');
|
|
printWindow.document.write('<style>body { font-family: Arial, sans-serif; margin: 20px; } .header { text-align: center; margin-bottom: 20px; } .section { margin-bottom: 15px; } .label { font-weight: bold; }</style>');
|
|
printWindow.document.write('</head><body>');
|
|
printWindow.document.write($('#previewContent').html());
|
|
printWindow.document.write('</body></html>');
|
|
printWindow.document.close();
|
|
printWindow.print();
|
|
}
|
|
|
|
function emailSummary() {
|
|
var patientId = '{{ patient.patient_id|default:"" }}';
|
|
|
|
$.post('{% url "emr:email_discharge_summary" %}', {
|
|
patient_id: patientId,
|
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
|
}, function(data) {
|
|
if (data.success) {
|
|
toastr.success('Discharge summary emailed successfully');
|
|
} else {
|
|
toastr.error('Failed to email summary: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.card-tools {
|
|
margin-left: auto;
|
|
}
|
|
|
|
.followup-row {
|
|
border-bottom: 1px solid #dee2e6;
|
|
padding-bottom: 15px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.followup-row:last-child {
|
|
border-bottom: none;
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.form-control-sm {
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.table th {
|
|
border-top: none;
|
|
font-weight: 600;
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.list-group-item-action:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.card-header h4 {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.form-check-input:checked {
|
|
background-color: #0d6efd;
|
|
border-color: #0d6efd;
|
|
}
|
|
|
|
.btn-group .btn {
|
|
margin-right: 5px;
|
|
}
|
|
|
|
.btn-group .btn:last-child {
|
|
margin-right: 0;
|
|
}
|
|
|
|
#previewContent {
|
|
max-height: 70vh;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.preview-section {
|
|
margin-bottom: 20px;
|
|
padding: 15px;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
}
|
|
|
|
.preview-section h5 {
|
|
color: #0d6efd;
|
|
border-bottom: 1px solid #dee2e6;
|
|
padding-bottom: 5px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.medication-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.medication-table th,
|
|
.medication-table td {
|
|
border: 1px solid #dee2e6;
|
|
padding: 8px;
|
|
text-align: left;
|
|
}
|
|
|
|
.medication-table th {
|
|
background-color: #f8f9fa;
|
|
font-weight: 600;
|
|
}
|
|
|
|
@media print {
|
|
.btn, .card-header, .breadcrumb {
|
|
display: none !important;
|
|
}
|
|
|
|
.card {
|
|
border: none !important;
|
|
box-shadow: none !important;
|
|
}
|
|
|
|
.card-body {
|
|
padding: 0 !important;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|