fix: honor ValidModifierClass subset; inherit usage type; harden ordering
- Fix 1: capture <ValidModifierClass> codes from <ModifiedBy all="false">
and filter each modifier level to only valid codes before cartesian
product; eliminates ~194 phantom codes (e.g. M07.01–03) while keeping
valid ones (M07.00/04/07/09). Split Start/Empty XML event arms to
correctly track children of <ModifiedBy>.
- Fix 2: synthesized para295/para301 inherit parent values; "V" is
promoted to "P" (parent "V" = needs subdivision, terminal is codeable).
Other types ("P", "O", "Z", "") pass through unchanged.
- Fix 3: debug_assert in ModifierClass handler guards against ClaML
document-order assumption changing silently in debug/test builds.
- Fix 4: add expands_single_modifier_chain regression test verifying
C88.00/C88.01 synthesis from a single all="true" ModifiedBy (corpus-
verified: Alpha-ID I30531, I31044).
This commit is contained in:
@@ -14,3 +14,39 @@ fn expands_diabetes_5th_digit_codes_as_billable() {
|
||||
assert!(a010.description.contains("Typhus abdominalis"));
|
||||
assert_eq!(map.get("E11").expect("E11 root").para295, "V");
|
||||
}
|
||||
|
||||
/// Regression test: a category with a single `<ModifiedBy all="true">` expands
|
||||
/// correctly into its terminal 5th-digit leaves.
|
||||
///
|
||||
/// `C88.0` (Makroglobulinämie Waldenström) has exactly one `<ModifiedBy
|
||||
/// all="true" code="S02C88_5"/>` with two `<ModifierClass>` codes ("0" and
|
||||
/// "1"), yielding `C88.00` and `C88.01`. Both codes appear in the
|
||||
/// Alpha-ID corpus (`data/icd10gm2026_alphaidse_edvtxt_20250926.txt`).
|
||||
///
|
||||
/// The parent `C88.0` carries `Para295 = "P"` (already billable at the 4th
|
||||
/// digit) and `Para301 = "V"`. The synthesized terminals therefore inherit
|
||||
/// `para295 = "P"` (parent value, not "V") and `para301 = "P"` ("V" promoted).
|
||||
#[test]
|
||||
fn expands_single_modifier_chain() {
|
||||
let map = claml::load("icd-claml/Klassifikationsdateien/icd10gm2026syst_claml_20250912.xml").unwrap();
|
||||
|
||||
// C88.00 – verified in corpus (e.g. Alpha-ID I30531 "Makroglobulinämie Waldenström").
|
||||
let c8800 = map.get("C88.00").expect("C88.00 synthesized from single ModifiedBy");
|
||||
assert_eq!(c8800.para295, "P",
|
||||
"para295 inherited from parent C88.0 (which is already P, not V)");
|
||||
// Parent label + modifier label joined by " - ".
|
||||
assert!(c8800.description.contains("Waldenström"),
|
||||
"description must contain parent label: {:?}", c8800.description);
|
||||
assert!(c8800.description.contains("Remission"),
|
||||
"description must contain modifier label: {:?}", c8800.description);
|
||||
|
||||
// C88.01 – verified in corpus (Alpha-ID I31044 "Makroglobulinämie in kompletter Remission").
|
||||
let c8801 = map.get("C88.01").expect("C88.01 synthesized");
|
||||
assert_eq!(c8801.para295, "P");
|
||||
assert!(c8801.description.contains("kompletter Remission"),
|
||||
"description must include modifier label: {:?}", c8801.description);
|
||||
|
||||
// The 4th-digit parent itself must still be present and unchanged.
|
||||
let c880 = map.get("C88.0").expect("C88.0 explicit parent still present");
|
||||
assert_eq!(c880.para295, "P", "explicit parent entry must not be overwritten");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user