fix(db): map physical exam to outpatient registration

use outpatient registration as the linked record for physical
examinations and enforce a one-to-one relationship.
rename the relation field to registration_outpatient for clarity
This commit is contained in:
avicenan
2026-03-11 11:00:00 +07:00
parent 782667f73a
commit 8c66518127

View File

@ -5,20 +5,20 @@ import {
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
ManyToOne,
JoinColumn,
OneToOne,
} from "typeorm";
import { EmrRegistration } from "./emr_registration";
import { EmrRegistrationOutpatient } from "./emr_registration_outpatient";
@Entity("emr_physical_examination", { schema: "emr" })
export class EmrPhysicalExamination {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" })
@OneToOne(() => EmrRegistrationOutpatient, { onDelete: "CASCADE" })
@JoinColumn()
registration: EmrRegistration;
registration_outpatient: EmrRegistrationOutpatient;
@Column({ nullable: true, type: "text" })
internal_status: string;