Circle V2 API Docs
    Preparing search index...

    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-sync so the two pipelines do not deduplicate each other during migration.

    Lives in @repo/services (not @repo/jobs) because it depends on syncIntegrationEpisodesService; co-locating jobbables that need services here avoids a @repo/jobs <-> @repo/services package cycle, mirroring GenerateTextNoteJobbable in session-notes/.

    Hierarchy (View Summary)

    • Jobbable<SyncCensusJobParams, void>
      • SyncCensusJobbable
    Index

    Constructors

    Properties

    config: JobConfig = ...
    serviceName: "SyncCensusJobbable"

    Stable, 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.

    Accessors

    • get name(): string

      Returns string

    Methods

    • Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string

      Returns string

    • Extract an entityId from params for job_executions tracking. Override in subclasses when applicable.

      Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string

      Returns EntityId

    • NEW 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.

      Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string

      Returns string | null

    • Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string

      Returns Promise<Safe<void>>

    • Enqueue this job for async processing via Vercel Queues. Checks for deduplication via job_executions before sending.

      Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string
      • Optionaloptions: PerformLaterOptions

      Returns Promise<SendResult>

    • Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string

      Returns Promise<void>

    • Run the job with status tracking. Used by the queue handler. Errors propagate (not caught by safe()) so the RetryHandler can decide.

      Parameters

      • params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string
      • metadata: MessageMetadata

      Returns Promise<void>

    • Optional 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.

      Parameters

      • _params: {
            entityId: EntityId;
            fromDate?: string;
            integrationId: IntegrationId;
            toDate?: string;
        }
        • entityId: EntityId
        • OptionalfromDate?: string

          Explicit 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.

        • integrationId: IntegrationId
        • OptionaltoDate?: string

      Returns Attributes

    • Optional 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.

      Parameters

      • _result: void

      Returns Attributes

    • Parameters

      • params: unknown

      Returns params is {
          entityId: EntityId;
          fromDate?: string;
          integrationId: IntegrationId;
          toDate?: string;
      }