Fix API deploy healthcheck by starting Kestrel before migrate/seed.
CI / backend (push) Canceled after 0s
CI / frontend (push) Canceled after 0s

Compose was marking the API unhealthy because bootstrap blocked app.Run(), so /health/live never answered within the HEALTHCHECK window.
This commit is contained in:
2026-10-04 19:27:21 +08:00
parent d013dd4bb5
commit 7d7332641f
9 changed files with 915 additions and 22 deletions
+11 -4
View File
@@ -73,9 +73,10 @@ jobs:
# Postgres lives on the deploy host's shared-services network and is not
# reachable from act_runner, so the bundle is copied there and executed in
# a one-shot container joined to that network (Host=postgres resolves).
# NOTE: Program.cs also runs db.Database.MigrateAsync() on API startup, so
# this job is a defense-in-depth pre-deploy step using a DDL-privileged
# credential the API container never sees, not the only migration path.
# NOTE: AppBootstrapHostedService also runs db.Database.MigrateAsync() after
# Kestrel listens, so this job is a defense-in-depth pre-deploy step using a
# DDL-privileged credential the API container never sees, not the only
# migration path.
steps:
- uses: actions/checkout@v4
@@ -162,7 +163,13 @@ jobs:
fi
docker compose -f docker-compose.prod.yml --env-file .env pull
docker compose -f docker-compose.prod.yml --env-file .env up -d --remove-orphans
if ! docker compose -f docker-compose.prod.yml --env-file .env up -d --remove-orphans; then
echo "Compose up failed — dumping API status/logs:"
docker inspect --format 'status={{.State.Status}} health={{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' \
vigilcare_records_api || true
docker compose -f docker-compose.prod.yml --env-file .env logs --tail 100 api || true
exit 1
fi
docker image prune -f
EOF
@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Minio;
using Minio.DataModel.Args;
/// <summary>
/// Runs migrate / demo seed / MinIO bucket ensure after Kestrel is listening.
/// Keeping this off the Program.cs path before <c>app.Run()</c> lets Docker's
/// /health/live HEALTHCHECK succeed while dependencies warm up; /health/ready
/// stays gated by <see cref="StartupHealthCheck"/> until this finishes.
/// </summary>
public sealed class AppBootstrapHostedService : BackgroundService
{
private readonly IServiceScopeFactory _scopeFactory;
private readonly StartupHealthCheck _startupHealthCheck;
private readonly IHostApplicationLifetime _lifetime;
private readonly ILogger<AppBootstrapHostedService> _logger;
public AppBootstrapHostedService(
IServiceScopeFactory scopeFactory,
StartupHealthCheck startupHealthCheck,
IHostApplicationLifetime lifetime,
ILogger<AppBootstrapHostedService> logger)
{
_scopeFactory = scopeFactory;
_startupHealthCheck = startupHealthCheck;
_lifetime = lifetime;
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Yield so the generic host can finish starting Kestrel before we block on I/O.
await Task.Yield();
try
{
using var scope = _scopeFactory.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
await db.Database.MigrateAsync(stoppingToken);
await DataSeeder.SeedAsync(db);
var minio = scope.ServiceProvider.GetRequiredService<IMinioClient>();
var minioOpts = scope.ServiceProvider.GetRequiredService<IOptions<MinioOptions>>().Value;
if (!await minio.BucketExistsAsync(
new BucketExistsArgs().WithBucket(minioOpts.BucketName), stoppingToken))
{
await minio.MakeBucketAsync(
new MakeBucketArgs().WithBucket(minioOpts.BucketName), stoppingToken);
_logger.LogInformation("Created MinIO bucket {Bucket}", minioOpts.BucketName);
}
_startupHealthCheck.StartupCompleted = true;
_logger.LogInformation("Application bootstrap completed.");
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
_logger.LogCritical(ex, "Application bootstrap failed — stopping host.");
_lifetime.StopApplication();
}
}
}
+3 -1
View File
@@ -52,7 +52,9 @@ USER app
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
# Liveness only (/health/live). Readiness is asserted by CD smoke (/health/ready).
# start-period covers process + Kestrel bind; migrate/seed no longer block listen.
HEALTHCHECK --interval=10s --timeout=5s --start-period=40s --retries=6 \
CMD curl -fsS http://localhost:8080/health/live || exit 1
ENTRYPOINT ["dotnet", "VigilCareRecordsAPI.dll"]
@@ -0,0 +1,25 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;
/// <summary>
/// Tracks whether one-shot startup work (migrate / seed / MinIO bucket) has finished.
/// Tagged on /health/ready and /health/startup so probes stay unhealthy until bootstrap completes.
/// </summary>
public sealed class StartupHealthCheck : IHealthCheck
{
private volatile bool _completed;
public bool StartupCompleted
{
get => _completed;
set => _completed = value;
}
public Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context, CancellationToken cancellationToken = default)
{
return Task.FromResult(
_completed
? HealthCheckResult.Healthy("Startup completed.")
: HealthCheckResult.Unhealthy("Startup still running."));
}
}
+13 -17
View File
@@ -6,10 +6,8 @@ using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.RateLimiting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Minio;
using Minio.DataModel.Args;
using Prometheus;
using Serilog;
using StackExchange.Redis;
@@ -148,8 +146,10 @@ try
builder.Services.AddHostedService<MetricsCollectorService>();
builder.Services.AddHostedService<PromotionRetryService>();
// Health checks
builder.Services.AddHealthChecks()
// Health checks. Startup bootstrap (migrate/seed/MinIO) runs in a hosted
// service AFTER Kestrel listens so Docker's /health/live probe can pass;
// /health/ready stays gated until StartupHealthCheck flips.
var healthChecks = builder.Services.AddHealthChecks()
.AddNpgSql(
builder.Configuration.GetConnectionString("DefaultConnection")!,
name: "postgresql",
@@ -162,6 +162,15 @@ try
"minio",
tags: new[] { "ready" });
if (!isTesting)
{
builder.Services.AddSingleton<StartupHealthCheck>();
builder.Services.AddHostedService<AppBootstrapHostedService>();
healthChecks.AddCheck<StartupHealthCheck>(
"startup",
tags: new[] { "ready", "startup" });
}
builder.Services.AddValidatorsFromAssemblyContaining<Program>();
builder.Services.AddScoped<ValidationFilter>();
builder.Services.AddControllers(options =>
@@ -229,19 +238,6 @@ try
}
});
if (!app.Environment.IsEnvironment("Testing"))
{
using var scope = app.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
await db.Database.MigrateAsync();
await DataSeeder.SeedAsync(db);
var minio = scope.ServiceProvider.GetRequiredService<IMinioClient>();
var minioOpts = scope.ServiceProvider.GetRequiredService<IOptions<MinioOptions>>().Value;
if (!await minio.BucketExistsAsync(new BucketExistsArgs().WithBucket(minioOpts.BucketName)))
await minio.MakeBucketAsync(new MakeBucketArgs().WithBucket(minioOpts.BucketName));
}
app.Run();
}
catch (System.Exception)
+6
View File
@@ -37,6 +37,12 @@ services:
networks:
- vigilcare_records_prod
- shared-services
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:8080/health/live"]
interval: 10s
timeout: 5s
retries: 6
start_period: 40s
logging:
driver: json-file
options: { max-size: "50m", max-file: "5" }
+587
View File
@@ -0,0 +1,587 @@
#!/usr/bin/env python3
"""Generate a printable PDF of the VigilCare Records executive PRD summary."""
from reportlab.lib.colors import HexColor, black, white
from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY, TA_LEFT
from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib.units import inch
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.platypus import (
HRFlowable,
Paragraph,
SimpleDocTemplate,
Spacer,
Table,
TableStyle,
)
pdfmetrics.registerFont(TTFont("NotoSans", "/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf"))
pdfmetrics.registerFont(TTFont("NotoSans-Bold", "/usr/share/fonts/truetype/noto/NotoSans-Bold.ttf"))
pdfmetrics.registerFont(TTFont("NotoSans-Italic", "/usr/share/fonts/truetype/noto/NotoSans-Italic.ttf"))
OUT = "/home/sevia/Documents/Programming/Git/vigilcare-records/docs/vigilcare-records-executive-prd.pdf"
NAVY = HexColor("#0B3D5C")
BLUE = HexColor("#1A6B9A")
LIGHT = HexColor("#F4F7FA")
BORDER = HexColor("#C5D0DA")
MUTED = HexColor("#4A5560")
styles = getSampleStyleSheet()
styles.add(
ParagraphStyle(
name="DocTitle",
fontName="NotoSans-Bold",
fontSize=18,
leading=22,
textColor=NAVY,
spaceAfter=6,
alignment=TA_LEFT,
)
)
styles.add(
ParagraphStyle(
name="DocSubtitle",
fontName="NotoSans",
fontSize=10,
leading=13,
textColor=MUTED,
spaceAfter=4,
)
)
styles.add(
ParagraphStyle(
name="Meta",
fontName="NotoSans",
fontSize=9,
leading=12,
textColor=MUTED,
spaceAfter=2,
)
)
styles.add(
ParagraphStyle(
name="H1Custom",
fontName="NotoSans-Bold",
fontSize=13,
leading=16,
textColor=NAVY,
spaceBefore=14,
spaceAfter=6,
)
)
styles.add(
ParagraphStyle(
name="H2Custom",
fontName="NotoSans-Bold",
fontSize=11,
leading=14,
textColor=BLUE,
spaceBefore=10,
spaceAfter=4,
)
)
styles.add(
ParagraphStyle(
name="Body",
fontName="NotoSans",
fontSize=9.5,
leading=13,
textColor=black,
spaceAfter=6,
alignment=TA_JUSTIFY,
)
)
styles.add(
ParagraphStyle(
name="BodyTight",
fontName="NotoSans",
fontSize=9.5,
leading=12.5,
textColor=black,
spaceAfter=3,
)
)
styles.add(
ParagraphStyle(
name="BulletBody",
fontName="NotoSans",
fontSize=9.5,
leading=12.5,
textColor=black,
leftIndent=12,
spaceAfter=2,
)
)
styles.add(
ParagraphStyle(
name="Callout",
fontName="NotoSans-Italic",
fontSize=10,
leading=13,
textColor=NAVY,
leftIndent=10,
rightIndent=10,
spaceBefore=4,
spaceAfter=8,
)
)
styles.add(ParagraphStyle(name="Cell", fontName="NotoSans", fontSize=8.5, leading=11, textColor=black))
styles.add(
ParagraphStyle(name="CellBold", fontName="NotoSans-Bold", fontSize=8.5, leading=11, textColor=black)
)
styles.add(
ParagraphStyle(name="HeaderCell", fontName="NotoSans-Bold", fontSize=8.5, leading=11, textColor=white)
)
styles.add(
ParagraphStyle(
name="Diagram",
fontName="NotoSans",
fontSize=9,
leading=13,
textColor=NAVY,
alignment=TA_CENTER,
spaceBefore=4,
spaceAfter=6,
)
)
def p(text, style="Body"):
return Paragraph(text, styles[style])
def make_table(headers, rows, col_widths):
data = [[Paragraph(h, styles["HeaderCell"]) for h in headers]]
for row in rows:
data.append(
[
Paragraph(c, styles["CellBold" if i == 0 else "Cell"])
for i, c in enumerate(row)
]
)
t = Table(data, colWidths=col_widths, repeatRows=1)
t.setStyle(
TableStyle(
[
("BACKGROUND", (0, 0), (-1, 0), NAVY),
("TEXTCOLOR", (0, 0), (-1, 0), white),
("BACKGROUND", (0, 1), (-1, -1), LIGHT),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [LIGHT, white]),
("GRID", (0, 0), (-1, -1), 0.4, BORDER),
("VALIGN", (0, 0), (-1, -1), "TOP"),
("LEFTPADDING", (0, 0), (-1, -1), 5),
("RIGHTPADDING", (0, 0), (-1, -1), 5),
("TOPPADDING", (0, 0), (-1, -1), 4),
("BOTTOMPADDING", (0, 0), (-1, -1), 4),
]
)
)
return t
def footer(canvas, doc):
canvas.saveState()
canvas.setStrokeColor(BORDER)
canvas.setLineWidth(0.5)
canvas.line(0.7 * inch, 0.55 * inch, letter[0] - 0.7 * inch, 0.55 * inch)
canvas.setFont("NotoSans", 8)
canvas.setFillColor(MUTED)
canvas.drawString(0.7 * inch, 0.35 * inch, "VigilCare Records — Executive Product Summary")
canvas.drawRightString(letter[0] - 0.7 * inch, 0.35 * inch, f"Page {doc.page}")
canvas.restoreState()
def build():
story = []
story.append(p("VigilCare Records", "DocTitle"))
story.append(p("Executive Product Summary", "DocSubtitle"))
story.append(Spacer(1, 4))
story.append(HRFlowable(width="100%", thickness=1.5, color=NAVY, spaceAfter=8))
story.append(
p(
"<b>Audience:</b> Medical directors, nursing leadership, hospital administrators, and clinical partners",
"Meta",
)
)
story.append(
p(
"<b>Purpose:</b> A plain-language overview of what VigilCare Records does, how work moves through it, and why the controls exist",
"Meta",
)
)
story.append(
p(
"<b>Status:</b> Core digitization, verification, approval, live capture, and interoperability features are implemented",
"Meta",
)
)
story.append(Spacer(1, 6))
story.append(p("1. What this product is", "H1Custom"))
story.append(
p(
"<b>VigilCare Records</b> is a governed pathway for turning paper clinical charts into trusted electronic patient data.",
"Body",
)
)
story.append(
p(
"It is designed for hospitals and clinics that still rely on handwritten vitals sheets, lab printouts, face sheets, allergy notes, and medication lists—especially smaller facilities and district or island health systems preparing to use electronic monitoring and early warning tools.",
"Body",
)
)
story.append(
p(
"<b>One-sentence summary:</b> Paper is scanned → humans enter and check the data → authorized clinicians approve it → only then does it become part of the permanent electronic record used for care and monitoring.",
"Body",
)
)
story.append(
p(
"It is <b>not</b> a full electronic medical record (EMR). It does not diagnose, bill, schedule, or replace clinical judgment. It is the <b>intake and quality gate</b> that makes downstream clinical systems trustworthy.",
"Body",
)
)
story.append(p("2. The problem it solves", "H1Custom"))
story.append(
p(
"Electronic alerting and early warning only work if the numbers in the computer match the chart.",
"Body",
)
)
story.append(p("In paper-based facilities:", "BodyTight"))
for item in [
"Patient identity often lives in folders, ward books, or duplicate cards",
"Vitals and labs are handwritten, sometimes illegible or poorly timed",
"“The patient” is not always clearly separated from “this admission”",
"Staff cannot trust machine alerts if the underlying values may be wrong",
]:
story.append(p(f"• {item}", "BulletBody"))
story.append(Spacer(1, 4))
story.append(
p(
"Without a controlled digitization process, transcription errors and unreviewed computer guesses can flow into alerts and dashboards. That creates patient risk and destroys clinician trust.",
"Body",
)
)
story.append(p("VigilCare Records answers the management question:", "BodyTight"))
story.append(
p(
"<i>How do we know the electronic values are the same values that were written on the chart?</i>",
"Callout",
)
)
story.append(p("3. How the system works (end to end)", "H1Custom"))
story.append(p("Standard pathway (historical charts / backfill)", "H2Custom"))
story.append(
make_table(
["Step", "What happens", "Who"],
[
["1. Receive &amp; scan", "A chart section is scanned and stored securely", "Intake"],
[
"2. Classify &amp; assign",
"The work is labeled (vitals, labs, registration, etc.) and given to one clerk",
"Intake / Admin",
],
[
"3. Enter",
"Clerk reads the scan and fills structured fields (demographics, encounter, observations)",
"Data entry",
],
[
"4. Verify",
"A <b>different</b> person checks every field against the scan",
"Verifier",
],
[
"5. Clinically approve",
"For high-stakes content, an authorized approver signs off before it goes live",
"Clinical approver",
],
[
"6. Promote",
"Approved data becomes part of the permanent patient record",
"System (after approval)",
],
[
"7. Use in care",
"Live data can support monitoring, scores, and continuity of care",
"Downstream clinical systems",
],
],
[1.35 * inch, 4.3 * inch, 1.55 * inch],
)
)
story.append(Spacer(1, 6))
story.append(
p(
"<b>Unapproved drafts never reach clinical monitoring, early warning scores, or clinician dashboards.</b>",
"Body",
)
)
story.append(p("Bedside pathway (live capture)", "H2Custom"))
story.append(
p(
"A credentialed clinician can enter current vitals at the point of care and <b>attest</b> that the values are accurate. That lighter path skips the dual entry/verification queue, but still creates a full audit record and can trigger real-time alerts when clinically appropriate.",
"Body",
)
)
story.append(p("Correction pathway", "H2Custom"))
story.append(
p(
"Once data is live, it is <b>not quietly overwritten</b>. A correction creates a new digitization job linked to the original, goes through the same quality gates, and marks the old value as superseded while keeping the history visible.",
"Body",
)
)
story.append(p("4. What kinds of documents it handles", "H1Custom"))
story.append(
make_table(
["Document type", "Typical content", "Extra clinical sign-off (default)"],
[
["Patient registration", "Name, date of birth, sex, contacts, blood type", "Usually not"],
["Allergy update", "Documented allergies / NKA", "Usually not"],
["Encounter summary", "Admission context, department, bed, reason", "Yes"],
["Vitals sheet", "Heart rate, BP, SpO<sub>2</sub>, temperature, etc.", "Yes"],
["Lab results", "Laboratory values with chart timestamps", "Yes"],
["Medication list", "Current medications", "Yes"],
["Mixed", "Combined chart sections", "Yes"],
],
[1.7 * inch, 3.6 * inch, 1.9 * inch],
)
)
story.append(Spacer(1, 5))
story.append(
p(
"Facilities can adjust which document types require the extended clinical approval queue.",
"Body",
)
)
story.append(p("5. People and accountability", "H1Custom"))
story.append(
make_table(
["Role", "Responsibility"],
[
["Intake clerk", "Scan/upload, classify, link patient when known, assign work"],
["Data entry clerk", "Transcribe the scan into structured fields"],
[
"Verifier",
"Independent check against the original image; pass or reject with reason",
],
["Clinical approver", "Authorize promotion into the permanent record"],
["Clinician", "Bedside live capture with attestation"],
[
"Administrator",
"Users, queues, staffing oversight, site routing, program governance",
],
],
[1.7 * inch, 5.5 * inch],
)
)
story.append(Spacer(1, 5))
story.append(
p(
"<b>Staffing reality for small sites:</b> One person may do both intake and entry. The system still <b>never</b> allows the same person to enter and verify the same chart section. Paper backfill needs at least two people.",
"Body",
)
)
story.append(p("6. Safety and governance (why leaders should care)", "H1Custom"))
story.append(p("These controls are the product—not optional extras.", "BodyTight"))
controls = [
("Separation of duties", "Enterer cannot verify or approve their own work."),
(
"Dual-human check for paper backfill",
"One person types; another compares to the scan.",
),
(
"Clinical approval for high-stakes content",
"Vitals, labs, medications, and encounter summaries get an explicit clinical gate by default.",
),
("Draft isolation", "Working copies cannot drive alerts until approved."),
(
"Plausibility checks",
"Impossible values (for example, a misplaced decimal on potassium) are blocked early.",
),
(
"Immutable audit trail",
"Who entered, who checked, who approved, who viewed the scan, and when.",
),
("Document integrity", "Scans are retained; rejection does not delete the source image."),
(
"Controlled corrections",
"Errors after go-live are superseded with a full re-review, not silent edits.",
),
(
"Backfill alert policy",
"Historical critical values do <b>not</b> page today’s ward by default; facilities opt in per batch if they want retrospective alerting.",
),
(
"Optional OCR assist",
"Computer may pre-fill fields to speed entry; humans still review, verify, and approve. OCR never puts labs into the chart alone.",
),
]
for i, (title, desc) in enumerate(controls, 1):
story.append(p(f"<b>{i}. {title}</b> — {desc}", "BulletBody"))
story.append(p("7. Relationship to clinical monitoring", "H1Custom"))
story.append(p("Think of two layers:", "BodyTight"))
story.append(p("<b>VigilCare Records</b> → governed paper-to-digital intake", "Diagram"))
story.append(p("↓ (approved data only)", "Diagram"))
story.append(p("<b>VigilCare Clinical</b> → live record, scoring, alerts, ward views", "Diagram"))
story.append(
p(
"Records creates trustworthy fuel. Clinical monitoring consumes it. If digitization skips quality gates, alerting becomes noise or harm. If digitization is governed, monitoring becomes credible.",
"Body",
)
)
story.append(p("8. What staff see day to day", "H1Custom"))
story.append(
make_table(
["Workstation", "Main job"],
[
["Intake", "Upload scans; optional barcode cover sheets for high-volume days"],
["Entry", "Side-by-side scan and form"],
["Verification", "Field-by-field check against the scan"],
["Clinical approval", "Final authorization before data becomes permanent"],
["Live capture", "Bedside vitals with attestation"],
["Patient history", "Digitization timeline and correction chain"],
["Supervisor dashboard", "Backlog, aging work, rejection patterns"],
[
"Interoperability browser",
"View promoted data in a standard clinical exchange format (FHIR), for partner/system readiness",
],
],
[1.9 * inch, 5.3 * inch],
)
)
story.append(p("9. Scope boundaries (important for expectations)", "H1Custom"))
story.append(p("In scope", "H2Custom"))
for item in [
"Paper chart digitization with human quality gates",
"Bedside live capture with clinician attestation",
"Patient identity, encounters, observations, allergies, medication lists (as digitized content)",
"Audit, corrections, work queues, and operational oversight",
"Read-only standard clinical data export for partner systems (after promotion)",
]:
story.append(p(f"• {item}", "BulletBody"))
story.append(p("Out of scope (v1)", "H2Custom"))
for item in [
"Full EMR (billing, pharmacy inventory, comprehensive scheduling/charting)",
"Replacing the clinical alert engine or ward dashboard",
"Fully automated extraction without human review",
"Multi-hospital federated identity across sites (single-site deployment model)",
]:
story.append(p(f"• {item}", "BulletBody"))
story.append(Spacer(1, 4))
story.append(
p(
"<b>Paper originals:</b> The scan is the working reference for digitization. The physical chart remains the legal original until local policy says otherwise.",
"Body",
)
)
story.append(p("10. Success measures leadership can track", "H1Custom"))
story.append(
make_table(
["Measure", "Suggested target (first 6 months)"],
[
[
"Active patients with at least one approved digitized chart section",
"≥ 80%",
],
["Average time from submission to verification", "&lt; 24 hours"],
[
"Rejection rate",
"&lt; 15% (higher usually means scan quality or training issues)",
],
["Share of new observations from bedside live capture", "Rising over time"],
[
"Demonstrated critical-value pathway from live capture to clinical response",
"At least one proven site workflow",
],
],
[4.2 * inch, 3.0 * inch],
)
)
story.append(p("11. Decisions for clinical leadership", "H1Custom"))
story.append(p("Before or during rollout, leadership should decide:", "BodyTight"))
for i, item in enumerate(
[
"<b>Which document types require physician/clinical approver review</b> after verification",
"<b>Whether historical critical values may ever page the ward</b> (default: no)",
"<b>Who holds verifier and approver roles</b> given local staffing",
"<b>Retention and legal status of paper vs scan</b> under local regulation",
"<b>Whether OCR assist is used</b>, and under what privacy agreements if cloud-based",
],
1,
):
story.append(p(f"{i}. {item}", "BulletBody"))
story.append(p("12. Quick answers for common concerns", "H1Custom"))
story.append(
make_table(
["Concern", "Answer"],
[
["Will OCR put values into the chart by itself?", "No."],
["Can someone check their own typing?", "No."],
["Do unfinished drafts trigger NEWS2 / sepsis screens?", "No."],
[
"Can we silently fix a wrong promoted value?",
"No — use a correction with full review.",
],
["Will backfilling old labs flood today’s alerts?", "Not by default."],
[
"Is this our new EMR?",
"No — it is the governed bridge into trusted electronic clinical data.",
],
],
[3.6 * inch, 3.6 * inch],
)
)
story.append(p("Closing statement for partners", "H1Custom"))
story.append(
p(
"VigilCare Records exists so that paper-based facilities can adopt electronic monitoring <b>without pretending handwriting is already structured data</b>. It trades speed for trust at each gate, then unlocks real-time clinical value once the organization can defend every promoted number: who entered it, who checked it, and when it became permanent.",
"Body",
)
)
story.append(Spacer(1, 8))
story.append(HRFlowable(width="100%", thickness=0.6, color=BORDER, spaceAfter=6))
story.append(
p(
"Companion documents: clinical overview (<i>vigilcare-records-clinical-overview.md</i>) and full technical PRD (<i>vigilcare-records-prd.md</i>).",
"Meta",
)
)
doc = SimpleDocTemplate(
OUT,
pagesize=letter,
leftMargin=0.7 * inch,
rightMargin=0.7 * inch,
topMargin=0.65 * inch,
bottomMargin=0.75 * inch,
title="VigilCare Records — Executive Product Summary",
author="VigilCare Records",
subject="Management-level product summary for clinical leadership",
)
doc.build(story, onFirstPage=footer, onLaterPages=footer)
print(f"Wrote {OUT}")
if __name__ == "__main__":
build()
+208
View File
@@ -0,0 +1,208 @@
# VigilCare Records — Executive Product Summary
**Audience:** Medical directors, nursing leadership, hospital administrators, and clinical partners
**Purpose:** A plain-language overview of what VigilCare Records does, how work moves through it, and why the controls exist
**Status:** Core digitization, verification, approval, live capture, and interoperability features are implemented
---
## 1. What this product is
**VigilCare Records** is a governed pathway for turning paper clinical charts into trusted electronic patient data.
It is designed for hospitals and clinics that still rely on handwritten vitals sheets, lab printouts, face sheets, allergy notes, and medication lists—especially smaller facilities and district or island health systems preparing to use electronic monitoring and early warning tools.
**One-sentence summary:**
Paper is scanned → humans enter and check the data → authorized clinicians approve it → only then does it become part of the permanent electronic record used for care and monitoring.
It is **not** a full electronic medical record (EMR). It does not diagnose, bill, schedule, or replace clinical judgment. It is the **intake and quality gate** that makes downstream clinical systems trustworthy.
---
## 2. The problem it solves
Electronic alerting and early warning only work if the numbers in the computer match the chart.
In paper-based facilities:
- Patient identity often lives in folders, ward books, or duplicate cards
- Vitals and labs are handwritten, sometimes illegible or poorly timed
- “The patient” is not always clearly separated from “this admission”
- Staff cannot trust machine alerts if the underlying values may be wrong
Without a controlled digitization process, transcription errors and unreviewed computer guesses can flow into alerts and dashboards. That creates patient risk and destroys clinician trust.
VigilCare Records answers the management question:
> *How do we know the electronic values are the same values that were written on the chart?*
---
## 3. How the system works (end to end)
### Standard pathway (historical charts / backfill)
| Step | What happens | Who |
|---|---|---|
| 1. Receive & scan | A chart section is scanned and stored securely | Intake |
| 2. Classify & assign | The work is labeled (vitals, labs, registration, etc.) and given to one clerk | Intake / Admin |
| 3. Enter | Clerk reads the scan and fills structured fields (demographics, encounter, observations) | Data entry |
| 4. Verify | A **different** person checks every field against the scan | Verifier |
| 5. Clinically approve | For high-stakes content, an authorized approver signs off before it goes live | Clinical approver |
| 6. Promote | Approved data becomes part of the permanent patient record | System (after approval) |
| 7. Use in care | Live data can support monitoring, scores, and continuity of care | Downstream clinical systems |
**Unapproved drafts never reach clinical monitoring, early warning scores, or clinician dashboards.**
### Bedside pathway (live capture)
A credentialed clinician can enter current vitals at the point of care and **attest** that the values are accurate. That lighter path skips the dual entry/verification queue, but still creates a full audit record and can trigger real-time alerts when clinically appropriate.
### Correction pathway
Once data is live, it is **not quietly overwritten**. A correction creates a new digitization job linked to the original, goes through the same quality gates, and marks the old value as superseded while keeping the history visible.
---
## 4. What kinds of documents it handles
| Document type | Typical content | Extra clinical sign-off (default) |
|---|---|---|
| Patient registration | Name, date of birth, sex, contacts, blood type | Usually not |
| Allergy update | Documented allergies / NKA | Usually not |
| Encounter summary | Admission context, department, bed, reason | Yes |
| Vitals sheet | Heart rate, BP, SpO₂, temperature, etc. | Yes |
| Lab results | Laboratory values with chart timestamps | Yes |
| Medication list | Current medications | Yes |
| Mixed | Combined chart sections | Yes |
Facilities can adjust which document types require the extended clinical approval queue.
---
## 5. People and accountability
| Role | Responsibility |
|---|---|
| **Intake clerk** | Scan/upload, classify, link patient when known, assign work |
| **Data entry clerk** | Transcribe the scan into structured fields |
| **Verifier** | Independent check against the original image; pass or reject with reason |
| **Clinical approver** | Authorize promotion into the permanent record |
| **Clinician** | Bedside live capture with attestation |
| **Administrator** | Users, queues, staffing oversight, site routing, program governance |
**Staffing reality for small sites:** One person may do both intake and entry. The system still **never** allows the same person to enter and verify the same chart section. Track A (paper backfill) needs at least two people.
---
## 6. Safety and governance (why leaders should care)
These controls are the product—not optional extras.
1. **Separation of duties** — Enterer cannot verify or approve their own work.
2. **Dual-human check for paper backfill** — One person types; another compares to the scan.
3. **Clinical approval for high-stakes content** — Vitals, labs, medications, and encounter summaries get an explicit clinical gate by default.
4. **Draft isolation** — Working copies cannot drive alerts until approved.
5. **Plausibility checks** — Impossible values (for example, a misplaced decimal on potassium) are blocked early.
6. **Immutable audit trail** — Who entered, who checked, who approved, who viewed the scan, and when.
7. **Document integrity** — Scans are retained; rejection does not delete the source image.
8. **Controlled corrections** — Errors after go-live are superseded with a full re-review, not silent edits.
9. **Backfill alert policy** — Historical critical values do **not** page today’s ward by default; facilities opt in per batch if they want retrospective alerting.
10. **Optional OCR assist** — Computer may pre-fill fields to speed entry; humans still review, verify, and approve. OCR never puts labs into the chart alone.
---
## 7. Relationship to clinical monitoring
Think of two layers:
```
VigilCare Records → governed paper-to-digital intake
↓ (approved data only)
VigilCare Clinical → live record, scoring, alerts, ward views
```
Records creates trustworthy fuel. Clinical monitoring consumes it.
If digitization skips quality gates, alerting becomes noise or harm. If digitization is governed, monitoring becomes credible.
---
## 8. What staff see day to day
| Workstation | Main job |
|---|---|
| Intake | Upload scans; optional barcode cover sheets for high-volume days |
| Entry | Side-by-side scan and form |
| Verification | Field-by-field check against the scan |
| Clinical approval | Final authorization before data becomes permanent |
| Live capture | Bedside vitals with attestation |
| Patient history | Digitization timeline and correction chain |
| Supervisor dashboard | Backlog, aging work, rejection patterns |
| Interoperability browser | View promoted data in a standard clinical exchange format (FHIR), for partner/system readiness |
---
## 9. Scope boundaries (important for expectations)
### In scope
- Paper chart digitization with human quality gates
- Bedside live capture with clinician attestation
- Patient identity, encounters, observations, allergies, medication lists (as digitized content)
- Audit, corrections, work queues, and operational oversight
- Read-only standard clinical data export for partner systems (after promotion)
### Out of scope (v1)
- Full EMR (billing, pharmacy inventory, comprehensive scheduling/charting)
- Replacing the clinical alert engine or ward dashboard
- Fully automated extraction without human review
- Multi-hospital federated identity across sites (single-site deployment model)
**Paper originals:** The scan is the working reference for digitization. The physical chart remains the legal original until local policy says otherwise.
---
## 10. Success measures leadership can track
| Measure | Suggested target (first 6 months) |
|---|---|
| Active patients with at least one approved digitized chart section | ≥ 80% |
| Average time from submission to verification | < 24 hours |
| Rejection rate | < 15% (higher usually means scan quality or training issues) |
| Share of new observations from bedside live capture | Rising over time |
| Demonstrated critical-value pathway from live capture to clinical response | At least one proven site workflow |
---
## 11. Decisions for clinical leadership
Before or during rollout, leadership should decide:
1. **Which document types require physician/clinical approver review** after verification
2. **Whether historical critical values may ever page the ward** (default: no)
3. **Who holds verifier and approver roles** given local staffing
4. **Retention and legal status of paper vs scan** under local regulation
5. **Whether OCR assist is used**, and under what privacy agreements if cloud-based
---
## 12. Quick answers for common concerns
| Concern | Answer |
|---|---|
| Will OCR put values into the chart by itself? | No. |
| Can someone check their own typing? | No. |
| Do unfinished drafts trigger NEWS2 / sepsis screens? | No. |
| Can we silently fix a wrong promoted value? | No — use a correction with full review. |
| Will backfilling old labs flood today’s alerts? | Not by default. |
| Is this our new EMR? | No — it is the governed bridge into trusted electronic clinical data. |
---
## Closing statement for partners
VigilCare Records exists so that paper-based facilities can adopt electronic monitoring **without pretending handwriting is already structured data**. It trades speed for trust at each gate, then unlocks real-time clinical value once the organization can defend every promoted number: who entered it, who checked it, and when it became permanent.
For a fuller clinical narrative with examples and journey walkthroughs, see [vigilcare-records-clinical-overview.md](vigilcare-records-clinical-overview.md).
For technical product requirements, see [vigilcare-records-prd.md](vigilcare-records-prd.md).
Binary file not shown.