fix(pharmacy-order): change paradigm and relation
This commit is contained in:
@ -15,14 +15,22 @@ import { UsageTime } from "../pharmacy/usage_time";
|
||||
import { UsageInstructions } from "../pharmacy/usage_instructions";
|
||||
import { EmrRegistration } from "./emr_registration";
|
||||
import { Room } from "../room";
|
||||
import { EmrPatient } from "./emr_patient";
|
||||
import { User } from "../users";
|
||||
import { EmrPharmacyOrder } from "./emr_pharmacy_order";
|
||||
|
||||
@Entity("emr_compounding_medicine", { schema: "emr" })
|
||||
export class EmrCompoundingMedicine {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@OneToMany(() => EmrCompoundingMedicineItem, (detail) => detail.compoundingmedicine)
|
||||
compoundingmedicineitem: EmrCompoundingMedicineItem[];
|
||||
@ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "registration_id" })
|
||||
registration: EmrRegistration;
|
||||
|
||||
@ManyToOne(() => EmrPatient, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "patient_id" })
|
||||
patient: EmrPatient;
|
||||
|
||||
@Column({ nullable: true, type: "text" })
|
||||
name: string;
|
||||
@ -34,27 +42,22 @@ export class EmrCompoundingMedicine {
|
||||
qty: number;
|
||||
|
||||
@Column({ nullable: true, type: "text" })
|
||||
compounding_notes: string;
|
||||
note: string;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
room: Room;
|
||||
@ManyToOne(() => UsageTime, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "usage_time_id" })
|
||||
usage_time: UsageTime | null;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
reffering_room: Room;
|
||||
@ManyToOne(() => UsageInstructions, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "usage_instruction_id" })
|
||||
usage_instruction: UsageInstructions | null;
|
||||
|
||||
@ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
emrregistration: EmrRegistration;
|
||||
@ManyToOne(() => EmrPharmacyOrder, { onDelete: "CASCADE", nullable: true })
|
||||
@JoinColumn({ name: "pharmacy_order_id" })
|
||||
pharmacy_order: EmrPharmacyOrder | null;
|
||||
|
||||
@ManyToOne(() => UsageTime, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
usagetime: UsageTime;
|
||||
|
||||
@ManyToOne(() => UsageInstructions, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
usageinstructions: UsageInstructions;
|
||||
@OneToMany(() => EmrCompoundingMedicineItem, (item) => item.compounding_medicine, { cascade: true })
|
||||
items: EmrCompoundingMedicineItem[];
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
|
||||
@ -10,19 +10,20 @@ import {
|
||||
} from "typeorm";
|
||||
import { ItemMaster } from "../pharmacy/item_master";
|
||||
import { EmrCompoundingMedicine } from "./emr_compounding_medicine";
|
||||
import { RoomStock } from "../pharmacy-logistic/room_stock";
|
||||
|
||||
@Entity("emr_compounding_medicine_item", { schema: "emr" })
|
||||
export class EmrCompoundingMedicineItem {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => ItemMaster, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
itemmaster: ItemMaster;
|
||||
@ManyToOne(() => ItemMaster, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "item_master_id" })
|
||||
item_master: ItemMaster;
|
||||
|
||||
@ManyToOne(() => EmrCompoundingMedicine, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
compoundingmedicine: EmrCompoundingMedicine;
|
||||
@JoinColumn({ name: "compounding_medicine_id" })
|
||||
compounding_medicine: EmrCompoundingMedicine;
|
||||
|
||||
@Column({
|
||||
type: "int",
|
||||
@ -30,6 +31,10 @@ export class EmrCompoundingMedicineItem {
|
||||
})
|
||||
dose: number
|
||||
|
||||
@ManyToOne(() => RoomStock, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "room_stock_id" })
|
||||
room_stock: RoomStock;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
87
src/entity/emr/emr_pharmacy_order.ts
Normal file
87
src/entity/emr/emr_pharmacy_order.ts
Normal file
@ -0,0 +1,87 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
OneToMany,
|
||||
Index,
|
||||
} from "typeorm";
|
||||
import { EmrCompoundingMedicine } from "./emr_compounding_medicine";
|
||||
import { EmrPrescription } from "./emr_prescription";
|
||||
import { User } from "../users";
|
||||
import { Room } from "../room";
|
||||
import { EmrRegistration } from "./emr_registration";
|
||||
import { EmrPatient } from "./emr_patient";
|
||||
import { PharmacyOrderStatus } from "../../types/pharmacy_order_status";
|
||||
|
||||
@Entity("emr_pharmacy_order", { schema: "emr" })
|
||||
@Index(["code"], { unique: true })
|
||||
export class EmrPharmacyOrder {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "varchar", unique: true })
|
||||
code: string;
|
||||
|
||||
@ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "registration_id" })
|
||||
registration: EmrRegistration | null;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "doctor_id" })
|
||||
doctor: User | null;
|
||||
|
||||
@ManyToOne(() => EmrPatient, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "patient_id" })
|
||||
patient: EmrPatient | null;
|
||||
|
||||
@OneToMany(() => EmrCompoundingMedicine, compounding => compounding.pharmacy_order, { cascade: true })
|
||||
compounding_medicines: EmrCompoundingMedicine[];
|
||||
|
||||
@OneToMany(() => EmrPrescription, (prescription) => prescription.pharmacy_order, { cascade: true })
|
||||
prescriptions: EmrPrescription[];
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "room_id" })
|
||||
room: Room;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "referring_room_id" })
|
||||
referring_room: Room | null;
|
||||
|
||||
@Column({ nullable: true, type: "text", array: true })
|
||||
prescription_screening: string[] | null;
|
||||
|
||||
@Column({ nullable: true, type: "text" })
|
||||
status: PharmacyOrderStatus;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
function Sequence(arg0: string): (target: EmrPharmacyOrder, propertyKey: "order_number") => void {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
|
||||
@ -1,107 +0,0 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
ManyToMany,
|
||||
JoinTable
|
||||
} from "typeorm";
|
||||
|
||||
import { EmrCompoundingMedicine } from "./emr_compounding_medicine";
|
||||
import { EmrPrescription } from "./emr_prescription";
|
||||
import { User } from "../users";
|
||||
import { PatientGuarantor } from "../patient_guarantor";
|
||||
import { Room } from "../room";
|
||||
import { Department } from "../department";
|
||||
import { EmrRegistration } from "./emr_registration";
|
||||
|
||||
|
||||
@Entity("emr_pharmacy_order_list", { schema: "emr" })
|
||||
export class EmrPharmacyOrderList {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@ManyToMany(() => EmrCompoundingMedicine)
|
||||
@JoinTable({
|
||||
name: "emr_pharmacy_order_list_compounding", // bebas, tapi konsisten
|
||||
joinColumn: {
|
||||
name: "pharmacy_order_list_id",
|
||||
referencedColumnName: "id",
|
||||
},
|
||||
inverseJoinColumn: {
|
||||
name: "compounding_medicine_id",
|
||||
referencedColumnName: "id",
|
||||
},
|
||||
})
|
||||
emrcompoundingmedicines: EmrCompoundingMedicine[];
|
||||
|
||||
@Column({ nullable: true })
|
||||
order_date: Date;
|
||||
|
||||
@Column({ nullable: true, type: "text" })
|
||||
prescription_number: string;
|
||||
|
||||
@Column({ nullable: true, type: "text" })
|
||||
type: string;
|
||||
|
||||
@Column({ nullable: true, type: "text" })
|
||||
status: string;
|
||||
|
||||
@Column({ nullable: true, type: "text", array: true })
|
||||
prescription_screening: string[];
|
||||
|
||||
@ManyToOne(() => EmrPrescription, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
emrprescription: EmrPrescription;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
user: User;
|
||||
|
||||
@ManyToOne(() => PatientGuarantor, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
patientguarantor: PatientGuarantor;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
room: Room;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
destination_room: Room;
|
||||
|
||||
@ManyToOne(() => Department, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
department: Department;
|
||||
|
||||
@ManyToOne(() => EmrRegistration, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
emrregistration: EmrRegistration;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@ -8,18 +8,19 @@ import {
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
OneToOne,
|
||||
} 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";
|
||||
import { EmrPharmacyOrder } from "./emr_pharmacy_order";
|
||||
import { UsageTime } from "../pharmacy/usage_time";
|
||||
import { UsageInstructions } from "../pharmacy/usage_instructions";
|
||||
import { ItemMaster } from "../pharmacy/item_master";
|
||||
import { RoomStock } from "../pharmacy-logistic/room_stock";
|
||||
|
||||
/**
|
||||
* Prescription entity.
|
||||
* Header information for a medication prescription: order number, patient, doctor, rooms, registration.
|
||||
*/
|
||||
@Entity("emr_prescription", { schema: "emr" })
|
||||
export class EmrPrescription {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
@ -33,23 +34,28 @@ export class EmrPrescription {
|
||||
@JoinColumn({ name: "patient_id" })
|
||||
patient: EmrPatient;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "doctor_id" })
|
||||
doctor: User | null;
|
||||
@ManyToOne(() => ItemMaster, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "item_master_id" })
|
||||
item_master: ItemMaster;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "room_id" })
|
||||
room: Room | null;
|
||||
@Column({ type: "int", nullable: false, default: 1 })
|
||||
qty: number;
|
||||
|
||||
@ManyToOne(() => Room, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "referring_room_id" })
|
||||
referring_room: Room | null;
|
||||
@ManyToOne(() => UsageInstructions, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "usage_instruction_id" })
|
||||
usage_instruction: UsageInstructions | null;
|
||||
|
||||
@OneToMany(() => EmrPrescriptionItem, (item) => item.prescription, { cascade: true })
|
||||
items: EmrPrescriptionItem[];
|
||||
@ManyToOne(() => UsageTime, { onDelete: "NO ACTION", nullable: true })
|
||||
@JoinColumn({ name: "usage_time_id" })
|
||||
usage_time: UsageTime | null;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
is_ordered: boolean;
|
||||
@ManyToOne(() => EmrPharmacyOrder, { onDelete: "CASCADE", nullable: true })
|
||||
@JoinColumn({ name: "pharmacy_order_id" })
|
||||
pharmacy_order: EmrPharmacyOrder | null;
|
||||
|
||||
@ManyToOne(() => RoomStock, { onDelete: "NO ACTION" })
|
||||
@JoinColumn({ name: "room_stock_id" })
|
||||
room_stock: RoomStock;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@ -16,17 +16,15 @@ 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";
|
||||
export * from "../entity/emr/emr_radiology_services";
|
||||
export * from "../entity/emr/emr_compounding_medicine";
|
||||
export * from "../entity/emr/emr_compounding_medicine_item";
|
||||
export * from "../entity/emr/emr_room_medical_equipment";
|
||||
export * from "../entity/emr/emr_external_consultation";
|
||||
export * from "../entity/emr/emr_pharmacy_order_list";
|
||||
export * from "../entity/emr/emr_pharmacy_order";
|
||||
|
||||
export * from "../types/registration_type";
|
||||
export * from "../types/registration_status";
|
||||
export * from "../types/pharmacy_order_status";
|
||||
export * from "../types/prescription_pharmacy_status";
|
||||
|
||||
16
src/types/pharmacy_order_status.ts
Normal file
16
src/types/pharmacy_order_status.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Workflow status untuk order farmasi.
|
||||
* Waiting: menunggu persiapan obat
|
||||
* Preparing: sedang mempersiapkan obat
|
||||
* Ready: obat siap untuk diambil
|
||||
* Completed: order selesai
|
||||
* Canceled: order dibatalkan
|
||||
*/
|
||||
export enum PharmacyOrderStatus {
|
||||
WAITING = "waiting",
|
||||
PREPARING = "preparing",
|
||||
READY = "ready",
|
||||
COMPLETED = "completed",
|
||||
CANCELED = "canceled",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user