SPB Git forge

spb/cancerindex

Public
37commits 1branches 0releases
2.9 MBsize
maindefault branch
10 days agolast push
TypeScript 97.2% SQL 1.5% CSS 0.6% JavaScript 0.5%
3.8 KB · 85 lines typescript
Raw Blame History
1import { pgTable, text, integer, bigserial, index, uniqueIndex, boolean, jsonb } from 'drizzle-orm/pg-core';2import { ciId, createdAt, updatedAt } from './_common.js';34/** Drugs (CLAUDE.md §7, §344): brand names are aliases, never separate molecules. */5export const drugs = pgTable(6  'drugs',7  {8    id: ciId().primaryKey(), // CI-DRUG-…9    slug: text('slug').notNull(),10    name: text('name').notNull(), // generic / INN preferred11    kind: text('kind'), // small_molecule | monoclonal_antibody | adc | bispecific | car_t | cell_therapy | gene_therapy | vaccine | radiopharmaceutical | chemotherapy | hormonal | immunotherapy | targeted | other12    ncitCode: text('ncit_code'),13    chemblId: text('chembl_id'),14    civicTherapyId: integer('civic_therapy_id'),15    drugbankId: text('drugbank_id'),16    pubchemCid: text('pubchem_cid'),17    unii: text('unii'),18    mechanism: text('mechanism'),19    targetGeneIds: text('target_gene_ids').array().notNull().default([]),20    developmentStatus: text('development_status'),21    description: text('description'),22    createdAt: createdAt(),23    updatedAt: updatedAt(),24  },25  (t) => [uniqueIndex('drugs_slug_uq').on(t.slug), index('drugs_ncit_idx').on(t.ncitCode), index('drugs_civic_idx').on(t.civicTherapyId), index('drugs_chembl_idx').on(t.chemblId)],26);2728export const drugAliases = pgTable(29  'drug_aliases',30  {31    id: bigserial('id', { mode: 'number' }).primaryKey(),32    drugId: ciId('drug_id').notNull(),33    alias: text('alias').notNull(),34    normalized: text('normalized').notNull(),35    aliasType: text('alias_type').notNull().default('synonym'), // generic | brand | development_code | salt | synonym36    sourceId: ciId('source_id'),37  },38  (t) => [uniqueIndex('drug_aliases_uq').on(t.drugId, t.normalized, t.aliasType), index('drug_aliases_norm_idx').on(t.normalized)],39);4041/** Regimens / combinations (CLAUDE.md §53). */42export const treatmentRegimens = pgTable(43  'treatment_regimens',44  {45    id: ciId().primaryKey(), // CI-TRT-…46    slug: text('slug').notNull(),47    name: text('name').notNull(),48    componentDrugIds: text('component_drug_ids').array().notNull().default([]),49    modality: text('modality').notNull().default('drug_combination'), // drug | drug_combination | surgery | radiotherapy | transplantation | cell_therapy | surveillance50    description: text('description'),51    createdAt: createdAt(),52  },53  (t) => [uniqueIndex('treatment_regimens_slug_uq').on(t.slug)],54);5556/** Country-aware regulatory status (CLAUDE.md §13). Never a bare approved=true. */57export const drugApprovals = pgTable(58  'drug_approvals',59  {60    id: bigserial('id', { mode: 'number' }).primaryKey(),61    drugId: ciId('drug_id').notNull(),62    cancerId: ciId('cancer_id'),63    biomarkerIds: text('biomarker_ids').array().notNull().default([]),64    tumorAgnostic: boolean('tumor_agnostic').notNull().default(false),65    jurisdiction: text('jurisdiction').notNull(), // US | CA | EU | UK | AU | JP | CH | OTHER66    authority: text('authority').notNull(), // FDA | Health Canada | EMA | MHRA | TGA | PMDA | Swissmedic67    indication: text('indication').notNull(),68    lineOfTherapy: text('line_of_therapy'),69    diseaseStage: text('disease_stage'),70    approvalType: text('approval_type'),71    accelerated: boolean('accelerated'),72    conditional: boolean('conditional'),73    approvalDate: text('approval_date'),74    withdrawalDate: text('withdrawal_date'),75    status: text('status').notNull(), // approved | conditional | accelerated | withdrawn | superseded76    applicationNumber: text('application_number'),77    sourceId: ciId('source_id').notNull(),78    provenanceId: integer('provenance_id').notNull(),79    raw: jsonb('raw'),80    createdAt: createdAt(),81    updatedAt: updatedAt(),82  },83  (t) => [index('drug_approvals_drug_idx').on(t.drugId), index('drug_approvals_cancer_idx').on(t.cancerId)],84);85