ReadonlyconfigReadonlyserviceStable, human-readable name for the service. Must be set explicitly on each subclass
because this.constructor.name gets mangled by minification in production builds,
which breaks tracing/observability span names.
ProtectedloggerOptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringExtract an entityId from params for job_executions tracking. Override in subclasses when applicable.
OptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringNEW key format — intentionally distinct from v1's integration_{id}_admissions-sync. An explicit window (the "Fetch episodes" action) keys on the range so it never dedupes against the cron census or a fetch over a different window.
OptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringOptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringEnqueue this job for async processing via Vercel Queues. Checks for deduplication via job_executions before sending.
OptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringOptionaloptions: PerformLaterOptionsOptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringRun the job with status tracking. Used by the queue handler. Errors propagate (not caught by safe()) so the RetryHandler can decide.
OptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringProtectedspanOptional hook for subclasses to attach extra non-PII span attributes derived from params.
The returned attributes appear on the service.${serviceName} span (and, for jobs,
on job.enqueue.* and job.run.* spans too).
Safe ID-like keys on params (e.g. patientId, templateIds, limit, cursor) are
already auto-extracted via toSpanAttributes("service.input", params) — you don't need
to enumerate them here. Use this hook for derived/computed attributes (counts, flags,
computed names) or for fields you've explicitly verified safe but that aren't in the
global allowlist. Hook output overrides auto-extracted attributes on key collision.
Safe by default: returns {} when not overridden. Only declare keys you've confirmed
are non-PII. Never include emails, names, dob, free-text, etc.
OptionalfromDate?: stringExplicit window for the "Fetch episodes" facility action (admins pulling older history). Carried as ISO strings so the params survive JSON serialization through the queue. When present, the census runs admissions + episode upsert over this window; when absent (the hourly cron), the default 7-day window is used. Documents are NOT pulled here — episodes are upserted so they show up in the app, and a user fetches a specific patient's charts on demand.
OptionaltoDate?: stringProtectedspanOptional hook for subclasses to attach extra non-PII span attributes derived from the
successful service result. Only called when run resolves successfully; on error, the
span is marked via markSpanError instead.
Safe by default: returns {} when not overridden. Only declare keys you've confirmed
are non-PII (e.g. counts, status flags, computed summaries). Never include emails,
names, dob, free-text, etc.
Integration-wide census sync (port of v1 sync-admissions): pulls the last 7 days of admissions from the EMR into patients/patient_admissions/levels-of-care, then bulk-syncs treatment_episodes over the same window (non-fatal — adapters without episode support return empty).
Key format is intentionally distinct from v1's
integration_{id}_admissions-syncso the two pipelines do not deduplicate each other during migration.Lives in
@repo/services(not@repo/jobs) because it depends onsyncIntegrationEpisodesService; co-locating jobbables that need services here avoids a@repo/jobs <-> @repo/servicespackage cycle, mirroringGenerateTextNoteJobbableinsession-notes/.