From c14920085832f2cb81294f15bb33249053434c99 Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Thu, 26 Mar 2026 15:57:02 +0700 Subject: [PATCH] update entity and controller for compounding medicine to add relation with usage time and usage instructions --- src/entity/emr/emr_compounding_medicine.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/entity/emr/emr_compounding_medicine.ts b/src/entity/emr/emr_compounding_medicine.ts index e1a3ee4..6b7f871 100644 --- a/src/entity/emr/emr_compounding_medicine.ts +++ b/src/entity/emr/emr_compounding_medicine.ts @@ -5,10 +5,14 @@ import { CreateDateColumn, UpdateDateColumn, DeleteDateColumn, - OneToMany + OneToMany, + ManyToOne, + JoinColumn } from "typeorm"; -import {EmrCompoundingMedicineItem} from "./emr_compounding_medicine_item"; +import { EmrCompoundingMedicineItem } from "./emr_compounding_medicine_item"; +import { UsageTime } from "../pharmacy/usage_time"; +import { UsageInstructions } from "../pharmacy/usage_instructions"; @Entity("emr_compounding_medicine", { schema: "emr" }) export class EmrCompoundingMedicine { @@ -30,11 +34,13 @@ export class EmrCompoundingMedicine { @Column({ nullable: true, type: "text" }) compounding_notes: string; - @Column({ nullable: true, type: "text" }) - usage_time: string; + @ManyToOne(() => UsageTime, { onDelete: "CASCADE" }) + @JoinColumn() + usagetime: UsageTime; - @Column({ nullable: true, type: "text" }) - usage_instructions: string; + @ManyToOne(() => UsageInstructions, { onDelete: "CASCADE" }) + @JoinColumn() + usageinstructions: UsageInstructions; @Column() @CreateDateColumn()