///|
pub fn sample_entries() -> Array[IcdEntry] {
[
{
code: "A00",
title: "Cholera",
chapter_id: "I",
parent: None,
excludes: ["A05"],
note: "Example ICD-10 category for intestinal infection.",
},
{
code: "A00.0",
title: "Cholera due to Vibrio cholerae 01, biovar cholerae",
chapter_id: "I",
parent: Some("A00"),
excludes: [],
note: "Built-in sample entry for parser and hierarchy demos.",
},
{
code: "A05",
title: "Other bacterial intestinal infections",
chapter_id: "I",
parent: None,
excludes: [],
note: "Referenced by the A00 exclusion fixture.",
},
{
code: "B20",
title: "Human immunodeficiency virus disease",
chapter_id: "I",
parent: None,
excludes: ["Z21"],
note: "Shows exclusion hint for asymptomatic HIV status.",
},
{
code: "E11",
title: "Type 2 diabetes mellitus",
chapter_id: "IV",
parent: None,
excludes: ["E10", "E13"],
note: "Common metabolic disease category.",
},
{
code: "E10",
title: "Type 1 diabetes mellitus",
chapter_id: "IV",
parent: None,
excludes: [],
note: "Referenced by the E11 exclusion fixture.",
},
{
code: "E13",
title: "Other specified diabetes mellitus",
chapter_id: "IV",
parent: None,
excludes: [],
note: "Referenced by the E11 exclusion fixture.",
},
{
code: "I10",
title: "Essential hypertension",
chapter_id: "IX",
parent: None,
excludes: [],
note: "Circulatory system sample entry.",
},
{
code: "J45",
title: "Asthma",
chapter_id: "X",
parent: None,
excludes: ["J44"],
note: "Respiratory sample entry.",
},
{
code: "J44",
title: "Chronic obstructive pulmonary disease",
chapter_id: "X",
parent: None,
excludes: [],
note: "Referenced by the J45 exclusion fixture.",
},
{
code: "U07",
title: "Special respiratory virus category",
chapter_id: "XXII",
parent: None,
excludes: [],
note: "Representative parent fixture for U07.1.",
},
{
code: "U07.1",
title: "COVID-19, virus identified",
chapter_id: "XXII",
parent: Some("U07"),
excludes: [],
note: "Special purpose sample entry.",
},
{
code: "Z21",
title: "Asymptomatic human immunodeficiency virus status",
chapter_id: "XXI",
parent: None,
excludes: ["B20"],
note: "Contrasts with HIV disease coding.",
},
]
}
///|
pub fn find_entry(code : String) -> IcdEntry? {
let normalized = parse_icd10(code).canonical() catch {
_ => compact_code(code)
}
sample_entries()
.search_by(fn(entry) { entry.code == normalized })
.map(fn(i) { sample_entries()[i] })
}
///|
pub fn children_of(parent : String) -> Array[IcdEntry] {
sample_entries().filter(fn(entry) {
entry.parent == Some(compact_code(parent))
})
}
///|
pub fn query_prefix(prefix : String) -> Array[IcdEntry] {
let p = compact_code(prefix)
sample_entries().filter(fn(entry) { entry.code.has_prefix(p) })
}
///|
pub fn exclusion_hints(entry : IcdEntry) -> Array[IcdEntry] {
entry.excludes.filter_map(fn(code) { find_entry(code) })
}