{
 "openapi": "3.1.0",
 "info": {
  "title": "Prescribing (EHR)",
  "version": "20261030b",
  "description": "Written, transmitted and dispensed. A controlled substance must be sent electronically or printed."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "prescriptions": {
    "type": "object",
    "required": [
     "patient_id",
     "formulary_id",
     "dose",
     "frequency"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "Id",
      "readOnly": true
     },
     "org_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org id",
      "readOnly": true
     },
     "org_unit_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org unit id",
      "readOnly": true
     },
     "rx_no": {
      "type": "string",
      "description": "Rx no",
      "readOnly": true
     },
     "patient_id": {
      "type": "string",
      "format": "uuid",
      "description": "Patient"
     },
     "encounter_id": {
      "type": "string",
      "format": "uuid",
      "description": "Encounter id"
     },
     "formulary_id": {
      "type": "string",
      "format": "uuid",
      "description": "Medication"
     },
     "prescriber_id": {
      "type": "string",
      "format": "uuid",
      "description": "Prescriber"
     },
     "dose": {
      "type": "string",
      "description": "Dose"
     },
     "route": {
      "type": "string",
      "description": "Route"
     },
     "frequency": {
      "type": "string",
      "description": "Frequency"
     },
     "duration_days": {
      "type": "integer",
      "description": "Duration (days)"
     },
     "quantity": {
      "type": "string",
      "format": "decimal",
      "description": "Quantity"
     },
     "refills": {
      "type": "integer",
      "description": "Refills"
     },
     "refills_used": {
      "type": "integer",
      "description": "Refills used",
      "readOnly": true
     },
     "indication": {
      "type": "string",
      "description": "Indication"
     },
     "instructions": {
      "type": "string",
      "description": "Instructions"
     },
     "is_prn": {
      "type": "boolean",
      "description": "As needed"
     },
     "written_at": {
      "type": "string",
      "format": "date-time",
      "description": "Written at",
      "readOnly": true
     },
     "start_date": {
      "type": "string",
      "format": "date",
      "description": "Start date"
     },
     "end_date": {
      "type": "string",
      "format": "date",
      "description": "End date"
     },
     "status": {
      "type": "string",
      "description": "Status",
      "readOnly": true
     },
     "transmitted_at": {
      "type": "string",
      "format": "date-time",
      "description": "Transmitted at",
      "readOnly": true
     },
     "transmit_method": {
      "type": "string",
      "description": "Transmit method",
      "readOnly": true
     },
     "pharmacy_name": {
      "type": "string",
      "description": "Pharmacy name"
     },
     "discontinued_reason": {
      "type": "string",
      "description": "Discontinued reason",
      "readOnly": true
     },
     "xf_text_1": {
      "type": "string",
      "description": "Xf text 1",
      "readOnly": true
     },
     "xf_text_2": {
      "type": "string",
      "description": "Xf text 2",
      "readOnly": true
     },
     "xf_text_3": {
      "type": "string",
      "description": "Xf text 3",
      "readOnly": true
     },
     "xf_text_4": {
      "type": "string",
      "description": "Xf text 4",
      "readOnly": true
     },
     "xf_text_5": {
      "type": "string",
      "description": "Xf text 5",
      "readOnly": true
     },
     "xf_num_1": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 1",
      "readOnly": true
     },
     "xf_num_2": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 2",
      "readOnly": true
     },
     "xf_num_3": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 3",
      "readOnly": true
     },
     "xf_date_1": {
      "type": "string",
      "format": "date",
      "description": "Xf date 1",
      "readOnly": true
     },
     "xf_date_2": {
      "type": "string",
      "format": "date",
      "description": "Xf date 2",
      "readOnly": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "created_by": {
      "type": "string",
      "format": "uuid",
      "description": "Created by",
      "readOnly": true
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Updated at",
      "readOnly": true
     },
     "updated_by": {
      "type": "string",
      "format": "uuid",
      "description": "Updated by",
      "readOnly": true
     },
     "pharmacy_id": {
      "type": "string",
      "format": "uuid",
      "description": "Pharmacy"
     },
     "drug_ndc": {
      "type": "string",
      "description": "Drug ndc"
     },
     "sig_text": {
      "type": "string",
      "description": "Directions (Sig)"
     },
     "sig_dose_quantity": {
      "type": "string",
      "format": "decimal",
      "description": "Dose quantity"
     },
     "sig_dose_unit_code": {
      "type": "string",
      "description": "Sig dose unit code"
     },
     "sig_frequency_per_day": {
      "type": "string",
      "format": "decimal",
      "description": "Sig frequency per day"
     },
     "quantity_unit_code": {
      "type": "string",
      "description": "Quantity unit code"
     },
     "days_supply": {
      "type": "integer",
      "description": "Days supply"
     },
     "substitutions": {
      "type": "string",
      "description": "Substitution",
      "enum": [
       "0",
       "1"
      ]
     },
     "note_to_pharmacist": {
      "type": "string",
      "description": "Note to the pharmacist"
     },
     "erx_status": {
      "type": "string",
      "description": "Erx status",
      "readOnly": true
     },
     "erx_message_id": {
      "type": "string",
      "description": "Erx message id",
      "readOnly": true
     },
     "erx_status_note": {
      "type": "string",
      "description": "Erx status note",
      "readOnly": true
     },
     "epcs_signed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Epcs signed at",
      "readOnly": true
     },
     "epcs_signed_by": {
      "type": "string",
      "format": "uuid",
      "description": "Epcs signed by",
      "readOnly": true
     },
     "renewal_of_id": {
      "type": "string",
      "format": "uuid",
      "description": "Renewal of id",
      "readOnly": true
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/ehr/prescriptions": {
   "get": {
    "summary": "list prescriptions",
    "operationId": "list_prescriptions_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create prescriptions",
    "operationId": "create_prescriptions_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}": {
   "get": {
    "summary": "get prescriptions",
    "operationId": "get_prescriptions_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change prescriptions",
    "operationId": "change_prescriptions_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete prescriptions",
    "operationId": "delete_prescriptions_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}/transmit": {
   "post": {
    "summary": "Transmit",
    "operationId": "action_prescriptions_0_6",
    "description": "Body keys: method, pharmacyId, password, otp, overrideReason",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}/erx-cancel": {
   "post": {
    "summary": "Erx cancel",
    "operationId": "action_prescriptions_0_6",
    "description": "Body keys: reason*",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}/erx-simulate": {
   "post": {
    "summary": "Erx simulate",
    "operationId": "action_prescriptions_0_6",
    "description": "Body keys: kind",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}/erx-messages": {
   "get": {
    "summary": "Erx messages",
    "operationId": "action_prescriptions_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_prescriptions_0_6",
    "description": "Body keys: overrides, preview, withLines",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{parentId}/dispenses": {
   "get": {
    "summary": "Dispenses",
    "operationId": "action_prescriptions_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Dispenses",
    "operationId": "action_prescriptions_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{parentId}/dispenses/{lineId}": {
   "put": {
    "summary": "Dispenses",
    "operationId": "action_prescriptions_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Dispenses",
    "operationId": "action_prescriptions_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/check": {
   "post": {
    "summary": "Check",
    "operationId": "action_prescriptions_0_5",
    "description": "Body keys: patientId*, formularyId",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/ehr/prescriptions/{id}/dispense": {
   "post": {
    "summary": "Dispense",
    "operationId": "action_prescriptions_0_6",
    "description": "Body keys: quantity, lotNo, expiryDate, dispensedBy, binId, counselled",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}