From f0a1cf6f93c0738a810fe990ba4e88c242c20adc Mon Sep 17 00:00:00 2001 From: Iki Date: Mon, 22 Jun 2026 18:43:54 +0900 Subject: [PATCH] add entity for hemodialysis_schedule and emr_hemodialysis_visits --- src/entity/emr/emr_hemodialysis_schedule.ts | 62 +++++++++++++++++ src/entity/emr/emr_hemodialysis_visit.ts | 77 +++++++++++++++++++++ src/schema/emr.ts | 2 + 3 files changed, 141 insertions(+) create mode 100644 src/entity/emr/emr_hemodialysis_schedule.ts create mode 100644 src/entity/emr/emr_hemodialysis_visit.ts diff --git a/src/entity/emr/emr_hemodialysis_schedule.ts b/src/entity/emr/emr_hemodialysis_schedule.ts new file mode 100644 index 0000000..c7d8939 --- /dev/null +++ b/src/entity/emr/emr_hemodialysis_schedule.ts @@ -0,0 +1,62 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; +import { EmrPatient } from "./emr_patient"; +import { HemodialysisPlan } from "./emr_hemodialysis_plan"; + +export enum HemodialysisScheduleStatus { + SCHEDULED = "SCHEDULED", + CHECKED_IN = "CHECKED_IN", + COMPLETED = "COMPLETED", + CANCELLED = "CANCELLED", +} + +@Entity("emr_hemodialysis_schedules", { schema: "emr" }) +export class HemodialysisSchedule { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => HemodialysisPlan, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn({ name: "plan_id" }) + plan: HemodialysisPlan; + + @ManyToOne(() => EmrPatient, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn({ name: "patient_id" }) + patient: EmrPatient; + + @Column({ type: "date", nullable: false }) + scheduled_date: string; + + /** ISO weekday: 1 = Monday … 7 = Sunday (recurring weekly slot) */ + @Column({ type: "smallint", nullable: true }) + day_of_week: number | null; + + @Column({ + type: "enum", + enum: HemodialysisScheduleStatus, + default: HemodialysisScheduleStatus.SCHEDULED, + }) + status: HemodialysisScheduleStatus; + + @Column({ nullable: true, length: 256 }) + assigned_by: string | null; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} diff --git a/src/entity/emr/emr_hemodialysis_visit.ts b/src/entity/emr/emr_hemodialysis_visit.ts new file mode 100644 index 0000000..e2a3ed5 --- /dev/null +++ b/src/entity/emr/emr_hemodialysis_visit.ts @@ -0,0 +1,77 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; +import { EmrPatient } from "./emr_patient"; +import { EmrRegistration } from "./emr_registration"; +import { HemodialysisSchedule } from "./emr_hemodialysis_schedule"; + +export enum HemodialysisVisitStatus { + WAITING_NURSING = "WAITING_NURSING", + IN_PROGRESS = "IN_PROGRESS", + COMPLETED = "COMPLETED", +} + +export enum HemodialysisCheckinMethod { + SCAN = "SCAN", + MANUAL = "MANUAL", +} + +@Entity("emr_hemodialysis_visits", { schema: "emr" }) +export class HemodialysisVisit { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => HemodialysisSchedule, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn({ name: "schedule_id" }) + schedule: HemodialysisSchedule; + + @ManyToOne(() => EmrPatient, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn({ name: "patient_id" }) + patient: EmrPatient; + + @ManyToOne(() => EmrRegistration, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn({ name: "registration_id" }) + registration: EmrRegistration | null; + + @Column({ type: "date", nullable: false }) + visit_date: string; + + @Column({ type: "timestamptz", nullable: true }) + checkin_time: Date | null; + + @Column({ type: "timestamptz", nullable: true }) + checkout_time: Date | null; + + @Column({ + type: "enum", + enum: HemodialysisVisitStatus, + default: HemodialysisVisitStatus.WAITING_NURSING, + }) + status: HemodialysisVisitStatus; + + @Column({ + type: "enum", + enum: HemodialysisCheckinMethod, + nullable: true, + }) + checkin_method: HemodialysisCheckinMethod | null; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} diff --git a/src/schema/emr.ts b/src/schema/emr.ts index 60ea28f..cdd6a26 100644 --- a/src/schema/emr.ts +++ b/src/schema/emr.ts @@ -6,6 +6,8 @@ export * from "../entity/emr/emr_registration_emergency"; export * from "../entity/emr/emr_registration_hemodialysis"; export * from "../entity/emr/emr_hemodialysis_settings"; export * from "../entity/emr/emr_hemodialysis_plan"; +export * from "../entity/emr/emr_hemodialysis_schedule"; +export * from "../entity/emr/emr_hemodialysis_visit"; export * from "../entity/emr/emr_anamnesis"; export * from "../entity/emr/emr_vital_signs"; export * from "../entity/emr/emr_physical_examination";