feat: tag derivation from ClaML metadata + validity
This commit is contained in:
+12
-1
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user