Skip to main content

HIS inbound

HIS inbound is how scheduled appointments enter OSIGU automatically. Your Hospital Information System (HIS) pushes each appointment as it's created; this is the first inbound endpoint of the ecosystem (push HIS → OSIGU).

POST /v1/checkin/appointments/his-inbound
PUT /v1/checkin/appointments/his-inbound/{external_appointment_id}
DELETE /v1/checkin/appointments/his-inbound/{external_appointment_id}
POST /v1/checkin/appointments/his-inbound/{external_appointment_id}/documents
Dedicated credentials

All four HIS integration operations (create, update, delete, document upload) are gated by a single permission, granted separately from the manual reception-desk operations. Ask OSIGU for dedicated credentials for your HIS integration rather than reusing the reception desk's — it keeps the two access paths independent and auditable.

Identity and idempotency​

An appointment is identified by the pair (provider, external_appointment_id) — the provider comes from your token, and external_appointment_id is your HIS's own identifier for the appointment. This makes the endpoint idempotent and safe to retry: sending the same appointment twice never creates a duplicate.

The pair is unique only among live appointments

Deduplication looks only at appointments that are still enabled. Once an appointment has been deleted (DELETE /his-inbound/{external_appointment_id}, a soft-delete), a later POST with the same external_appointment_id no longer finds it and creates a brand-new appointment instead of resurrecting the old one. So (provider, external_appointment_id) is not a permanent key — plan for delete-then-resend producing a new record, with a new id.

What happens on a re-send is a charge merge, not an overwrite:

The rules on a re-send are strict and worth memorising:

  • The appointment header is never modified — beneficiary, payer, doctor, appointment date, notes, agreement, service. Whatever was captured on first creation stays.
  • Only charges whose provider_product_code is not already present are merged in, under a row lock (concurrent re-sends are safe).

Response codes​

CodeMeaning
201 CreatedA new pre-appointment was created, or an existing one received at least one new charge.
200 OKNo-op: the appointment already existed and none of the request's charges were new (all already present, or charges empty/absent).
422 Unprocessable EntityRequest validation failed — returns field paths and messages — or agreement_code did not resolve to an agreement of this provider.
404 Not FoundThe provider could not be resolved in the RCM platform.
502 Bad GatewayThe RCM API is unavailable or timed out.
Treat 200 and 201 the same

Both 200 and 201 return the current pre-appointment in the body. For an idempotent push you usually don't need to branch on the code — just persist the returned appointment. The distinction is there if you want to log "created something new" vs "already up to date".

Request shape​

The payload carries the appointment header and the charges. The agreement is the anchor: both the payer and the agreement's canonical name are resolved from agreement_code. The beneficiary, doctor, specialty and service are captured as sent.

{
"external_appointment_id": "HIS20260706001234",
"appointment_date": "2026-07-15T14:30:00-05:00",
"beneficiary_card_number": "0123456789",
"beneficiary_name": "Juan Carlos Perez Gomez",
"beneficiary_document_type": "CC",
"beneficiary_document_number": "1234567890",
"doctor_name": "Dr. Maria Sanchez",
"doctor_code": "123456",
"doctor_state_code": "SP",
"specialty_name": "Cardiology",
"agreement_code": "AGR2024001",
"service_code": "S1",
"charges": [
{ "provider_product_code": "PROC001", "provider_product_name": "Electrocardiogram (ECG)", "quantity": 1 }
]
}

doctor_code (digits only) and doctor_state_code (the Brazilian CRM-issuing UF) are required when creating or updating an appointment's header, but not read on a charge re-send. If either is missing, the API responds 422 with code 077-0500-0009; a non-digit CRM or a UF outside the 27 returns 422 with the field in errors[].path.

See the API Reference for the complete field list, constraints, and a live playground. For a step-by-step integration walk-through, see Integrate HIS inbound.

Managing an existing appointment​

Beyond creating and merging, the HIS can update and delete an appointment it created, and upload its support documents. All three operations address the appointment by its external_appointment_id in the path, are restricted to appointments with source HIS_INBOUND, and require the same HIS integration permission as POST.

Update — PUT /his-inbound/{external_appointment_id}​

Unlike a POST re-send (which never touches the header and only adds charges), PUT updates the header and reconciles the charges:

  • Header — beneficiary, doctor, specialty, service, notes and appointment date are updated to the request's values.
  • Agreement — agreement_code is optional on PUT. Omit it and the appointment keeps its current agreement, payer and agreement name untouched (so you can edit a note without re-sending the agreement). Send a different code and the agreement is re-resolved against the RCM platform, replacing the payer and the agreement name. Sending the same code changes nothing.
  • Charges are reconciled against the request's charges list:
    • not yet present → added;
    • present in both → updated in place (quantity / provider_product_name);
    • no longer present → soft-deleted, along with their documents.

Only appointments in a non-terminal status (PENDING / CONFIRMED) can be updated.

CodeMeaning
200 OKHeader updated and charges reconciled; returns the current pre-appointment.
400 Bad RequestThe appointment exists but was not created by the HIS integration (source ≠ HIS_INBOUND).
404 Not FoundNo appointment for that external_appointment_id + provider, or the provider is not resolvable in RCM.
409 ConflictThe appointment is in a terminal status (COMPLETED / CANCELLED) and can't be updated.
422 Unprocessable EntityRequest validation failed, or agreement_code did not resolve to an agreement of this provider.
403 ForbiddenYour credentials aren't enabled for HIS integration.

Delete — DELETE /his-inbound/{external_appointment_id}​

Soft-deletes the appointment along with its charges and documents (the S3 objects are left intact). Only HIS_INBOUND appointments can be deleted.

CodeMeaning
204 No ContentSoft-deleted — or the appointment was already CANCELLED (idempotent no-op).
400 Bad RequestThe appointment was not created by the HIS integration (source ≠ HIS_INBOUND).
404 Not FoundNo appointment for that external_appointment_id + provider.
409 ConflictThe appointment is COMPLETED and can't be deleted.
403 ForbiddenYour credentials aren't enabled for HIS integration.

DELETE is idempotent — deleting an already-cancelled appointment still returns 204.

Upload a document — POST /his-inbound/{external_appointment_id}/documents​

Completes the appointment's PENDING document placeholders with a file sent by the HIS. The request is the multipart/form-data described in Support documents — a binary file part plus a request_data JSON part with support_file_code and provider_product_codes, and the appointment is addressed by your external_appointment_id.

The resulting documents are stored with source HIS_INBOUND: the HIS is their system of record, so they can't be deleted or cleared afterwards from the documents endpoints (403). Only appointments in a non-terminal status (PENDING / CONFIRMED) accept uploads.

CodeMeaning
201 CreatedOne array element per completed placeholder.
400 Bad RequestThe appointment was not created by the HIS integration (source ≠ HIS_INBOUND).
404 Not FoundNo appointment for that external_appointment_id + provider.
409 ConflictThe appointment is in a terminal status (COMPLETED / CANCELLED).
413 Payload Too LargeThe file exceeds the platform limit (45 MB is accepted; larger requests may be rejected with a 500 and no message).
422 Unprocessable EntityValidation failed (missing file or support_file_code, MIME type not PDF/JPEG/PNG), or there is nothing to complete or replace for support_file_code + provider_product_codes (no PENDING placeholder and, with explicit codes, no received document).
403 ForbiddenYour credentials aren't enabled for HIS integration, or the document you are replacing was uploaded from the reception desk.
502 Bad GatewayDocument storage is unavailable.

The HIS can replace the documents it uploaded by sending the file again with explicit provider_product_codes. The replacement is resolved per charge (the most recently received document); with the support document's keep_support_file_history setting on, the previous file stays as an active record and the response contains the new one. Documents uploaded from the reception desk can't be replaced by the HIS (403). See Documents for the full rules.

If generating the download link fails, the API still answers 201 with download_url: null: the documents are already saved and the file is already in storage. Don't re-send the upload — it would duplicate the documents and the stored file.

Common pitfalls​

  • Reusing external_appointment_id across appointments. It's the dedup key. Two genuinely different visits must have different identifiers, or the second will be treated as a re-send of the first.
  • Expecting a re-send to update the header. A POST re-send won't — it only adds charges. If the beneficiary or date genuinely changed, use PUT, which updates the header and reconciles charges.