{
"version": 431, # MS-DRG version (e.g. 400, 410, 421, 431)
"age": 65, # Patient age in years
"sex": 0, # 0=Male, 1=Female, 2=Unknown
"discharge_status": 1, # 1=Home/Self Care, 20=Died
"hospital_status": "NOT_EXEMPT", # "NOT_EXEMPT" (default), "EXEMPT", or "UNKNOWN"
"tie_breaker": "CLINICAL_SIGNIFICANCE", # "CLINICAL_SIGNIFICANCE" (default) or "ALPHABETICAL"
"source_icd_version": 2025, # Source ICD-10 year for code conversion (optional)
"pdx": { # Principal diagnosis (required)
"code": "I5020",
"poa": "Y" # Present on Admission: Y/N/U/W (optional)
},
"admit_dx": { # Admission diagnosis (optional)
"code": "R0602"
},
"sdx": [ # Secondary diagnoses (optional)
{"code": "E1165", "poa": "Y"},
{"code": "I10", "poa": "Y"}
],
"procedures": [ # Procedure codes (optional)
{"code": "02703DZ"}
]
}
Hospital status
The hospital_status field controls how Hospital-Acquired Condition (HAC) processing is applied, per CMS rules:
Value
Behavior
"NOT_EXEMPT"
Standard HAC processing. Default.
"EXEMPT"
Hospital is exempt from POA reporting. No HAC/POA ungroupable conditions.
"UNKNOWN"
Stricter POA validation with specific ungroupable return codes.
Tie breaker
The tie_breaker field controls how the grouper resolves attribute matches when multiple secondary diagnoses could match the same DRG formula attribute. This determines which diagnosis "wins" during the marking phase.
Value
Behavior
"CLINICAL_SIGNIFICANCE"
MCC diagnoses get first pick over CC, then by ICD code string. Default, matches CMS Java grouper.
"ALPHABETICAL"
Sort by ICD code string only, ignoring severity.
Output format
{
"initial_drg": 293,
"final_drg": 293,
"initial_mdc": 5,
"final_mdc": 5,
"initial_drg_description": "Heart Failure and Shock without CC/MCC",
"final_drg_description": "Heart Failure and Shock without CC/MCC",
"initial_mdc_description": "Diseases and Disorders of the Circulatory System",
"final_mdc_description": "Diseases and Disorders of the Circulatory System",
"return_code": "OK",
"pdx_output": {
"code": "I5020",
"mdc": 5,
"severity": "CC",
"drg_impact": "BOTH",
"poa_error": "POA_NOT_CHECKED",
"flags": ["VALID", "MARKED_FOR_INITIAL", "MARKED_FOR_FINAL"]
},
"sdx_output": [...],
"proc_output": [...],
"conversions": [] # ICD version conversions (empty if source_icd_version not set)
}
Supported DRG versions
Version
CMS Fiscal Year
400
FY 2023 (Oct 2022 – Apr 2023)
401
FY 2023 (Apr 2023 – Sep 2023)
410
FY 2024 (Oct 2023 – Apr 2024)
411
FY 2024 (Apr 2024 – Sep 2024)
420
FY 2025 (Oct 2024 – Apr 2025)
421
FY 2025 (Apr 2025 – Sep 2025)
430
FY 2026 (Oct 2025 – Apr 2026)
431
FY 2026 (Apr 2026 – Sep 2026)
440
FY 2027 (Oct 2026 – Mar 2027)
Medicare Code Editor (MCE)
The MCE validates ICD diagnosis and procedure codes against CMS edit rules. It checks for sex conflicts, age conflicts, unacceptable principal diagnoses, E-codes as PDX, non-covered procedures, bilateral procedures, and more.
Both engines share the same shared library and data files. The grouping pipeline is a chain of composable processors; the MCE is a linear validation pipeline. Both mirror the original Java architecture for validation purposes.
The Java comparisons require JDK 17+ and the reference JARs in jars/. This is only needed for validation — the Python package itself has no Java dependency.
C API
mz-drg exposes a C ABI for integration with any language. A complete header is auto-generated at zig-out/include/msdrg.h after building.