Orders API Documentation
Overview
The PLACE_ORDER action is part of the Cases API that allows external systems to place medication orders for specific cases. This endpoint enables third-party integrations to create orders with prescription items, prescriber information, and patient health details.
Endpoint
POST /api/v1/cases/:caseId
Authentication
- Header:
cv-api-key(required) - Type: String
- Description: API key for organization authentication
Request Parameters
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
caseId | String | Yes | The unique identifier of the case |
Request Body
The request body must be a JSON object with the following structure:
{
"action": "PLACE_ORDER",
"order": {
"shippingAddress": {
"addressLine1": "string",
"addressLine2": "string (optional)",
"city": "string",
"state": "string",
"country": "string",
"postalCode": "string"
},
"patientHealthInfo": {
"allergies": "string (optional)",
"healthConditions": "string (optional)",
"currentMedications": "string (optional)"
},
"prescriber": {
"firstName": "string",
"lastName": "string",
"title": "string (optional)",
"titleSuffix": "string (optional)",
"npi": "string",
"dea": "string (optional)",
"email": "string",
"phoneNumber": "string",
"address": {
"addressLine1": "string",
"addressLine2": "string (optional)",
"city": "string",
"state": "string",
"country": "string",
"postalCode": "string"
}
},
"diagnosis": "string",
"pharmacyId": "string",
"dateWritten": "string (optional)",
"dateSigned": "string (optional)",
"datePrescribed": "string (optional)",
"prescriptionItems": [
{
"drugId": "string",
"direction": "string (optional)",
"quantity": "string",
"refillCount": "number (optional)",
"supplyDays": "number (optional)",
"customFields": "object (optional)"
}
]
}
}
Field Specifications
Required Fields
Root Level
action: Must be exactly"PLACE_ORDER"order: Object containing order details
Order Object
prescriber: Prescriber information (optional fields are mentioned in above JSON structure)diagnosis: Medical diagnosis for the prescriptionpharmacyId: Target pharmacy identifierprescriptionItems: Array of prescription items (at least one required)
Prescriber Object
firstName: Prescriber's first namelastName: Prescriber's last namenpi: National Provider Identifieremail: Prescriber's email addressphoneNumber: Contact phone numberaddress: Address object containingaddressLine1, addressLine2, city, state, country, postalCode
Prescription Items
drugId: Unique identifier for the medicationquantity: Quantity to be prescribed
Optional Fields
Shipping Address
shippingAddress: If not provided, uses patient's address from case
Patient Health Information
patientHealthInfo: Optional health detailsallergies: Known allergieshealthConditions: Current health conditionscurrentMedications: Current medications
Prescriber Details
title: Professional title (e.g., "Dr.")titleSuffix: Title suffix (e.g., "MD", "DO")dea: Drug Enforcement Administration number
Dates
dateWritten: Date prescription was writtendateSigned: Date prescription was signeddatePrescribed: Date prescription was prescribed
Prescription Items
direction: Dosage instructionsrefillCount: Number of refills allowedsupplyDays: Days of supplycustomFields: Additional custom fields as key-value pairs
Validation Rules
State Validation
statemust be a valid US state abbreviation (e.g., "CA", "NY", "TX")
Country Validation
countrymust be exactly 2 characters- Will be automatically converted to uppercase
Postal Code Validation
- Must be exactly 5 digits
- Only numeric characters allowed
Email Validation
- Must be a valid email format
Phone Number Validation
- Must be a valid phone number format
Response Format
Success Response
{
"status": 200,
"success": true,
"message": "Order created successfully",
"data": {
"order": {
"id": "<order_id>"
}
}
}
Error Response
{
"status": 400,
"success": false,
"message": "Invalid request",
"error": "Error description"
}
Error Scenarios
400 Bad Request
- Missing required fields
- Invalid field formats
- Invalid state codes
- Invalid email format
- Invalid postal code format
- Missing API key
401 Unauthorized
- Invalid or missing API key
- Organization not found
403 Forbidden
- Case does not belong to the organization
- Permission denied
Example Request
curl -X POST "https://api.example.com/api/cases/123e4567-e89b-12d3-a456-426614174000" \
-H "Content-Type: application/json" \
-H "cv-api-key: your-api-key-here" \
-d '{
"action": "PLACE_ORDER",
"order": {
"shippingAddress": {
"addressLine1": "123 Main St",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postalCode": "94105"
},
"patientHealthInfo": {
"allergies": "Penicillin",
"healthConditions": "Hypertension",
"currentMedications": "Lisinopril 10mg daily"
},
"prescriber": {
"firstName": "John",
"lastName": "Smith",
"title": "Dr.",
"titleSuffix": "MD",
"npi": "1234567890",
"email": "john.smith@example.com",
"phoneNumber": "+1234567890",
"address": {
"addressLine1": "456 Medical Center Dr",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postalCode": "94102"
}
},
"diagnosis": "Hypertension",
"pharmacyId": "pharmacy-123",
"dateWritten": "2024-01-15",
"prescriptionItems": [
{
"drugId": "drug-456",
"direction": "Take 1 tablet daily with food",
"quantity": "30",
"refillCount": 3,
"supplyDays": 30
}
]
}
}'
Example Response
Success
{
"status": 200,
"success": true,
"message": "Order created successfully",
"data": {
"order": {
"id": "<order_id>"
}
}
}
Error
{
"status": 400,
"success": false,
"message": "Invalid request",
"error": "firstName is required"
}
Notes
-
Case Ownership: The case must belong to the organization associated with the provided API key.
-
Order Processing: Orders are processed asynchronously and may take time to complete.
-
Prescription Download: Upon successful order creation, prescription documents are automatically downloaded and stored.
-
Address Handling: If no shipping address is provided, the system will use the patient's address from the case.
-
Notifications: Case activity notifications are sent upon successful order creation via webhooks.