From 782667f73ae1453846955603723dfdeb20053298 Mon Sep 17 00:00:00 2001 From: avicenan Date: Tue, 10 Mar 2026 22:51:03 +0700 Subject: [PATCH] fix(db): map emr records to outpatient registration Switch anamnesis and vital signs to reference EmrRegistrationOutpatient with one-to-one relations. Rename complaint and blood pressure fields to use consistent, correct naming. BREAKING CHANGE: emr_anamnesis.registration is now registration_outpatient and chief_complaint is now main_complaint. emr_vital_signs.registration is now registration_outpatient and blood_preasure is now blood_pressure. --- src/entity/emr/emr_anamnesis.ts | 11 +++++------ src/entity/emr/emr_vital_signs.ts | 18 ++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/entity/emr/emr_anamnesis.ts b/src/entity/emr/emr_anamnesis.ts index 904c24e..ad4dc3e 100644 --- a/src/entity/emr/emr_anamnesis.ts +++ b/src/entity/emr/emr_anamnesis.ts @@ -6,30 +6,29 @@ import { UpdateDateColumn, DeleteDateColumn, ManyToOne, - OneToOne, JoinColumn, + OneToOne, } from "typeorm"; import { anamnesisStatus } from "../../enum/anamnesisStatus"; -import { EmrRegistration } from "./emr_registration"; import { EmrPatient } from "./emr_patient"; +import { EmrRegistrationOutpatient } from "./emr_registration_outpatient"; @Entity("emr_anamnesis", { schema: "emr" }) export class Emranamnesis { @PrimaryGeneratedColumn("uuid") id: string; - @ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" }) + @OneToOne(() => EmrRegistrationOutpatient, { onDelete: "CASCADE" }) @JoinColumn() - registration: EmrRegistration; + registration_outpatient: EmrRegistrationOutpatient; @ManyToOne(() => EmrPatient, { onDelete: "CASCADE" }) @JoinColumn() patient: EmrPatient; - /** Contoh: "08:00-12:00" atau "Pagi" */ @Column({ nullable: true, type: "text" }) - chief_complaint: string; + main_complaint: string; @Column({ nullable: true, type: "text" }) additional_complaint: string; diff --git a/src/entity/emr/emr_vital_signs.ts b/src/entity/emr/emr_vital_signs.ts index f13c68c..e7d597e 100644 --- a/src/entity/emr/emr_vital_signs.ts +++ b/src/entity/emr/emr_vital_signs.ts @@ -5,30 +5,24 @@ import { CreateDateColumn, UpdateDateColumn, DeleteDateColumn, - ManyToOne, JoinColumn, + OneToOne, } from "typeorm"; import { consciousness } from "../../enum/consciousness"; -import { EmrRegistration } from "./emr_registration"; - -enum YesNoEnum { - YES = "YES", - NO = "NO" -} +import { EmrRegistrationOutpatient } from "./emr_registration_outpatient"; @Entity("emr_vital_signs", { schema: "emr" }) export class EmrVitalSigns { @PrimaryGeneratedColumn("uuid") id: string; - @ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" }) + @OneToOne(() => EmrRegistrationOutpatient, { onDelete: "CASCADE" }) @JoinColumn() - registration: EmrRegistration; + registration_outpatient: EmrRegistrationOutpatient; - /** Contoh: "08:00-12:00" atau "Pagi" */ @Column({ nullable: true, length: 64 }) - blood_preasure: string; + blood_pressure: string; @Column({ nullable: true, length: 64 }) heart_rate: string; @@ -106,7 +100,7 @@ export class EmrVitalSigns { @Column({ nullable: true, length: 256 }) nutritional_status_assessment: string; - @Column({ nullable: true, type: "text" }) + @Column({ nullable: true, type: "text" }) patient_education: string; @Column({ nullable: true, length: 256 })