Files
step3/api/QuestionsApi/Services/Step3SystemCatalog.cs
T

75 lines
4.6 KiB
C#

using QuestionsApi.Models;
namespace QuestionsApi.Services;
public static class Step3SystemCatalog
{
private static readonly IReadOnlyDictionary<string, string> Overrides = new Dictionary<string, string>(StringComparer.Ordinal)
{
["d5-expansion-pediatrics-urea-cycle-hyperammonemia-001"] = "Endocrine System",
["d5-expansion-pediatrics-neonatal-hsv-disseminated-001"] = "Immune System, Blood & Lymphoreticular System, and Multisystem Processes/Disorders",
["d5-expansion-pediatrics-cdh-delivery-stabilization-001"] = "Respiratory System",
["d5-expansion-pediatrics-hie-therapeutic-hypothermia-001"] = "Nervous System & Special Senses",
["d5-expansion-pediatrics-fnait-intracranial-bleeding-001"] = "Immune System, Blood & Lymphoreticular System, and Multisystem Processes/Disorders",
["nbme6-s3-i029-infant-hyperchloremic-acidosis-growth-risk"] = "Renal/Urinary & Male Reproductive Systems",
["form7-s1-i042-genitourinary-syndrome-menopause"] = "Pregnancy/Childbirth & Female Reproductive System & Breast",
["free137-i019-inguinal-node-vulvar-source"] = "Pregnancy/Childbirth & Female Reproductive System & Breast",
["free137-i061-klinefelter-confirmation"] = "Renal/Urinary & Male Reproductive Systems",
["form7-s1-i009-cremasteric-reflex"] = "Renal/Urinary & Male Reproductive Systems",
["form7-s2-i015-acrosome-head"] = "Renal/Urinary & Male Reproductive Systems",
["nbme6-s1-i033-prostate-primary-osteoblastic-metastases"] = "Renal/Urinary & Male Reproductive Systems",
["nbme6-s3-i043-lytic-lesion-hematuria-staging"] = "Renal/Urinary & Male Reproductive Systems"
};
public static readonly string[] All =
[
"Human Development",
"Immune System, Blood & Lymphoreticular System, and Multisystem Processes/Disorders",
"Behavioral Health",
"Nervous System & Special Senses",
"Skin & Subcutaneous Tissue",
"Musculoskeletal System",
"Cardiovascular System",
"Respiratory System",
"Gastrointestinal System",
"Renal/Urinary & Male Reproductive Systems",
"Pregnancy/Childbirth & Female Reproductive System & Breast",
"Endocrine System",
"Biostatistics & Epidemiology/Population Health & Interpretation of the Medical Literature",
"Social Sciences: Communication Skills/Ethics/Patient Safety"
];
public static string? Normalize(Question question) =>
Normalize(question.Step3System)
?? Derive(question);
public static string? Derive(Question question) =>
Overrides.GetValueOrDefault(question.ExternalId)
?? Normalize(question.System) ?? Normalize(question.PerformanceCategory) ?? Normalize(question.Discipline);
public static string? Normalize(string? value)
{
if (string.IsNullOrWhiteSpace(value)) return null;
var trimmed = value.Trim();
var exact = All.FirstOrDefault(system => string.Equals(system, trimmed, StringComparison.OrdinalIgnoreCase));
if (exact is not null) return exact;
var lower = trimmed.ToLowerInvariant();
if (Has(lower, "human development", "well patient", "preventive", "health maintenance", "geriatr", "age-related", "neonat")) return All[0];
if (Has(lower, "social science", "communication", "ethic", "patient safety", "professionalism", "systems-based")) return All[13];
if (Has(lower, "pregnan", "obstetric", "gynec", "female reproductive", "breast", "puerper")) return All[10];
if (Has(lower, "renal", "urinary", "male reproductive", "urolog", "nephro")) return All[9];
if (Has(lower, "biostat", "epidemi", "population health", "medical literature")) return All[12];
if (Has(lower, "immune", "immun", "blood", "hemat", "lymph", "multisystem", "infectious", "toxicolog", "poisoning", "oncolog", "trauma")) return All[1];
if (Has(lower, "behavior", "psychi", "mental health")) return All[2];
if (Has(lower, "nervous", "neuro", "special sense", "ophthalm", "eye & adnexa", "otolaryng", "ear, nose", " ent")) return All[3];
if (Has(lower, "skin", "derm", "subcutaneous", "integument")) return All[4];
if (Has(lower, "musculo", "orthop", "rheumat")) return All[5];
if (Has(lower, "cardio", "circulatory", "peripheral vascular")) return All[6];
if (Has(lower, "resp", "pulmon")) return All[7];
if (Has(lower, "gastro", "digest", "hepato", "oral/dental")) return All[8];
if (Has(lower, "endocr", "metabolic")) return All[11];
return null;
}
private static bool Has(string value, params string[] fragments) => fragments.Any(value.Contains);
}