Merge branch 'main' of https://git.shiblysolution.id/SAUDE-TL/entity
This commit is contained in:
71
src/entity/emr/emr_prescription.ts
Normal file
71
src/entity/emr/emr_prescription.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
} from "typeorm";
|
||||
|
||||
import { EmrPatient } from "./emr_patient";
|
||||
import { Room } from "../room";
|
||||
import { User } from "../users";
|
||||
import { EmrRegistration } from "./emr_registration";
|
||||
import { EmrPrescriptionItem } from "./emr_prescription_item";
|
||||
|
||||
/**
|
||||
* Prescription entity.
|
||||
* Header information for a medication prescription: order number, patient, doctor, rooms, registration.
|
||||
*/
|
||||
@Entity("emr_prescription", { schema: "emr" })
|
||||
export class EmrPrescription {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => EmrRegistration, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "registration_id" })
|
||||
registration: EmrRegistration | null;
|
||||
|
||||
@ManyToOne(() => EmrPatient, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "patient_id" })
|
||||
patient: EmrPatient;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "doctor_id" })
|
||||
doctor: User | null;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "room_id" })
|
||||
room: Room | null;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "referring_room_id" })
|
||||
referring_room: Room | null;
|
||||
|
||||
@OneToMany(() => EmrPrescriptionItem, (item) => item.prescription, { cascade: true })
|
||||
items: EmrPrescriptionItem[];
|
||||
|
||||
@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;
|
||||
}
|
||||
66
src/entity/emr/emr_prescription_item.ts
Normal file
66
src/entity/emr/emr_prescription_item.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from "typeorm";
|
||||
|
||||
import { ItemMaster } from "../pharmacy/item_master";
|
||||
import { UsageInstructions } from "../pharmacy/usage_instructions";
|
||||
import { UsageTime } from "../pharmacy/usage_time";
|
||||
import { EmrPrescription } from "./emr_prescription";
|
||||
|
||||
/**
|
||||
* Prescription items entity.
|
||||
* Stores each medication item with quantity and usage instructions/timing for a prescription.
|
||||
*/
|
||||
@Entity("emr_prescription_items", { schema: "emr" })
|
||||
export class EmrPrescriptionItem {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => EmrPrescription, (prescription) => prescription.items, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "prescription_id" })
|
||||
prescription: EmrPrescription;
|
||||
|
||||
@ManyToOne(() => ItemMaster, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "item_master_id" })
|
||||
item_master: ItemMaster;
|
||||
|
||||
@Column({ type: "int", nullable: false, default: 1 })
|
||||
qty: number;
|
||||
|
||||
@ManyToOne(() => UsageInstructions, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "usage_instruction_id" })
|
||||
usage_instruction: UsageInstructions | null;
|
||||
|
||||
@ManyToOne(() => UsageTime, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "usage_time_id" })
|
||||
usage_time: UsageTime | 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;
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ export * from "../entity/emr/emr_internal_consultation";
|
||||
export * from "../entity/emr/emr_laboratory_orders";
|
||||
export * from "../entity/emr/emr_laboratory_order_items";
|
||||
export * from "../entity/emr/emr_laboratory_order_item_results";
|
||||
export * from "../entity/emr/emr_prescription";
|
||||
export * from "../entity/emr/emr_prescription_item";
|
||||
export * from "../entity/emr/emr_prescription_orders";
|
||||
export * from "../entity/emr/emr_prescription_order_items";
|
||||
export * from "../entity/emr/emr_radiology";
|
||||
|
||||
Reference in New Issue
Block a user