openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: MedAI — Clinical Decision Support API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: medai description: MedAI clinical decision support operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /medai/analyze-symptoms: post: operationId: analyzeSymptoms tags: [medai] summary: Analyze patient symptoms and generate SOAP note with triage decision requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AnalyzeSymptomsBody" responses: "200": description: SOAP note with triage decision content: application/json: schema: $ref: "#/components/schemas/SoapAnalysis" /medai/check-prescription: post: operationId: checkPrescription tags: [medai] summary: Check prescription for safety issues requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CheckPrescriptionBody" responses: "200": description: Prescription safety report content: application/json: schema: $ref: "#/components/schemas/PrescriptionSafetyReport" /medai/patients: get: operationId: listPatients tags: [medai] summary: List all patients responses: "200": description: List of patients content: application/json: schema: type: array items: $ref: "#/components/schemas/Patient" post: operationId: createPatient tags: [medai] summary: Create a patient profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePatientBody" responses: "201": description: Created patient content: application/json: schema: $ref: "#/components/schemas/Patient" /medai/patients/{id}: get: operationId: getPatient tags: [medai] summary: Get patient details parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Patient details content: application/json: schema: $ref: "#/components/schemas/Patient" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/MedaiError" put: operationId: updatePatient tags: [medai] summary: Update patient profile parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePatientBody" responses: "200": description: Updated patient content: application/json: schema: $ref: "#/components/schemas/Patient" delete: operationId: deletePatient tags: [medai] summary: Delete patient parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /medai/case-records: get: operationId: listCaseRecords tags: [medai] summary: List recent case analysis records parameters: - name: patientId in: query required: false schema: type: integer responses: "200": description: List of case records content: application/json: schema: type: array items: $ref: "#/components/schemas/CaseRecord" /medai/prescription-records: get: operationId: listPrescriptionRecords tags: [medai] summary: List recent prescription check records parameters: - name: patientId in: query required: false schema: type: integer responses: "200": description: List of prescription check records content: application/json: schema: type: array items: $ref: "#/components/schemas/PrescriptionRecord" /medai/stats: get: operationId: getMedaiStats tags: [medai] summary: Get summary statistics for dashboard responses: "200": description: Dashboard statistics content: application/json: schema: $ref: "#/components/schemas/MedaiStats" components: schemas: HealthStatus: type: object properties: status: type: string required: - status AnalyzeSymptomsBody: type: object properties: symptoms: type: string description: "Patient description e.g. '45M, breathlessness 2 days, fever, diabetic'" patientId: type: integer description: Optional patient ID to associate the case with required: - symptoms SoapAnalysis: type: object properties: id: type: integer subjective: type: string objective: type: string assessment: type: string plan: type: string triageDecision: type: string enum: [refer_immediately, urgent_care, routine_care, self_care] confidence: type: number description: Confidence percentage 0-100 redFlags: type: array items: type: string summary: type: string severity: type: string enum: [low, medium, high] description: Overall case severity createdAt: type: string format: date-time required: - id - subjective - objective - assessment - plan - triageDecision - confidence - redFlags - summary - severity - createdAt CheckPrescriptionBody: type: object properties: prescription: type: string description: "Medication list, one per line e.g. 'Paracetamol 500 TDS\nDolo 650 SOS'" patientId: type: integer description: Optional patient ID to associate the check with required: - prescription PrescriptionSafetyReport: type: object properties: id: type: integer warnings: type: array items: $ref: "#/components/schemas/PrescriptionWarning" safe: type: boolean adviceSummary: type: string severity: type: string enum: [low, medium, high] description: Overall prescription risk severity createdAt: type: string format: date-time required: - id - warnings - safe - adviceSummary - severity - createdAt PrescriptionWarning: type: object properties: type: type: string enum: [duplicate, overdose, interaction, contraindication, general] severity: type: string enum: [high, medium, low] message: type: string medicines: type: array items: type: string required: - type - severity - message - medicines CreatePatientBody: type: object properties: name: type: string age: type: integer gender: type: string enum: [male, female, other] bloodGroup: type: string conditions: type: array items: type: string allergies: type: array items: type: string currentMedications: type: array items: type: string emergencyContact: type: string required: - name - age - gender Patient: type: object properties: id: type: integer name: type: string age: type: integer gender: type: string bloodGroup: type: string conditions: type: array items: type: string allergies: type: array items: type: string currentMedications: type: array items: type: string emergencyContact: type: string createdAt: type: string format: date-time required: - id - name - age - gender - conditions - allergies - currentMedications - createdAt CaseRecord: type: object properties: id: type: integer patientId: type: integer nullable: true symptoms: type: string triageDecision: type: string confidence: type: number redFlagsCount: type: integer summary: type: string severity: type: string enum: [low, medium, high] description: Overall case severity createdAt: type: string format: date-time required: - id - symptoms - triageDecision - confidence - redFlagsCount - summary - severity - createdAt PrescriptionRecord: type: object properties: id: type: integer patientId: type: integer nullable: true prescription: type: string warningsCount: type: integer safe: type: boolean createdAt: type: string format: date-time required: - id - prescription - warningsCount - safe - createdAt DailyCount: type: object properties: date: type: string count: type: integer required: - date - count SeverityDistribution: type: object properties: low: type: integer medium: type: integer high: type: integer required: - low - medium - high RiskTypeStat: type: object properties: type: type: string count: type: integer required: - type - count ActivityItem: type: object properties: kind: type: string enum: [case, prescription, patient] description: type: string createdAt: type: string format: date-time required: - kind - description - createdAt MedaiStats: type: object properties: totalPatients: type: integer totalCasesAnalyzed: type: integer totalPrescriptionChecks: type: integer referralsToday: type: integer warningsIssued: type: integer avgConfidence: type: number highRiskCases: type: integer casesOverTime: type: array items: $ref: "#/components/schemas/DailyCount" severityDistribution: $ref: "#/components/schemas/SeverityDistribution" riskTypeBreakdown: type: array items: $ref: "#/components/schemas/RiskTypeStat" recentActivity: type: array items: $ref: "#/components/schemas/ActivityItem" aiInsight: type: string required: - totalPatients - totalCasesAnalyzed - totalPrescriptionChecks - referralsToday - warningsIssued - avgConfidence - highRiskCases - casesOverTime - severityDistribution - riskTypeBreakdown - recentActivity - aiInsight MedaiError: type: object properties: error: type: string required: - error