Skip to content

HA Annual PM Report

The HA Annual PM Report module (roots_hemms_ha_report) produces the Thai-government-format annual preventive maintenance report required by HA Thailand accreditation under มาตรฐานระบบบริการสุขภาพ ด้านที่ 6 ข้อ 6.1.4 (equipment register + risk-based PM with documented evidence).

It aggregates the PM data captured by roots_hemms_pm (Q1), classifies every equipment item against the MoPH 82-device risk-tier table, and produces a locked-on-submit PDF with appendices and a three-signer e-signature page routed through sign_oca (Q4).

Key features

1. One report per (department, fiscal year)

Each report is a hemms.ha.report with a running reference (HA/2026/00001) covering one Thai fiscal year (ปีงบประมาณ พ.ศ., Oct → Sep) and one department. A SQL unique constraint blocks duplicate reports for the same dept × year.

2. MoPH 82-device risk-tier seed

Out of the box, the module ships 82 medical-equipment device classes seeded from the trusted-source MoPH guideline document — แนวทาง ประเมินระดับความเสี่ยงของเครื่องมือแพทย์ฯ (พ.ศ. 2564) published by กองวิศวกรรมการแพทย์, กรมสนับสนุนบริการสุขภาพ. Each class carries the official tier (สูง / กลาง / ต่ำ), PM frequency in months, and recommended PM duration in hours.

The seed is noupdate="1" so hospital edits (adding local devices, adjusting frequencies) survive module upgrades.

3. Three-step risk-tier waterfall on equipment

Every maintenance.equipment gets a Risk Assessment (HA) tab with three classification paths:

  1. Explicit override — engineer judgement (auditable).
  2. MoPH device class — link a class from the seed; tier + frequency inherit automatically.
  3. EM-score worksheet — for off-list equipment, four sliders (Function + Application + Maintenance + History) computed per the WHO Fennigkoh-Smith model. Score ≤12 drops from PM; 13–14→ low, 1×/yr; 15–18→ medium, 2×/yr; ≥19→ high, 3×/yr.

The chosen path is recorded in roots_ha_risk_tier_source so appendix B of the report can prove the provenance for each equipment line.

4. One-click generate wizard

Maintenance → Reporting → Generate HA Annual PM Report:

  1. Pick fiscal year + department.
  2. Wizard shows the resolved period + a live count of in-scope equipment.
  3. Click Generate → a fully populated report draft is created with one line per piece of equipment, pm_planned_count derived from frequency, pm_actual_count counted from closed preventive maintenance.request inside the fiscal-year window.
  4. Engineer reviews lines, fills exception reasons for any not-done items, submits.

5. Audit-defensible lock-on-submit

action_submit() builds an immutable JSON snapshot containing every line's denormalised data, the full MoPH device-class table at the moment of submission, and a paperformat fingerprint. The QWeb template reads from the snapshot for any submitted/archived report — surveyor reprints stay byte-identical even years later, even if equipment data or the MoPH table change.

Line writes/unlinks after submit raise UserError. Reset-to-Draft (manager only) clears the snapshot and unfreezes for re-editing.

6. e-Signature via Q4 sign_oca bridge

A Send for Signature button on submitted reports spawns a sign.oca.request with three signers — BME Head, Engineering Head, Hospital Director. The pre-flight refuses when any signer slot is empty or has no linked partner. Signing happens in-app for internal signers or via portal email for the Director.

When all three sign, the Q5.9 _check_signed super-extension writes the signed PDF to roots_signed_pdf and posts it to chatter. The header badge flips from 🟡 รอลงนาม to 🟢 ลงนามครบ. State stays submitted — signing is a parallel facet, NOT a state transition (matches the Q4 e-Signature OQ3 decision).

7. Thai-government-format PDF

The QWeb template renders 7 sections, A4 portrait, TH Sarabun:

  1. ปก (Cover) — dept, fiscal year, period, reference, status.
  2. บทสรุปผู้บริหาร — total equipment, tier counts, planned vs actual PM, compliance %.
  3. ตารางครุภัณฑ์ + ผลการบำรุงรักษา — 11-column per-equipment detail.
  4. รายการครุภัณฑ์ที่ไม่ได้ทำตามแผน — exceptions with reasons (rendered only if any lines are fail/not_done).
  5. ภาคผนวก ก — MoPH 82-device classification table.
  6. ภาคผนวก ข — EM-score worksheet for equipment using the EM path (rendered only when applicable).
  7. หน้าลงนาม — paper-style empty signature boxes when unsigned; 🟢 ลงนามครบ banner when signed PDF is set.

When to use this module

  • Required for HA Thailand accreditation. Surveyors ask for this document on day 1 of an HA visit.
  • Pairs with the existing ปจป. Asset Inspection report. Together they cover both year-end compliance artifacts a Thai public hospital must produce — equipment register evidence (ปจป.) and PM evidence (HA Annual).
  • Replaces 2–4 weeks of manual Excel reconciliation. Per-year. Per department.

Trusted source

แนวทางประเมินระดับความเสี่ยงของเครื่องมือแพทย์ที่ต้องการการบำรุงรักษา และกำหนดความถี่ในการตรวจสอบและบำรุงรักษาเชิงป้องกันตามรอบเวลา (พ.ศ. 2564) — กองวิศวกรรมการแพทย์, กรมสนับสนุนบริการสุขภาพ, กระทรวงสาธารณสุข, co-developed with บริษัท อาร์เอฟเอส (รามาธิบดี / ม.มหิดล) and ECRI APAC.

Module dependencies

Layer Module
Q1 roots_hemms_pm — PM event source
Q3 roots_hemms_service_contracts — indirect via Q4
Q4 roots_hemms_signature — sign_oca bridge primitives
Layer 2 (OCA) maintenance_equipment_ref, maintenance_partner, sign_oca

License: LGPL-3 wrapper over AGPL-3 transitive (sign_oca via Q4). Same boundary pattern as Q2/Q3/Q4.

Next steps