Skip to main content

Support documents

Support documents are the files that back a pre-appointment's charges — the same evidence a payer will later require to honour the billing (medical orders, TISS guides, ID documents, and so on). Collecting them before care is the whole point of pre-attendance.

Placeholders and completion​

When required supports are configured for a charge's provider_product_code, the pre-appointment is seeded with PENDING document placeholders — one per required support_file_code. A placeholder is a "slot" that says "this charge still needs this document".

Uploading a file completes the matching placeholder(s):

POST /v1/checkin/appointments/{id}/documents
Content-Type: multipart/form-data
Which route to call
  • Reception desk / manual flow (providers-web): POST /v1/checkin/appointments/{id}/documents, where {id} is OSIGU's UUID for the pre-appointment.
  • HIS integration: POST /v1/checkin/appointments/his-inbound/{external_appointment_id}/documents, addressed by your HIS's own identifier and authorised with your HIS credentials. Same request and response; see HIS inbound.

The request has two parts:

PartContent-TypeWhat
filebinary (PDF, JPEG or PNG)The document itself. Max 45 MB.
request_dataapplication/jsonThe metadata: support_file_code and provider_product_codes.
// request_data part — application/json
{
"support_file_code": "CPF",
"provider_product_codes": ["PROC001", "PROC002"]
}

How provider_product_codes selects which placeholders get completed:

  • Empty or absent → completes the PENDING placeholders of all charges of the pre-appointment for that support_file_code (case-insensitive).
  • Non-empty → restricts completion to the matching charges. Codes with no corresponding charge are silently ignored.

Replacing a document. To replace a document that is already received, send the same support_file_code with explicit provider_product_codes. The API resolves it per charge:

  • If the charge still has PENDING placeholders for that code, they are completed — there is nothing to replace.
  • Otherwise, the most recently received document of that charge is the one replaced.

What happens to the previous file depends on the support document's keep_support_file_history setting, which OSIGU configures per provider and document code:

SettingResult
false (default)The file is overwritten on the same record: the document keeps its id.
trueThe previous document stays active and a new record (new id) is added with the new file. GET .../documents then lists both, ordered by creation date.

The setting is copied to each document when its placeholder is created, so a change applies only to documents created afterwards; existing documents keep the value they had.

The 201 response contains only the resulting document — the new one, or the overwritten one. Every upload or replacement restarts the AI validation of the resulting documents. The previous file is not removed from storage. Without explicit provider_product_codes there is nothing to replace and the request fails with 422.

The file is uploaded to storage once and shared across every placeholder it completes — one upload can satisfy the same required document across several charges. The response is a 201 with one array element per completed document.

MIME type is enforced by content, not extension

The whitelist (application/pdf, image/jpeg, image/png) is checked by inspecting the file's magic bytes, not by trusting the filename. A .pdf that isn't really a PDF is rejected with 422.

Source: MANUAL vs HIS_INBOUND​

Every document records its source: the channel that uploaded its file. It determines what you can do with it:

SourceOriginDeletable?Clearable?
MANUALUploaded through POST /{id}/documents✅ Yes✅ Yes
HIS_INBOUNDUploaded by the HIS through POST /his-inbound/{external_appointment_id}/documents❌ No (403)❌ No (403)

Documents uploaded by the HIS are treated as already received and can't be deleted or cleared here — the HIS is their system of record. Only manually uploaded documents can be deleted (soft-delete) or cleared back to PENDING.

  • Delete (DELETE .../documents/{documentId}) marks the record disabled. The file is not removed from storage (it may be shared with other placeholders completed by the same upload).
  • Clear (POST .../documents/{documentId}/clear) reverts a MANUAL document to PENDING, wiping the file fields (name, extension, path, size, MIME, AI-validation) while keeping support_file_code, required, the charge link, and source = MANUAL. Also does not touch storage.
  • Each document record is deleted or cleared independently, including the ones kept as history when keep_support_file_history is on.

Replacing follows the same split: a channel can only replace the documents it uploaded itself. Replacing a document uploaded by the other channel (for example, the HIS replacing a file uploaded from the reception desk, or the other way round) returns 403.

AI / DVS validation​

Uploaded documents are validated by AI/DVS using the same rules as the RCM account-assembly flow. Each document carries an AI validation status:

ai_validation_statusMeaning
PENDINGNot yet validated.
APPROVEDPassed the applicable rules.
REJECTEDFailed one or more rules.
NOT_APPLICABLENo validation rules apply to this document.
ERRORThe validation itself failed to run (not a verdict on the document). Retry the upload or contact support.

The no-hard-block rule​

This is the rule that shapes the whole flow:

Missing or rejected documents never block check-in

A missing mandatory document or an AI-REJECTED one produces a warning and a recorded pendencia — never a block. The reception user always lets the patient through, with no justification or approval; the pre-appointment simply stays PENDING. Pendencias are visible downstream to the billing team (faturamento), who resolve them as part of the normal billing cycle.

The API's job is to surface what's missing so the user can act on it while the patient is present — not to gate care.

Listing​

GET /v1/checkin/appointments/{id}/documents returns all enabled documents (including PENDING placeholders without a file), each with a presigned download URL (null for empty placeholders) and the associated charge info. Documents that share a stored file share one presigned URL.

Endpoints​

OperationEndpoint
Upload (manual)POST /v1/checkin/appointments/{id}/documents
Upload (HIS integration)POST /v1/checkin/appointments/his-inbound/{external_appointment_id}/documents
ListGET /v1/checkin/appointments/{id}/documents
Delete (soft)DELETE /v1/checkin/appointments/{id}/documents/{documentId}
Clear to PENDINGPOST /v1/checkin/appointments/{id}/documents/{documentId}/clear

Common pitfalls​

  • Uploading a file larger than 45 MB → the platform rejects the request and, depending on the environment, may answer 500 without a message instead of 413 Payload Too Large. Split the file.
  • A support_file_code / provider_product_codes combination with nothing to complete or replace → 422: no PENDING placeholder matches and, when you send explicit codes, there is no received document of those charges either. Check the configured supports for the charge.
  • Trying to delete or clear a HIS document → 403. Only MANUAL documents are mutable.
  • Replacing a document uploaded by the other channel → 403.
  • Replacing without explicit provider_product_codes → 422.
  • Assuming the download URL is permanent — presigned URLs expire. Re-list to get a fresh one.