{"openapi":"3.1.0","info":{"title":"DeviationIQ API","version":"1.0.0"},"paths":{"/api/health":{"get":{"summary":"Health","operationId":"health_api_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Api Health Get"}}}}}}},"/api/chat":{"post":{"summary":"Chat","operationId":"chat_api_chat_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/upload":{"post":{"summary":"Upload Document","operationId":"upload_document_api_upload_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_document_api_upload_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/save":{"post":{"summary":"Save","operationId":"save_api_save_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Payload"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Save Api Save Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/commit":{"post":{"summary":"Commit","operationId":"commit_api_commit_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Payload"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Commit Api Commit Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/ledger":{"get":{"summary":"Get Ledger","operationId":"get_ledger_api_ledger_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Response Get Ledger Api Ledger Get"}}}}}}}},"components":{"schemas":{"Body_upload_document_api_upload_post":{"properties":{"file":{"type":"string","contentMediaType":"application/octet-stream","title":"File"},"current_form":{"type":"string","title":"Current Form","default":"{}"},"current_risk":{"type":"string","title":"Current Risk","default":"{}"}},"type":"object","required":["file"],"title":"Body_upload_document_api_upload_post"},"ChatRequest":{"properties":{"message":{"type":"string","title":"Message"},"current_form":{"$ref":"#/components/schemas/DeviationForm"},"current_risk":{"$ref":"#/components/schemas/RiskAssessment"},"history":{"items":{"additionalProperties":{"type":"string"},"type":"object"},"type":"array","title":"History"}},"type":"object","required":["message"],"title":"ChatRequest"},"ChatResponse":{"properties":{"reply":{"type":"string","title":"Reply"},"form":{"$ref":"#/components/schemas/DeviationForm"},"risk_assessment":{"$ref":"#/components/schemas/RiskAssessment"},"changed_fields":{"items":{"type":"string"},"type":"array","title":"Changed Fields"},"status":{"type":"string","enum":["pending_triage","ready_to_save"],"title":"Status"},"intent":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Intent"}},"type":"object","required":["reply","form","risk_assessment","changed_fields","status"],"title":"ChatResponse"},"DeviationForm":{"properties":{"complaint_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Complaint Source","description":"How the deviation was reported, e.g. Pharmacy, Email, Phone, Distributor, Physician, Patient"},"customer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Name","description":"Reporter name, role, department, site, or company that raised the deviation"},"product_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Name","description":"Full name of the pharmaceutical product or API"},"product_strength":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Strength","description":"Strength or grade, e.g. '500 mg' or 'IP/BP'"},"batch_lot_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Batch Lot Number","description":"Batch or lot number of the affected product"},"affected_quantity":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Affected Quantity","description":"Quantity affected, e.g. '12 capsules' or '50 kg (2 HDPE Drum)'"},"manufacturing_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Manufacturing Date","description":"Manufacturing date of the batch, as stated by the user"},"expiry_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expiry Date","description":"Expiry date of the batch, or 'Not Provided' if genuinely unknown"},"originating_site_block":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Originating Site Block","description":"Explicitly stated manufacturing site, area, block, suite, or line; leave null if not provided"},"impacted_npm":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Impacted Npm","description":"Impacted non-product materials, e.g. primary packaging, HDPE drums"},"complaint_category":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Complaint Category","description":"Deviation category, e.g. 'Manufacturing Process Deviation - Tablet Weight Excursion'"},"complaint_description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Complaint Description","description":"Concise, formal QMS-style synthesis of the deviation"}},"type":"object","title":"DeviationForm"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"RiskAssessment":{"properties":{"severity":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Severity","description":"One of: Minor, Major, Critical"},"suggested_next_action":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Suggested Next Action","description":"Recommended next step for QA"},"initial_risk_assessment":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Initial Risk Assessment","description":"1-2 sentence impact, product quality risk, containment, and investigation status"}},"type":"object","title":"RiskAssessment"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}