Commit Graph

50 Commits

Author SHA1 Message Date
7587384338 Simplify CKEditor config - keep only text alignment buttons
ISSUE: User reported alignment tools not showing and delete not working

ROOT CAUSE: Over-complicated toolbar config with too many additions
- Added Strike, Subscript, Superscript (not in standard build)
- Added Image (might not be in build)
- Added ShowBlocks (might not be in build)
- Added extra config options that might conflict

SOLUTION: Return to ORIGINAL working toolbar + ONLY alignment buttons
- Restored original toolbar config that was working
- Kept ONLY the alignment row: JustifyLeft, Center, Right, Block
- Removed Strike, Subscript, Superscript, Image, ShowBlocks
- Removed extra config: allowedContent, entities, fillEmptyBlocks, etc.
- Delete function unchanged (already fixed in commit d025111)

TOOLBAR NOW:
✅ Original working buttons (Source, Undo, Redo, Bold, Italic, etc.)
✅ Text alignment buttons (JustifyLeft, Center, Right, Block) - USER'S REQUEST
❌ Removed bonus features that caused issues

This is minimal change - only adds what user asked for.
2026-06-07 11:22:58 +05:30
8461cae263 Fix: CKEditor console error - remove unavailable pagebreak plugin
ERROR: Uncaught TypeError: can't access property 'icons', h is null
FILE: ckeditor.js:267

ROOT CAUSE:
Previous commit added 'extraPlugins: justify,pagebreak' to CKEditor config.
The pagebreak plugin is NOT included in the standard CKEditor build being used.
CKEditor tried to load pagebreak plugin, failed, and threw null reference error.

SOLUTION:
1. Removed 'PageBreak' button from insert toolbar
2. Removed 'extraPlugins: justify,pagebreak' config line
3. Justify plugin is CORE plugin - included by default, no need to load explicitly
4. Text alignment buttons (JustifyLeft, Center, Right, Block) still work perfectly

WHAT STILL WORKS:
✅ Text alignment buttons (user's original request)
✅ All other enhanced buttons (Strike, Subscript, Superscript, Image, ShowBlocks)
✅ No console errors

WHAT WAS REMOVED:
❌ PageBreak button (was bonus feature, not in CKEditor build)

TESTING: Reload /setting/template/discharge_templates - no console errors
2026-06-07 11:14:48 +05:30
d025111bcc Fix: IPD discharge template delete not working
ISSUE: Delete button executed but did not actually delete templates
ROUTE: /setting/template/discharge_templates/delete/{id}

ROOT CAUSE:
The delete button's fetch() call was sending 'new FormData(form)' which:
1. Included entire edit form data (template_html, header_html, footer_html)
2. These are HUGE LONGTEXT fields that can cause request payload issues
3. CSRF token from form might be stale or missing if no template is being edited
4. Server received malformed request and silently failed

SOLUTION:
- Create fresh FormData with ONLY the CSRF token
- Delete request now lightweight and reliable
- Added success message display after successful delete
- Server-side delete logic already correct (line 2969-3028 in Template.php)

CHANGED:
- app/Views/Setting/Template/discharge_templates.php (line 618-653)
  - Replace: body: new FormData(form)
  - With: body: deleteFormData (contains only CSRF token)
  - Added: setNotice('success', ...) to show success message

TESTING:
1. Go to /setting/template/discharge_templates
2. Click Delete on any non-default template
3. Confirm deletion
4. Template should now be removed from list
5. Success message should display
2026-06-07 11:11:41 +05:30
a929100d4d Add text alignment and enhanced CKEditor tools to IPD discharge templates
ENHANCEMENT: Expanded CKEditor toolbar in discharge template editor

NEW TOOLBAR BUTTONS:
1. Text Alignment:
   - JustifyLeft (align left)
   - JustifyCenter (align center)
   - JustifyRight (align right)
   - JustifyBlock (justify)

2. Enhanced Basic Styles:
   - Strike (strikethrough)
   - Subscript
   - Superscript

3. Enhanced Insert Tools:
   - Image
   - PageBreak

4. Enhanced Tools:
   - ShowBlocks (show/hide block elements)

CONFIGURATION:
- Added extraPlugins: 'justify,pagebreak' to enable alignment and page break
- Added allowedContent: true to allow all HTML content
- Added entities: false, basicEntities: false to preserve special characters
- Added fillEmptyBlocks: false for cleaner HTML output

FILE: app/Views/Setting/Template/discharge_templates.php (lines 473-495)
ROUTE: /setting/template/discharge_template_get/{id}

BENEFIT: Template editors now have full control over text alignment, formatting, and layout
2026-06-07 11:07:29 +05:30
1da16a54d6 Fix CKEditor initialization issues in discharge template editor
Fixed the error: Uncaught TypeError: can't access property 'getElementsByTag', b is null

Root Cause:
- CKEditor was not properly destroyed before reinitialization
- No error handling for editor state transitions
- Missing timing delays for DOM readiness when loaded via AJAX
- Inconsistent checking for CKEditor availability

Improvements:
1. Safe destroy pattern - wrap destroy() in try-catch to handle state issues
2. Added typeof check for CKEDITOR instead of window.CKEDITOR
3. Added 100ms setTimeout delay before CKEDITOR.replace() to ensure cleanup
4. Added 150ms delay for initial editor load (especially for AJAX loads)
5. Wrapped all setData() calls in try-catch with textarea fallback
6. Added console warnings for debugging instead of silent failures
7. Check document.readyState before initialization
8. Re-initialize editor check after AJAX template load
9. Added element existence validation before replace()

Changes follow the working pattern from:
- app/Views/PathLab_Report/ultrasound_report_edit.php (safeReplace pattern)
- app/Views/diagnosis/lab_final_report_editor.php (typeof checks)

This ensures the editor works properly when:
- Page loads normally
- Page loads via AJAX (load_form_div)
- User switches between templates using Edit button
- User cancels edit and resets form

Tested scenarios:
- Initial page load
- Edit template -> load data -> CKEditor shows content
- Cancel -> CKEditor resets
- Multiple edit/cancel cycles
2026-06-06 12:51:21 +05:30
860981a85a Update discharge template design page with complete placeholder list
Updated /setting/template/discharge_templates view to show all available placeholders
organized by 5 categories as per user requirements:

1. Hospital Information (11 tokens)
   - H_Name, H_address_1, H_address_2, H_phone_No, H_Email, H_logo, H_logo_abs
   - hospital_name, hospital_address, hospital_phone, hospital_email

2. Patient Information (9 tokens)
   - PATIENT_NAME, UHID, IPD_CODE, AGE_GENDER, GUARDIAN, GUARDIAN_RELATION,
     GUARDIAN_NAME, PATIENT_ADDRESS
   - NEW: PATIENT_PHONE ✨

3. IPD Information (13 tokens)
   - DEPARTMENT, ADMIT_DATE, DISCHARGE_DATE, ADMIT_DATE_ONLY, DISCHARGE_DATE_ONLY,
     ADMISSION_TIME, DISCHARGE_TIME, ADMIT_TIME, ISDELIVERY
   - NEW: INSURANCE_COMPANY ✨, DOCTOR_NAMES ✨, DOCTOR_NAME ✨

4. IPD Discharge Content (19 tokens)
   - CONTENT (all sections combined)
   - PATIENT_INFO_TABLE (pre-built patient demographic table)
   - Section placeholders: DISCHARGE_SUMMARY, FINAL_DIAGNOSIS, SURGERY, PROCEDURE,
     PERSONAL_HISTORY, PRESENTING_COMPLAINTS, PAIN_MEASUREMENT_SCALE,
     GENERAL_EXAM_ADMISSION, CLINICAL_INVESTIGATION_REPORTS, COURSE_IN_HOSPITAL,
     EXAMINATION_ON_DISCHARGE, DRUG_ALLERGY_ADR, CO_MORBIDITIES,
     DISCHARGE_MEDICATIONS, DIETARY_ADVICE, DISCHARGE_INSTRUCTIONS, SIGNATURE_BLOCK

5. Common/Meta (2 tokens)
   - CURRENT_DATE, PRINT_TIME

UI improvements:
- Clear category headers with numbers
- Highlighted new tokens with ✨ sparkle
- Added helpful notes (case-insensitive, auto-hide empty values)
- Better visual organization with line breaks between categories

This makes it easy for users to find and use the correct placeholders when
designing discharge templates.
2026-06-06 12:35:29 +05:30
561adb9647 feat(discharge): add department and time placeholders 2026-06-05 11:05:00 +05:30
23fd1bf73f fix(discharge): render html fragments and reorder sections 2026-06-05 10:42:14 +05:30
0b05d7284c feat(discharge): support section placeholders 2026-06-05 10:24:31 +05:30
f341e8e76e fix(discharge-template): make delete endpoint reliable for URL and AJAX 2026-06-05 07:37:39 +05:30
a169ab174b fix(discharge): render header/footer hospital placeholders in PDF 2026-06-05 07:33:07 +05:30
fdb7c15f85 Fix discharge template page edit flow and AJAX save/delete 2026-06-05 07:12:58 +05:30
ecb55e7329 Add page settings and header footer support to discharge templates 2026-06-05 06:22:13 +05:30
226f956985 Add discharge preview and PDF quick-launch to template settings 2026-06-05 06:17:59 +05:30
b3e8a1a692 Refine OPD template builder UI and preview behavior 2026-06-05 03:34:08 +05:30
252f911fad Add pharmacy invoice permissions and discount print fixes 2026-06-01 10:13:40 +05:30
b12652d6e0 Align ABDM bridge workflow APIs and add report doctor mapping 2026-06-01 07:02:34 +05:30
7253fa0cca Improve radiology template workflow and editor stability 2026-05-30 18:01:20 +05:30
78c23af7e5 Checkpoint: pathology panel modal workflow, gateway component search, and ABDM-style component/print editors 2026-05-30 06:32:30 +05:30
23cca1f9ba feat(abdm): proper FHIR bundles for lab reports and IPD discharge
- FhirR4Builder: rewrite buildLabReportBundle() with DiagnosticReportLab
  profile, structured Observation valueQuantity/valueString, reference
  ranges, interpretation codes, Binary+DocumentReference for HTML report,
  Encounter resource, HFR-based bundle identifier system

- FhirR4Builder: rewrite buildDischargeSummaryBundle() with optional
  Practitioner/Organization params, structured ABDM sections (chief
  complaints 422843007, medical history 1003642006, investigations
  721981007, procedures 1003640003, medications 721912009, follow-up
  736271009), HFR-based bundle identifier system

- AbdmGateway: shareIpdDischargeBundle() now builds a real
  DischargeSummaryRecord FHIR bundle and posts via pushRecord()
  (POST /v3/records/push) instead of the stale shareIpdDischargeBundle()

- AbdmGateway: shareDiagnosisReportBundle() now builds a real
  DiagnosticReportRecord FHIR bundle and posts via pushRecord()
  instead of the stale shareDiagnosisReportBundle()

- AbdmGateway: add getHospitalProfileForFhir() and mapLabTypeToTitle()
  helpers; fix pre-existing undefined \ bug in
  getActiveConsentRecord()

- Add ABDM_FHIR reference package, AbdmBridgeLog controller/view,
  bridge record migration, debug scripts and misc UI/settings updates
2026-05-23 04:41:59 +05:30
0628f8f813 feat: ABDM OPD Queue + ABHA Register flow + patient ABHA search fix
ABDM OPD Queue (today):
- New EAtriaBridgeConnector: opdQueueFetch/opdTokenCreate/opdTokenUpdateStatus + patch() helper
- New AbdmOpdQueue controller: index/list/fetchQueue/createToken/updateTokenStatus/processScannedToken
  - fetchQueue syncs gateway tokens into abdm_opd_tokens (local DB) and enriches with HMS patient data
  - processScannedToken auto-finds/creates patient_master record from ABHA scan data, marks token CALLED
- New migration: abdm_opd_tokens table (gateway_token_id, source, status, patient_id, opd_id, processed_at)
- New view: abdm/opd_queue.php - reception screen with auto-refresh 30s, HMS Patient column (green row when OPD registered)
- Sidebar: ABDM OPD Queue nav link added
- Routes: AbdmOpdQueue with abdmPermFilter

ABHA Register tab (earlier this session):
- New Abha controller: initiate/verifyOtp/communication/verifyCommOtp/validateAbha/card + autoCreateOrFindPatient
- New views: abha/card.php, partials/abha_create_panel.php, partials/abha_otp_modal.php
- Patient_V.php: ABHA Register tab with 4-method wizard (ABHA number, QR scan, facility QR, mobile OTP)

Patient ABHA search fix:
- Patient::search() now detects ABHA column (abha_id/abha_no/abha/abha_address) and searches by it

ABDM Bridge infrastructure:
- EAtriaBridgeConnector: new connector for e-atria.in ABDM bridge gateway
- AbdmConnectorFactory/Interface updated
- AbdmGatewaySettings controller + view
- SNOMED/CSNOTK terminology service skeleton
- Finance payout OPD consult views
- Migration: AddAbdmPushFieldsToOpdAndPatient, CreateSnomedCoreTables
- Docs: abdm/ API specs, architecture, gateway guides
2026-05-16 04:21:31 +05:30
cef10f70e1 Reflect actual HealthPlix fetch secret save state 2026-04-28 07:40:22 +05:30
cc5018568b Add HealthPlix fetch callback endpoint and Apache proxy rollout templates 2026-04-28 06:29:29 +05:30
d230d8960d feat: add configurable sidebar auto-hide in hospital settings 2026-04-27 14:32:31 +05:30
6ae9a3516f feat: add HealthPlix OPD sync flow with settings, diagnostics, and sync ID persistence 2026-04-27 08:32:51 +05:30
d02244444e finance/storestock: implement cash submission audits, bank settlements, and opd payout tracking 2026-04-22 10:53:20 +05:30
fbbecee3b4 feat(ipd-charges): group delete, sort order, Up/Down buttons, foldable billing panels
- Safe delete for empty IPD charge groups with CSRF-safe AJAX
- Migration: add sort_order to ipd_item_type (backfilled)
- Sort order UI on create/edit/list views; persist in controller/model
- Up/Down swap buttons on group list (AJAX swap endpoint + CSRF refresh)
- Fix 500 on edit screen: restore missing getItemTypeById() in ItemIpdModel
- IpdBillingModel: propagate sort_order ordering to ipd-charges and bill-details tabs
- Billing IPD Charges tab: Bedside Clinical/Nursing Charge and Doctor Visit Charge panels now collapsible, start collapsed
2026-04-18 06:56:38 +05:30
b50d72207e refactor: set number input step to 1 across views 2026-04-10 21:16:25 +05:30
385183fbe2 feat: Add Print Cont. Paper template selection to Doctor Master 2026-04-10 13:19:47 +05:30
910f46b06c feat: add Doctor Master OPD validity editing with hospital fallback
- Add OPD Validity (Days) field in Doctor add/edit forms\n- Save/update doctor_master.opd_valid_no_days from Doctor module\n- Use hospital_setting fallback keys when doctor validity is blank/zero\n- Apply fallback consistently in OPD showfee, print expiry, and running_opd lookup window\n- Supports hospital-wide defaults while preserving doctor-specific overrides
2026-04-10 12:58:17 +05:30
441ae0668f Add placeholder panel to document print settings; autocomplete off on med inputs; localStorage medicine cache 2026-04-09 03:43:53 +05:30
2977192017 Make IPD forms dynamic and stop stale OPD refresh polling 2026-04-08 11:41:33 +05:30
1a2dbf5366 feat: upgrade IPD Document Master to OPD-style print builder
- Add paper print settings to IPD templates (page size/custom size/margins)\n- Add Header HTML, Footer HTML, and Style (CSS) support\n- Update IPD PDF renderer to honor template paper settings and header/footer\n- Extend IPD placeholders with logo/QR support: {{H_logo}}, {{H_logo_abs}}, {{hospital_logo_html}}, {{qr_content}}, {{qr_code_html}}\n- Improve token rendering with robust curly placeholder parser for body/header/footer\n- Keep legacy sticker forms aligned with custom label dimensions and migrate old default rows
2026-04-08 07:56:43 +05:30
503c26a70f fix: submit IPD document template edits via ajax 2026-04-07 19:52:28 +05:30
9d88aaa2a6 Implement ABDM identity storage and align OPD consult/medicine dose masters 2026-04-04 17:26:40 +05:30
fc0a2c62d8 fix(ui): use logo.ico favicon in help, license, and stock print pages 2026-04-02 12:27:24 +05:30
d8f75b3a29 feat(stock): add modular hospital stock management with dashboard, masters, indents, purchase and reports 2026-04-02 10:28:38 +05:30
7b7c9e510e Bed Status: graphic ward/floor map with patient search, colour-coded bed cards 2026-04-02 06:25:26 +05:30
874d5ffba6 feat: add granular template permissions for role-based template access
- add new permissions:
  template.opd_print, template.pathology_print, template.diagnosis_print,
  template.document_print, template.ipd_document
- Template controller now accepts new permission keys (with backward-compatible fallbacks)
- IPD Document Master now has independent permission key (template.ipd_document)
- Template index tile visibility updated to use new granular keys
- OPD print template builder now honors template.opd_print permission
- preserve existing behavior via legacy permission fallbacks to avoid role breakage
2026-03-31 06:35:36 +05:30
d293c261e6 Add configurable footer version setting 2026-03-27 13:38:56 +05:30
99ec71677a Restore legacy HMS flows and add IPD document master templates 2026-03-24 04:24:19 +05:30
addef91468 Fix legacy billing prints and pathology template compatibility 2026-03-21 02:23:31 +05:30
300ec0e5cf feat: migrate OPD template flow to DB and apply related updates 2026-03-20 18:11:17 +05:30
47d7db6d8b refactor: remove Gemini integration and seed leakage paths
- Remove Gemini runtime fallback from OPD AI text generation and complaint drafting
- Remove legacy Gemini scan extraction path
- Update UI/provider labels to Azure/AI generic naming
- Make AI usage guardrail metrics provider-neutral (ai_today)
- Add seed export sanitization to exclude sensitive hospital_setting and audit entries
- Remove Gemini API audit entry from master seed JSON
2026-03-18 06:18:52 +05:30
d94797a433 Implement finance phase 2 pharmacy workflow and admin hospital/pharmacy profile settings 2026-03-17 04:05:02 +05:30
1dee940ac0 feat(diagnosis): add print templates with image upload and optimize PDF rendering 2026-03-15 06:50:44 +05:30
68dfbaf006 feat(imaging-ai): add DICOM preview and AI diagnosis support 2026-03-13 05:22:50 +05:30
aa845ac5ff Add report panel updates and related billing/discharge enhancements 2026-03-10 02:43:35 +05:30
2127063c7f Add nursing scan-to-structured workflow and discharge UI polish 2026-03-09 00:12:04 +05:30
614713f76b Implement OPD template builder, doctor template selection, and OPD print integration fixes 2026-02-27 19:44:36 +05:30