Skip to content

Commit

Permalink
Merge pull request #32 from CarolineMorton/fix-tests
Browse files Browse the repository at this point in the history
tests fixed
  • Loading branch information
CarolineMorton authored Jan 13, 2025
2 parents 8aa9479 + 073117b commit 79d67f2
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 71 deletions.
48 changes: 24 additions & 24 deletions rust/codelist-validator-rs/src/icd10_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,29 @@ 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(())
}

#[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();

Expand All @@ -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();

Expand Down
48 changes: 24 additions & 24 deletions rust/codelist-validator-rs/src/opcs_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,29 +191,29 @@ 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(())
}

#[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();

Expand All @@ -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();

Expand Down
46 changes: 23 additions & 23 deletions rust/codelist-validator-rs/src/snomed_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 79d67f2

Please sign in to comment.