Circle V2 API Docs
    Preparing search index...

    Function fetchAndFormatEmrDocuments

    • Fetches full EMR documents by ID from patient_charts and formats them into a single context string using EMRDocumentFormatter.

      Returns empty string if document count exceeds MAX_FULL_EMR_DOCUMENTS to avoid blowing up context window.

      Used to bypass Pinecone chunked retrieval when full document text is needed.

      Note: v1 also looked up the facility timezone via the chart's integration and forwarded it to EMRDocumentFormatter.format as metadata.facilityTimeZone. v2's DocumentFormatMetadata no longer carries that field (timezone handling has been hoisted out of the formatter), so the lookup was dropped during the port. Reintroduce a v2-native equivalent if EMR document timestamps need facility-local rendering again.

      Parameters

      • options: {
            documentIds: string[];
            patient: Pick<
                PatientRow,
                "patient_id"
                | "entity_id"
                | "first_name"
                | "last_name",
            >;
            supabase: SupabaseClient<Database>;
        }

      Returns Promise<string>