Add API Q1 CAPA: root cause, corrective action gate, effectiveness verification
Implements tester feedback against API Q1 §5.9.1.2 / §6.4.2: - Root Cause field + 6M Root Cause Category lookup (Man/Machine/Method/ Material/Measurement/Environment), separate from Deviation Detail/Category - "Corrective Action Required?" Yes/No gate on every NCR with a required justification - Corrective action plan with owner + due date; owner is notified by email - Effectiveness verification (result, notes, server-stamped verifier/date) required before an NCR can close when corrective action is required — costing returns 409 listing the missing pieces - Recurring-issue flag with bidirectional NCR-to-NCR links; prior NCRs show a warning when later NCRs reference them - Dashboard metrics: % root cause completed, % CAPA verified effective, avg CAPA close time, overdue CAPA count, NCRs by root cause category - CAPA section in the NCR detail UI, printable PDF, CSV export, and the vw_ncr_full Power BI view; admin list manager for root cause categories - Migrations 0003 (schema + seeded 6M lookup) and 0004 (view refresh); demo seed data exercises every metric Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,61 @@
|
||||
<div class="notes">{{ ncr.inspection_notes }}</div>
|
||||
{% endif %}
|
||||
|
||||
<h2>Corrective & Preventive Action (API Q1)</h2>
|
||||
<table class="fields">
|
||||
<tr>
|
||||
<td class="lbl">Root Cause Category</td>
|
||||
<td>{{ ncr.root_cause_category.name if ncr.root_cause_category else "—" }}</td>
|
||||
<td class="lbl">Recurring Issue</td>
|
||||
<td>
|
||||
{% if ncr.is_recurring %}Yes{% if related_ncr_numbers %} —
|
||||
{{ related_ncr_numbers | join(", ") }}{% endif %}
|
||||
{% else %}No{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lbl">Corrective Action Required</td>
|
||||
<td>
|
||||
{% if ncr.corrective_action_required is none %}<span class="pending">Not answered</span>
|
||||
{% elif ncr.corrective_action_required %}Yes{% else %}No{% endif %}
|
||||
</td>
|
||||
<td class="lbl">Justification</td>
|
||||
<td>{{ ncr.corrective_action_justification or "—" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lbl">Action Owner</td>
|
||||
<td>{{ ncr.corrective_action_owner.display_name if ncr.corrective_action_owner else "—" }}</td>
|
||||
<td class="lbl">Due Date</td>
|
||||
<td>{{ ncr.corrective_action_due_date.strftime("%Y-%m-%d") if ncr.corrective_action_due_date else "—" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lbl">Effectiveness</td>
|
||||
<td>
|
||||
{% if ncr.effectiveness_result == "effective" %}Verified Effective
|
||||
{% elif ncr.effectiveness_result == "not_effective" %}Not Effective
|
||||
{% else %}<span class="pending">Pending verification</span>{% endif %}
|
||||
</td>
|
||||
<td class="lbl">Verified By / At</td>
|
||||
<td>
|
||||
{% if ncr.effectiveness_verified_by %}
|
||||
{{ ncr.effectiveness_verified_by.display_name }} —
|
||||
{{ ncr.effectiveness_verified_at.strftime("%Y-%m-%d %H:%M") }} UTC
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if ncr.root_cause %}
|
||||
<div class="notes"><strong>Root Cause:</strong> {{ ncr.root_cause }}</div>
|
||||
{% else %}
|
||||
<div class="notes pending">No root cause recorded.</div>
|
||||
{% endif %}
|
||||
{% if ncr.corrective_action_plan %}
|
||||
<div class="notes"><strong>Corrective Action Plan:</strong> {{ ncr.corrective_action_plan }}</div>
|
||||
{% endif %}
|
||||
{% if ncr.effectiveness_notes %}
|
||||
<div class="notes"><strong>Verification Notes:</strong> {{ ncr.effectiveness_notes }}</div>
|
||||
{% endif %}
|
||||
|
||||
<h2>Costing</h2>
|
||||
<table class="fields costs">
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user