Commit Graph

797 Commits

Author SHA1 Message Date
3036b2189f Add failure-path diagnostics for OPD scan upload/list 2026-08-07 14:15:47 +05:30
a1a06c5dee Fix OPD scan list for live schema/path differences 2026-08-07 13:41:32 +05:30
4f906424a6 Add migration for refer master address fields 2026-08-07 12:36:02 +05:30
d5c7d1030c Show patient grid controls and scope datatable search to filtered results 2026-08-07 12:32:21 +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
bedb1c922a Show old UHID in patient search results 2026-08-06 08:46:54 +05:30
dd36e3af54 Fix patient search old UHID matching 2026-08-06 08:43:25 +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
b2fdf9751d test: add deployment verification test file
This file is used to verify the GitHub deployment feature works.
- Deployed via 'Deploy from GitHub' button
- Tests that files sync correctly from GitHub to live server
- Use presence of this file to confirm deployment success

Verification: Check live server for /var/www/html/hms_etria/TEST_DEPLOYMENT.txt
2026-08-04 03:23:05 +05:30
518b92ee46 fix: add missing routes for system-ops updateDirect and diagnose endpoints
- Add POST route for /setting/admin/system-ops/updateDirect
- Add GET route for /setting/admin/system-ops/diagnose
- Both endpoints were implemented but routes were missing

This fixes 'Request failed' error on Deploy from GitHub button
2026-08-04 03:20:01 +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
cb4636e599 feat: add detailed git diagnostics endpoint
- New /setting/admin/system-ops/diagnose endpoint
- Shows git binary location, version, config values
- Includes file permissions and directory checks
- Displays actual git command outputs with exit codes
- Provides troubleshooting commands for setup

This helps debug git configuration issues without guessing
2026-08-04 03:13:59 +05:30
cc4ee09906 refactor: use local repository git config instead of global
- Skip problematic global .gitconfig in /var/www
- Use local repository config (.git/config) instead
- Avoids permission issues with /var/www directory
- Public repos don't need global config
- Simpler 4-step process with better error handling
2026-08-04 03:11:43 +05:30
b5950d48e3 fix: ensure .gitconfig created with www-data ownership from start
- Create .gitconfig as www-data user (not root)
- Ensures file has correct owner and permissions from creation
- Add fallback to use local repository git config if global fails
- Prevents 'could not lock config file' permission errors

This fixes the issue where www-data user cannot write to root-owned files
2026-08-04 03:10:06 +05:30
0e597b47da simplify: optimize setup script for public repositories
For public repos, only minimal git config needed:
- Fix corrupted .gitconfig file
- Set git user.name and user.email (required by git)
- Remove unnecessary SSL and SSH configuration
- Fix directory permissions for www-data user
- Test git status

Removed:
- SSH key setup (not needed for public repos)
- SSL verification config (not needed for public HTTPS)
- HTTPS remote URL configuration (already correct)

Updated from 8 steps to 5 simpler steps
2026-08-04 03:08:19 +05:30
a01771fa4d fix: handle corrupted .gitconfig file permissions
- Remove corrupted /var/www/.gitconfig file
- Create fresh .gitconfig with correct owner (www-data)
- Set proper permissions (600) before git config commands
- This prevents 'could not lock config file' permission errors
2026-08-04 03:06:41 +05:30
9156bb2ebd improve: comprehensive git diagnostics and automated setup script
Enhanced error reporting:
- Show detailed diagnostic information: git version, user config, email, remote, branch
- Check .git directory and config file existence
- Detect if repository has uncommitted changes
- Error categorization: PERMISSION, CONFIG, REPO, NETWORK, SSL, GIT errors
- Actionable error messages with command suggestions
- Report raw error output to log file for debugging

Added setup_git_config.sh script:
- Automated configuration for www-data user
- Creates .ssh directory with proper permissions
- Sets git user.name and user.email globally
- Disables SSL verification (for HTTPS repos)
- Configures git to use HTTPS remote URL
- Fixes directory ownership and permissions
- Tests git status to verify configuration

Usage on live server:
  sudo bash setup_git_config.sh

This script handles the common git configuration issues
that prevent 'Update HMS' button from working.
2026-08-04 03:04:53 +05:30
8f9920e71c improve: enhanced git status error messages with full diagnostics
Better error message handling:
- Show actual error output from git status
- Detect specific issues: missing config, SSL certs, repository corruption
- Parse error patterns for user-friendly messages
- Include git version, config, and remote info in error response

Added getGitDiagnostics() method:
- Returns git version
- Checks git config user.name and user.email
- Shows configured remote URL
- Displays current branch
- Helps diagnose setup issues

Error message now includes: [git version, user name, remote URL]
Helps users identify: missing user config, wrong remote, SSH vs HTTPS issues
2026-08-04 03:01:43 +05:30
ca570d6366 fix: resolve git command not found by checking common installation paths
- Added findGitCommand() method to check for git in common locations:
  * /usr/bin/git (standard Linux)
  * /bin/git (alternative location)
  * /usr/local/bin/git (compiled from source)
  * Falls back to 'which git' and 'command -v git'

- Uses absolute git path in all shell commands
- Fixes 'Git command not found' error on systems where git is not in PATH
- No dependencies added, uses PHP file_exists() + is_executable() checks
2026-08-04 02:59:42 +05:30
a024f89205 improve: enhanced git pull error handling with detailed diagnostics
Pre-checks before git pull:
- Verify .git directory exists
- Check if git command is available
- Run git status to detect permission/connectivity issues

Better error messages for common failures:
- Permission denied → 'Git directory may not be writable'
- Authentication failed → 'SSH keys may not be configured for www-data'
- Connection refused → 'GitHub server unreachable'
- fatal errors → Parse and return specific error details

Returns actual error message instead of generic 'Check logs for details'
2026-08-04 02:56:58 +05:30
b352bc9ff0 test: create test file for git pull verification
This file can be used to verify that the 'Update HMS' button successfully
pulls from GitHub on the live server. If this file appears in your remote
server directory after git pull, the update mechanism is working correctly.
2026-08-04 02:54:30 +05:30
87bf2d8368 improve: add 8-method fallback for internet connectivity check
- Method 1: ping to Google DNS (8.8.8.8)
- Method 2: DNS resolution via nslookup
- Method 3: DNS query using dig
- Method 4: curl HTTP HEAD to google.com
- Method 5: wget --spider
- Method 6: fsockopen to Google DNS (8.8.8.8:53)
- Method 7: curl to Cloudflare DNS (1.1.1.1)
- Method 8: PHP gethostbyname() for DNS resolution

Tries multiple DNS providers (Google, Cloudflare, Quad9)
Falls back to 'Offline' only if all methods fail
Handles firewalls, ICMP blocks, and missing commands
2026-08-04 02:50:23 +05:30
998eb7f2bf improve: add 6-method fallback for server IP detection
- Method 1: \['SERVER_ADDR'] from Apache/Nginx (most reliable)
- Method 2: /sbin/ip (absolute path, works if ip not in PATH)
- Method 3: Parse /proc/net/route for default gateway interface + IP
- Method 4: hostname -I (space-separated IPs)
- Method 5: ifconfig (fallback for older systems)
- Method 6: Socket connection to 8.8.8.8 (pure PHP, no shell commands)

Each method validates IP and skips loopback (127.x, ::1, ::ffff:127.x)
Fixes 'Unavailable' when shell commands fail or aren't available
2026-08-04 02:47:36 +05:30
1ade027b00 fix: prioritize real server IP, skip loopback (127.x, ::1)
- Changed primary method to: ip -4 addr show scope global (gets public/private IPs only)
- Added isLoopbackIp() helper to filter out loopback addresses (127.* and ::1)
- Fallback: hostname -I with loopback filtering
- Last resort: gethostbyname() with loopback check
- On remote server with eth0: 159.89.175.190, will now show public IP instead of 127.0.0.1
2026-08-04 02:45:01 +05:30
a4bccc765c fix: show server IP address in Network field instead of "Unavailable"
Three-level fallback chain:
1. gethostbyname(gethostname()) - PHP built-in, works on Linux and Windows
2. ip -4 addr show scope global | grep inet - Linux shell fallback
3. hostname -I - Linux shell secondary fallback

All results validated with FILTER_VALIDATE_IP before display.
2026-08-04 02:40:33 +05:30
bb8ed60216 fix: repair broken @media print CSS and add PDF tips modal
- Fixed split @media print blocks that caused all print rules to be orphaned
  (gallery section had added its own block which broke the main rules)
- Consolidated into one clean @media print block with proper A4 settings
- Print improvements: cover fills page 1, intro on page 2, each section
  starts on new page, screenshots print at fixed height, 3-col gallery grid
- Added "How to save as PDF" button with step-by-step modal overlay
- Steps guide: Destination → Save as PDF, A4 Portrait, Background graphics
- Both print bar buttons hidden in @media print
- @page: A4 portrait, 14mm/12mm/18mm margins, first page margin 0
2026-08-04 02:30:38 +05:30
7c63e738e8 feat: add real screenshots and complete module reference table from Word doc
Screenshots gallery:
- Replaced placeholder icons with 11 real PNG screenshots extracted from
  E-AtriaHMS.docx (Dashboard, Patient Search, ABHA Create, ABHA Register,
  IPD Billing Panel, OPD Queue, Bed Status Map, Charge Master, Stock Control,
  Report Panel, Admin Panel)
- Added new ABHA Register card showing 4 registration methods (Number,
  Scan ABHA QR, Scan Facility QR, Mobile OTP)
- Added new IPD Billing Panel card showing full tabbed panel layout
- Lightbox now opens real images on click
- Screenshots saved to public/assets/img/screenshots/image*.png

Module Reference Table (section 10):
- Added 25-row complete module reference table derived from Word document
- Covers Registration through Web/Cross-platform including LIS, RIS, OT,
  Emergency, Daycare, ABDM Dashboard, AI, Doctor's Workspace, RBAC
2026-08-04 02:26:16 +05:30
1f0f7566e8 feat: add screenshot gallery section to HMS presentation
- Added 9-card screenshot gallery section between intro and features
- Cards for: Dashboard, Patient Management, ABHA Creation, OPD Queue,
  Bed Status Map, Charge Master/Insurance Rates, Stock Control Center,
  Report Panel, Admin Panel
- Lightbox overlay for full-screen image viewing (keyboard Escape to close)
- Placeholder icons shown now; replace with real images by dropping PNGs
  into public/assets/img/screenshots/ and updating src on each card
- Added gallery CSS with hover lift effect and lightbox styles
- Print-friendly: lightbox hidden in @media print
2026-08-04 02:17:26 +05:30
0e6cf1664d feat: add HMS Features link on login page
- Added "View HMS Features & Capabilities" link below the login card
- Copied HMS_FEATURES_PRESENTATION.html to public/ so it is accessible
  via base_url without auth (same pattern as software-use-license.html)
- Link opens in a new tab
2026-08-04 02:05:09 +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
232bf3ef8a fix: add PHP built-in function fallbacks for system operations when shell_exec is disabled
When shell_exec() is disabled on the server (common in production), the system
operations panel now gracefully falls back to PHP built-in functions:

- gethostname() for hostname instead of shell 'hostname' command
- php_uname() for OS info instead of shell 'uname -a' command
- /proc/uptime parsing or unavailable status for uptime
- disk_free_space() and disk_total_space() for disk usage
- memory_get_usage() and PHP memory limit for memory usage
- Improved parsePhpMemoryLimit() to handle memory limit parsing

This ensures the admin panel shows meaningful information even in restricted
production environments where shell_exec is disabled for security reasons.
2026-08-03 16:52:46 +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
37631c27a0 Improve patient search for legacy UHID values 2026-08-03 15:32:16 +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
f57da52725 Refine IPD bill group row colspan and bold styling 2026-08-01 16:44:55 +05:30
6be0df028e Highlight IPD bill group headers and subtotals 2026-08-01 16:36:54 +05:30
b1846696a4 Prevent stale cached IPD bill PDF responses 2026-08-01 16:28:27 +05:30
71a7875fe1 Format IPD bill print group headers and subtotals 2026-08-01 16:21:22 +05:30
49d83dd105 Add PATIENT_TITLE discharge placeholder 2026-08-01 16:13:13 +05:30
53bc924c06 Polish IPD bill labels and wording 2026-08-01 16:05:16 +05:30