diff --git a/src/entity/emr/emr_odontogram.ts b/src/entity/emr/emr_odontogram.ts new file mode 100644 index 0000000..bb3302c --- /dev/null +++ b/src/entity/emr/emr_odontogram.ts @@ -0,0 +1,66 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, + OneToOne, +} from "typeorm"; + +import { EmrPatient } from "./emr_patient"; +import { EmrRegistration } from "./emr_registration"; +import { User } from "../users"; +import { EmrOdontogramTeeth } from "./emr_odontogram_teeth"; +import { OneToMany } from "typeorm"; + +@Entity("emr_odontogram", { schema: "emr" }) +export class EmrOdontogram { + @PrimaryGeneratedColumn("uuid") + id: string; + + @OneToOne(() => EmrRegistration, { onDelete: "CASCADE" }) + @JoinColumn() + registration: EmrRegistration; + + @ManyToOne(() => EmrPatient, { onDelete: "CASCADE" }) + @JoinColumn() + patient: EmrPatient; + + @ManyToOne(() => User, { onDelete: "CASCADE" }) + @JoinColumn() + doctor: User; + + @Column({ nullable: true, type: "text" }) + notes: string; + + @Column({ nullable: true, type: "text" }) + status: string; + + @OneToMany(() => EmrOdontogramTeeth, (teeth: EmrOdontogramTeeth) => teeth.odontogram) + teeth: EmrOdontogramTeeth[] + + @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; +} + diff --git a/src/entity/emr/emr_odontogram_teeth.ts b/src/entity/emr/emr_odontogram_teeth.ts new file mode 100644 index 0000000..be75de8 --- /dev/null +++ b/src/entity/emr/emr_odontogram_teeth.ts @@ -0,0 +1,59 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; + +import { EmrOdontogram } from "./emr_odontogram"; + +@Entity("emr_odontogram_teeth", { schema: "emr" }) +export class EmrOdontogramTeeth { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => EmrOdontogram, { onDelete: "CASCADE" }) + @JoinColumn() + odontogram: EmrOdontogram; + + @Column({ nullable: true, type: "text" }) + tooth_number: string; + + @Column({ nullable: true, type: "text" }) + surface: string; + + @Column({ nullable: true, type: "text" }) + condition_code: string; + + @Column({ nullable: true, type: "text" }) + note: string; + + @Column({ nullable: true, type: "text" }) + status: string; + + @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; +} + diff --git a/src/entity/medical_form.ts b/src/entity/medical_form.ts new file mode 100644 index 0000000..5492bcf --- /dev/null +++ b/src/entity/medical_form.ts @@ -0,0 +1,50 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, +} from "typeorm"; + +@Entity("medical_form") +export class MedicalForm { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + nullable: false, + length: 256, + type: "varchar", + }) + name: string; + + @Column({ + nullable: false, + length: 512, + type: "varchar", + }) + description: string; + + @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; +} + diff --git a/src/entity/room.ts b/src/entity/room.ts index aa59d74..04cbfc6 100644 --- a/src/entity/room.ts +++ b/src/entity/room.ts @@ -5,6 +5,9 @@ import { Department } from "./department"; import { Service } from "./service"; import { RoomStock } from "./pharmacy-logistic/room_stock"; import { ServiceClass } from "./service_class"; +import { OneToMany } from "typeorm"; +import { MedicalForm } from "./medical_form"; +import { JoinTable } from "typeorm"; @Entity("rooms") export class Room { @@ -66,6 +69,10 @@ export class Room { @ManyToMany(() => Service, (service) => service.rooms) services: Service[]; + @ManyToMany(() => MedicalForm, { onDelete: "CASCADE" }) + @JoinTable() + medical_forms: MedicalForm[]; + @CreateDateColumn() created_at: Date; diff --git a/src/schema/emr.ts b/src/schema/emr.ts index b76efc6..30d5e71 100644 --- a/src/schema/emr.ts +++ b/src/schema/emr.ts @@ -45,6 +45,8 @@ export * from "../entity/emr/emr_nursing_assesment"; export * from "../entity/emr/emr_patient_education"; export * from "../entity/emr/emr_soap_notes"; export * from "../entity/emr/emr_surgery_schedules"; +export * from "../entity/emr/emr_odontogram"; +export * from "../entity/emr/emr_odontogram_teeth"; export * from "../types/registration_type"; export * from "../types/registration_status"; diff --git a/src/schema/public.ts b/src/schema/public.ts index 16d312c..f94d06c 100644 --- a/src/schema/public.ts +++ b/src/schema/public.ts @@ -56,6 +56,7 @@ export * from "../entity/responsible_party_consent"; export * from "../entity/foster_care_history"; export * from "../entity/notification"; export * from "../entity/counter"; +export * from "../entity/medical_form"; export * from "../types/public"; export * from "../types/action";