Skip to main content

Integrate HIS inbound

This guide walks through wiring your Hospital Information System to push appointments into OSIGU as they're scheduled. See HIS inbound for the concept.

Prerequisites​

  • OSIGU credentials enabled for HIS integration — one permission covers all four operations (create, update, delete and document upload). Ask for credentials dedicated to the HIS, separate from the reception desk's.
  • The (provider, payer, agreement) combinations you'll use enabled for your integration.

Step 1 — Get an access token​

Pre-Attendance uses the same OAuth2 client-credentials flow as the rest of the platform:

curl -X POST https://sandbox.osigu.com/v1/oauth/token \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d "grant_type=client_credentials"

Cache the token for ~50 minutes. See Obtaining tokens.

Step 2 — Push the appointment​

Send each appointment as it's created in your HIS:

curl -X POST https://sandbox.osigu.com/pre-attendance-api/v1/checkin/appointments/his-inbound \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"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",
"charges": [
{ "provider_product_code": "PROC001", "provider_product_name": "Electrocardiogram (ECG)", "quantity": 1 }
]
}'

external_appointment_id is your HIS identifier for the appointment and is the deduplication key. Use a stable, unique value per real appointment.

Step 3 — Handle the response​

CodeWhat it meansWhat to do
201 CreatedNew pre-appointment created, or new charge(s) merged into an existing one.Persist the returned appointment (note its id).
200 OKNothing new (already existed, no new charges).Safe to ignore — you're already in sync.
422Validation failed, or agreement_code did not resolve.Fix the payload; the body lists field paths. For an unresolved agreement, check agreement_code against your agreement configuration with Osigu.
404Provider not resolvable.The provider behind your credentials is not configured in RCM — contact Osigu.
502RCM API unavailable.Retry with backoff (see below).

Both success codes return the current pre-appointment in the body, so for a simple sync you can persist the body without branching.

Step 4 — Retries are safe​

Because identity is (provider, external_appointment_id), re-sending is idempotent:

  • Re-send after a network error → no duplicate; you get the current state.
  • Re-send with an additional charge → only the new charge (by provider_product_code) is merged; the header is untouched.
  • Re-send unchanged → 200 OK no-op.

So on 502 or a timeout, just retry the same request with exponential backoff.

Step 5 — Update or delete an appointment​

When an appointment genuinely changes in your HIS (a re-send won't update the header), or is cancelled, use the management operations. Both address the appointment by external_appointment_id in the path and use the same HIS integration credentials as POST. See Managing an existing appointment for the full semantics.

Update (updates the header and reconciles charges — added / updated / removed):

curl -X PUT https://sandbox.osigu.com/pre-attendance-api/v1/checkin/appointments/his-inbound/HIS20260706001234 \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "appointment_date": "2026-07-16T09:00: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", "charges": [ { "provider_product_code": "PROC001", "provider_product_name": "Electrocardiogram (ECG)", "quantity": 2 } ] }'

Note this PUT carries no agreement_code: it's optional on update, so the appointment keeps its current agreement, payer and agreement name. Include it only when the agreement actually changed.

Returns 200 with the updated appointment. Charges missing from the list are soft-deleted. Only HIS_INBOUND appointments in PENDING/CONFIRMED can be updated (400 if it wasn't created by the HIS, 409 if it's COMPLETED/CANCELLED).

Delete (soft-delete, idempotent):

curl -X DELETE https://sandbox.osigu.com/pre-attendance-api/v1/checkin/appointments/his-inbound/HIS20260706001234 \
-H "Authorization: Bearer $ACCESS_TOKEN"

Returns 204 (also 204 if it was already cancelled). A COMPLETED appointment can't be deleted (409).

Step 6 — Upload support documents​

When the HIS already holds a required document (a medical order, a TISS guide…), upload it against the appointment's PENDING placeholders. Address the appointment by your external_appointment_id.

curl -X POST https://sandbox.osigu.com/pre-attendance-api/v1/checkin/appointments/his-inbound/HIS20260706001234/documents \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-F "file=@medical-order.pdf;type=application/pdf" \
-F 'request_data={"support_file_code":"CPF","provider_product_codes":["PROC001"]};type=application/json'
  • support_file_code picks the placeholder; provider_product_codes restricts it to those charges (empty or absent → every charge with that placeholder). See Support documents.
  • The file must be PDF, JPEG or PNG (checked by content) and at most 200 MB.
  • Returns 201 with one element per completed placeholder. The documents are stored with source HIS_INBOUND, so they can't be deleted or cleared later from the documents endpoints (403).
CodeWhat to do
400The appointment wasn't created by the HIS integration; the HIS can only upload documents to appointments it created.
404Check the external_appointment_id; the appointment may have been deleted.
409The appointment is COMPLETED or CANCELLED; it no longer accepts documents.
413 / 422Fix the file or the metadata: size, type, or a support_file_code + provider_product_codes with nothing to complete or replace (no PENDING placeholder and, with explicit codes, no received document).
502Storage unavailable; retry with backoff.

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.

What NOT to do​

  • Don't reuse an external_appointment_id for a different visit — it will be treated as a re-send.
  • Don't expect a re-send to update the beneficiary/date/notes — a POST re-send never touches the header. Use PUT (Step 5) for that.

Next steps​