Clinical APIs - Prescription Management
This document covers the Clinical Prescription Management APIs including:
- Prescription Groups (advice/diet/notes templates)
- Medicine Groups (reusable medicine collections)
- Test Groups (reusable lab test collections)
- Practitioner Medicines (practitioner's medicine library)
- Prescription Templates (complete prescription templates)
Base URL: /clinical
Authentication: Bearer token required in Authorization header.
1. Prescription Groups
Prescription groups are reusable templates for advice, diet, and notes content.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /prescription_groups | List prescription groups |
| POST | /prescription_groups | Create prescription group |
| PATCH | /prescription_groups/:id | Update prescription group |
| DELETE | /prescription_groups/:id | Delete prescription group |
| POST | /prescription_groups/search | Search prescription groups |
List Prescription Groups
GET /prescription_groups
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Filter by practitioner |
| group_type | string | Yes | Type: advice, diet, or note |
Request Example:
GET /prescription_groups?practitioner_id=01900004-0000-7000-8000-000000000001&group_type=adviceResponse (200 OK):
{
"data": [
{
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"group_type": "advice",
"name": "General Fever Advice",
"content": "Take rest and plenty of fluids. Take medications as prescribed.",
"is_active": true
}
],
"meta": {
"request_id": "abc123"
}
}Create Prescription Group
POST /prescription_groups
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"group_type": "advice",
"name": "General Fever Advice",
"content": "Take rest and plenty of fluids. Take medications as prescribed."
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Practitioner UUID |
| group_type | string | Yes | Type: advice, diet, or note |
| name | string | Yes | Group name (max 255 chars) |
| content | text | No | Group content text |
Response (201 Created):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"group_type": "advice",
"name": "General Fever Advice",
"content": "Take rest and plenty of fluids. Take medications as prescribed.",
"is_active": true
},
"meta": {
"request_id": "abc123"
}
}Update Prescription Group
PATCH /prescription_groups/:id
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"name": "Updated Advice Name",
"content": "Updated content here"
}Response (200 OK):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T11:00:00Z",
"group_type": "advice",
"name": "Updated Advice Name",
"content": "Updated content here",
"is_active": true
},
"meta": {
"request_id": "abc123"
}
}Delete Prescription Group
DELETE /prescription_groups/:id?practitioner_id=:practitioner_id
Response (204 No Content)
2. Medicine Groups
Medicine groups are reusable collections of medicines for practitioners.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /medicine_groups | List medicine groups |
| POST | /medicine_groups | Create medicine group |
| GET | /medicine_groups/:id | Get medicine group details |
| PATCH | /medicine_groups/:id | Update medicine group |
| DELETE | /medicine_groups/:id | Delete medicine group |
| POST | /medicine_groups/search | Search medicine groups |
List Medicine Groups
GET /medicine_groups
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Filter by practitioner |
| search | string | No | Search by name |
| sort_by | string | No | Sort field: name, created_at |
| sort_order | string | No | Sort order: asc, desc |
Request Example:
GET /medicine_groups?practitioner_id=01900004-0000-7000-8000-000000000001&sort_by=nameResponse (200 OK):
{
"data": [
{
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Fever Medicines",
"description": "Standard fever treatment",
"medicines_count": 3,
"is_active": true
}
],
"meta": {
"request_id": "abc123"
}
}Create Medicine Group
POST /medicine_groups
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"name": "Fever Medicines",
"description": "Standard fever treatment protocol",
"medicines": [
{
"practitioner_medicine_id": "01940001-0000-7000-8000-000000000001"
},
{
"reference_medicine_id": "01930001-0000-7000-8000-000000000001",
"name": "Paracetamol 500mg",
"dosage_config": {
"timings": ["B", "D"],
"frequency": "DAILY",
"instructions": "after food"
},
"duration_value": 5,
"duration_unit": "days",
"dose_quantity": 1,
"dose_unit": "tablet"
}
]
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Practitioner UUID |
| name | string | Yes | Group name |
| description | text | No | Group description |
| medicines | array | No | Array of medicine items |
Medicine Item Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_medicine_id | UUID | No* | From practitioner's medicine library |
| reference_medicine_id | UUID | No* | From generic drug database |
| name | string | No* | Medicine name (required if no ID) |
| dosage_config | object | No | Dosage configuration |
| duration_value | integer | No | Duration value |
| duration_unit | string | No | Duration unit: days, weeks, months |
| dose_quantity | string | No | Dose quantity |
| dose_unit | string | No | Dose unit: tablet, ml, mg, etc. |
*At least one of practitioner_medicine_id, reference_medicine_id, or name is required.
Response (201 Created):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Fever Medicines",
"description": "Standard fever treatment protocol",
"medicines_count": 2,
"is_active": true,
"practitioner": {
"id": "01900004-0000-7000-8000-000000000001",
"name": "Dr. John Smith"
},
"items": [
{
"id": "01940002-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Paracetamol 500mg",
"dosage_config": {
"timings": ["B", "D"],
"frequency": "DAILY",
"instructions": "after food"
},
"duration_value": 5,
"duration_unit": "days",
"dose_quantity": "1",
"dose_unit": "tablet",
"medication_type": null,
"notes": null,
"practitioner_medicine_id": "01940001-0000-7000-8000-000000000001",
"reference_medicine_id": null
}
]
},
"meta": {
"request_id": "abc123"
}
}Update Medicine Group
PATCH /medicine_groups/:id
Request Body:
{
"name": "Updated Fever Medicines",
"description": "Updated description",
"medicines": [
{
"practitioner_medicine_id": "01940001-0000-7000-8000-000000000001"
}
]
}Response (200 OK): Returns updated medicine group with items.
Delete Medicine Group
DELETE /medicine_groups/:id
Response (200 OK):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"name": "Fever Medicines",
"is_active": false
}
}3. Test Groups
Test groups are reusable collections of lab tests for practitioners.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /practitioners/:practitioner_id/test_groups | List test groups |
| POST | /practitioners/:practitioner_id/test_groups | Create test group |
| PATCH | /practitioners/:practitioner_id/test_groups/:id | Update test group |
| DELETE | /practitioners/:practitioner_id/test_groups/:id | Delete test group |
List Test Groups
GET /practitioners/:practitioner_id/test_groups
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Practitioner UUID (in path) |
| sort | string | No | Sort by: name, created_desc |
Request Example:
GET /practitioners/01900004-0000-7000-8000-000000000001/test_groups?sort=nameResponse (200 OK):
{
"data": [
{
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Basic Blood Panel",
"external_cms_id": null,
"test_count": 3,
"is_active": true,
"tests": [
{
"id": "01940002-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Complete Blood Count",
"dosage_config": {},
"duration_value": null,
"duration_unit": null,
"dose_quantity": null,
"dose_unit": null,
"medication_type": null,
"notes": null,
"practitioner_medicine_id": null,
"reference_medicine_id": "01930001-0000-7000-8000-000000000001"
}
]
}
],
"meta": {
"request_id": "abc123"
}
}Create Test Group
POST /practitioners/:practitioner_id/test_groups
Request Body:
{
"name": "Fever Panel",
"external_cms_id": "FP-001",
"tests": [
{
"reference_lab_test_id": "01930001-0000-7000-8000-000000000001"
},
{
"custom_test_name": "Malaria Antigen Test"
}
]
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Test group name |
| external_cms_id | string | No | External CMS reference |
| tests | array | No | Array of test items |
Test Item Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| reference_lab_test_id | UUID | No* | Reference to lab test catalog |
| custom_test_name | string | No* | Custom test name |
*Either reference_lab_test_id OR custom_test_name is required.
Response (201 Created):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Fever Panel",
"external_cms_id": "FP-001",
"test_count": 2,
"is_active": true,
"tests": [
{
"id": "01940002-0000-7000-8000-000000000001",
"name": "Complete Blood Count",
"dosage_config": {},
"duration_value": null,
"duration_unit": null,
"dose_quantity": null,
"dose_unit": null,
"medication_type": null,
"notes": null,
"practitioner_medicine_id": null,
"reference_medicine_id": "01930001-0000-7000-8000-000000000001"
},
{
"id": "01940002-0000-7000-8000-000000000002",
"name": "Malaria Antigen Test",
"dosage_config": {},
"duration_value": null,
"duration_unit": null,
"dose_quantity": null,
"dose_unit": null,
"medication_type": null,
"notes": null,
"practitioner_medicine_id": null,
"reference_medicine_id": null
}
]
},
"meta": {
"request_id": "abc123"
}
}Update Test Group
PATCH /practitioners/:practitioner_id/test_groups/:id
Request Body:
{
"name": "Updated Fever Panel",
"tests": [
{
"reference_lab_test_id": "01930001-0000-7000-8000-000000000001"
}
]
}Response (200 OK): Returns updated test group.
Delete Test Group
DELETE /practitioners/:practitioner_id/test_groups/:id
Response (204 No Content)
4. Practitioner Medicines
Practitioner medicines represent a practitioner's personal medicine library with custom dosage configurations.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /practitioner_medicines | List practitioner medicines |
| POST | /practitioner_medicines | Create practitioner medicine |
| PATCH | /practitioner_medicines/:id | Update practitioner medicine |
| DELETE | /practitioner_medicines/:id | Delete practitioner medicine |
| POST | /practitioner_medicines/search | Search medicines by name |
List Practitioner Medicines
GET /practitioner_medicines
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Filter by practitioner |
| sort | string | No | Sort by: name, created_desc |
| medication_type | string | No | Filter by type: tablet, syrup, etc. |
Request Example:
GET /practitioner_medicines?practitioner_id=01900004-0000-7000-8000-000000001&sort=nameResponse (200 OK):
{
"data": [
{
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Paracetamol 500mg",
"alternate_name": "Acetaminophen",
"medication_type": "tablet",
"dosage_config": {
"timings": ["B", "D"],
"frequency": "DAILY",
"instructions": "after food"
},
"duration_value": 5,
"duration_unit": "days",
"dose_quantity": "1",
"dose_unit": "tablet",
"notes": "Take with meals",
"is_active": true,
"reference_medicine_id": "01930001-0000-7000-8000-000000000001"
}
],
"meta": {
"request_id": "abc123"
}
}Create Practitioner Medicine
POST /practitioner_medicines
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"reference_medicine_id": "01930001-0000-7000-8000-000000000001",
"name": "Paracetamol 500mg",
"alternate_name": "Acetaminophen",
"dosage_config": {
"timings": ["B", "D"],
"frequency": "DAILY",
"instructions": "after food"
},
"duration_value": 5,
"duration_unit": "days",
"dose_quantity": 1,
"dose_unit": "tablet",
"medication_type": "tablet",
"notes": "Take with meals"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Practitioner UUID |
| name | string | Yes* | Medicine name |
| reference_medicine_id | UUID | No* | Reference to generic drug |
| alternate_name | string | No | Alternate medicine name |
| dosage_config | object | No | Dosage configuration object |
| duration_value | integer | No | Duration value |
| duration_unit | string | No | Duration unit |
| dose_quantity | string | No | Dose quantity |
| dose_unit | string | No | Dose unit |
| medication_type | string | No | Type: tablet, capsule, syrup, injection |
| notes | text | No | Additional notes |
*Either name or reference_medicine_id is required.
Dosage Config Structure:
{
"timings": ["B", "L", "D"],
"frequency": "DAILY",
"instructions": "after food"
}Response (201 Created):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Paracetamol 500mg",
"alternate_name": "Acetaminophen",
"medication_type": "tablet",
"dosage_config": {
"timings": ["B", "D"],
"frequency": "DAILY",
"instructions": "after food"
},
"duration_value": 5,
"duration_unit": "days",
"dose_quantity": "1",
"dose_unit": "tablet",
"notes": "Take with meals",
"is_active": true,
"reference_medicine_id": "01930001-0000-7000-8000-000000000001"
},
"meta": {
"request_id": "abc123"
}
}Update Practitioner Medicine
PATCH /practitioner_medicines/:id
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"notes": "Updated notes",
"duration_value": 7
}Response (200 OK): Returns updated medicine.
Delete Practitioner Medicine
DELETE /practitioner_medicines/:id?practitioner_id=:practitioner_id
Response (204 No Content)
Search Medicines
POST /practitioner_medicines/search
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"name": "paracetamol"
}Response (200 OK): Returns array of matching medicines.
5. Prescription Templates
Prescription templates are complete prescription templates that reference existing groups. Templates can combine:
- Advice Group - PrescriptionGroup with
group_type: 'advice' - Diet Group - PrescriptionGroup with
group_type: 'diet' - Notes Group - PrescriptionGroup with
group_type: 'note' - Medicine Group - for medicine collections
- Test Group - for lab test collections
- Direct content - advice, diet, notes text
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /prescription_templates | List prescription templates |
| POST | /prescription_templates | Create prescription template |
| GET | /prescription_templates/:id | Get template details |
| PATCH | /prescription_templates/:id | Update prescription template |
| DELETE | /prescription_templates/:id | Delete prescription template |
| POST | /prescription_templates/search | Search templates |
List Prescription Templates
GET /prescription_templates
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Filter by practitioner |
| category | string | No | Filter by category |
| template_type | string | No | Filter by type: simple, grouped, hybrid |
| favorites_only | boolean | No | Only favorites |
Request Example:
GET /prescription_templates?practitioner_id=01900004-0000-7000-8000-000000001&category=consultationResponse (200 OK):
{
"data": [
{
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Fever Consultation",
"category": "consultation",
"template_type": "grouped",
"medicines_count": 3,
"tests_count": 2,
"is_favorite": true,
"is_active": true
}
],
"meta": {
"request_id": "abc123"
}
}Create Prescription Template
POST /prescription_templates
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"name": "Fever Consultation",
"category": "consultation",
"description": "Standard fever treatment template",
"advice": "Take rest and plenty of fluids",
"diet": "Light diet, avoid spicy food",
"notes": "Follow up after 3 days if symptoms persist",
"is_favorite": true,
"advice_group_id": "01940001-0000-7000-8000-000000000001",
"diet_group_id": "01940001-0000-7000-8000-000000000002",
"notes_group_id": "01940001-0000-7000-8000-000000000003",
"medicine_group_id": "01940001-0000-7000-8000-000000000010",
"test_group_id": "01940001-0000-7000-8000-000000000020"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| practitioner_id | UUID | Yes | Practitioner UUID |
| name | string | Yes | Template name (unique per practitioner) |
| category | string | No | Category (e.g., consultation, follow_up) |
| description | text | No | Template description |
| advice | text | No | Direct advice content |
| diet | text | No | Direct diet content |
| notes | text | No | Direct notes content |
| is_favorite | boolean | No | Mark as favorite (default: false) |
| advice_group_id | UUID | No | Reference to PrescriptionGroup with group_type: 'advice' |
| diet_group_id | UUID | No | Reference to PrescriptionGroup with group_type: 'diet' |
| notes_group_id | UUID | No | Reference to PrescriptionGroup with group_type: 'note' |
| medicine_group_id | UUID | No | Reference to MedicineGroup |
| test_group_id | UUID | No | Reference to TestGroup |
Response (201 Created):
{
"data": {
"id": "01940001-0000-7000-8000-000000000001",
"created_at": "2026-02-16T10:00:00Z",
"updated_at": "2026-02-16T10:00:00Z",
"name": "Fever Consultation",
"category": "consultation",
"template_type": "grouped",
"medicines_count": 3,
"tests_count": 2,
"is_favorite": true,
"is_active": true,
"advice": "Take rest and plenty of fluids",
"diet": "Light diet, avoid spicy food",
"notes": "Follow up after 3 days if symptoms persist",
"description": "Standard fever treatment template",
"advice_group": {
"id": "01940001-0000-7000-8000-000000000001",
"name": "Fever Advice",
"group_type": "advice",
"content": "Take rest and plenty of fluids"
},
"diet_group": {
"id": "01940001-0000-7000-8000-000000000002",
"name": "Fever Diet",
"group_type": "diet",
"content": "Light diet, avoid spicy food"
},
"notes_group": {
"id": "01940001-0000-7000-8000-000000000003",
"name": "Fever Notes",
"group_type": "note",
"content": "Follow up after 3 days if symptoms persist"
},
"medicine_group": {
"id": "01940001-0000-7000-8000-000000000010",
"name": "Fever Medicines",
"medicines_count": 3
},
"test_group": {
"id": "01940001-0000-7000-8000-000000000020",
"name": "Fever Panel",
"tests_count": 2
},
"practitioner": {
"id": "01900004-0000-7000-8000-000000000001",
"name": "Dr. John Smith"
}
},
"meta": {
"request_id": "abc123"
}
}Get Template Details
GET /prescription_templates/:id
Response (200 OK): Returns detailed template with all group references.
Update Prescription Template
PATCH /prescription_templates/:id
Request Body:
{
"name": "Updated Fever Treatment",
"advice": "Complete the full course of medication",
"is_favorite": false,
"advice_group_id": "01940001-0000-7000-8000-000000000010",
"medicine_group_id": "01940001-0000-7000-8000-000000000011"
}Response (200 OK): Returns updated template.
Delete Prescription Template
DELETE /prescription_templates/:id
Response (204 No Content)
Search Templates
POST /prescription_templates/search
Request Body:
{
"practitioner_id": "01900004-0000-7000-8000-000000000001",
"search": "fever",
"category": "consultation"
}Response (200 OK): Returns array of matching templates.
Error Responses
Validation Error (422)
{
"success": false,
"errors": [
{
"code": "validation_error",
"message": "Name can't be blank",
"field": "name"
}
]
}Not Found Error (404)
{
"success": false,
"errors": [
{
"code": "not_found",
"message": "PrescriptionTemplate not found",
"field": "id"
}
]
}Unauthorized Error (401)
{
"success": false,
"errors": [
{
"code": "unauthorized",
"message": "Access denied"
}
]
}Template Types
Prescription templates can have the following types based on their content:
| Type | Description |
|---|---|
simple | Only direct content (advice/diet/notes), no group references |
grouped | Only group references, no direct content |
hybrid | Both direct content and group references |
empty | No content (will fail validation) |
Common Workflows
Creating a Complete Prescription Template
- Create Prescription Groups (for advice, diet, notes)
- Create Practitioner Medicines (add medicines to library)
- Create Medicine Group (group medicines together)
- Create Test Group (group lab tests)
- Create Prescription Template (reference all groups)
Example: Full Workflow
// 1. Create advice group
POST /prescription_groups
{
"practitioner_id": "...",
"group_type": "advice",
"name": "Fever Advice",
"content": "Take rest and plenty of fluids"
}
// Response: { "data": { "id": "ADVICE_GROUP_ID", ... } }
// 2. Create diet group
POST /prescription_groups
{
"practitioner_id": "...",
"group_type": "diet",
"name": "Fever Diet",
"content": "Light diet, avoid spicy food"
}
// Response: { "data": { "id": "DIET_GROUP_ID", ... } }
// 3. Create notes group
POST /prescription_groups
{
"practitioner_id": "...",
"group_type": "note",
"name": "Fever Notes",
"content": "Follow up after 3 days if symptoms persist"
}
// Response: { "data": { "id": "NOTES_GROUP_ID", ... } }
// 4. Create medicine group
POST /medicine_groups
{
"practitioner_id": "...",
"name": "Fever Medicines",
"medicines": [
{ "reference_medicine_id": "...", "name": "Paracetamol 500mg" }
]
}
// Response: { "data": { "id": "MEDICINE_GROUP_ID", ... } }
// 5. Create test group
POST /practitioners/:id/test_groups
{
"name": "Fever Panel",
"tests": [
{ "reference_lab_test_id": "..." }
]
}
// Response: { "data": { "id": "TEST_GROUP_ID", ... } }
// 6. Create prescription template with all group references
POST /prescription_templates
{
"practitioner_id": "...",
"name": "Fever Consultation",
"category": "consultation",
"advice_group_id": "ADVICE_GROUP_ID",
"diet_group_id": "DIET_GROUP_ID",
"notes_group_id": "NOTES_GROUP_ID",
"medicine_group_id": "MEDICINE_GROUP_ID",
"test_group_id": "TEST_GROUP_ID"
}
// Response: { "data": { "id": "TEMPLATE_ID", ... } }Notes
- All UUIDs are in UUIDv7 format
- All timestamps are in ISO8601 format (UTC)
- Soft-deleted resources are excluded from list endpoints by default
- Practitioners can only access their own resources
- Group references must belong to the same practitioner as the template