Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 285 additions & 0 deletions sql-scripts/Ward-Admission-LocalSurgery-Card-Templates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
-- Ward Admission Card and Local Surgery Card Document Templates
-- This script creates the default document templates for ward admission and local surgery cards

-- Insert Ward Admission Card Template Type
INSERT INTO document_template_type (id, code, name, created_date, created_user, modified_date, modified_user, retired, retired_date, retired_user, description)
VALUES (
UUID(),
'WARD_ADMISSION_CARD',
'Ward Admission Card',
NOW(),
'system',
NOW(),
'system',
false,
NULL,
NULL,
'Document template for ward admission records with patient, clinical, and discharge information'
);

-- Insert Local Surgery Card Template Type
INSERT INTO document_template_type (id, code, name, created_date, created_user, modified_date, modified_user, retired, retired_date, retired_user, description)
VALUES (
UUID(),
'LOCAL_SURGERY_CARD',
'Local Surgery Card',
NOW(),
'system',
NOW(),
'system',
false,
NULL,
NULL,
'Document template for surgical procedure records with surgical team and operative details'
);

-- Insert Default Ward Admission Card Template
INSERT INTO document_template (
id,
name,
code,
template_type_id,
contents,
is_default,
is_retired,
created_date,
created_user,
modified_date,
modified_user,
description,
department_id,
institution_id
)
SELECT
UUID(),
'Standard Ward Admission Card',
'WARD_ADMISSION_STANDARD',
dtt.id,
CONCAT(
'<div style="font-family: Arial; padding: 20px; border: 1px solid #ccc; max-width: 800px;">',
'<h1 style="text-align: center; margin-bottom: 20px;">WARD ADMISSION CARD</h1>',
'<hr style="border: 1px solid #000;">',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #003366; padding-bottom: 5px;">Patient Information</h3>',
'<table style="width: 100%; border-collapse: collapse; margin: 10px 0;">',
' <tr>',
' <td style="width: 25%; padding: 5px;"><strong>Name:</strong></td>',
' <td style="width: 25%; padding: 5px;">{{name}}</td>',
' <td style="width: 25%; padding: 5px;"><strong>Age:</strong></td>',
' <td style="width: 25%; padding: 5px;">{{age}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>Gender:</strong></td>',
' <td style="padding: 5px;">{{sex}}</td>',
' <td style="padding: 5px;"><strong>Phone:</strong></td>',
' <td style="padding: 5px;">{{phone}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>Address:</strong></td>',
' <td colspan="3" style="padding: 5px;">{{address}}</td>',
' </tr>',
'</table>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #003366; padding-bottom: 5px;">Hospital Record</h3>',
'<table style="width: 100%; border-collapse: collapse; margin: 10px 0;">',
' <tr>',
' <td style="width: 25%; padding: 5px;"><strong>BHT No:</strong></td>',
' <td style="width: 25%; padding: 5px;">{{bht}}</td>',
' <td style="width: 25%; padding: 5px;"><strong>Room/Bed:</strong></td>',
' <td style="width: 25%; padding: 5px;">{{room}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>Date of Admission:</strong></td>',
' <td style="padding: 5px;">{{doa}}</td>',
' <td style="padding: 5px;"><strong>Date of Discharge:</strong></td>',
' <td style="padding: 5px;">{{dod}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>Height:</strong></td>',
' <td style="padding: 5px;">{{height}} cm</td>',
' <td style="padding: 5px;"><strong>Weight:</strong></td>',
' <td style="padding: 5px;">{{weight}} kg</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>BMI:</strong></td>',
' <td style="padding: 5px;">{{bmi}}</td>',
' <td style="padding: 5px;"><strong>BP:</strong></td>',
' <td style="padding: 5px;">{{bp}}</td>',
' </tr>',
'</table>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #003366; padding-bottom: 5px;">Diagnosis & Medical History</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Current Diagnosis:</strong><br>{{dx}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Past Medical History:</strong><br>{{past-dx}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 30px;">',
' <strong>Known Allergies:</strong><br>{{allergies}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #003366; padding-bottom: 5px;">Treatment During Ward Stay</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 80px;">',
' <strong>Routine Medications & Treatment:</strong><br>{{rx}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Procedures Performed:</strong><br>{{procedures}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #003366; padding-bottom: 5px;">Discharge Instructions</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Discharge Medications:</strong><br>{{drx}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Follow-up Investigations:</strong><br>{{ix}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #003366; padding-bottom: 5px;">Clinical Notes</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' {{comments}}',
'</div>',
'',
'<hr style="border: 1px solid #000; margin-top: 30px;">',
'<p style="font-size: 10px; text-align: center; color: #666;">Generated by HMIS - Hospital Management Information System</p>',
'</div>'
),
true,
false,
NOW(),
'system',
NOW(),
'system',
'Default ward admission card with patient info, diagnosis, treatment, and discharge instructions',
NULL,
NULL
FROM document_template_type dtt
WHERE dtt.code = 'WARD_ADMISSION_CARD'
LIMIT 1;

-- Insert Default Local Surgery Card Template
INSERT INTO document_template (
id,
name,
code,
template_type_id,
contents,
is_default,
is_retired,
created_date,
created_user,
modified_date,
modified_user,
description,
department_id,
institution_id
)
SELECT
UUID(),
'Standard Local Surgery Card',
'LOCAL_SURGERY_STANDARD',
dtt.id,
CONCAT(
'<div style="font-family: Arial; padding: 20px; border: 1px solid #c00; max-width: 800px;">',
'<h1 style="text-align: center; margin-bottom: 20px; color: #c00;">SURGICAL PROCEDURE RECORD</h1>',
'<hr style="border: 2px solid #c00;">',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Patient Details</h3>',
'<table style="width: 100%; border-collapse: collapse; margin: 10px 0;">',
' <tr>',
' <td style="width: 25%; padding: 5px;"><strong>Name:</strong></td>',
' <td style="width: 25%; padding: 5px;">{{name}}</td>',
' <td style="width: 25%; padding: 5px;"><strong>Age:</strong></td>',
' <td style="width: 25%; padding: 5px;">{{age}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>Gender:</strong></td>',
' <td style="padding: 5px;">{{sex}}</td>',
' <td style="padding: 5px;"><strong>Phone:</strong></td>',
' <td style="padding: 5px;">{{phone}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 5px;"><strong>BHT No:</strong></td>',
' <td style="padding: 5px;">{{bht}}</td>',
' <td style="padding: 5px;"><strong>Room/Bed:</strong></td>',
' <td style="padding: 5px;">{{room}}</td>',
' </tr>',
'</table>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Pre-Operative Assessment</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Pre-Operative Diagnosis:</strong><br>{{dx}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 30px;">',
' <strong>Height:</strong> {{height}} cm | <strong>Weight:</strong> {{weight}} kg | <strong>BMI:</strong> {{bmi}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Surgical Procedure</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 80px;">',
' <strong>Surgery Type & Details:</strong><br>{{procedures}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Date of Surgery:</strong><br>{{surgery-date}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Surgical Team</h3>',
'<table style="width: 100%; border: 1px solid #ddd; border-collapse: collapse; margin: 10px 0;">',
' <tr style="background-color: #f5f5f5;">',
' <td style="width: 30%; padding: 10px; border: 1px solid #ddd;"><strong>Surgeon (Performed By):</strong></td>',
' <td style="width: 70%; padding: 10px; border: 1px solid #ddd;">{{surgery-performed-by}}</td>',
' </tr>',
' <tr>',
' <td style="padding: 10px; border: 1px solid #ddd;"><strong>Anesthesiologist (Anesthesia By):</strong></td>',
' <td style="padding: 10px; border: 1px solid #ddd;">{{anesthesia-by}}</td>',
' </tr>',
' <tr style="background-color: #f5f5f5;">',
' <td style="padding: 10px; border: 1px solid #ddd;"><strong>Surgical Assistant (Assistant By):</strong></td>',
' <td style="padding: 10px; border: 1px solid #ddd;">{{assistant-by}}</td>',
' </tr>',
'</table>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Intra-Operative Details</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 80px;">',
' <strong>Operative Findings & Procedure Notes:</strong><br>{{comments}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Implants/Materials/Supplies Used:</strong><br>{{implants-used}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Intra-Operative Complications</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px; background-color: #fff3cd;">',
' {{complications}}',
'</div>',
'',
'<h3 style="margin-top: 20px; border-bottom: 2px solid #c00; padding-bottom: 5px;">Post-Operative Instructions</h3>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Post-Operative Medications:</strong><br>{{drx}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Follow-up Investigations:</strong><br>{{ix}}',
'</div>',
'<div style="border: 1px solid #ddd; padding: 10px; margin: 10px 0; min-height: 50px;">',
' <strong>Post-Operative Notes & Care Instructions:</strong><br>{{post-op-notes}}',
'</div>',
'',
'<hr style="border: 2px solid #c00; margin-top: 30px;">',
'<p style="font-size: 10px; text-align: center; color: #666;">Generated by HMIS - Hospital Management Information System</p>',
'</div>'
),
true,
false,
NOW(),
'system',
NOW(),
'system',
'Default local surgery card with surgical team, procedure details, and post-operative instructions',
NULL,
NULL
FROM document_template_type dtt
WHERE dtt.code = 'LOCAL_SURGERY_CARD'
LIMIT 1;

-- Verify Inserts
SELECT 'Verification Results:' as status;
SELECT COUNT(*) as ward_admission_templates FROM document_template WHERE code LIKE 'WARD_ADMISSION_%';
SELECT COUNT(*) as local_surgery_templates FROM document_template WHERE code LIKE 'LOCAL_SURGERY_%';
Loading