Refactor substances part 1

This commit is contained in:
xqtc 2024-10-20 22:47:39 +02:00 committed by xqtc
parent 212dbdb313
commit 86736b77ab
Signed by: xqtc
GPG key ID: 2C064D095926D9D1
6 changed files with 1228 additions and 2 deletions

866
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,9 @@
# meowlog
---
> Huge thanks to the people of [TripSit](https://tripsit.me) for letting me use their database on drugs. Go check them out. They're doing great things for harm reduction.
## WIP SUBJECT TO CHANGE
### ⚠️ IMPORTANT

View file

@ -18,6 +18,7 @@ serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
strum = { version = "0.26.3", features = ["derive"] }
strum_macros = "0.26.4"
sqlx = { version = "0.8.2", features = ["sqlite"] }
toml = "0.8.19"
uuid = { version = "1.10.0", features = ["serde", "v4"] }

View file

@ -5,7 +5,7 @@ mod parser;
pub fn parse() {
let file = include_str!("../../../drugs.json");
let db: DrugDatabase = serde_json::from_str(file).unwrap();
println!("{:?}", db);
println!("{:#?}", db);
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -17,6 +17,8 @@ mod util;
mod drugs_parser;
mod substances_new;
mod ingestions;
mod ingestions_util;
mod substance_util;

View file

@ -0,0 +1,356 @@
// export type Drug = {
// aliases?: string[];
// categories?: Category[];
// formatted_aftereffects?: Duration;
// formatted_dose?: Dose;
// formatted_duration?: Duration;
// formatted_effects?: string[];
// formatted_onset?: Duration;
// links?: Links;
// name: string;
// pretty_name: string;
// properties: Properties;
// pweffects?: { [key: string]: string };
// dose_note?: string;
// sources?: Sources;
// combos?: Interactions;
// };
//
// export enum Category {
// Barbiturate = "barbiturate",
// Benzodiazepine = "benzodiazepine",
// Common = "common",
// Deliriant = "deliriant",
// Depressant = "depressant",
// Dissociative = "dissociative",
// Empathogen = "empathogen",
// HabitForming = "habit-forming",
// Inactive = "inactive",
// Nootropic = "nootropic",
// Opioid = "opioid",
// Psychedelic = "psychedelic",
// ResearchChemical = "research-chemical",
// Ssri = "ssri",
// Stimulant = "stimulant",
// Supplement = "supplement",
// Tentative = "tentative",
// }
//
// export type Duration = {
// _unit: Unit;
// value?: string;
// insufflated?: string;
// oral?: string;
// rectal?: string;
// vapourized?: string;
// smoked?: string;
// Oral_ER?: string;
// Oral_IR?: string;
// Oral_MAOI?: string;
// intramuscular?: string;
// intravenous?: string;
// metabolites?: string;
// parent?: string;
// oralMAOI?: string;
// buccal?: string;
// transdermal?: string;
// sublingual?: string;
// Insufflated_IR?: string;
// Insufflated_XR?: string;
// };
//
// export type Dose = {
// oral?: Dosage;
// insufflated?: Dosage;
// rectal?: Dosage;
// vapourized?: Dosage;
// intravenous?: Dosage;
// smoked?: Dosage;
// sublingual?: Dosage;
// buccal?: Dosage;
// intramuscular?: Dosage;
// transdermal?: Dosage;
// hbwr?: Dosage;
// Morning_Glory?: Dosage;
// dried?: Dosage;
// fresh?: Dosage;
// "Insufflated(Pure)"?: Dosage;
// "Oral(Benzedrex)"?: Dosage;
// "Oral(Pure)"?: Dosage;
// dry?: Dosage;
// wet?: Dosage;
// };
//
// export type Dosage = {
// common?: string;
// light?: string;
// strong?: string;
// threshold?: string;
// heavy?: string;
// dangerous?: string;
// fatal?: string;
// note?: string;
// };
//
// export type Links = {
// experiences: string;
// pihkal?: string;
// tihkal?: string;
// };
//
// export type Properties = {
// "after-effects"?: string;
// aliases?: string[];
// avoid?: string;
// categories?: Category[];
// dose?: string;
// duration?: string;
// "half-life"?: string;
// onset?: string;
// summary?: string;
// "test-kits"?: string;
// experiences?: string;
// warning?: string;
// marquis?: string;
// effects?: string;
// risks?: string;
// comeup?: string;
// note?: string;
// detection?: string;
// wiki?: string;
// mdma?: string;
// tolerance?: string;
// bioavailability?: string;
// dose_to_diazepam?: string;
// "adverse-effects"?: string;
// chemistry?: string;
// contraindications?: string;
// legal?: string;
// "overdose-symptoms"?: string;
// pharmacokinetics?: string;
// pharmacology?: string;
// obtain?: string;
// pharmacodynamics?: string;
// "side-effects"?: string;
// molecule?: string;
// vaporization?: string;
// calculator?: string;
// chart?: string;
// oral?: string;
// "general-advice"?: string;
// potentiators?: string;
// };
//
// export interface Combos {
// "2c-t-x": Interactions;
// "2c-x": Interactions;
// "5-meo-xxt": Interactions;
// alcohol: Interactions;
// amphetamines: Interactions;
// amt: Interactions;
// benzodiazepines: Interactions;
// caffeine: Interactions;
// cannabis: Interactions;
// cocaine: Interactions;
// diphenhydramine: Interactions;
// dextromethorphan: Interactions;
// dmt: Interactions;
// dox: Interactions;
// "ghb/gbl": Interactions;
// ketamine: Interactions;
// lithium: Interactions;
// lsd: Interactions;
// maois: Interactions;
// mdma: Interactions;
// mephedrone: Interactions;
// mescaline: Interactions;
// mushrooms: Interactions;
// mxe: Interactions;
// nbomes: Interactions;
// nitrous: Interactions;
// opioids: Interactions;
// pcp: Interactions;
// ssris: Interactions;
// tramadol: Interactions;
// }
//
// export interface Interactions {
// "2c-t-x"?: ComboData;
// "2c-x"?: ComboData;
// "5-meo-xxt"?: ComboData;
// alcohol?: ComboData;
// amphetamines?: ComboData;
// amt?: ComboData;
// benzodiazepines?: ComboData;
// caffeine?: ComboData;
// cannabis?: ComboData;
// cocaine?: ComboData;
// diphenhydramine?: ComboData;
// dextromethorphan?: ComboData;
// dmt?: ComboData;
// dox?: ComboData;
// "ghb/gbl"?: ComboData;
// lithium?: ComboData;
// ketamine?: ComboData;
// lsd?: ComboData;
// maois?: ComboData;
// mdma?: ComboData;
// mephedrone?: ComboData;
// mescaline?: ComboData;
// mushrooms?: ComboData;
// mxe?: ComboData;
// nbomes?: ComboData;
// nitrous?: ComboData;
// opioids?: ComboData;
// pcp?: ComboData;
// ssris?: ComboData;
// tramadol?: ComboData;
// }
//
// export interface ComboData {
// note?: string;
// sources?: {
// author: string;
// title: string;
// url: string;
// }[];
// status: Status;
// }
//
// export enum Status {
// Caution = "Caution",
// Dangerous = "Dangerous",
// LowRiskDecrease = "Low Risk & Decrease",
// LowRiskNoSynergy = "Low Risk & No Synergy",
// LowRiskSynergy = "Low Risk & Synergy",
// Self = "Self",
// Unsafe = "Unsafe",
// }
//
// export type ComboDefinitions = {
// status: Status;
// emoji: string;
// color: string;
// definition: string;
// thumbnail: string;
// }
//
// export enum Unit {
// Hours = "hours",
// Minutes = "minutes",
// }
//
// export type Sources = {
// general?: string[];
// dose?: string[];
// duration?: string[];
// bioavailability?: string[];
// legality?: string[];
// onset?: string[];
// };
pub struct Dug {
aliases: Option<Vec<String>>,
categories: Option<Vec<Category>>,
formatted_aftereffects: Option<Duration>,
formatted_dose: Option<Dose>,
formatted_duration: Option<Duration>,
formatted_effects: Option<Vec<String>>,
formatted_onset: Option<Duration>,
links: Option<Links>,
name: String,
pretty_name: String,
properties: Properties,
pweffects: Option<(String, Strin)>,
dose_note: Option<String>,
sources: Option<Sources>,
combos: Option<Interactions>,
}
pub enum Category {
Barbiturate,
Benzodiazepine,
Common,
Deliriant,
Depressant,
Dissociative,
Empathogen,
HabitForming,
Inactive,
Nootropic,
Opioid,
Psychedelic,
ResearchChemical,
Ssri,
Stimulant,
Supplement,
Tentative,
}
pub struct Duration {
unit: Unit,
value: Option<String>,
insufflated: Option<String>,
oral: Option<String>,
rectal: Option<String>,
vapourized: Option<String>,
smoked: Option<String>,
oral_ER: Option<String>,
oral_IR: Option<String>,
oral_MAOI: Option<String>,
intramuscular: Option<String>,
intravenous: Option<String>,
metabolites: Option<String>,
parent: Option<String>,
oralMAOI: Option<String>,
buccal: Option<String>,
transdermal: Option<String>,
sublingual: Option<String>,
Insufflated_IR: Option<String>,
Insufflated_XR: Option<String>,
}
pub struct Dose {
oral: Option<Dosage>,
insufflated: Option<Dosage>,
rectal: Option<Dosage>,
vapourized: Option<Dosage>,
intravenous: Option<Dosage>,
smoked: Option<Dosage>,
sublingual: Option<Dosage>,
buccal: Option<Dosage>,
intramuscular: Option<Dosage>,
transdermal: Option<Dosage>,
hbwr: Option<Dosage>,
morning_glory: Option<Dosage>,
dried: Option<Dosage>,
fresh: Option<Dosage>,
insufflated_pure: Option<Dosage>,
oral_benzedrex: Option<Dosage>,
oral_pure: Option<Dosage>,
dry: Option<Dosage>,
wet: Option<Dosage>,
}
pub struct Dosage {
common: Option<String>,
light: Option<String>,
strong: Option<String>,
threshold: Option<String>,
heavy: Option<String>,
dangerous: Option<String>,
fatal: Option<String>,
note: Option<String>,
}
pub struct Links {
experiences: String,
pihkal: Option<String>,
tihkal: Option<String>,
}
pub struct Properties {
after_effects: Option<String>,
aliases: Option<Vec<String>>,
avoid: Option<String>,
}