feat: tag derivation from ClaML metadata + validity

This commit is contained in:
2026-05-18 16:40:08 +02:00
parent 27d5144864
commit ce7403fee9
2 changed files with 32 additions and 1 deletions
+12 -1
View File
@@ -1 +1,12 @@
// implemented in a later task use crate::model::{IcdMeta, Tags};
/// Build display/filter Tags from ICD metadata and the Alpha-ID
/// validity flag of the matched entry.
pub fn tags_for(m: &IcdMeta, alpha_valid: bool) -> Tags {
Tags {
billable: m.para295 == "P",
valid: alpha_valid,
chapter: m.chapter.clone(),
exotic: m.exotic,
}
}
+20
View File
@@ -0,0 +1,20 @@
use alpha_id::model::IcdMeta;
use alpha_id::tags::tags_for;
#[test]
fn billable_when_para295_is_p_and_valid() {
let mut m = IcdMeta::default();
m.para295 = "P".into();
m.chapter = "01".into();
let t = tags_for(&m, true);
assert!(t.billable);
assert!(t.valid);
assert_eq!(t.chapter, "01");
}
#[test]
fn not_billable_when_para295_is_v() {
let mut m = IcdMeta::default();
m.para295 = "V".into();
assert!(!tags_for(&m, true).billable);
}