diff --git a/src/entity/cashier/cashier.ts b/src/entity/cashier/cashier.ts new file mode 100644 index 0000000..880c9fc --- /dev/null +++ b/src/entity/cashier/cashier.ts @@ -0,0 +1,71 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + JoinColumn, + OneToOne, +} from "typeorm"; +import { EmrRegistration } from "../emr/emr_registration"; +import { Room } from "../room"; + +@Entity("cashier", { schema: "cashier" }) +export class Cashier { + @PrimaryGeneratedColumn("uuid") + id: string; + + @OneToOne(() => EmrRegistration, { onDelete: "CASCADE" }) + @JoinColumn() + emrregistration: EmrRegistration; + + @OneToOne(() => Room, { onDelete: "CASCADE" }) + @JoinColumn() + room: Room; + + @Column({ type: "date", nullable: true }) + regdate: Date; + + @Column({ + nullable: true, + type: 'bigint' + }) + total_amount: number; + + @Column({ + nullable: true, + type: 'bigint' + }) + amount_paid: number; + + @Column({ + nullable: true, + type: 'bigint' + }) + balance_due: number; + + @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; +} \ No newline at end of file diff --git a/src/entity/cashier/cashier_item.ts b/src/entity/cashier/cashier_item.ts new file mode 100644 index 0000000..873878c --- /dev/null +++ b/src/entity/cashier/cashier_item.ts @@ -0,0 +1,103 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + JoinColumn, + ManyToOne, +} from "typeorm"; +import { Cashier } from "./cashier"; +import { Room } from "../room"; +import { Department } from "../department"; +import { ServiceClass } from "../service_class"; +import { Service } from "../service"; +import { ServiceType } from "../service_type"; + +@Entity("cashier_item", { schema: "cashier" }) +export class CashierItem { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => Service, { onDelete: "CASCADE" }) + @JoinColumn() + service: Service; + + @ManyToOne(() => ServiceType, { onDelete: "CASCADE" }) + @JoinColumn() + servicetype: ServiceType; + + @ManyToOne(() => Cashier, { onDelete: "CASCADE" }) + @JoinColumn() + cashier: Cashier; + + @ManyToOne(() => Room, { onDelete: "CASCADE" }) + @JoinColumn() + room: Room; + + @ManyToOne(() => Department, { onDelete: "CASCADE" }) + @JoinColumn() + department: Department; + + @ManyToOne(() => ServiceClass, { onDelete: "CASCADE" }) + @JoinColumn() + serviceclass: ServiceClass; + + @Column({ type: "date", nullable: true }) + service_date: Date; + + @Column({ type: "boolean", default: false }) + ispay: boolean; + + @Column({ + nullable: true, + type: 'bigint' + }) + guarantor_liability: number; + + @Column({ + nullable: true, + type: 'bigint' + }) + subtotal: number; + + @Column({ + nullable: true, + type: 'bigint' + }) + price: number; + + @Column({ + nullable: true, + type: 'bigint' + }) + qty: number; + + @Column({ nullable: true, type: "text" }) + status: string; + + @Column({ nullable: true, length: 256 }) + category: 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; +} \ No newline at end of file diff --git a/src/entity/emr/emr_patient.ts b/src/entity/emr/emr_patient.ts index 6fb8f32..94ef86e 100644 --- a/src/entity/emr/emr_patient.ts +++ b/src/entity/emr/emr_patient.ts @@ -15,7 +15,6 @@ import { Aldeia } from "../aldeia"; import { Suco } from "../suco"; import { Administrativu } from "../administrativu"; import { Munisipo } from "../munisipo"; -import { PatientGuarantor } from "../patient_guarantor"; @Entity("emr_patients", { schema: "emr" }) export class EmrPatient { @@ -61,10 +60,6 @@ export class EmrPatient { @Column({ type: "text", nullable: true }) address: string; - @ManyToOne(() => PatientGuarantor, { onDelete: "NO ACTION" }) - @JoinColumn() - guarantor: PatientGuarantor; - @ManyToOne(() => Munisipo, { onDelete: "NO ACTION" }) @JoinColumn() munisipio: Munisipo; diff --git a/src/entity/emr/emr_registration.ts b/src/entity/emr/emr_registration.ts index 8b3140a..c427e18 100644 --- a/src/entity/emr/emr_registration.ts +++ b/src/entity/emr/emr_registration.ts @@ -12,6 +12,7 @@ import { import { RegistrationType } from "../../types/registration_type"; import { RegistrationStatus } from "../../types/registration_status"; import { EmrPatient } from "./emr_patient"; +import { PatientGuarantor } from "../patient_guarantor"; /** * Registrasi base: data umum untuk semua tipe (rawat jalan, rawat inap, emergency, hemodialysis). @@ -30,6 +31,10 @@ export class EmrRegistration { @Column({ nullable: true, type: "text" }) cancellation_reason: string; + @ManyToOne(() => PatientGuarantor, { onDelete: "NO ACTION" }) + @JoinColumn() + guarantor: PatientGuarantor; + @Column({ type: "varchar", length: 32, diff --git a/src/entity/emr/emr_registration_outpatient.ts b/src/entity/emr/emr_registration_outpatient.ts index eae542f..052347e 100644 --- a/src/entity/emr/emr_registration_outpatient.ts +++ b/src/entity/emr/emr_registration_outpatient.ts @@ -16,6 +16,7 @@ import { User } from "../users"; import { DoctorSchedule } from "../doctor_schedule"; import { EmrInternalConsultation } from "./emr_internal_consultation"; import { ScheduleSeries } from "../schedule_series"; +import { PatientGuarantor } from "../patient_guarantor"; // import { RegistrationOutPatientStatus } from "../../enum/registrationOutPatientStatus"; /** @@ -32,6 +33,10 @@ export class EmrRegistrationOutpatient { @JoinColumn() registration: EmrRegistration; + @ManyToOne(() => PatientGuarantor, { onDelete: "NO ACTION" }) + @JoinColumn() + guarantor: PatientGuarantor; + @ManyToOne(() => Room, { onDelete: "NO ACTION" }) @JoinColumn() room: Room; diff --git a/src/index.ts b/src/index.ts index 59459b5..f41acf1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,4 +4,5 @@ export * from "./schema/emr"; export * from "./schema/finances"; export * from "./schema/procurement"; export * from "./schema/pharmacy"; -export * from "./schema/pharmacy_logistic"; \ No newline at end of file +export * from "./schema/pharmacy_logistic"; +export * from "./schema/cashier"; \ No newline at end of file diff --git a/src/schema/cashier.ts b/src/schema/cashier.ts new file mode 100644 index 0000000..efd1910 --- /dev/null +++ b/src/schema/cashier.ts @@ -0,0 +1,2 @@ +export * from "../entity/cashier/cashier"; +export * from "../entity/cashier/cashier_item";