<?php
/**
 * Jubilee Insurance Pre-Authorization Form Fields
 * Based on Jubilee Health Insurance form requirements
 */

// Prevent direct access
if (!defined('PREAUTH_FORM_INCLUDE')) {
    exit('Direct access not allowed');
}
?>

<!-- Jubilee-Specific Form Fields -->
<div class="form-section insurer-specific-section" id="jubileeFormFields">
    <div class="form-section-title">
        <i class="ri-shield-star-line"></i> Jubilee Pre-Authorization Details
    </div>

    <!-- Scheme & Membership Information -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-team-line me-2"></i>Scheme & Membership Information</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Scheme Name <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" name="preauth_data[scheme_name]"
                            placeholder="Enter scheme/company name" required>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Employee/Principal Name</label>
                        <input type="text" class="form-control" name="preauth_data[employee_name]"
                            placeholder="Name of principal member">
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Relation to Principal Member <span class="text-danger">*</span></label>
                        <select class="form-select" name="preauth_data[relation_to_insured]" required>
                            <option value="">Select Relation</option>
                            <option value="Self">Self (Principal)</option>
                            <option value="Spouse">Spouse</option>
                            <option value="Child">Child</option>
                            <option value="Parent">Parent</option>
                            <option value="Other Dependant">Other Dependant</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Membership Number</label>
                        <input type="text" class="form-control" name="preauth_data[membership_number]"
                            placeholder="Jubilee membership number">
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">ID Number</label>
                        <input type="text" class="form-control" name="preauth_data[id_number]"
                            placeholder="National ID number">
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Contact Phone</label>
                        <input type="tel" class="form-control" name="preauth_data[contact_phone]"
                            placeholder="+254...">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Admission Details -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-hospital-line me-2"></i>Admission Details</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Admission Date</label>
                        <input type="date" class="form-control" name="preauth_data[admission_date]">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Admission Time</label>
                        <input type="time" class="form-control" name="preauth_data[admission_time]">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Type of Admission <span class="text-danger">*</span></label>
                        <div class="d-flex gap-4 mt-2">
                            <div class="form-check">
                                <input class="form-check-input" type="radio" name="preauth_data[admission_type]"
                                    value="Emergency" id="jubAdmissionEmergency">
                                <label class="form-check-label" for="jubAdmissionEmergency">
                                    <span class="badge bg-danger">Emergency</span>
                                </label>
                            </div>
                            <div class="form-check">
                                <input class="form-check-input" type="radio" name="preauth_data[admission_type]"
                                    value="Planned" id="jubAdmissionPlanned" checked>
                                <label class="form-check-label" for="jubAdmissionPlanned">
                                    <span class="badge bg-primary">Planned</span>
                                </label>
                            </div>
                            <div class="form-check">
                                <input class="form-check-input" type="radio" name="preauth_data[admission_type]"
                                    value="Day Case" id="jubAdmissionDayCase">
                                <label class="form-check-label" for="jubAdmissionDayCase">
                                    <span class="badge bg-info">Day Case</span>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Clinical Information -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-stethoscope-line me-2"></i>Clinical Information</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Presenting Complaints <span class="text-danger">*</span></label>
                        <textarea class="form-control" name="preauth_data[presenting_complaints]" rows="3"
                            placeholder="Describe the patient's main complaints" required></textarea>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Relevant Clinical Findings <span class="text-danger">*</span></label>
                        <textarea class="form-control" name="preauth_data[clinical_findings]" rows="3"
                            placeholder="Key clinical findings from examination" required></textarea>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Duration of Ailment</label>
                        <input type="text" class="form-control" name="preauth_data[duration_of_ailment]"
                            placeholder="e.g., 3 days, 2 weeks">
                    </div>
                </div>
                <div class="col-md-8">
                    <div class="mb-3">
                        <label class="form-label">Reason for Admission <span class="text-danger">*</span></label>
                        <textarea class="form-control" name="preauth_data[reason_for_admission]" rows="2"
                            placeholder="Why is hospital admission necessary?" required></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Proposed Line of Treatment -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-medicine-bottle-line me-2"></i>Proposed Line of Treatment</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-12 mb-3">
                    <label class="form-label">Select Treatment Categories (Multiple allowed)</label>
                    <div class="d-flex flex-wrap gap-4">
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="preauth_data[treatment_medical]"
                                value="1" id="jubTreatmentMedical">
                            <label class="form-check-label" for="jubTreatmentMedical">
                                <i class="ri-capsule-line me-1"></i> Medical
                            </label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="preauth_data[treatment_surgical]"
                                value="1" id="jubTreatmentSurgical">
                            <label class="form-check-label" for="jubTreatmentSurgical">
                                <i class="ri-surgical-mask-line me-1"></i> Surgical
                            </label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="preauth_data[treatment_intensive]"
                                value="1" id="jubTreatmentIntensive">
                            <label class="form-check-label" for="jubTreatmentIntensive">
                                <i class="ri-heart-pulse-line me-1"></i> Intensive Care
                            </label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="preauth_data[treatment_investigative]"
                                value="1" id="jubTreatmentInvestigative">
                            <label class="form-check-label" for="jubTreatmentInvestigative">
                                <i class="ri-search-line me-1"></i> Investigative
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="mb-3">
                        <label class="form-label">Treatment Details</label>
                        <textarea class="form-control" name="preauth_data[treatment_details]" rows="2"
                            placeholder="Provide details of the proposed treatment plan"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Maternity Section -->
    <div class="card mb-4">
        <div class="card-header bg-light d-flex justify-content-between align-items-center">
            <h6 class="mb-0"><i class="ri-parent-line me-2"></i>Maternity Information</h6>
            <div class="form-check form-switch">
                <input class="form-check-input" type="checkbox" id="jubShowMaternity" onchange="toggleJubileeMaternity()">
                <label class="form-check-label" for="jubShowMaternity">Is this a maternity case?</label>
            </div>
        </div>
        <div class="card-body" id="jubileeMaternitySection" style="display: none;">
            <div class="row">
                <div class="col-md-2">
                    <div class="mb-3">
                        <label class="form-label">Gravida (G)</label>
                        <input type="number" class="form-control" name="preauth_data[maternity_gravida]"
                            min="0" placeholder="0">
                        <small class="text-muted">Number of pregnancies</small>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="mb-3">
                        <label class="form-label">Para (P)</label>
                        <input type="number" class="form-control" name="preauth_data[maternity_para]"
                            min="0" placeholder="0">
                        <small class="text-muted">Number of deliveries</small>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="mb-3">
                        <label class="form-label">Living (L)</label>
                        <input type="number" class="form-control" name="preauth_data[maternity_living]"
                            min="0" placeholder="0">
                        <small class="text-muted">Living children</small>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="mb-3">
                        <label class="form-label">Abortions (A)</label>
                        <input type="number" class="form-control" name="preauth_data[maternity_abortions]"
                            min="0" placeholder="0">
                        <small class="text-muted">Miscarriages</small>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Expected Delivery Date (EDD)</label>
                        <input type="date" class="form-control" name="preauth_data[maternity_edd]">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Last Menstrual Period (LMP)</label>
                        <input type="date" class="form-control" name="preauth_data[maternity_lmp]">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Gestation (Weeks)</label>
                        <input type="number" class="form-control" name="preauth_data[maternity_gestation_weeks]"
                            min="0" max="45" placeholder="0">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="mb-3">
                        <label class="form-label">Pregnancy Complications (if any)</label>
                        <textarea class="form-control" name="preauth_data[maternity_complications]" rows="2"
                            placeholder="Describe any complications or high-risk factors"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Chronic Illness Section -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-heart-3-line me-2"></i>Chronic Illness / Pre-existing Conditions</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-12 mb-3">
                    <label class="form-label">Does the patient suffer from any of the following?</label>
                    <div class="row">
                        <div class="col-md-3">
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_diabetes]"
                                    value="1" id="jubChronicDiabetes">
                                <label class="form-check-label" for="jubChronicDiabetes">Diabetes Mellitus</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_hypertension]"
                                    value="1" id="jubChronicHypertension">
                                <label class="form-check-label" for="jubChronicHypertension">Hypertension</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_heart]"
                                    value="1" id="jubChronicHeart">
                                <label class="form-check-label" for="jubChronicHeart">Heart Disease</label>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_kidney]"
                                    value="1" id="jubChronicKidney">
                                <label class="form-check-label" for="jubChronicKidney">Kidney Disease</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_liver]"
                                    value="1" id="jubChronicLiver">
                                <label class="form-check-label" for="jubChronicLiver">Liver Disease</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_asthma]"
                                    value="1" id="jubChronicAsthma">
                                <label class="form-check-label" for="jubChronicAsthma">Asthma/COPD</label>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_cancer]"
                                    value="1" id="jubChronicCancer">
                                <label class="form-check-label" for="jubChronicCancer">Cancer</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_epilepsy]"
                                    value="1" id="jubChronicEpilepsy">
                                <label class="form-check-label" for="jubChronicEpilepsy">Epilepsy</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_hiv]"
                                    value="1" id="jubChronicHIV">
                                <label class="form-check-label" for="jubChronicHIV">HIV/AIDS</label>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_stroke]"
                                    value="1" id="jubChronicStroke">
                                <label class="form-check-label" for="jubChronicStroke">Stroke</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_mental]"
                                    value="1" id="jubChronicMental">
                                <label class="form-check-label" for="jubChronicMental">Mental Illness</label>
                            </div>
                            <div class="form-check mb-2">
                                <input class="form-check-input" type="checkbox" name="preauth_data[chronic_other]"
                                    value="1" id="jubChronicOther">
                                <label class="form-check-label" for="jubChronicOther">Other</label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="mb-3">
                        <label class="form-label">Chronic Illness Details / Duration</label>
                        <textarea class="form-control" name="preauth_data[chronic_details]" rows="2"
                            placeholder="Provide details and duration of any chronic conditions"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Accident Related -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-alarm-warning-line me-2"></i>Accident Information</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Is this accident-related?</label>
                        <select class="form-select" name="preauth_data[is_accident_related]" id="jubAccidentRelated"
                            onchange="toggleJubileeAccident()">
                            <option value="no">No</option>
                            <option value="yes">Yes</option>
                        </select>
                    </div>
                </div>
            </div>
            <div id="jubileeAccidentSection" style="display: none;">
                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">Date of Accident</label>
                            <input type="date" class="form-control" name="preauth_data[accident_date]">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">Type of Accident</label>
                            <select class="form-select" name="preauth_data[accident_type]">
                                <option value="">Select Type</option>
                                <option value="RTA">Road Traffic Accident</option>
                                <option value="Work">Work-related</option>
                                <option value="Home">Home Accident</option>
                                <option value="Assault">Assault</option>
                                <option value="Other">Other</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">Police Report Number</label>
                            <input type="text" class="form-control" name="preauth_data[police_report_no]"
                                placeholder="If applicable">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Specialty Charges Table -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-money-dollar-circle-line me-2"></i>Specialty Charges Breakdown</h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered">
                    <thead class="table-light">
                        <tr>
                            <th>Specialty</th>
                            <th>Doctor Name</th>
                            <th>Registration/License No.</th>
                            <th>Estimated Charges (KES)</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong>Physician</strong></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[physician_name]" placeholder="Dr. Name"></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[physician_license]" placeholder="License No."></td>
                            <td><input type="number" step="0.01" class="form-control form-control-sm" name="preauth_data[physician_charges]" placeholder="0.00" onchange="calculateJubileeTotalCharges()"></td>
                        </tr>
                        <tr>
                            <td><strong>Surgeon</strong></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[surgeon_name]" placeholder="Dr. Name"></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[surgeon_license]" placeholder="License No."></td>
                            <td><input type="number" step="0.01" class="form-control form-control-sm" name="preauth_data[surgeon_charges]" placeholder="0.00" onchange="calculateJubileeTotalCharges()"></td>
                        </tr>
                        <tr>
                            <td><strong>Anesthetist</strong></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[anesthetist_name]" placeholder="Dr. Name"></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[anesthetist_license]" placeholder="License No."></td>
                            <td><input type="number" step="0.01" class="form-control form-control-sm" name="preauth_data[anesthetist_charges]" placeholder="0.00" onchange="calculateJubileeTotalCharges()"></td>
                        </tr>
                        <tr>
                            <td><strong>Other Specialist</strong></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[other_specialist_name]" placeholder="Dr. Name"></td>
                            <td><input type="text" class="form-control form-control-sm" name="preauth_data[other_specialist_license]" placeholder="License No."></td>
                            <td><input type="number" step="0.01" class="form-control form-control-sm" name="preauth_data[other_specialist_charges]" placeholder="0.00" onchange="calculateJubileeTotalCharges()"></td>
                        </tr>
                        <tr class="table-secondary">
                            <td colspan="3"><strong>Total Specialty Charges</strong></td>
                            <td><input type="number" step="0.01" class="form-control form-control-sm bg-light" name="preauth_data[total_specialty_charges]" id="jubTotalSpecialtyCharges" readonly placeholder="0.00"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- Hospital Services Estimate -->
    <div class="card mb-4">
        <div class="card-header bg-light">
            <h6 class="mb-0"><i class="ri-hospital-line me-2"></i>Hospital Services Estimate</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Room & Board (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[room_board_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Theatre (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[theatre_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Pharmacy (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[pharmacy_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Laboratory (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[laboratory_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Radiology (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[radiology_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Supplies (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[supplies_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">Other Services (KES)</label>
                        <input type="number" step="0.01" class="form-control" name="preauth_data[other_services_estimate]"
                            placeholder="0.00" onchange="calculateJubileeHospitalTotal()">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label"><strong>Total Hospital Est. (KES)</strong></label>
                        <input type="number" step="0.01" class="form-control bg-light" name="preauth_data[total_hospital_estimate]"
                            id="jubTotalHospitalEstimate" readonly placeholder="0.00">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
// Jubilee Form Specific JavaScript
function toggleJubileeMaternity() {
    var isMaternity = document.getElementById('jubShowMaternity').checked;
    document.getElementById('jubileeMaternitySection').style.display = isMaternity ? 'block' : 'none';
}

function toggleJubileeAccident() {
    var isAccident = document.getElementById('jubAccidentRelated').value === 'yes';
    document.getElementById('jubileeAccidentSection').style.display = isAccident ? 'block' : 'none';
}

function calculateJubileeTotalCharges() {
    var physician = parseFloat(document.querySelector('input[name="preauth_data[physician_charges]"]').value) || 0;
    var surgeon = parseFloat(document.querySelector('input[name="preauth_data[surgeon_charges]"]').value) || 0;
    var anesthetist = parseFloat(document.querySelector('input[name="preauth_data[anesthetist_charges]"]').value) || 0;
    var other = parseFloat(document.querySelector('input[name="preauth_data[other_specialist_charges]"]').value) || 0;

    var total = physician + surgeon + anesthetist + other;
    document.getElementById('jubTotalSpecialtyCharges').value = total.toFixed(2);
}

function calculateJubileeHospitalTotal() {
    var room = parseFloat(document.querySelector('input[name="preauth_data[room_board_estimate]"]').value) || 0;
    var theatre = parseFloat(document.querySelector('input[name="preauth_data[theatre_estimate]"]').value) || 0;
    var pharmacy = parseFloat(document.querySelector('input[name="preauth_data[pharmacy_estimate]"]').value) || 0;
    var laboratory = parseFloat(document.querySelector('input[name="preauth_data[laboratory_estimate]"]').value) || 0;
    var radiology = parseFloat(document.querySelector('input[name="preauth_data[radiology_estimate]"]').value) || 0;
    var supplies = parseFloat(document.querySelector('input[name="preauth_data[supplies_estimate]"]').value) || 0;
    var other = parseFloat(document.querySelector('input[name="preauth_data[other_services_estimate]"]').value) || 0;

    var total = room + theatre + pharmacy + laboratory + radiology + supplies + other;
    document.getElementById('jubTotalHospitalEstimate').value = total.toFixed(2);
}
</script>
