feat(emr_boarding_room_bed_histories): create entity to track bed transfer and swap events in boarding rooms

This commit is contained in:
Sony Surahmn
2026-05-05 00:56:02 +07:00
parent b81967fa36
commit 8244b80117
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,76 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
ManyToOne,
JoinColumn,
Index,
} from "typeorm";
import { EmrBoardingRoom } from "./emr_boarding_rooms";
import { InpatientRoom } from "../inpatient_rooms";
/** Tracks every bed-transfer and bed-swap event for a boarding room. */
@Entity("emr_boarding_room_bed_histories", { schema: "emr" })
@Index("idx_emr_brbed_hist_boarding_room", ["boarding_room"])
export class EmrBoardingRoomBedHistory {
@PrimaryGeneratedColumn("uuid")
id: string;
/** The boarding room (patient) whose bed changed. */
@ManyToOne(() => EmrBoardingRoom, { onDelete: "NO ACTION" })
@JoinColumn()
boarding_room: EmrBoardingRoom;
/** "transfer" = pindah kamar, "swap" = tukar tempat tidur dengan pasien lain */
@Column({ length: 16 })
type: string;
@ManyToOne(() => InpatientRoom, { onDelete: "NO ACTION", nullable: true })
@JoinColumn({ name: "from_inpatient_room_id" })
from_inpatient_room: InpatientRoom | null;
@Column({ nullable: true, type: "int" })
from_bed_number: number | null;
@ManyToOne(() => InpatientRoom, { onDelete: "NO ACTION", nullable: true })
@JoinColumn({ name: "to_inpatient_room_id" })
to_inpatient_room: InpatientRoom | null;
@Column({ nullable: true, type: "int" })
to_bed_number: number | null;
/**
* For "swap" type: the other boarding room involved in the swap.
* Null for "transfer" events.
*/
@ManyToOne(() => EmrBoardingRoom, { onDelete: "NO ACTION", nullable: true })
@JoinColumn({ name: "swapped_with_boarding_room_id" })
swapped_with_boarding_room: EmrBoardingRoom | null;
@Column({ nullable: true, type: "text" })
note: string | null;
@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;
}

View File

@ -10,6 +10,7 @@ export * from "../entity/emr/emr_physical_examination";
export * from "../entity/emr/emr_diet";
export * from "../entity/emr/emr_boarding_rooms";
export * from "../entity/emr/emr_boarding_room_doctor_histories";
export * from "../entity/emr/emr_boarding_room_bed_histories";
export * from "../entity/emr/emr_diagnosis";
export * from "../entity/emr/emr_diagnostic_procedure";
export * from "../entity/emr/emr_doctor_procedure";