diff --git a/rust/codelist-validator-rs/src/icd10_validator.rs b/rust/codelist-validator-rs/src/icd10_validator.rs index 90245e0..6e0a73d 100644 --- a/rust/codelist-validator-rs/src/icd10_validator.rs +++ b/rust/codelist-validator-rs/src/icd10_validator.rs @@ -180,14 +180,14 @@ mod tests { #[test] fn test_validate_codelist_with_valid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("A54".to_string(), "Gonorrhoea".to_string())?; - codelist.add_entry("A37".to_string(), "Pertussis".to_string())?; - codelist.add_entry("A05".to_string(), "Measles".to_string())?; - codelist.add_entry("B74.0".to_string(), "Lymphatic filariasis".to_string())?; - codelist.add_entry("N40".to_string(), "Benign prostatic hypertrophy".to_string())?; - codelist.add_entry("M10".to_string(), "Gout".to_string())?; - codelist.add_entry("Q90".to_string(), "Down Syndrome".to_string())?; - codelist.add_entry("K02".to_string(), "Dental caries".to_string())?; + codelist.add_entry("A54".to_string(), "Gonorrhoea".to_string(), None)?; + codelist.add_entry("A37".to_string(), "Pertussis".to_string(), None)?; + codelist.add_entry("A05".to_string(), "Measles".to_string(), None)?; + codelist.add_entry("B74.0".to_string(), "Lymphatic filariasis".to_string(), None)?; + codelist.add_entry("N40".to_string(), "Benign prostatic hypertrophy".to_string(), None)?; + codelist.add_entry("M10".to_string(), "Gout".to_string(), None)?; + codelist.add_entry("Q90".to_string(), "Down Syndrome".to_string(), None)?; + codelist.add_entry("K02".to_string(), "Dental caries".to_string(), None)?; assert!(codelist.validate_all_code().is_ok()); Ok(()) } @@ -195,14 +195,14 @@ mod tests { #[test] fn test_validate_codelist_with_all_invalid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("A009000000".to_string(), "Gonorrhoea".to_string())?; - codelist.add_entry("1009".to_string(), "Pertussis".to_string())?; - codelist.add_entry("AA09".to_string(), "Measles".to_string())?; - codelist.add_entry("A0A9".to_string(), "Lymphatic filariasis".to_string())?; - codelist.add_entry("A00A".to_string(), "Benign prostatic hypertrophy".to_string())?; - codelist.add_entry("A00.A".to_string(), "Gout".to_string())?; - codelist.add_entry("A00X12".to_string(), "Down Syndrome".to_string())?; - codelist.add_entry("A00.4AA".to_string(), "Dental caries".to_string())?; + codelist.add_entry("A009000000".to_string(), "Gonorrhoea".to_string(), None)?; + codelist.add_entry("1009".to_string(), "Pertussis".to_string(), None)?; + codelist.add_entry("AA09".to_string(), "Measles".to_string(), None)?; + codelist.add_entry("A0A9".to_string(), "Lymphatic filariasis".to_string(), None)?; + codelist.add_entry("A00A".to_string(), "Benign prostatic hypertrophy".to_string(), None)?; + codelist.add_entry("A00.A".to_string(), "Gout".to_string(), None)?; + codelist.add_entry("A00X12".to_string(), "Down Syndrome".to_string(), None)?; + codelist.add_entry("A00.4AA".to_string(), "Dental caries".to_string(), None)?; let error = codelist.validate_all_code().unwrap_err(); let error_string = error.to_string(); @@ -223,14 +223,14 @@ mod tests { #[test] fn test_validate_codelist_with_mixed_invalid_and_valid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("A54".to_string(), "Gonorrhoea".to_string())?; - codelist.add_entry("1009".to_string(), "Pertussis".to_string())?; - codelist.add_entry("A05".to_string(), "Measles".to_string())?; - codelist.add_entry("A0A9".to_string(), "Lymphatic filariasis".to_string())?; - codelist.add_entry("N40".to_string(), "Benign prostatic hypertrophy".to_string())?; - codelist.add_entry("A00.A".to_string(), "Gout".to_string())?; - codelist.add_entry("Q90".to_string(), "Down Syndrome".to_string())?; - codelist.add_entry("A00.4AA".to_string(), "Dental caries".to_string())?; + codelist.add_entry("A54".to_string(), "Gonorrhoea".to_string(), None)?; + codelist.add_entry("1009".to_string(), "Pertussis".to_string(), None)?; + codelist.add_entry("A05".to_string(), "Measles".to_string(), None)?; + codelist.add_entry("A0A9".to_string(), "Lymphatic filariasis".to_string(), None)?; + codelist.add_entry("N40".to_string(), "Benign prostatic hypertrophy".to_string(), None)?; + codelist.add_entry("A00.A".to_string(), "Gout".to_string(), None)?; + codelist.add_entry("Q90".to_string(), "Down Syndrome".to_string(), None)?; + codelist.add_entry("A00.4AA".to_string(), "Dental caries".to_string(), None)?; let error = codelist.validate_all_code().unwrap_err(); let error_string = error.to_string(); diff --git a/rust/codelist-validator-rs/src/opcs_validator.rs b/rust/codelist-validator-rs/src/opcs_validator.rs index b7d08ad..732cba3 100644 --- a/rust/codelist-validator-rs/src/opcs_validator.rs +++ b/rust/codelist-validator-rs/src/opcs_validator.rs @@ -191,14 +191,14 @@ mod tests { #[test] fn test_validate_codelist_with_valid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("C01".to_string(), "Excision of eye".to_string())?; - codelist.add_entry("C02".to_string(), "Extirpation of lesion of orbit".to_string())?; - codelist.add_entry("C03".to_string(), "Insertion of prosthesis of eye".to_string())?; - codelist.add_entry("C04".to_string(), "Attention to prosthesis of eye".to_string())?; - codelist.add_entry("C05".to_string(), "Plastic repair of orbit ".to_string())?; - codelist.add_entry("L31.4".to_string(), "Insertion Artery Carotid Stent Transluminal Percutaneous".to_string())?; - codelist.add_entry("L35.3".to_string(), "Insertion Artery Cerebral Stent Transluminal Percutaneous".to_string())?; - codelist.add_entry("L47.4".to_string(), "Insertion Artery Coeliac Stent Transluminal Percutaneous".to_string())?; + codelist.add_entry("C01".to_string(), "Excision of eye".to_string(), None)?; + codelist.add_entry("C02".to_string(), "Extirpation of lesion of orbit".to_string(), None)?; + codelist.add_entry("C03".to_string(), "Insertion of prosthesis of eye".to_string(), None)?; + codelist.add_entry("C04".to_string(), "Attention to prosthesis of eye".to_string(), None)?; + codelist.add_entry("C05".to_string(), "Plastic repair of orbit ".to_string(), None)?; + codelist.add_entry("L31.4".to_string(), "Insertion Artery Carotid Stent Transluminal Percutaneous".to_string(), None)?; + codelist.add_entry("L35.3".to_string(), "Insertion Artery Cerebral Stent Transluminal Percutaneous".to_string(), None)?; + codelist.add_entry("L47.4".to_string(), "Insertion Artery Coeliac Stent Transluminal Percutaneous".to_string(), None)?; assert!(codelist.validate_all_code().is_ok()); Ok(()) } @@ -206,14 +206,14 @@ mod tests { #[test] fn test_validate_codelist_with_all_invalid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("A0".to_string(), "Excision of eye".to_string())?; - codelist.add_entry("A01000".to_string(), "Extirpation of lesion of orbit".to_string())?; - codelist.add_entry("101".to_string(), "Insertion of prosthesis of eye".to_string())?; - codelist.add_entry("AA1".to_string(), "Attention to prosthesis of eye".to_string())?; - codelist.add_entry("A0A".to_string(), "Plastic repair of orbit ".to_string())?; - codelist.add_entry("A01.".to_string(), "Insertion Artery Carotid Stent Transluminal Percutaneous".to_string())?; - codelist.add_entry("A01.A".to_string(), "Insertion Artery Cerebral Stent Transluminal Percutaneous".to_string())?; - codelist.add_entry("A010A".to_string(), "Insertion Artery Coeliac Stent Transluminal Percutaneous".to_string())?; + codelist.add_entry("A0".to_string(), "Excision of eye".to_string(), None)?; + codelist.add_entry("A01000".to_string(), "Extirpation of lesion of orbit".to_string(), None)?; + codelist.add_entry("101".to_string(), "Insertion of prosthesis of eye".to_string(), None)?; + codelist.add_entry("AA1".to_string(), "Attention to prosthesis of eye".to_string(), None)?; + codelist.add_entry("A0A".to_string(), "Plastic repair of orbit ".to_string(), None)?; + codelist.add_entry("A01.".to_string(), "Insertion Artery Carotid Stent Transluminal Percutaneous".to_string(), None)?; + codelist.add_entry("A01.A".to_string(), "Insertion Artery Cerebral Stent Transluminal Percutaneous".to_string(), None)?; + codelist.add_entry("A010A".to_string(), "Insertion Artery Coeliac Stent Transluminal Percutaneous".to_string(), None)?; let error = codelist.validate_all_code().unwrap_err(); let error_string = error.to_string(); @@ -234,14 +234,14 @@ mod tests { #[test] fn test_validate_codelist_with_mixed_invalid_and_valid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("C01".to_string(), "Excision of eye".to_string())?; - codelist.add_entry("A01000".to_string(), "Extirpation of lesion of orbit".to_string())?; - codelist.add_entry("C03".to_string(), "Insertion of prosthesis of eye".to_string())?; - codelist.add_entry("AA1".to_string(), "Attention to prosthesis of eye".to_string())?; - codelist.add_entry("C05".to_string(), "Plastic repair of orbit ".to_string())?; - codelist.add_entry("A01.".to_string(), "Insertion Artery Carotid Stent Transluminal Percutaneous".to_string())?; - codelist.add_entry("L35.3".to_string(), "Insertion Artery Cerebral Stent Transluminal Percutaneous".to_string())?; - codelist.add_entry("A010A".to_string(), "Insertion Artery Coeliac Stent Transluminal Percutaneous".to_string())?; + codelist.add_entry("C01".to_string(), "Excision of eye".to_string(), None)?; + codelist.add_entry("A01000".to_string(), "Extirpation of lesion of orbit".to_string(), None)?; + codelist.add_entry("C03".to_string(), "Insertion of prosthesis of eye".to_string(), None)?; + codelist.add_entry("AA1".to_string(), "Attention to prosthesis of eye".to_string(), None)?; + codelist.add_entry("C05".to_string(), "Plastic repair of orbit ".to_string(), None)?; + codelist.add_entry("A01.".to_string(), "Insertion Artery Carotid Stent Transluminal Percutaneous".to_string(), None)?; + codelist.add_entry("L35.3".to_string(), "Insertion Artery Cerebral Stent Transluminal Percutaneous".to_string(), None)?; + codelist.add_entry("A010A".to_string(), "Insertion Artery Coeliac Stent Transluminal Percutaneous".to_string(), None)?; let error = codelist.validate_all_code().unwrap_err(); let error_string = error.to_string(); diff --git a/rust/codelist-validator-rs/src/snomed_validator.rs b/rust/codelist-validator-rs/src/snomed_validator.rs index e216a3a..b0ca803 100644 --- a/rust/codelist-validator-rs/src/snomed_validator.rs +++ b/rust/codelist-validator-rs/src/snomed_validator.rs @@ -163,14 +163,14 @@ mod tests { #[test] fn test_validate_all_code_with_valid_codelist() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("204351007".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("405752007".to_string(), "Congenital atrial septal defect (disorder)".to_string())?; - codelist.add_entry("405752008".to_string(), "Congenital atrial septal defect with patent foramen ovale (disorder)".to_string())?; - codelist.add_entry("77480004".to_string(), "Congenital biliary atresia (disorder)".to_string())?; - codelist.add_entry("34000006".to_string(), "Crohn's disease (disorder)".to_string())?; - codelist.add_entry("417357006".to_string(), "Sickling disorder due to hemoglobin S (disorder)".to_string())?; - codelist.add_entry("24700007".to_string(), "Multiple sclerosis (disorder)".to_string())?; - codelist.add_entry("398254007".to_string(), "Pre-eclampsia (disorder)".to_string())?; + codelist.add_entry("204351007".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("405752007".to_string(), "Congenital atrial septal defect (disorder)".to_string(), None)?; + codelist.add_entry("405752008".to_string(), "Congenital atrial septal defect with patent foramen ovale (disorder)".to_string(), None)?; + codelist.add_entry("77480004".to_string(), "Congenital biliary atresia (disorder)".to_string(), None)?; + codelist.add_entry("34000006".to_string(), "Crohn's disease (disorder)".to_string(), None)?; + codelist.add_entry("417357006".to_string(), "Sickling disorder due to hemoglobin S (disorder)".to_string(), None)?; + codelist.add_entry("24700007".to_string(), "Multiple sclerosis (disorder)".to_string(), None)?; + codelist.add_entry("398254007".to_string(), "Pre-eclampsia (disorder)".to_string(), None)?; assert!(codelist.validate_all_code(None, None).is_ok()); @@ -180,13 +180,13 @@ mod tests { #[test] fn test_validate_codelist_with_all_invalid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("11".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("111111111111111111111111111111".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("AA090".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("BB".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("1".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("1111111111111111111AAAAAAAAAA".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("11111".to_string(), "Fallot's trilogy (disorder)".to_string())?; + codelist.add_entry("11".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("111111111111111111111111111111".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("AA090".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("BB".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("1".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("1111111111111111111AAAAAAAAAA".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("11111".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; let error = codelist.validate_all_code(None, None).unwrap_err(); let error_string = error.to_string(); @@ -205,14 +205,14 @@ mod tests { #[test] fn test_validate_all_code_with_mixed_valid_and_invalid_codes() -> Result<(), CodeListError> { let mut codelist = create_test_codelist()?; - codelist.add_entry("11".to_string(), "Fallot's trilogy (disorder)".to_string())?; - codelist.add_entry("405752007".to_string(), "Congenital atrial septal defect (disorder)".to_string())?; - codelist.add_entry("AA090".to_string(), "Congenital atrial septal defect with patent foramen ovale (disorder)".to_string())?; - codelist.add_entry("77480004".to_string(), "Congenital biliary atresia (disorder)".to_string())?; - codelist.add_entry("34000006".to_string(), "Crohn's disease (disorder)".to_string())?; - codelist.add_entry("417357006".to_string(), "Sickling disorder due to hemoglobin S (disorder)".to_string())?; - codelist.add_entry("24700007".to_string(), "Multiple sclerosis (disorder)".to_string())?; - codelist.add_entry("11111".to_string(), "Pre-eclampsia (disorder)".to_string())?; + codelist.add_entry("11".to_string(), "Fallot's trilogy (disorder)".to_string(), None)?; + codelist.add_entry("405752007".to_string(), "Congenital atrial septal defect (disorder)".to_string(), None)?; + codelist.add_entry("AA090".to_string(), "Congenital atrial septal defect with patent foramen ovale (disorder)".to_string(), None)?; + codelist.add_entry("77480004".to_string(), "Congenital biliary atresia (disorder)".to_string(), None)?; + codelist.add_entry("34000006".to_string(), "Crohn's disease (disorder)".to_string(), None)?; + codelist.add_entry("417357006".to_string(), "Sickling disorder due to hemoglobin S (disorder)".to_string(), None)?; + codelist.add_entry("24700007".to_string(), "Multiple sclerosis (disorder)".to_string(), None)?; + codelist.add_entry("11111".to_string(), "Pre-eclampsia (disorder)".to_string(), None)?; let error = codelist.validate_all_code(None, None).unwrap_err(); let error_string = error.to_string();