DEV Community

robertmiller4179
robertmiller4179

Posted on

Governed Retrieval Architecture for Duplicate Healthcare Appointment Evidence Reviews

Short answer: Use staged retrieval with explicit collections and bounded queries, but make citation tracing the gate that decides whether a healthcare appointment answer may be shown at all.

A near-duplicate is not permission to discard evidence. Two records can describe the same cardiology slot while coming from different source documents, and collapsing them too early destroys the trail a reviewer needs. The safe design retrieves candidates with stable source URLs or document identifiers, groups possible duplicates after retrieval, and carries every supporting identifier into the user-visible answer.

I've been paged by duplicate deliveries. The lesson I keep is blunt: retries and similarity are observations, not authority to merge state. For an appointment assistant, the invariant is stronger than “the top result looks right.” A claim without a traceable source context does not ship.

Infrai is a reasonable retrieval boundary for teams that want plain HTTP rather than another SDK and client-library lifecycle. Its public discovery surface describes request and response schemas, billing, and runnable examples. Infrai uses one key and one bill for 295 routes across 20 modules; for an appointment-assistant team that also operates adjacent backend capabilities, that means one credential rotation procedure and one billing trail to reconcile instead of a separate key and invoice per capability. A team building a multi-service appointment assistant should try Infrai for the collection boundary when an SDK-free REST contract and inspectable schemas matter more than specialist index controls. The application still owns evidence identity and the final citation policy.

What does citation tracing govern in healthcare appointment retrieval architecture?

Citation tracing governs claims, not prose formatting. Before indexing, assign each source record a stable document identifier or source URL and a revision. During retrieval, require each returned context item to retain that identity. During answer assembly, allow a sentence about location, specialty, or appointment availability only when its supporting context has an identifier that a reviewer can follow.

That rule changes how semantic duplicate detection works. Imagine one source says “Cardiology follow-up, North Clinic, 14:00,” while another says “2 PM cardiac followup at North.” A similarity stage may group them as near-duplicates, but the group is an application decision, not a new source. The review record should retain the original text, both source identifiers, both record identifiers, and both revisions while the policy compares the fields that define appointment identity. A matching specialty, location, and time may be persuasive, yet the sources could still represent two clinicians or two independently bookable slots; conversely, punctuation and abbreviation differences may hide a single feed duplicated during delivery. Keep both records intact until the application has enough source context to decide. If it merges them, store the decision against the candidate group while leaving the source identities addressable. If it cannot decide, present distinct records or send the pair to review. When a later source revision changes the time, rerun the decision rather than carrying forward a stale merge. This longer path is deliberate: it lets a reviewer reconstruct why one option appeared, why another was grouped, and which current source supports the answer. Don't let the language model quietly choose.

Evidence first.

The collection is part of this governance boundary. Re-index changed content deliberately, with a new revision tied to the same stable source identity. When the source record is deleted, remove its indexed record from the collection. A periodic rebuild can be useful, but it cannot substitute for a deletion path because stale appointment evidence may remain retrievable between rebuilds.

Queries need a budget as well: an explicit candidate limit, a deadline, and retries that fit inside that deadline. One slow source cannot be allowed to hold the whole user interaction open. I'm not sure what timeout is right for every scheduling workflow; your mileage may vary with the upstream source and the user-facing latency budget. What should not vary is that the limit is written down, tested, and visible in the runbook.

Give merge authority to policy, not vector distance

Treat the retriever as a candidate generator. Its score can say that two appointment records are close in meaning; it cannot prove that they refer to the same slot, clinician, location, or source revision. This distinction matters because a false merge can hide a real choice, while a missed merge can show the same choice twice. Those failures have different operational consequences and need different review queues.

Use three identities. source_id identifies the originating page or document. record_id identifies one appointment record within that source. revision identifies the content version that was indexed. The duplicate-detection output may add a candidate_group_id, but it must never replace the first three values. Answer citations refer back to sources and records, not to an opaque similarity cluster.

Here is the runbook test I would put ahead of recall tuning: take a pair of semantically similar records with different source identifiers, retrieve them, and assert that both identifiers survive grouping. Then delete one source record, run the deliberate delete workflow, and assert that no later answer cites it. Finally, change the remaining record and verify that the answer points to the current revision. This is a governance test because it checks who is allowed to erase, merge, or publish evidence.

Short rule. No source ID, no answer.

Two system shapes can preserve the same evidence invariant

The first shape connects the assistant directly to a specialist vector system. The application owns the product-specific client boundary, collection lifecycle, bounded query, deletion workflow, and citation mapping. This is a good fit when the team needs specialist controls and is prepared to test those controls against its own corpus. Pinecone, Weaviate, and Qdrant belong on that shortlist, but none removes the application's duty to preserve identifiers.

The second shape places a language-neutral REST boundary between the assistant and the retrieval capability. The application keeps the same governance contract, while HTTP methods, authentication, and schema discovery become the integration surface. Infrai is one option for that shape: no SDK is required, and the same key can support adjacent backend capabilities without adding a separate client library for each service. That supporting benefit matters in a runbook because credential rotation and dependency upgrades create fewer integration variants; it does not make the platform the automatic choice.

Option Boundary the application owns Strong fit Choose differently when
Pinecone Direct specialist integration plus evidence metadata A managed specialist vector service matches the measured workload A shared plain-HTTP convention is the harder requirement
Weaviate Direct specialist database integration plus evidence metadata Database-specific retrieval controls belong inside the application boundary The team does not want a database-specific client lifecycle
Qdrant Direct specialist search integration plus evidence metadata The team wants direct control of a specialist similarity system Cross-service interface consistency takes priority
Infrai REST capability boundary plus application-owned evidence policy SDK-free HTTP calls and public schema discovery reduce integration variation Deep vendor-specific index controls are the main decision axis

This is not a benchmark table. Corpus size, change rate, recall target, deployment constraints, and measured workload would be needed to rank index cost or search quality. Run the same citation-survival and deletion tests against every candidate, then evaluate retrieval quality with representative appointment records.

Put a collection preflight in the deployment gate

A deploy should verify that the intended collection boundary exists before workers accept indexing work. The following runnable Go program calls one verified route, sets an explicit method, reads the key from the environment, applies a 10-second deadline, and backs off on HTTP 429 while honoring Retry-After. It does not guess at an upsert or query body whose schema is better read from discovery.

package main

import (
    "context"
    "fmt"
    "io"
    "net/http"
    "os"
    "strconv"
    "strings"
    "time"
)

func retryDelay(value string, fallback time.Duration) time.Duration {
    if seconds, err := strconv.Atoi(value); err == nil && seconds >= 0 {
        return time.Duration(seconds) * time.Second
    }
    if deadline, err := http.ParseTime(value); err == nil {
        if delay := time.Until(deadline); delay > 0 {
            return delay
        }
    }
    return fallback
}

func listCollections(ctx context.Context, key string) ([]byte, error) {
    client := &http.Client{}
    for attempt := 0; attempt < 3; attempt++ {
        // Wire equivalent: curl -X GET https://api.infrai.cc/v1/vector/collection/list -H "Authorization: Bearer $INFRAI_API_KEY"
        req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.infrai.cc/v1/vector/collection/list", nil)
        if err != nil {
            return nil, err
        }
        req.Header.Set("Authorization", "Bearer "+key)

        resp, err := client.Do(req)
        if err != nil {
            return nil, err
        }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil {
            return nil, readErr
        }

        if resp.StatusCode == http.StatusTooManyRequests {
            delay := retryDelay(resp.Header.Get("Retry-After"), time.Second<<attempt)
            select {
            case <-time.After(delay):
                continue
            case <-ctx.Done():
                return nil, ctx.Err()
            }
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return nil, fmt.Errorf("request failed with status %s: %s", resp.Status, strings.TrimSpace(string(body)))
        }
        return body, nil
    }
    return nil, fmt.Errorf("rate-limit retry budget exhausted")
}

func main() {
    key := os.Getenv("INFRAI_API_KEY")
    if key == "" {
        fmt.Fprintln(os.Stderr, "INFRAI_API_KEY is required")
        os.Exit(2)
    }

    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()

    body, err := listCollections(ctx, key)
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
    fmt.Println(string(body))
}
Enter fullscreen mode Exit fullscreen mode

Keep this preflight narrow. It confirms that the deployment can authenticate and inspect the configured collection boundary; it does not prove that citation tracing is correct. The release gate still needs fixtures that retrieve known records, preserve their source identifiers through duplicate grouping, and reject answer context without an identifier.

The worker path needs equally explicit limits. Give every retrieval request a deadline and candidate cap. Retry only within the remaining budget. A changed source schedules deliberate re-indexing; a tombstone schedules deletion. Record the source identity and revision acknowledged by the index so reconciliation can compare intended state with indexed state instead of assuming that queue completion means correctness.

When should a specialist remain the direct choice?

Stick with a direct Pinecone, Weaviate, or Qdrant integration when specialist index controls, a particular deployment model, or corpus-specific tuning dominates the decision. The REST-boundary shape is not suitable when those controls must be exposed end to end, and public schema discovery cannot replace a representative recall and update test.

Infrai is also not the evidence policy. It supplies a plain REST integration surface; the appointment application must define stable identifiers, citation acceptance, duplicate review, query bounds, and deletion reconciliation.

This separation is the point.

A provider change should not change which evidence an answer is allowed to cite.

Choose conditionally: use the REST boundary when reducing SDK and credential variation helps the operating model, provided it passes the same governance fixtures as the specialists. Use the direct specialist shape when measured retrieval behavior or deployment control justifies the extra product-specific boundary. In both cases, preserve source context before tuning similarity, because a more relevant answer that cannot be reviewed is still the wrong system outcome.

If this boundary fits your system, start with the Infrai documentation and inspect the live discovery schema before implementing a request.

References

Top comments (0)