Hii
Can you make a hospital ipd file
Shree shankalp Chhattisgarh mission hospital Hardi road chhura
mkdir -p /tmp/workspace/ipd-file && ls /tmp/workspace/ipd-file/
cat << 'PYEOF' > /tmp/workspace/ipd-file/create_ipd.py from docx import Document from docx.shared import Pt, Inches, RGBColor, Cm from docx.enum.text import WD_ALIGN_PARAGRAPH from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL from docx.oxml.ns import qn from docx.oxml import OxmlElement import copy HOSPITAL_NAME = "Shree Shankalp Chhattisgarh Mission Hospital" HOSPITAL_ADDRESS = "Hardi Road, Chhura, Chhattisgarh" HOSPITAL_PHONE = "Phone: _______________ | Emergency: _______________" def set_cell_bg(cell, hex_color): tc = cell._tc tcPr = tc.get_or_add_tcPr() shd = OxmlElement('w:shd') shd.set(qn('w:val'), 'clear') shd.set(qn('w:color'), 'auto') shd.set(qn('w:fill'), hex_color) tcPr.append(shd) def set_col_width(table, col_index, width_cm): for row in table.rows: row.cells[col_index].width = Cm(width_cm) def add_header(doc, title): # Hospital name h = doc.add_paragraph() h.alignment = WD_ALIGN_PARAGRAPH.CENTER run = h.add_run(HOSPITAL_NAME) run.bold = True run.font.size = Pt(16) run.font.color.rgb = RGBColor(0x00, 0x3A, 0x70) # Address a = doc.add_paragraph() a.alignment = WD_ALIGN_PARAGRAPH.CENTER run2 = a.add_run(HOSPITAL_ADDRESS) run2.font.size = Pt(10) run2.font.color.rgb = RGBColor(0x44, 0x44, 0x44) # Phone p = doc.add_paragraph() p.alignment = WD_ALIGN_PARAGRAPH.CENTER run3 = p.add_run(HOSPITAL_PHONE) run3.font.size = Pt(9) # Divider line doc.add_paragraph("โ" * 90) # Section title t = doc.add_paragraph() t.alignment = WD_ALIGN_PARAGRAPH.CENTER run4 = t.add_run(title) run4.bold = True run4.font.size = Pt(13) run4.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF) t.paragraph_format.space_before = Pt(2) # Blue background for title via shading on heading from docx.oxml import OxmlElement from docx.oxml.ns import qn pPr = t._p.get_or_add_pPr() shd = OxmlElement('w:shd') shd.set(qn('w:val'), 'clear') shd.set(qn('w:color'), 'auto') shd.set(qn('w:fill'), '003A70') pPr.append(shd) doc.add_paragraph() def add_field_row(table, label, value="", colspan=False): row = table.add_row() label_cell = row.cells[0] label_cell.text = label label_cell.paragraphs[0].runs[0].bold = True label_cell.paragraphs[0].runs[0].font.size = Pt(9) set_cell_bg(label_cell, 'E8F0FE') if colspan: val_cell = row.cells[1] val_cell.merge(row.cells[-1]) val_cell.text = value val_cell.paragraphs[0].runs[0].font.size = Pt(9) else: val_cell = row.cells[1] val_cell.text = value val_cell.paragraphs[0].runs[0].font.size = Pt(9) return row def section_heading(doc, text): p = doc.add_paragraph() run = p.add_run(f" {text} ") run.bold = True run.font.size = Pt(10) run.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF) pPr = p._p.get_or_add_pPr() shd = OxmlElement('w:shd') shd.set(qn('w:val'), 'clear') shd.set(qn('w:color'), 'auto') shd.set(qn('w:fill'), '1565C0') pPr.append(shd) p.paragraph_format.space_before = Pt(6) p.paragraph_format.space_after = Pt(2) def blank_line(doc): p = doc.add_paragraph() p.paragraph_format.space_before = Pt(0) p.paragraph_format.space_after = Pt(0) # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # CREATE DOCUMENT # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc = Document() # Page margins section = doc.sections[0] section.page_width = Inches(8.27) # A4 section.page_height = Inches(11.69) section.top_margin = Inches(0.5) section.bottom_margin = Inches(0.5) section.left_margin = Inches(0.6) section.right_margin = Inches(0.6) # Default style style = doc.styles['Normal'] style.font.name = 'Arial' style.font.size = Pt(10) # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 1: PATIENT ADMISSION FORM # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ add_header(doc, "IPD PATIENT ADMISSION FORM") # Registration info table (top-right style) reg_table = doc.add_table(rows=1, cols=4) reg_table.style = 'Table Grid' reg_table.alignment = WD_TABLE_ALIGNMENT.CENTER cells = reg_table.rows[0].cells labels = ["IPD No.:", "Admission Date:", "Ward/Bed No.:", "Reg. No.:"] for i, lbl in enumerate(labels): cells[i].paragraphs[0].clear() run = cells[i].paragraphs[0].add_run(f"{lbl} ___________") run.font.size = Pt(9) run.bold = True set_cell_bg(cells[i], 'FFF9C4') doc.add_paragraph() # --- PATIENT DETAILS --- section_heading(doc, "1. PATIENT DETAILS") pt = doc.add_table(rows=0, cols=4) pt.style = 'Table Grid' pt.alignment = WD_TABLE_ALIGNMENT.CENTER def add_4col_row(tbl, items): row = tbl.add_row() for i, (lbl, val) in enumerate(items): c = row.cells[i] c.paragraphs[0].clear() p = c.paragraphs[0] run_lbl = p.add_run(lbl + " ") run_lbl.bold = True run_lbl.font.size = Pt(9) run_val = p.add_run(val if val else "_" * 15) run_val.font.size = Pt(9) set_cell_bg(c, 'FAFAFA') add_4col_row(pt, [("Patient Name:", ""), ("Age:", ""), ("Gender:", " M / F / O"), ("Blood Group:", "")]) add_4col_row(pt, [("Father/Husband Name:", ""), ("Mother Name:", ""), ("DOB:", ""), ("Marital Status:", "")]) add_4col_row(pt, [("Address:", ""), ("", ""), ("City:", ""), ("Pin Code:", "")]) add_4col_row(pt, [("State:", ""), ("Mobile No.:", ""), ("Alternate No.:", ""), ("Aadhar No.:", "")]) add_4col_row(pt, [("Occupation:", ""), ("Religion:", ""), ("Nationality:", ""), ("Language:", "")]) doc.add_paragraph() # --- NEXT OF KIN --- section_heading(doc, "2. NEXT OF KIN / ATTENDANT DETAILS") nok = doc.add_table(rows=0, cols=4) nok.style = 'Table Grid' nok.alignment = WD_TABLE_ALIGNMENT.CENTER add_4col_row(nok, [("Name:", ""), ("Relation:", ""), ("Mobile:", ""), ("Address:", "")]) doc.add_paragraph() # --- ADMISSION DETAILS --- section_heading(doc, "3. ADMISSION DETAILS") ad = doc.add_table(rows=0, cols=4) ad.style = 'Table Grid' ad.alignment = WD_TABLE_ALIGNMENT.CENTER add_4col_row(ad, [("Admitted Under Dr.:", ""), ("Dept./Specialty:", ""), ("Referred By:", ""), ("Ref. Hospital:", "")]) add_4col_row(ad, [("Admission Type:", " Elective / Emergency"), ("Mode of Arrival:", " Walking / Ambulance / Other"), ("Chief Complaint:", ""), ("Duration:", "")]) add_4col_row(ad, [("Provisional Diagnosis:", ""), ("", ""), ("Room Type:", " Gen / Semi / Private"), ("Payment Type:", " Cash / Insurance / Gov")]) doc.add_paragraph() # --- INSURANCE / GOVT SCHEME --- section_heading(doc, "4. INSURANCE / GOVT. SCHEME DETAILS") ins = doc.add_table(rows=0, cols=4) ins.style = 'Table Grid' ins.alignment = WD_TABLE_ALIGNMENT.CENTER add_4col_row(ins, [("Scheme Name:", ""), ("Policy / Card No.:", ""), ("Insurer Name:", ""), ("Valid Upto:", "")]) doc.add_paragraph() # --- DECLARATION --- section_heading(doc, "5. PATIENT / ATTENDANT DECLARATION") decl_para = doc.add_paragraph() decl_para.add_run( "I/We hereby give consent for the medical treatment, investigations and procedures as deemed necessary by the treating doctor(s). " "I/We agree to abide by the hospital rules and regulations. I/We understand that the hospital authorities shall not be responsible " "for any valuables kept with the patient. I/We undertake to clear all dues before discharge." ) decl_para.runs[0].font.size = Pt(9) doc.add_paragraph() sig_table = doc.add_table(rows=1, cols=3) sig_table.style = 'Table Grid' for i, lbl in enumerate(["Patient Signature / Thumb Impression", "Attendant Signature & Name", "Admitting Staff Signature & Date"]): c = sig_table.rows[0].cells[i] c.paragraphs[0].clear() c.add_paragraph() c.add_paragraph() p = c.add_paragraph(lbl) p.runs[0].bold = True p.runs[0].font.size = Pt(9) p.alignment = WD_ALIGN_PARAGRAPH.CENTER # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 2: CLINICAL CASE SHEET # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "CLINICAL CASE SHEET / HISTORY & EXAMINATION") # Patient ID strip id_strip = doc.add_table(rows=1, cols=5) id_strip.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Date: ___________"]): c = id_strip.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() section_heading(doc, "PRESENTING COMPLAINTS") comp_table = doc.add_table(rows=6, cols=3) comp_table.style = 'Table Grid' comp_table.rows[0].cells[0].paragraphs[0].add_run("S.No.").bold = True comp_table.rows[0].cells[1].paragraphs[0].add_run("Complaint").bold = True comp_table.rows[0].cells[2].paragraphs[0].add_run("Duration").bold = True set_cell_bg(comp_table.rows[0].cells[0], 'BBDEFB') set_cell_bg(comp_table.rows[0].cells[1], 'BBDEFB') set_cell_bg(comp_table.rows[0].cells[2], 'BBDEFB') for i in range(1, 6): comp_table.rows[i].cells[0].paragraphs[0].add_run(str(i)) doc.add_paragraph() section_heading(doc, "HISTORY OF PRESENT ILLNESS") hist_table = doc.add_table(rows=5, cols=1) hist_table.style = 'Table Grid' for row in hist_table.rows: row.cells[0].paragraphs[0].add_run(" " * 120) doc.add_paragraph() section_heading(doc, "PAST MEDICAL HISTORY") pmh_table = doc.add_table(rows=1, cols=6) pmh_table.style = 'Table Grid' for i, item in enumerate(["DM: Y/N", "HTN: Y/N", "IHD: Y/N", "Asthma: Y/N", "TB: Y/N", "Other: _______"]): c = pmh_table.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(item) run.font.size = Pt(9) doc.add_paragraph() section_heading(doc, "DRUG / ALLERGY HISTORY") allergy_table = doc.add_table(rows=1, cols=2) allergy_table.style = 'Table Grid' allergy_table.rows[0].cells[0].paragraphs[0].add_run("Known Allergies: ").bold = True allergy_table.rows[0].cells[1].paragraphs[0].add_run("Current Medications: ") doc.add_paragraph() section_heading(doc, "FAMILY HISTORY") fh_table = doc.add_table(rows=1, cols=1) fh_table.style = 'Table Grid' fh_table.rows[0].cells[0].paragraphs[0].add_run(" " * 120) doc.add_paragraph() section_heading(doc, "PERSONAL / SOCIAL HISTORY") psh = doc.add_table(rows=1, cols=5) psh.style = 'Table Grid' for i, item in enumerate(["Smoking: Y/N", "Alcohol: Y/N", "Tobacco: Y/N", "Diet: Veg/Non-Veg", "Occupation: ___________"]): psh.rows[0].cells[i].paragraphs[0].add_run(item).font.size = Pt(9) # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 3: GENERAL EXAMINATION & VITALS # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "GENERAL EXAMINATION & VITAL SIGNS") # Patient ID strip id_strip2 = doc.add_table(rows=1, cols=5) id_strip2.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Date: ___________"]): c = id_strip2.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() section_heading(doc, "GENERAL PHYSICAL EXAMINATION") gpe = doc.add_table(rows=0, cols=4) gpe.style = 'Table Grid' add_4col_row(gpe, [("Built:", " Well / Average / Poor"), ("Nourishment:", " Well / Average / Poor"), ("Conscious:", " Yes / No"), ("Co-operative:", " Yes / No")]) add_4col_row(gpe, [("Pallor:", " Yes / No"), ("Icterus:", " Yes / No"), ("Cyanosis:", " Yes / No"), ("Clubbing:", " Yes / No")]) add_4col_row(gpe, [("Lymphadenopathy:", " Yes / No"), ("Edema:", " Yes / No"), ("JVP:", ""), ("Dehydration:", " Yes / No")]) doc.add_paragraph() section_heading(doc, "VITAL SIGNS") vt = doc.add_table(rows=0, cols=4) vt.style = 'Table Grid' add_4col_row(vt, [("Pulse Rate (/min):", ""), ("Blood Pressure:", " / mmHg"), ("Resp. Rate (/min):", ""), ("Temperature:", " ยฐF / ยฐC")]) add_4col_row(vt, [("SpO2 (%):", ""), ("Weight (kg):", ""), ("Height (cm):", ""), ("BMI:", "")]) add_4col_row(vt, [("GCS Score:", " E / V / M"), ("Pain Score (0-10):", ""), ("Blood Sugar (RBS):", " mg/dL"), ("Urine Output:", "")]) doc.add_paragraph() section_heading(doc, "SYSTEMIC EXAMINATION") for sys_name in ["CVS (Cardiovascular System):", "RS (Respiratory System):", "P/A (Per Abdomen):", "CNS (Central Nervous System):", "Local Examination:"]: p = doc.add_paragraph() run = p.add_run(sys_name) run.bold = True run.font.size = Pt(9) lines_tbl = doc.add_table(rows=2, cols=1) lines_tbl.style = 'Table Grid' for row in lines_tbl.rows: row.cells[0].paragraphs[0].add_run(" " * 120) doc.add_paragraph() section_heading(doc, "PROVISIONAL / WORKING DIAGNOSIS") diag_tbl = doc.add_table(rows=3, cols=1) diag_tbl.style = 'Table Grid' for row in diag_tbl.rows: row.cells[0].paragraphs[0].add_run(" " * 120) doc.add_paragraph() sig2 = doc.add_table(rows=1, cols=2) sig2.style = 'Table Grid' sig2.rows[0].cells[0].paragraphs[0].add_run("Examining Doctor Name & Signature:").bold = True sig2.rows[0].cells[1].paragraphs[0].add_run("Date & Time:").bold = True # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 4: INVESTIGATION / LAB ORDERS # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "INVESTIGATION REQUEST & REPORTS") id_strip3 = doc.add_table(rows=1, cols=5) id_strip3.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Date: ___________"]): c = id_strip3.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() section_heading(doc, "LABORATORY INVESTIGATIONS") lab_tbl = doc.add_table(rows=1, cols=5) lab_tbl.style = 'Table Grid' for i, hdr in enumerate(["S.No.", "Investigation Name", "Date Ordered", "Result / Value", "Normal Range"]): c = lab_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') common_labs = [ "CBC (Complete Blood Count)", "Hb%", "TLC / DLC", "Platelet Count", "Blood Sugar - FBS / PPBS / RBS", "HbA1c", "Serum Creatinine", "Blood Urea", "Serum Electrolytes (Na / K / Cl)", "LFT (Liver Function Tests)", "Lipid Profile", "Thyroid Profile (T3/T4/TSH)", "Urine R/E & M/E", "Urine Culture & Sensitivity", "Blood Culture & Sensitivity", "Serum Calcium / Phosphorus", "Coagulation Profile (PT/APTT/INR)", "Serum Uric Acid", "CRP / ESR", "Other: _______________" ] for idx, lab in enumerate(common_labs, 1): row = lab_tbl.add_row() row.cells[0].paragraphs[0].add_run(str(idx)).font.size = Pt(9) row.cells[1].paragraphs[0].add_run(lab).font.size = Pt(9) doc.add_paragraph() section_heading(doc, "RADIOLOGY & IMAGING INVESTIGATIONS") img_tbl = doc.add_table(rows=1, cols=4) img_tbl.style = 'Table Grid' for i, hdr in enumerate(["S.No.", "Investigation", "Date", "Findings / Report"]): c = img_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') imaging = ["X-Ray Chest (PA View)", "X-Ray (Other): ___________", "Ultrasound Abdomen/Pelvis", "ECG (12-Lead)", "ECHO (Echocardiogram)", "CT Scan: _______________", "MRI: ___________________", "Other: _______________"] for idx, img in enumerate(imaging, 1): row = img_tbl.add_row() row.cells[0].paragraphs[0].add_run(str(idx)).font.size = Pt(9) row.cells[1].paragraphs[0].add_run(img).font.size = Pt(9) # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 5: DOCTOR'S ORDER SHEET / TREATMENT # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "DOCTOR'S ORDER SHEET / TREATMENT CHART") id_strip4 = doc.add_table(rows=1, cols=5) id_strip4.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Date: ___________"]): c = id_strip4.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() section_heading(doc, "MEDICAL ORDERS") orders_tbl = doc.add_table(rows=1, cols=5) orders_tbl.style = 'Table Grid' for i, hdr in enumerate(["Date & Time", "Drug / Order Details", "Dose / Route / Freq.", "Doctor Signature", "Nurse Signature"]): c = orders_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for _ in range(15): row = orders_tbl.add_row() for cell in row.cells: cell.paragraphs[0].add_run(" ") doc.add_paragraph() section_heading(doc, "IV FLUID / INFUSION CHART") iv_tbl = doc.add_table(rows=1, cols=6) iv_tbl.style = 'Table Grid' for i, hdr in enumerate(["Date/Time", "IV Fluid / Drug", "Volume (mL)", "Rate (mL/hr)", "Start Time", "End Time"]): c = iv_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for _ in range(8): iv_tbl.add_row() # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 6: NURSING NOTES & INTAKE/OUTPUT # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "NURSING NOTES & INTAKE / OUTPUT CHART") id_strip5 = doc.add_table(rows=1, cols=5) id_strip5.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Date: ___________"]): c = id_strip5.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() section_heading(doc, "NURSING NOTES") nursing_tbl = doc.add_table(rows=1, cols=4) nursing_tbl.style = 'Table Grid' for i, hdr in enumerate(["Date", "Time", "Nursing Observation / Intervention", "Nurse Signature"]): c = nursing_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for _ in range(12): nursing_tbl.add_row() doc.add_paragraph() section_heading(doc, "INTAKE / OUTPUT CHART") io_tbl = doc.add_table(rows=1, cols=7) io_tbl.style = 'Table Grid' for i, hdr in enumerate(["Date/Time", "Oral (mL)", "IV (mL)", "Total Intake (mL)", "Urine (mL)", "Others (mL)", "Total Output (mL)"]): c = io_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for _ in range(8): io_tbl.add_row() # Balance row bal_row = io_tbl.add_row() bal_row.cells[0].paragraphs[0].add_run("24-Hr Balance:").bold = True set_cell_bg(bal_row.cells[0], 'FFF9C4') # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 7: DAILY PROGRESS NOTES # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "DAILY PROGRESS NOTES") id_strip6 = doc.add_table(rows=1, cols=5) id_strip6.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Diagnosis: ___________"]): c = id_strip6.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() prog_tbl = doc.add_table(rows=1, cols=4) prog_tbl.style = 'Table Grid' for i, hdr in enumerate(["Date & Time", "Subjective (S) / Objective (O)\nAssessment (A) / Plan (P)", "Vitals", "Doctor Signature"]): c = prog_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True c.paragraphs[0].runs[0].font.size = Pt(9) set_cell_bg(c, 'BBDEFB') for _ in range(10): row = prog_tbl.add_row() row.cells[0].height = Cm(2) for j, cell in enumerate(row.cells): cell.paragraphs[0].add_run(" " * 5) # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 8: OPERATION/PROCEDURE RECORD # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "OPERATION / PROCEDURE RECORD") id_strip7 = doc.add_table(rows=1, cols=5) id_strip7.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Ward: _______", "Date: ___________"]): c = id_strip7.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'E3F2FD') doc.add_paragraph() section_heading(doc, "PRE-OPERATIVE / PRE-PROCEDURE DETAILS") preop = doc.add_table(rows=0, cols=4) preop.style = 'Table Grid' add_4col_row(preop, [("Name of Procedure:", ""), ("Scheduled Date/Time:", ""), ("Surgeon:", ""), ("Anesthetist:", "")]) add_4col_row(preop, [("Pre-op Diagnosis:", ""), ("", ""), ("Anesthesia Type:", " GA / LA / SA / Epidural"), ("ASA Grade:", "")]) add_4col_row(preop, [("Pre-op Investigations Done:", " Yes / No"), ("Consent Taken:", " Yes / No"), ("Fasting Since:", ""), ("Pre-med Given:", "")]) doc.add_paragraph() section_heading(doc, "INTRA-OPERATIVE DETAILS") intraop = doc.add_table(rows=0, cols=4) intraop.style = 'Table Grid' add_4col_row(intraop, [("Operation Start Time:", ""), ("Operation End Time:", ""), ("Total Duration:", ""), ("Blood Loss (mL):", "")]) add_4col_row(intraop, [("Procedure Performed:", ""), ("", ""), ("Implants Used:", ""), ("Specimen Sent:", "")]) add_4col_row(intraop, [("Intra-op Complications:", ""), ("", ""), ("Blood Transfusion:", " Yes / No - Units:"), ("Drain Placed:", " Yes / No")]) doc.add_paragraph() section_heading(doc, "POST-OPERATIVE DETAILS") postop_notes = doc.add_table(rows=4, cols=1) postop_notes.style = 'Table Grid' for row in postop_notes.rows: row.cells[0].paragraphs[0].add_run(" " * 100) doc.add_paragraph() sig_op = doc.add_table(rows=1, cols=3) sig_op.style = 'Table Grid' for i, lbl in enumerate(["Surgeon Signature:", "Anesthetist Signature:", "Scrub Nurse Signature:"]): sig_op.rows[0].cells[i].paragraphs[0].add_run(lbl).bold = True # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 9: CONSENT FORMS # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "INFORMED CONSENT FORMS") section_heading(doc, "GENERAL TREATMENT CONSENT") c1 = doc.add_paragraph() c1.add_run( "I, _________________________, hereby voluntarily consent to the treatment, nursing care, investigations, " "medical/surgical procedures, and other hospital services as deemed necessary by the treating physician(s) " "at Shree Shankalp Chhattisgarh Mission Hospital, Chhura, for the patient named " "_________________________.\n\n" "I understand that the practice of medicine is not an exact science and that no guarantees can be made. " "I have been explained the nature of the treatment and the risks involved." ).font.size = Pt(9) doc.add_paragraph() sig3 = doc.add_table(rows=1, cols=3) sig3.style = 'Table Grid' for i, lbl in enumerate(["Patient / Guardian Signature:", "Witness Signature:", "Doctor Signature & Date:"]): sig3.rows[0].cells[i].paragraphs[0].add_run(lbl + "\n\n").bold = True doc.add_paragraph() section_heading(doc, "OPERATION / ANAESTHESIA CONSENT") c2 = doc.add_paragraph() c2.add_run( "I, _________________________, give my voluntary consent for the operation / procedure named: " "_________________________. I have been informed about the nature of the procedure, expected benefits, " "possible risks and complications including anaesthesia risks, and alternative treatments. " "I consent to blood transfusion if necessary, and to the use of photographic/video documentation for teaching purposes." ).font.size = Pt(9) doc.add_paragraph() sig4 = doc.add_table(rows=1, cols=3) sig4.style = 'Table Grid' for i, lbl in enumerate(["Patient / Guardian Signature:", "Witness Signature:", "Surgeon Signature & Date:"]): sig4.rows[0].cells[i].paragraphs[0].add_run(lbl + "\n\n").bold = True doc.add_paragraph() section_heading(doc, "DO NOT RESUSCITATE (DNR) / HIGH RISK CONSENT (If Applicable)") c3 = doc.add_paragraph() c3.add_run( "The patient / family has been informed about the critical condition and the prognosis. " "We understand the risks. The decision regarding resuscitation has been discussed and documented below.\n\n" "Decision: ____________________________________________________________\n\n" "Family Representative Name: ___________________________ Relation: _______________" ).font.size = Pt(9) doc.add_paragraph() sig5 = doc.add_table(rows=1, cols=3) sig5.style = 'Table Grid' for i, lbl in enumerate(["Family Signature:", "Witness:", "Doctor Signature & Date:"]): sig5.rows[0].cells[i].paragraphs[0].add_run(lbl + "\n\n").bold = True # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 10: DISCHARGE SUMMARY # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "DISCHARGE SUMMARY") id_strip8 = doc.add_table(rows=1, cols=5) id_strip8.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Admission Date:", "Discharge Date:"]): c = id_strip8.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'FFF9C4') doc.add_paragraph() section_heading(doc, "PATIENT & ADMISSION DETAILS") disch1 = doc.add_table(rows=0, cols=4) disch1.style = 'Table Grid' add_4col_row(disch1, [("Treated Under Dr.:", ""), ("Department:", ""), ("Room / Ward:", ""), ("Total Stay (Days):", "")]) add_4col_row(disch1, [("Final Diagnosis:", ""), ("", ""), ("Secondary Diagnosis:", ""), ("", "")]) add_4col_row(disch1, [("Procedures Done:", ""), ("", ""), ("Surgery (if any):", ""), ("", "")]) doc.add_paragraph() section_heading(doc, "HISTORY & CLINICAL SUMMARY") hs_tbl = doc.add_table(rows=5, cols=1) hs_tbl.style = 'Table Grid' for row in hs_tbl.rows: row.cells[0].paragraphs[0].add_run(" " * 100) doc.add_paragraph() section_heading(doc, "INVESTIGATIONS SUMMARY") inv_sum = doc.add_table(rows=1, cols=3) inv_sum.style = 'Table Grid' for i, hdr in enumerate(["Investigation", "Result / Value", "Remarks"]): c = inv_sum.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for _ in range(7): inv_sum.add_row() doc.add_paragraph() section_heading(doc, "TREATMENT GIVEN DURING STAY") tt_tbl = doc.add_table(rows=1, cols=4) tt_tbl.style = 'Table Grid' for i, hdr in enumerate(["Drug / Treatment", "Dose", "Route", "Duration"]): c = tt_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for _ in range(8): tt_tbl.add_row() doc.add_paragraph() section_heading(doc, "CONDITION AT DISCHARGE") cond_tbl = doc.add_table(rows=0, cols=4) cond_tbl.style = 'Table Grid' add_4col_row(cond_tbl, [("General Condition:", " Stable / Improved / Critical"), ("Pulse:", ""), ("BP:", ""), ("SpO2:", "")]) add_4col_row(cond_tbl, [("Discharge Type:", " Cured / Improved / LAMA / Refer / Expired"), ("", ""), ("Referred To:", ""), ("", "")]) doc.add_paragraph() section_heading(doc, "DISCHARGE MEDICATIONS (Prescription)") rx_tbl = doc.add_table(rows=1, cols=5) rx_tbl.style = 'Table Grid' for i, hdr in enumerate(["S.No.", "Drug Name", "Dose", "Frequency", "Duration"]): c = rx_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') for idx in range(1, 11): row = rx_tbl.add_row() row.cells[0].paragraphs[0].add_run(str(idx)).font.size = Pt(9) doc.add_paragraph() section_heading(doc, "ADVICE ON DISCHARGE") adv_tbl = doc.add_table(rows=6, cols=1) adv_tbl.style = 'Table Grid' advices = [ "1. Diet: ___________________________________________", "2. Activity: ________________________________________", "3. Wound Care: _____________________________________", "4. Follow-up Date: __________________________________", "5. Review Investigations: ____________________________", "6. Special Instructions: _____________________________" ] for i, adv in enumerate(advices): adv_tbl.rows[i].cells[0].paragraphs[0].add_run(adv).font.size = Pt(9) doc.add_paragraph() sig_final = doc.add_table(rows=1, cols=3) sig_final.style = 'Table Grid' for i, lbl in enumerate(["Treating Doctor Signature & Stamp:", "Patient / Attendant Signature:", "Nurse In-Charge Signature:"]): c = sig_final.rows[0].cells[i] c.paragraphs[0].add_run(lbl + "\n\n\n").bold = True # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # PAGE 11: BILLING SUMMARY # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ doc.add_page_break() add_header(doc, "IPD BILLING SUMMARY") id_strip9 = doc.add_table(rows=1, cols=5) id_strip9.style = 'Table Grid' for i, lbl in enumerate(["Patient Name: _______________", "IPD No.: _______", "Age/Sex: ___", "Admission Date:", "Discharge Date:"]): c = id_strip9.rows[0].cells[i] c.paragraphs[0].clear() run = c.paragraphs[0].add_run(lbl) run.font.size = Pt(8) run.bold = True set_cell_bg(c, 'FFF9C4') doc.add_paragraph() bill_tbl = doc.add_table(rows=1, cols=4) bill_tbl.style = 'Table Grid' for i, hdr in enumerate(["S.No.", "Service / Item Description", "Quantity / Days", "Amount (โน)"]): c = bill_tbl.rows[0].cells[i] c.paragraphs[0].add_run(hdr).bold = True set_cell_bg(c, 'BBDEFB') bill_items = [ "Room / Bed Charges", "Doctor Consultation / Visit Charges", "Nursing Charges", "Laboratory Investigation Charges", "Radiology / Imaging Charges", "OT (Operation Theatre) Charges", "Anaesthesia Charges", "Surgeon Charges", "Medicine / Pharmacy Charges", "IV Fluid & Consumable Charges", "Procedure / Dressing Charges", "ICU / HDU Charges (if applicable)", "Ambulance Charges", "Other Charges: _______________" ] for idx, item in enumerate(bill_items, 1): row = bill_tbl.add_row() row.cells[0].paragraphs[0].add_run(str(idx)).font.size = Pt(9) row.cells[1].paragraphs[0].add_run(item).font.size = Pt(9) row.cells[2].paragraphs[0].add_run("").font.size = Pt(9) row.cells[3].paragraphs[0].add_run("").font.size = Pt(9) # Subtotal, discount, total rows for lbl in ["Sub Total", "Discount (if any)", "Insurance / Govt. Scheme Deduction", "Amount Paid (Advance)", "Net Amount Payable"]: row = bill_tbl.add_row() row.cells[0].merge(row.cells[1]).merge(row.cells[2]) merged = row.cells[0] merged.paragraphs[0].clear() run = merged.paragraphs[0].add_run(lbl) run.bold = True run.font.size = Pt(10) set_cell_bg(merged, 'E8F0FE') row.cells[1].paragraphs[0].add_run("โน _______________").font.size = Pt(10) doc.add_paragraph() amt_words = doc.add_paragraph() amt_words.add_run("Amount in Words: ").bold = True amt_words.add_run("______________________________________________________________") doc.add_paragraph() sig_bill = doc.add_table(rows=1, cols=3) sig_bill.style = 'Table Grid' for i, lbl in enumerate(["Cashier / Billing Staff Signature:", "Patient / Attendant Signature:", "Hospital Seal & Authorized Signature:"]): sig_bill.rows[0].cells[i].paragraphs[0].add_run(lbl + "\n\n").bold = True # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # SAVE DOCUMENT # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ output_path = "/tmp/workspace/ipd-file/IPD_File_Shree_Shankalp_Hospital.docx" doc.save(output_path) print(f"SUCCESS: Saved to {output_path}") PYEOF python3 /tmp/workspace/ipd-file/create_ipd.py
IPD File Shree Shankalp Hospital
Word Document ยท DOCX
| Page | Section |
|---|---|
| 1 | Patient Admission Form - Registration, patient details, next of kin, admission type, insurance/govt scheme, declaration & signatures |
| 2 | Clinical Case Sheet - Presenting complaints, history of present illness, past medical history, allergy, family & social history |
| 3 | General Examination & Vitals - GPE, vital signs, systemic examination, provisional diagnosis |
| 4 | Investigation Request Sheet - Lab tests (CBC, LFT, RFT, etc.) + radiology/imaging orders with result columns |
| 5 | Doctor's Order Sheet - Medical orders table + IV fluid/infusion chart |
| 6 | Nursing Notes & I/O Chart - Nursing observations + 24-hour intake/output tracking |
| 7 | Daily Progress Notes - SOAP format progress notes |
| 8 | Operation/Procedure Record - Pre-op, intra-op, post-op details |
| 9 | Consent Forms - General consent, Operation/Anaesthesia consent, DNR/High Risk consent |
| 10 | Discharge Summary - Clinical summary, investigations, discharge medications, advice |
| 11 | Billing Summary - Itemized billing with totals, discount, insurance deduction |