Create an electronic prescription
This guide walks a doctor's integration through issuing a compliant electronic prescription end-to-end. Same shape for v1 and v1.1; the v2 flow (Spain repository certification) adds a signed-hash payload we call out at the end.
Concept refresher: Prescriptions.
Prerequisites
- OAuth token with
ehr:writescope. - The doctor's identity — usually derived from the token, but some flows need
doctor_idin the body. - The medications you plan to prescribe are already registered as provider products.
1. Resolve the patient
If your local system already has a patient_id mapped to Osigu, skip to step 2. Otherwise, look up or create the patient:
# Look up existing
curl "https://sandbox.osigu.com/ehr/v1/patients?document_number=1000000001" \
-H "Authorization: Bearer $TOKEN"
# Create new
curl -X POST "https://sandbox.osigu.com/ehr/v1/patients" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"first_name": "Ana",
"last_name": "López",
"document_type": "CC",
"document_number": "1000000001",
"date_of_birth": "1990-04-11"
}'
Persist the patient_id.
2. Pick a diagnosis
curl "https://sandbox.osigu.com/medical-catalogs/v1/diagnoses?query=cephalgia" \
-H "Authorization: Bearer $TOKEN"
Response returns ICD-10 codes. Pick the one the doctor confirms (e.g. R51 — Headache).
3. Pick medications
Medications must be in your provider-product list. List them:
curl "https://sandbox.osigu.com/arc/v1/providers/products?product_type=MEDICATION" \
-H "Authorization: Bearer $TOKEN"
If the medication the doctor wants isn't here, register it first — otherwise createPrescription returns 422.
4. Create the prescription (v1)
curl -X POST "https://sandbox.osigu.com/ehr/v1/prescriptions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"patient_id": "pat_01HXE...",
"diagnoses": [{ "diagnosis_code": "R51" }],
"medications": [{
"product_code": "MED-042",
"quantity": 30,
"posology": "1 tablet every 8h",
"duration_days": 10
}]
}'
Response (201):
{
"prescription_id": "rx_01HXF...",
"prescription_code": "RX-2026-9182",
"status": "PRESCRIPTION_ISSUED",
"created_at": "2026-06-25T16:00:00Z"
}
The prescription_code is what a pharmacy will use later to dispense.
5. Deliver to the patient
Osigu can email the prescription (or a link to a downloadable PDF) to the patient:
curl -X POST "https://sandbox.osigu.com/ehr/v1/prescriptions/rx_.../resend" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"channel": "EMAIL"}'
If the patient prefers a URL you can render yourself, getPrescription returns the download URL in the response.
v1.1: patient-data-consent variant
If your integration is in a market that mandates explicit consent capture (typically GDPR-adjacent regimes), use v1.1 — same body plus a required patient_data_consent = true. Server returns 422 if the consent flag is missing.
curl -X POST "https://sandbox.osigu.com/ehr/v1.1/prescriptions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"patient_id": "pat_...",
"patient_data_consent": true,
"diagnoses": [{ "diagnosis_code": "R51" }],
"medications": [{ "product_code": "MED-042", "quantity": 30, "posology": "1 tablet every 8h" }]
}'
v2: Spain national-repository variant
For Spain, the prescription must be certified against the national e-prescription repository. This adds two things:
national_repository_id— the registration identifier issued to your provider when it was certified.- A signed hash structure covering the immutable fields of the prescription.
Both are documented in the endpoint reference: createPrescriptionV2. Outside Spain, ignore v2.
Related
- Register a provider product — required before prescribing.
- Dispense an authorization — pharmacy-side redemption; works for prescription codes too.
- Concept: Prescriptions.