Commit Graph

92 Commits

Author SHA1 Message Date
414dc42c05 fix(diagnosis): resolve print template placeholders and base64 logo rendering
- Support hospital, patient, doctor, and date placeholders matching template variables
- Convert local logo and signature paths to base64 Data URIs for mPDF
- Apply token replacement to report body in single and compiled prints
- Add interactive placeholder toolbar in diagnosis template settings view
- Add unit tests in tests/unit/DiagnosisTemplateTokenTest.php
2026-10-03 02:45:22 +05:30
3f1e89d4be Fix IPD patient admit search error, add admission type filters to IPD patient list, remove redundant sidebar links, and add OPD Day Care template support 2026-09-23 10:12:42 +05:30
6e78e6010e feat: add Day Care & Emergency admission module with IPD conversion and clean patient names
- Add Day Care (<24h) and Emergency (Casualty) admission pathways with prefixes DC- and ER-
- Add dedicated physical wards, ESI 5-level triage, MLC tracking, and PADSS day care discharge
- Implement audited 'Convert to IPD' workflow with SBAR handover and automated bed transfer
- Support unified IPD billing with dedicated group headers for Day Care and Emergency charges
- Redesign Hospital Admission Desk with executive card layout and modern triage controls
- Add comprehensive user documentation and SVG flowchart in public/help.html
- Completely remove legacy patient_master.p_lname column from database and application code
2026-09-21 23:41:24 +05:30
ca6926015a fix(medical-store): remove third-party brand Marg from application and replace with generic Excel/CSV import 2026-09-10 04:58:59 +05:30
765286e7fa feat(medical-store): ABDM-compatible multi-building pharmacy, POS desktop keyboard workflow, unit dispensing, and split payments 2026-09-08 02:19:11 +05:30
5db3da6403 fix(setting): prevent standard form submit redirect on save button by using explicit AJAX functions and action=javascript:void(0) 2026-08-30 02:55:13 +05:30
31b2319419 feat(admin): add OPD Queue TV Settings panel for right-side ads upload, left-side bottom ad space, ticker text editing, and TTS pronunciation fixes 2026-08-30 02:49:59 +05:30
a6beb124cd feat(doctor): add Doctor App PIN auth, QR generator, DoctorCare EMR PWA (/app/doctor), and bedside clinical tools 2026-08-28 19:44:54 +05:30
7b0b1c3415 feat(auth): add Nurse PIN Security Authentication, App QR Codes, and Lock Screen for NursingCare PWA 2026-08-28 18:45:53 +05:30
69f0e1fa45 feat(nursing): add Nursing Station Master, ABDM credentials to Nurse Master, and Visual Bed Grid at /ipd/patient 2026-08-28 02:43:37 +05:30
7c04828e99 feat(ipd): align IPD Discharge prescribed medicine form design and autotext with OPD Consult 2026-08-27 04:33:10 +05:30
7ec5149ccf feat(ipd): manage admission examination fields
Add an Admin CRUD master for IPD admission examination fields with enabled state, display order, field types, and select options.
2026-08-24 00:53:01 +05:30
1fec6c8677 Add IPD discharge template builder 2026-08-18 15:18:13 +05:30
aee50cb52f Rebuild IPD discharge template selection 2026-08-18 14:28:27 +05:30
4ca463cc1e feat: add payment editing and fix discharge templates 2026-08-10 14:48:33 +05:30
9872e1c726 refactor: show management status as toasts
Route User Management and Role Master action results through fixed top-right notifications, including SPA partial responses, validation failures, session actions, and network errors.
2026-08-09 23:58:59 +05:30
8f25904a13 refactor: streamline user permission management
Move per-user permissions into row actions, add contextual module permission guides, show selected-user details, and relocate online sessions to the profile menu.
2026-08-09 23:45:35 +05:30
c263b9e4ac feat: add role and session access controls
Add configurable role management, expanded project permission coverage, secured module routes, and single-active-session enforcement with online user administration.
2026-08-09 23:21:16 +05:30
5f443f307a Enhance patient search and enforce refer master validation 2026-08-07 12:24:48 +05:30
780ebaa263 feat: add referral search to patient and IPD flows
Load referral master data into patient registration/edit screens, persist patient referby, expose searchable referral inputs in patient and IPD forms, and make referral title editable as free text in referral master CRUD.
2026-08-07 11:18:50 +05:30
dcc366444b feat: show New Update Available badge when GitHub has newer commits
- Add checkForUpdates() with 10-minute cached GitHub API check
- Add fetchLatestCommitInfo() to get latest commit SHA + message from GitHub API
- Save deployed commit SHA to writable/deployed_commit.txt after each deploy
- Invalidate update cache on successful deploy so next check is always fresh
- Button turns yellow + red NEW badge when update available
- Show commit message and short SHA diff (deployed → latest) in alert
- Show green 'Up to date' with deployed SHA when already current
- GitHub API rate limit safe: checks once per 10 mins via file cache
2026-08-04 04:03:09 +05:30
41f07357d2 fix: clean up orphaned running entries, add timeout handling
- Remove initial 'running' history entry (orphans when PHP times out)
- Add purgeStaleRunning() to mark old 'running' entries as 'timeout' on next deploy
- Add set_time_limit(300) to prevent PHP timeout during large ZIP download
- Add timestamps to log file entries for easier debugging
- Include ZIP size and source URL in success detail
- History now keeps last 20 entries (was 12)
- Show dash instead of blank for entries with no detail
- Style 'timeout' status same as 'failed' (red pill)
2026-08-04 03:59:38 +05:30
3fed2b6740 fix: prevent modal hang/fade by moving it outside refreshable panel div
- Move detail modal from system_ops_panel.php to system_ops.php
- Modal is now outside #systemOpsPanel so panel refresh never destroys it
- Skip refreshPanel() while modal is open (prevents backdrop desync)
- Add hidden.bs.modal handler to clean up lingering backdrop and body classes
- Fix show.bs.modal handler to correctly read data-detail via jQuery .data()
- Add white-space:pre-wrap to detail content for readable log output
2026-08-04 03:55:27 +05:30
f349b33001 feat: show all network interfaces with type badges (LAN/VPN/Public)
- readNetworkStatus() now returns array of all interfaces instead of single string
- Parses 'ip addr' output (with ifconfig fallback) for all IPv4 interfaces
- Each interface classified as LAN / VPN / Public by name and IP range
- VPN detected by interface prefix: wg*, tun*, tap*, vpn*
- RFC1918 ranges (192.168.x, 10.x, 172.16-31.x) shown as LAN
- Display: icon + IP + interface name badge + type label per row
- Handles NAT servers showing both local LAN and VPN IPs simultaneously
2026-08-04 03:45:51 +05:30
1073ab8aca feat: graphical RAID display, remove server action buttons
- Remove Restart Web, Restart PHP-FPM, Shutdown, Reboot buttons
- Remove runServerAction() library method and action() controller
- Remove /system-ops/action route (no longer needed)
- Parse /proc/mdstat into structured array (name, level, health, drives)
- Show each RAID array as a card with colored drive icons per-slot
- Green drive = healthy, red = failed, blue = spare
- Show rebuild progress bar when array is rebuilding
- Internet status shown as colored badge with wifi icon
- Services shown as colored badges (green=running, grey=other)
2026-08-04 03:39:49 +05:30
eb81f1999f refactor: remove git-based update method, keep only direct GitHub deployment
- Remove 'Update HMS (Git)' button and related functionality
- Remove runUpdate() method from SystemOperations
- Remove update() controller method
- Remove /setting/admin/system-ops/update route
- Remove setup_git_config.sh (no longer needed)
- Keep 'Deploy from GitHub' button as the only update method
- Rationale: Direct GitHub deployment is more reliable and requires no git config

Result: Single, simpler deployment method that always works
2026-08-04 03:27:22 +05:30
f3b8e28312 feat: add direct GitHub deployment as alternative to git pull
- New 'Deploy from GitHub' button downloads latest code directly
- No git configuration required - more reliable for git-unfriendly servers
- Automatically syncs changed files (skips .git, vendor, writable)
- Both methods available: git pull (if configured) or direct GitHub download
- Each has a clear confirmation dialog explaining the method
- Handles temporary extraction and cleanup automatically

This solves HMS deployment when git is not accessible to PHP process
2026-08-04 03:17:46 +05:30
4d7ae0d669 docs: add HMS feature presentation (HTML + Markdown)
- HMS_FEATURES_PRESENTATION.html: full styled presentation with cover,
  professional introduction, 11 feature sections, tech stack, compliance,
  print/PDF button, and proper @media print A4 layout
- HMS_FEATURES_PRESENTATION.md: plain Markdown version of the same content
- system_ops.php: fix confirm dialog text for Update HMS button
2026-08-04 02:02:26 +05:30
155c3ec4b5 feat: add error details modal to update history
- Added "Details" column to Update History table
- Shows info icon button when error details are available
- Clicking button opens a modal with full error message
- Details displayed in pre-formatted text for easy reading
- Helps diagnose why HMS updates failed or timed out

When an update fails, users can now click the info icon to see the exact
git error output, making troubleshooting much easier.
2026-08-03 17:03:23 +05:30
f9c0fd1a72 fix: simplify HMS update to only git pull and add timeout protection
Update improvements:
- Renamed button from "Update System" to "Update HMS"
- Changed update to run only 'git pull' (removed database migrations)
- Added 60-second timeout to prevent system hangup
- Better error messages for timeouts and failures
- Logs update status (running/success/failed/timeout) to history
- Confirmation dialog now says "Pull latest HMS code from repository?"

This ensures quick updates without long-running migrations that could hang
the admin interface. Database migrations can be run separately as needed.
2026-08-03 17:00:21 +05:30
3720da9b16 feat: add visual progress bars to resource usage and improve CPU detection
Resource Usage improvements:
- Added visual progress bars for CPU, RAM, and Disk usage
- Progress bars use Bootstrap styling (success/info/warning colors)
- Display percentage and detailed metrics (e.g., RAM 4 / 128 MB (3%))
- Bars animate smoothly with CSS transitions

CPU detection enhancements:
- Added fallback to /proc/stat parsing when shell commands unavailable
- Added fallback to PHP getrusage() for CPU time estimation
- CPU now displays even when shell_exec is disabled
- Graceful fallback chain ensures data is always available

Progress bar styling:
- Success (green) for CPU
- Info (blue) for RAM
- Warning (orange/yellow) for Disk
- All bars styled with height, rounded corners, and smooth transitions
2026-08-03 16:56:50 +05:30
096ce5e199 feat: add System Operations tile to admin dashboard and include helper library
- Added System Operations link to Admin dashboard (app/Views/Setting/Admin/index.php)
- Uses load_form_div to load the system operations page inline
- Added SystemOperations library for server status collection and actions
- Tile uses server icon (bi-server) and appears in the admin panel grid
- Link: javascript:load_form_div(base_url('setting/admin/system-ops'), 'maindiv', 'System Operations')
2026-08-03 16:50:00 +05:30
89b862db31 feat: add admin system operations panel with AJAX refresh and server monitoring
- Added SystemOps controller with index and panel endpoints for dynamic content refresh
- Created system_ops_panel.php fragment for AJAX-based UI updates (no full page reload)
- Implemented 30-second auto-refresh using AJAX instead of location.reload()
- Fixed health badge contrast by adding explicit dark text color (#1f2937)
- Added jQuery availability checks to prevent script errors on page load
- Included server overview, resource usage, services, events, and update history
- Integrated delegated event handlers for action buttons (Update, Restart, Reboot, Shutdown)
- All buttons are protected with confirmation dialogs
- Layout maintains NiceAdmin card styling and responsive design

Routes added:
- GET /admin/system-ops/panel - returns panel fragment for refresh
2026-08-03 16:47:41 +05:30
e473be3ae7 Fix diagnosis print template dual-PDF flow and settings save bug
- Diagnosis.php: resolve doctor mapping via ABDM Report Doctor Mapping,
  compile pathology/diagnosis reports into separate Letter Head and
  Plain Paper PDFs, add compiled-pdf-links endpoint
- Routes.php: add diagnosis/compiled-pdf-links route
- pathology_detail.php: render/persist dual compiled PDF buttons
- Setting/Template.php: per-modality Letter Head / Plain Paper template
  mapping via hospital_setting keys
- Setting/Template/index.php: fix tile links using load_form (which only
  replaces #main) instead of load_form_div, which broke every internal
  AJAX reload (template type switch, modality switch, reset) on the
  diagnosis/discharge/document print template settings pages
- diagnosis_print_settings.php: fix corrupted watermark_alpha number
  input (missing step attribute) that silently blocked form submission
  for templates with non-integer-step legacy values
2026-08-03 02:43:50 +05:30
49d83dd105 Add PATIENT_TITLE discharge placeholder 2026-08-01 16:13:13 +05:30
49a2027778 fix(discharge-template): prevent empty template payload on ajax save 2026-07-31 17:46:27 +05:30
a5219bca2d ABDM Gateway settings: add admin UI toggle for SSL certificate verification
Adds a 'Verify SSL Certificate' switch on Admin -> ABDM Gateway page,
persisted as hospital_setting.ABDM_BRIDGE_SSL_VERIFY (default ON/secure).
Wired into M3HiuGatewayClient, EAtriaBridgeConnector, and the settings
page's own Test Connection check. Per-machine ABDM_BRIDGE_SSL_VERIFY env
var still overrides this DB setting for deployments needing a quick
local-only workaround. Verification stays on by default everywhere;
disabling it is an explicit, visible opt-in with an on-page warning.
2026-07-28 03:47:06 +05:30
540de8c76e Enhance camera capture/edit permissions and fix OPD AdviceBlock rendering 2026-07-08 15:24:39 +05:30
191c25de68 Refine discharge placeholders and status heading 2026-06-11 10:24:04 +05:30
c0f7e213e6 Discharge templates: add status heading token and refine placeholders 2026-06-11 09:57:04 +05:30
328de6279d Fix: Disable auto-generation of discharge templates + add manual creation button
ISSUE: Templates auto-regenerate when deleted
User deletes template ID 3, page reload creates template ID 4 automatically

ROOT CAUSE: ensureDefaultDischargeTemplateSeeded() called on EVERY page load
- discharge_templates() method called it on every view
- getDischargeTemplateRows() called it on every discharge PDF generation
- When count=0, it auto-inserted default templates
- Made it impossible to delete all templates

SOLUTION: Changed to manual opt-in template creation

1. Removed auto-seeding calls:
   - Setting/Template::discharge_templates() - removed ensureDefaultDischargeTemplateSeeded()
   - Ipd_discharge::getDischargeTemplateRows() - removed ensureDefaultDischargeTemplateSeeded()
   - Both now only call ensureDischargeTemplateTable() (structure check only)

2. Added manual template creation:
   - New 'Create Default Templates' button shown when table is empty
   - New endpoint: discharge_templates_seed() - creates defaults on demand
   - Route: POST /setting/template/discharge_templates_seed
   - Button confirms before creating, shows success message, reloads page

3. Preserved seeding functions:
   - ensureDefaultDischargeTemplateSeeded() kept but not auto-called
   - Can be manually triggered via new button
   - Creates 'Default Discharge Template' and 'NABH Compliant Discharge Summary'

BEHAVIOR NOW:
- Users can delete ALL templates - they stay deleted
- Empty table shows helpful message with creation button
- Templates only created when user explicitly requests them
- No more surprise template regeneration

TESTING:
- Delete all templates
- Page reloads showing empty table with button
- Click 'Create Default Templates'
- 2 templates created (ID 1 and 2)
2026-06-07 11:38:18 +05:30
d923dc6c29 Fix: Template delete page refresh + add debug logging
ISSUE: Template delete returns success but record appears not deleted

ROOT CAUSE: Delete WAS working (verified in database), but page wasn't refreshing properly after success

CHANGES:

1. JavaScript fix (discharge_templates.php):
   - Replaced conditional load_form_div / location.assign logic
   - Now uses simple location.reload() after 500ms delay
   - Ensures page always refreshes after successful delete

2. Controller debug logging (Template.php):
   - Added comprehensive debug logs to trace delete flow
   - Logs: request ID, row fetch, query compilation, affected rows
   - Logs error codes and messages for troubleshooting
   - Will help diagnose future issues

VERIFIED:
- Database confirmed template ID 2 was deleted
- Only frontend refresh was failing
- Now forces reload to show updated list
2026-06-07 11:32:24 +05:30
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