Files
alpha-id/tests/claml_modifier_tests.rs
T
Brummel 944a4bef4f 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).
2026-05-18 17:58:22 +02:00

53 lines
2.8 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
use alpha_id::claml;
#[test]
fn expands_diabetes_5th_digit_codes_as_billable() {
let map = claml::load("icd-claml/Klassifikationsdateien/icd10gm2026syst_claml_20250912.xml").unwrap();
let e1190 = map.get("E11.90").expect("E11.90 synthesized from ModifierClass");
assert_eq!(e1190.para295, "P", "terminal 5th-digit diabetes code must be billable");
assert!(e1190.description.to_lowercase().contains("diabetes"),
"composed description from parent + modifier labels: {:?}", e1190.description);
let e1172 = map.get("E11.72").expect("E11.72 synthesized");
assert_eq!(e1172.para295, "P");
let a010 = map.get("A01.0").expect("A01.0 explicit");
assert_eq!(a010.para295, "P");
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");
}