// drug_interactions.sy -- Drug-drug interactions compiled from FDA labels.
//
// Sources:
//   FDA drug labels via DailyMed/OpenFDA (extracted 2025-2026)
//
// Marjorie McCubbins + Aether, April 2026
// Patent pending: 64/034,536

struct DDI {
    drug_a: String,
    drug_b: String,
    interaction_type: String,
    citation: String,
}

fn ddi(da: String, db: String, it: String) -> DDI {
    return DDI { drug_a: da, drug_b: db, interaction_type: it, citation: "FDA drug label" }
}

fn no_interaction() -> DDI {
    return DDI { drug_a: "", drug_b: "", interaction_type: "", citation: "" }
}

fn ddi_b(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "BUSPIRONE" { if drug_b == "DRUG" { return ddi("BUSPIRONE", "DRUG", "contraindicated") } }
    if drug_a == "BUSPIRONE HYDROCHLORIDE" { if drug_b == "DRUG" { return ddi("BUSPIRONE HYDROCHLORIDE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_c(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "CARBAMAZEPINE" { if drug_b == "DRUG" { return ddi("CARBAMAZEPINE", "DRUG", "contraindicated") } }
    if drug_a == "CLARITHROMYCIN" { if drug_b == "DRUG" { return ddi("CLARITHROMYCIN", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_d(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "DIETHYLPROPION HYDROCHLORIDE" { if drug_b == "DRUG" { return ddi("DIETHYLPROPION HYDROCHLORIDE", "DRUG", "contraindicated") } }
    if drug_a == "DOXYCYCLINE HYCLATE" { if drug_b == "DRUG" { return ddi("DOXYCYCLINE HYCLATE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_e(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "ERYTHROMYCIN" { if drug_b == "DRUG" { return ddi("ERYTHROMYCIN", "DRUG", "contraindicated") } }
    if drug_a == "ERYTHROMYCIN ETHYLSUCCINATE" { if drug_b == "DRUG" { return ddi("ERYTHROMYCIN ETHYLSUCCINATE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_f(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "FLUCONAZOLE" { if drug_b == "DRUG" { return ddi("FLUCONAZOLE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_i(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "ISOSORBIDE DINITRATE" { if drug_b == "DRUG" { return ddi("ISOSORBIDE DINITRATE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_k(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "KETOROLAC TROMETHAMINE" { if drug_b == "DRUG" { return ddi("KETOROLAC TROMETHAMINE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_n(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "NEFAZODONE HYDROCHLORIDE" { if drug_b == "DRUG" { return ddi("NEFAZODONE HYDROCHLORIDE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_p(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "PANTOPRAZOLE SODIUM DR" { if drug_b == "TABLE" { return ddi("PANTOPRAZOLE SODIUM DR", "TABLE", "contraindicated") } }
    if drug_a == "PAROXETINE" { if drug_b == "DRUG" { return ddi("PAROXETINE", "DRUG", "contraindicated") } }
    if drug_a == "PAROXETINE HYDROCHLORIDE" { if drug_b == "DRUG" { return ddi("PAROXETINE HYDROCHLORIDE", "DRUG", "contraindicated") } }
    if drug_a == "PHENDIMETRAZINE TARTRATE" { if drug_b == "DRUG" { return ddi("PHENDIMETRAZINE TARTRATE", "DRUG", "contraindicated") } }
    if drug_a == "PRIMAQUINE PHOSPHATE" { if drug_b == "DRUG" { return ddi("PRIMAQUINE PHOSPHATE", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_r(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "RIFAMPIN" { if drug_b == "DRUG" { return ddi("RIFAMPIN", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn ddi_s(drug_a: String, drug_b: String) -> DDI {
    if drug_a == "SERTRALINE HYDROCHLORIDE" { if drug_b == "DRUG" { return ddi("SERTRALINE HYDROCHLORIDE", "DRUG", "contraindicated") } }
    if drug_a == "SULFAMETHOXAZOLE AND TRIMETHOPRIM" { if drug_b == "DRUG" { return ddi("SULFAMETHOXAZOLE AND TRIMETHOPRIM", "DRUG", "contraindicated") } }
    return no_interaction()
}

fn check_interaction(drug_a: String, drug_b: String) -> DDI {
    if str_starts_with(drug_a, "B") { return ddi_b(drug_a, drug_b) }
    if str_starts_with(drug_a, "C") { return ddi_c(drug_a, drug_b) }
    if str_starts_with(drug_a, "D") { return ddi_d(drug_a, drug_b) }
    if str_starts_with(drug_a, "E") { return ddi_e(drug_a, drug_b) }
    if str_starts_with(drug_a, "F") { return ddi_f(drug_a, drug_b) }
    if str_starts_with(drug_a, "I") { return ddi_i(drug_a, drug_b) }
    if str_starts_with(drug_a, "K") { return ddi_k(drug_a, drug_b) }
    if str_starts_with(drug_a, "N") { return ddi_n(drug_a, drug_b) }
    if str_starts_with(drug_a, "P") { return ddi_p(drug_a, drug_b) }
    if str_starts_with(drug_a, "R") { return ddi_r(drug_a, drug_b) }
    if str_starts_with(drug_a, "S") { return ddi_s(drug_a, drug_b) }
    return no_interaction()
}

fn ddi_total_count() -> Int { return 20 }