diff --git a/src/entity/card-management/card_inventory.ts b/src/entity/card-management/card_inventory.ts new file mode 100644 index 0000000..bc22ca5 --- /dev/null +++ b/src/entity/card-management/card_inventory.ts @@ -0,0 +1,74 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, + Index, +} from "typeorm"; +import { EmrPatient } from "../emr/emr_patient"; +import { HealthcareFacility } from "./healthcare_facility"; +import { CardInventoryStatus } from "../../types/card_inventory_status"; + +@Entity({ schema: "card_management", name: "card_inventory" }) +@Index(["card_number"], { unique: true }) +@Index(["running_number"], { unique: true }) +export class CardInventory { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => EmrPatient, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn({ name: "patientId" }) + patient: EmrPatient; + + @Column({ nullable: true, length: 64 }) + mrn: string; + + @Column({ type: "bigint", nullable: false, unique: true }) + running_number: string; + + @Column({ nullable: true, length: 64, unique: true }) + card_number: string; + + @Column({ nullable: true, length: 128 }) + tag_id: string; + + @ManyToOne(() => HealthcareFacility, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + facility: HealthcareFacility; + + @Column({ + type: "enum", + enum: CardInventoryStatus, + nullable: false, + default: CardInventoryStatus.NOT_USED, + }) + status: CardInventoryStatus; + + @Column({ type: "timestamp", nullable: true }) + printed_at: Date; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/entity/card-management/card_stock_in.ts b/src/entity/card-management/card_stock_in.ts new file mode 100644 index 0000000..c4deab9 --- /dev/null +++ b/src/entity/card-management/card_stock_in.ts @@ -0,0 +1,48 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, +} from "typeorm"; + +/** + * Placeholder for future batch card stock-in workflow. + * Entity only — no API, UI, or business logic yet. + */ +@Entity({ schema: "card_management", name: "card_stock_in" }) +export class CardStockIn { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ nullable: true, length: 64 }) + batch_number: string; + + @Column({ type: "int", nullable: true }) + quantity: number; + + @Column({ type: "text", nullable: true }) + notes: string; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/entity/card-management/healthcare_facility.ts b/src/entity/card-management/healthcare_facility.ts new file mode 100644 index 0000000..aec55b6 --- /dev/null +++ b/src/entity/card-management/healthcare_facility.ts @@ -0,0 +1,73 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, + Index, +} from "typeorm"; +import { Munisipo } from "../munisipo"; +import { Administrativu } from "../administrativu"; +import { HealthcareFacilityStatus } from "../../types/healthcare_facility_status"; +import { HealthcareFacilityType } from "../../types/healthcare_facility_type"; + +@Entity({ schema: "card_management", name: "healthcare_facility" }) +@Index(["code"], { unique: true }) +export class HealthcareFacility { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ nullable: false, length: 64, unique: true }) + code: string; + + @Column({ type: "text", nullable: false }) + name: string; + + @Column({ + type: "enum", + enum: HealthcareFacilityType, + nullable: false, + default: HealthcareFacilityType.HOSPITAL, + }) + type: HealthcareFacilityType; + + @ManyToOne(() => Munisipo, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + municipio: Munisipo; + + @ManyToOne(() => Administrativu, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + administrativu: Administrativu; + + @Column({ + type: "enum", + enum: HealthcareFacilityStatus, + nullable: false, + default: HealthcareFacilityStatus.ACTIVE, + }) + status: HealthcareFacilityStatus; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/entity/card-management/running_number_log.ts b/src/entity/card-management/running_number_log.ts new file mode 100644 index 0000000..8ec1bb5 --- /dev/null +++ b/src/entity/card-management/running_number_log.ts @@ -0,0 +1,53 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + Index, +} from "typeorm"; + +@Entity({ schema: "card_management", name: "running_number_log" }) +@Index(["running_number"]) +@Index(["requested_at"]) +export class RunningNumberLog { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ type: "bigint", nullable: false }) + running_number: string; + + @Column({ nullable: false, length: 128 }) + service_name: string; + + @Column({ type: "uuid", nullable: false }) + requested_by: string; + + @Column({ nullable: false, length: 256 }) + requested_by_name: string; + + @Column({ type: "timestamp", nullable: false }) + requested_at: Date; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/index.ts b/src/index.ts index 88437b0..521db76 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,4 +6,5 @@ export * from "./schema/procurement"; export * from "./schema/pharmacy"; export * from "./schema/pharmacy_logistic"; export * from "./schema/cashier"; -export * from "./schema/blood_bank"; \ No newline at end of file +export * from "./schema/blood_bank"; +export * from "./schema/card_management"; \ No newline at end of file diff --git a/src/schema/card_management.ts b/src/schema/card_management.ts new file mode 100644 index 0000000..7823823 --- /dev/null +++ b/src/schema/card_management.ts @@ -0,0 +1,7 @@ +export * from "../types/card_inventory_status"; +export * from "../types/healthcare_facility_status"; +export * from "../types/healthcare_facility_type"; +export * from "../entity/card-management/card_inventory"; +export * from "../entity/card-management/healthcare_facility"; +export * from "../entity/card-management/running_number_log"; +export * from "../entity/card-management/card_stock_in"; diff --git a/src/types/card_inventory_status.ts b/src/types/card_inventory_status.ts new file mode 100644 index 0000000..351be3d --- /dev/null +++ b/src/types/card_inventory_status.ts @@ -0,0 +1,7 @@ +export enum CardInventoryStatus { + /** Blank card in stock — not yet assigned / injected to a patient */ + NOT_USED = "NOT_USED", + ACTIVE = "ACTIVE", + LOST = "LOST", + REPLACED = "REPLACED", +} diff --git a/src/types/healthcare_facility_status.ts b/src/types/healthcare_facility_status.ts new file mode 100644 index 0000000..5d9f5c7 --- /dev/null +++ b/src/types/healthcare_facility_status.ts @@ -0,0 +1,4 @@ +export enum HealthcareFacilityStatus { + ACTIVE = "ACTIVE", + INACTIVE = "INACTIVE", +} diff --git a/src/types/healthcare_facility_type.ts b/src/types/healthcare_facility_type.ts new file mode 100644 index 0000000..3586ff8 --- /dev/null +++ b/src/types/healthcare_facility_type.ts @@ -0,0 +1,6 @@ +export enum HealthcareFacilityType { + HOSPITAL = "HOSPITAL", + CLINIC = "CLINIC", + HEALTH_CENTER = "HEALTH_CENTER", + OTHER = "OTHER", +}