Circle V2 API Docs
    Preparing search index...

    Orchestrates a full patient merge: resolve EMR direction, run the database merge, then migrate Pinecone vectors.

    Ordering matters for recoverability. The database merge runs FIRST inside its own transaction, and Pinecone vectors are migrated only AFTER it commits. Pinecone is not transactional and the vector move is destructive (upsert to target, then delete from source), so migrating first risked leaving vectors already moved while the DB merge failed — an orphaned state with nothing to roll back. With the DB merge first:

    • a DB merge failure touches no vectors, so the whole merge is a clean retry, and
    • a vector-migration failure leaves the committed merge intact and is idempotently retryable via migratePatientPineconeVectorsService (namespaces are keyed by patient id and survive the merge). These failures are reported per-namespace, never thrown.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    serviceName: "ExecutePatientMergeService"

    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 logger(): BaseLogger

      Returns BaseLogger

    • get name(): string

      Returns string

    Methods

    • 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

      Returns { duplicatePatientId: PatientId; primaryPatientId: PatientId }

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

      Returns Attributes