{"openapi":"3.1.0","info":{"title":"KodeMed Grouper Server API","description":"DRG Grouping Service API for SwissDRG, TARPSY, and ST Reha tariff systems.","contact":{"name":"Mieres IT Support","email":"support@kodemed.ch"},"license":{"name":"Proprietary","url":"https://kodemed.ch/license"},"version":"2026.5.15.59502"},"servers":[{"url":"","description":"GrouperServer"}],"security":[{"openIdConnectAuth":[]}],"tags":[{"name":"Grouper","description":"DRG Grouping API - SwissDRG, TARPSY, ST Reha"}],"paths":{"/api/v1/grouper/spiges/xml":{"post":{"tags":["Grouper"],"summary":"Group SpiGes XML file","description":"Groups all patient cases from a SpiGes XML file. Accepts native SpiGes XML format as used by Swiss Federal Statistical Office (BFS). Returns grouping results for each case in the file.","operationId":"groupSpigesXmlFile","parameters":[{"name":"tariff","in":"query","description":"Tariff system","required":false,"schema":{"type":"string","default":"SWISSDRG","enum":["SWISSDRG","TARPSY","STREHA"]},"example":"SWISSDRG"},{"name":"version","in":"query","description":"Grouper version (optional, uses default if not specified)","required":false,"schema":{"type":"string"},"example":14.0},{"name":"calculateCostWeight","in":"query","description":"Calculate effective cost weight","required":false,"schema":{"type":"boolean","default":true},"example":true},{"name":"lang","in":"query","description":"Language for response localisation: de | fr | it (#454)","required":false,"schema":{"type":"string"},"example":"de"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary","description":"SpiGes XML file"}},"required":["file"]}}}},"responses":{"200":{"description":"Grouping successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesXmlGroupingResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesXmlGroupingResponse"}}}},"400":{"description":"Invalid XML or request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesXmlGroupingResponse"}}}}}}},"/api/v1/grouper/spiges/xml/{tariff}":{"post":{"tags":["Grouper"],"summary":"Group SpiGes XML (raw body)","description":"Groups all patient cases from SpiGes XML sent as raw request body. Alternative to multipart form upload.","operationId":"groupSpigesXmlRaw","parameters":[{"name":"tariff","in":"path","description":"Tariff system","required":true,"schema":{"type":"string","enum":["SWISSDRG","TARPSY","STREHA"]},"example":"SWISSDRG"},{"name":"version","in":"query","description":"Grouper version (optional)","required":false,"schema":{"type":"string"},"example":14.0},{"name":"calculateCostWeight","in":"query","description":"Calculate effective cost weight","required":false,"schema":{"type":"boolean","default":true},"example":true},{"name":"lang","in":"query","description":"Language for response localisation: de | fr | it (#454)","required":false,"schema":{"type":"string"},"example":"de"}],"requestBody":{"content":{"application/xml":{"schema":{"type":"string","format":"byte"}},"text/xml":{"schema":{"type":"string","format":"byte"}}},"required":true},"responses":{"400":{"description":"Invalid XML","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesXmlGroupingResponse"}}}},"200":{"description":"Grouping successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesXmlGroupingResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesXmlGroupingResponse"}}}}}}},"/api/v1/grouper/group":{"post":{"tags":["Grouper"],"summary":"Group a patient case","description":"Groups a single patient case using the specified tariff system (SwissDRG, TARPSY, or ST Reha). Returns the DRG/PCG code, cost weights, and grouper flags. Input format is SpiGes.","operationId":"groupCase","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupingRequest"}}},"required":true},"responses":{"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupingResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupingResponse"}}}},"200":{"description":"Grouping successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupingResponse"}}}}}}},"/api/v1/grouper/group/{tariff}":{"post":{"tags":["Grouper"],"summary":"Quick group endpoint","description":"Simplified grouping endpoint for common use cases. Uses default version if not specified.","operationId":"quickGroup","parameters":[{"name":"tariff","in":"path","description":"Tariff system","required":true,"schema":{"type":"string","enum":["SWISSDRG","TARPSY","STREHA"]},"example":"SWISSDRG"},{"name":"version","in":"query","description":"Grouper version (optional)","required":false,"schema":{"type":"string"},"example":14.0}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpigesCase"}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupingResponse"}}}}}}},"/api/v1/grouper/group/batch":{"post":{"tags":["Grouper"],"summary":"Group multiple patient cases","description":"Groups multiple patient cases in batch using the specified tariff system. All cases use the same tariff and version. Returns results for each case.","operationId":"groupBatch","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchGroupingRequest"}}},"required":true},"responses":{"200":{"description":"Batch grouping successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchGroupingResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchGroupingResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchGroupingResponse"}}}}}}},"/api/v1/license/status":{"get":{"tags":["license-controller"],"operationId":"status","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object","additionalProperties":{"type":"object"}}}}}}}},"/api/v1/grouper/versions":{"get":{"tags":["Grouper"],"summary":"Get available grouper versions","description":"Returns all available versions for SwissDRG, TARPSY, and ST Reha groupers, including which versions are loaded and ready for use.","operationId":"getAvailableVersions","responses":{"200":{"description":"Available versions retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AvailableVersionsResponse"}}}}}}},"/api/v1/grouper/health":{"get":{"tags":["Grouper"],"summary":"Health check for grouper","description":"Returns the status of the grouper service and loaded kernels.","operationId":"health","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}}},"components":{"schemas":{"CaseResult":{"type":"object","description":"Result for a single case from XML","properties":{"fallId":{"type":"string","description":"Case ID from XML","example":1001},"success":{"type":"boolean","description":"Whether grouping was successful","example":true},"drg":{"type":"string","description":"DRG/PCG code","example":"W01A"},"mdc":{"type":"string","description":"Major Diagnostic Category","example":"21A"},"pccl":{"type":"integer","format":"int32","description":"PCCL (Patient Clinical Complexity Level)","example":4},"partition":{"type":"string","description":"Partition","example":"O"},"baseCostWeight":{"type":"number","format":"double","description":"Base cost weight","example":12.543},"effectiveCostWeight":{"type":"number","format":"double","description":"Effective cost weight","example":15.234},"los":{"type":"integer","format":"int32","description":"Length of stay","example":26},"error":{"type":"string","description":"Error message if grouping failed"},"diagnosisCount":{"type":"integer","format":"int32","description":"Number of diagnoses","example":11},"procedureCount":{"type":"integer","format":"int32","description":"Number of procedures","example":10}}},"SpigesXmlGroupingResponse":{"type":"object","description":"Response from grouping a SpiGes XML file","properties":{"success":{"type":"boolean","description":"Whether the entire operation was successful","example":true},"totalCases":{"type":"integer","format":"int32","description":"Number of cases parsed from XML","example":6},"successfulGroupings":{"type":"integer","format":"int32","description":"Number of successfully grouped cases","example":5},"failedGroupings":{"type":"integer","format":"int32","description":"Number of failed groupings","example":1},"processingTimeMs":{"type":"integer","format":"int64","description":"Total processing time in milliseconds","example":150},"grouperVersion":{"type":"string","description":"Grouper version used","example":"SwissDRG 14.0"},"tariff":{"type":"string","description":"Tariff system used","example":"SWISSDRG"},"results":{"type":"array","description":"Individual case results","items":{"$ref":"#/components/schemas/CaseResult"}},"error":{"type":"string","description":"Error message if parsing failed"}}},"Administratives":{"type":"object","description":"Administrative data","properties":{"geschlecht":{"type":"string","description":"Patient sex (M, W, U)","example":"M"},"alter":{"type":"integer","format":"int32","description":"Patient age in years","example":45},"alterU1":{"type":"integer","format":"int32","description":"Patient age in days (for infants < 1 year)","example":0},"geburtsdatum":{"type":"string","description":"Birth date (YYYYMMDD)","example":19800115},"eintrittDatum":{"type":"string","description":"Admission date (YYYYMMDD)","example":20260115},"austrittDatum":{"type":"string","description":"Discharge date (YYYYMMDD)","example":20260120},"eintrittsart":{"type":"string","description":"Admission type","example":1},"austrittsart":{"type":"string","description":"Discharge type","example":0},"aufnahmegewicht":{"type":"integer","format":"int32","description":"Admission weight in grams (for newborns)","example":3200},"aufenthaltsdauer":{"type":"integer","format":"int32","description":"Length of stay in days","example":5},"urlaubstage":{"type":"integer","format":"int32","description":"Leave days","example":0},"aufenthaltTyp":{"type":"string","description":"Case type (A=acute, B=psychiatric, C=rehab)","example":"A"},"entbindungsmodus":{"type":"string","description":"Delivery mode (for births)","example":1},"geburtshaus":{"type":"string","description":"Birth house flag","example":0},"beatmungsstunden":{"type":"integer","format":"int32","description":"Breathing support hours","example":0}}},"Behandlung":{"type":"object","description":"Procedure (CHOP)","properties":{"behandlungId":{"type":"string","description":"Procedure ID","example":1},"behandlungCode":{"type":"string","description":"CHOP code","example":"39.95.21"},"istHauptbehandlung":{"type":"boolean","description":"Whether this is the main procedure","example":false},"behandlungSeitigkeit":{"type":"string","description":"Laterality (0-9)","example":0},"behandlungBeginn":{"type":"string","description":"Procedure date/time (YYYYMMDDHHmm)","example":202601151030}},"required":["behandlungCode"]},"Diagnose":{"type":"object","description":"Diagnosis (ICD-10)","properties":{"diagnoseId":{"type":"string","description":"Diagnosis ID","example":1},"diagnoseCode":{"type":"string","description":"ICD-10 code","example":"J18.9"},"istHauptdiagnose":{"type":"boolean","description":"Whether this is the main diagnosis","example":true},"diagnoseSeitigkeit":{"type":"string","description":"Laterality (0-9)","example":0},"diagnosePoa":{"type":"string","description":"Present on Admission status","example":"J"},"diagnoseZusatz":{"type":"string","description":"Additional code (dagger/asterisk)"}},"required":["diagnoseCode"]},"GroupingRequest":{"type":"object","description":"Request for grouping a patient case","properties":{"tariff":{"type":"string","description":"Tariff system to use","enum":["SWISSDRG","TARPSY","STREHA"],"example":"SWISSDRG"},"version":{"type":"string","description":"Grouper version","example":14.0},"patientCase":{"$ref":"#/components/schemas/SpigesCase","description":"Patient case data in SpiGes format"},"calculateCostWeight":{"type":"boolean","description":"Whether to calculate effective cost weight","example":true},"lang":{"type":"string","description":"Language code for response localisation: de | fr | it","enum":["de","fr","it"],"example":"de"}},"required":["patientCase","tariff"]},"Neugeborene":{"type":"object","description":"Newborn specific data","properties":{"geburtsgewicht":{"type":"integer","format":"int32","description":"Birth weight in grams","example":3200},"gestationsalterWochen":{"type":"integer","format":"int32","description":"Gestational age in weeks","example":40},"gestationsalterTage":{"type":"integer","format":"int32","description":"Gestational age days (additional)","example":2},"mehrling":{"type":"string","description":"Multiple birth","example":0}}},"Psychiatrie":{"type":"object","description":"Psychiatric specific data","properties":{"gafAufnahme":{"type":"integer","format":"int32","description":"GAF score at admission","example":45},"gafEntlassung":{"type":"integer","format":"int32","description":"GAF score at discharge","example":65},"honos":{"type":"array","description":"HoNOS scores","items":{"type":"integer","format":"int32"}}}},"SpigesCase":{"type":"object","description":"Patient case in SpiGes format","properties":{"fallId":{"type":"string","description":"Case identifier"},"administratives":{"$ref":"#/components/schemas/Administratives","description":"Administrative data"},"diagnosen":{"type":"array","description":"List of diagnoses (ICD-10)","items":{"$ref":"#/components/schemas/Diagnose"}},"behandlungen":{"type":"array","description":"List of procedures (CHOP)","items":{"$ref":"#/components/schemas/Behandlung"}},"neugeborene":{"$ref":"#/components/schemas/Neugeborene","description":"Newborn specific data"},"psychiatrie":{"$ref":"#/components/schemas/Psychiatrie","description":"Psychiatric specific data"}}},"GroupingResponse":{"type":"object","description":"Result of grouping a patient case","properties":{"drg":{"type":"string","description":"DRG/PCG code","example":"G67B"},"mdc":{"type":"string","description":"Major Diagnostic Category","example":"06"},"partition":{"type":"string","description":"Partition (M=Medical, O=Operative, A=Other)","example":"M"},"pccl":{"type":"integer","format":"int32","description":"PCCL (Patient Clinical Complexity Level)","example":2},"grouperStatus":{"type":"string","description":"Grouper status","example":"OK"},"gst":{"type":"string","description":"Grouper status flag","example":0},"baseCostWeight":{"type":"number","format":"double","description":"Base cost weight","example":0.654},"effectiveCostWeight":{"type":"number","format":"double","description":"Effective cost weight (after LOS adjustments)","example":0.654},"los":{"type":"integer","format":"int32","description":"Actual length of stay","example":5},"ltp":{"type":"integer","format":"int32","description":"Low trim point (days)","example":1},"htp":{"type":"integer","format":"int32","description":"High trim point (days)","example":9},"alos":{"type":"number","format":"double","description":"Average length of stay","example":4.2},"transferDiscount":{"type":"boolean","description":"Transfer discount applicable","example":false},"dayRate":{"type":"number","format":"double","description":"Day rate for transfers","example":0.0},"supplements":{"type":"array","description":"List of supplements","items":{"$ref":"#/components/schemas/Supplement"}},"flags":{"type":"array","description":"Grouper flags and warnings","items":{"type":"string"}},"usedDiagnoses":{"type":"array","description":"Used diagnoses (flagged)","items":{"$ref":"#/components/schemas/UsedCode"}},"usedProcedures":{"type":"array","description":"Used procedures (flagged)","items":{"$ref":"#/components/schemas/UsedCode"}},"grouperVersion":{"type":"string","description":"Grouper version used","example":"SwissDRG 14.0"},"tariff":{"type":"string","description":"Tariff system used","example":"SWISSDRG"},"timestamp":{"type":"string","description":"Calculation timestamp (ISO 8601)","example":"2026-01-15T10:30:00Z"},"error":{"type":"string","description":"Error message if grouping failed"},"success":{"type":"boolean","description":"Whether grouping was successful","example":true}}},"Supplement":{"type":"object","description":"Supplement (Zusatzentgelt)","properties":{"code":{"type":"string","description":"Supplement code","example":"ZE-2026-01.01"},"description":{"type":"string","description":"Supplement description","example":"Dialyse"},"amount":{"type":"number","format":"double","description":"Supplement amount/weight","example":0.523},"count":{"type":"integer","format":"int32","description":"Count","example":1}}},"UsedCode":{"type":"object","description":"Used code in grouping","properties":{"code":{"type":"string","description":"Code","example":"J18.9"},"used":{"type":"boolean","description":"Whether code was used in grouping","example":true},"valid":{"type":"boolean","description":"Whether code is valid","example":true},"ccl":{"type":"integer","format":"int32","description":"CCL value if applicable","example":2}}},"BatchGroupingRequest":{"type":"object","description":"Request for batch grouping multiple patient cases","properties":{"tariff":{"type":"string","description":"Tariff system to use","enum":["SWISSDRG","TARPSY","STREHA"],"example":"SWISSDRG"},"version":{"type":"string","description":"Grouper version","example":14.0},"cases":{"type":"array","description":"List of patient cases to group","items":{"$ref":"#/components/schemas/SpigesCase"}},"calculateCostWeight":{"type":"boolean","description":"Whether to calculate effective cost weight","example":true},"lang":{"type":"string","description":"Language code for response localisation: de | fr | it","enum":["de","fr","it"],"example":"de"}},"required":["cases","tariff"]},"BatchGroupingResponse":{"type":"object","description":"Response for batch grouping","properties":{"results":{"type":"array","description":"List of grouping results","items":{"$ref":"#/components/schemas/GroupingResponse"}},"totalCases":{"type":"integer","format":"int32","description":"Total cases processed","example":10},"successfulGroupings":{"type":"integer","format":"int32","description":"Successful groupings","example":10},"failedGroupings":{"type":"integer","format":"int32","description":"Failed groupings","example":0},"processingTimeMs":{"type":"integer","format":"int64","description":"Processing time in milliseconds","example":150},"grouperVersion":{"type":"string","description":"Grouper version used","example":"SwissDRG 14.0"}}},"AvailableVersionsResponse":{"type":"object","description":"Available grouper versions","properties":{"swissdrg":{"type":"array","description":"Available SwissDRG versions","items":{"$ref":"#/components/schemas/VersionInfo"}},"tarpsy":{"type":"array","description":"Available TARPSY versions","items":{"$ref":"#/components/schemas/VersionInfo"}},"streha":{"type":"array","description":"Available ST Reha versions","items":{"$ref":"#/components/schemas/VersionInfo"}}}},"VersionInfo":{"type":"object","description":"Version information","properties":{"version":{"type":"string","description":"Version number","example":14.0},"displayName":{"type":"string","description":"Display name","example":"SwissDRG 14.0 (2026)"},"effectiveYear":{"type":"integer","format":"int32","description":"Year this version is effective","example":2026},"loaded":{"type":"boolean","description":"Whether specification is loaded and ready","example":true},"isDefault":{"type":"boolean","description":"Whether this is the default version","example":true}}},"HealthResponse":{"type":"object","description":"Health status response","properties":{"status":{"type":"string","description":"Service status","example":"UP"},"loadedSwissdrgVersions":{"type":"integer","format":"int32","description":"Number of loaded SwissDRG versions","example":1},"loadedTarpsyVersions":{"type":"integer","format":"int32","description":"Number of loaded TARPSY versions","example":0},"loadedStrehaVersions":{"type":"integer","format":"int32","description":"Number of loaded ST Reha versions","example":0}}}},"securitySchemes":{"openIdConnectAuth":{"type":"openIdConnect","description":"OpenID Connect authentication","openIdConnectUrl":"https://sso.kodemed.ch/realms/kodemed/.well-known/openid-configuration"}}}}