This commit is contained in:
Rizky 2024-01-24 09:30:27 +07:00
parent 3200496738
commit 5ad665f260
7 changed files with 16 additions and 495 deletions

5
.gitignore vendored
View File

@ -174,7 +174,4 @@ dist
# Finder (MacOS) folder config # Finder (MacOS) folder config
.DS_Store .DS_Store
app/web app
app/web/*
app/static
app/static/*

View File

@ -1,487 +0,0 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model m_academic_year {
id Int @id @default(autoincrement())
name String @db.VarChar
is_active Boolean
created_by Int
created_date DateTime @db.Timestamptz(6)
updated_by Int?
updated_date DateTime? @db.Timestamptz(6)
id_institution Int
start_time DateTime? @db.Timestamptz(6)
end_time DateTime? @db.Timestamptz(6)
id_client Int?
m_client m_client? @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user_m_user_id_yearTom_academic_year m_user[] @relation("m_user_id_yearTom_academic_year")
t_logbook t_logbook[]
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model m_action {
id Int @id @default(autoincrement())
id_type Int
name String @db.VarChar
has_notes Boolean
has_attachment Boolean
has_category Boolean
is_milestone Boolean
show_on_milestone Boolean
multiple_verification Boolean
has_score Boolean
has_presentation Boolean
has_location Boolean
has_emr Boolean
has_another_role Boolean
has_title Boolean
id_client Int
has_status Boolean @default(false)
show_on_menu Boolean @default(true)
has_hospital Boolean @default(false)
attachment_name Json? @default("[]")
has_score_option Boolean @default(false)
is_schedule Boolean @default(false)
max_entry_per_day Int @default(0)
identifier String @default(" ") @db.VarChar
is_grouped_by_category Boolean @default(false)
has_operation_code Boolean @default(false)
is_exam Boolean @default(false)
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_action_type m_action_type @relation(fields: [id_type], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_action_category m_action_category[]
m_action_rolemap m_action_rolemap[]
m_action_semester m_action_semester[]
m_asm_action m_asm_action[]
m_score_option m_score_option[]
m_user_action m_user_action[]
t_logbook t_logbook[]
}
model m_action_category {
id Int @id(map: "m_action_sub_category_pkey") @default(autoincrement())
name String @db.VarChar
id_action Int
id_client Int
required_asm Boolean @default(false)
m_action m_action @relation(fields: [id_action], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_action_sub_category_id_action_fkey")
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_action_sub_category_id_client_fkey")
m_user m_user[]
t_logbook t_logbook[]
}
model m_action_role {
id Int @id(map: "m_logbook_role_pkey") @default(autoincrement())
role String @db.VarChar
id_client Int
identifier String @default(" ") @db.VarChar
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_logbook_role_id_client_fkey")
m_action_rolemap m_action_rolemap[]
t_logbook_status t_logbook_status[]
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model m_action_rolemap {
id Int @id(map: "m_action_verificator_pkey") @default(autoincrement())
id_action_role Int
id_action Int
id_client Int
type String? @default("verificator") @db.VarChar
is_required Boolean @default(true)
m_action m_action @relation(fields: [id_action], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_action_verificator_id_action_fkey")
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_action_verificator_id_client_fkey")
m_action_role m_action_role @relation(fields: [id_action_role], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_action_verificator_id_logbook_role_fkey")
}
model m_action_semester {
id Int @id @default(autoincrement())
id_semester Int
id_action Int
id_client Int
m_action m_action @relation(fields: [id_action], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_semester m_semester @relation(fields: [id_semester], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
model m_action_status {
id Int @id @default(autoincrement())
status String @db.VarChar
id_action Int
id_client Int
}
model m_action_type {
id Int @id @default(autoincrement())
name String @db.VarChar
id_client Int
m_action m_action[]
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
model m_asm_action {
id Int @id(map: "m_assesment_indicator_action_pkey") @default(autoincrement())
id_action Int
id_asm_param Int
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_action m_action @relation(fields: [id_action], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_assesment_indicator_action_id_action_fkey")
m_asm_param m_asm_param @relation(fields: [id_asm_param], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_assesment_indicator_action_id_assesment_indicator_fkey")
}
model m_asm_param {
id Int @id(map: "m_assesment_indicator_pkey") @default(autoincrement())
name String @db.VarChar
min_score Float
max_score Float
id_client Int
m_asm_action m_asm_action[]
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_assessment_indicator_id_client_fkey")
t_logbook_asm t_logbook_asm[]
}
model m_client {
id Int @id @default(autoincrement())
name String @db.VarChar
m_academic_year m_academic_year[]
m_action m_action[]
m_action_category m_action_category[]
m_action_role m_action_role[]
m_action_rolemap m_action_rolemap[]
m_action_type m_action_type[]
m_another_role m_another_role[]
m_asm_action m_asm_action[]
m_asm_param m_asm_param[]
m_client_logo m_client_logo[]
m_hospital m_hospital[]
m_role m_role[]
m_score_option m_score_option[]
m_semester m_semester[]
m_session m_session[]
m_stage m_stage[]
m_stase m_stase[]
m_user_m_user_id_clientTom_client m_user[] @relation("m_user_id_clientTom_client")
m_user_m_user_id_institutionTom_client m_user[] @relation("m_user_id_institutionTom_client")
m_user_action m_user_action[]
t_audit_trails t_audit_trails[]
t_logbook t_logbook[]
t_logbook_asm t_logbook_asm[]
t_logbook_attachment t_logbook_attachment[]
other_t_logbook_emr t_logbook_emr[] @relation("t_logbook_emrTot_logbook_emr")
t_logbook_status t_logbook_status[]
t_menu t_menu[]
t_notif t_notif[]
}
model m_client_logo {
id Int @id @default(autoincrement())
id_client Int
file String
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
model m_hospital {
id Int @id @default(autoincrement())
name String @db.VarChar
address String? @db.VarChar
notes String? @db.VarChar
longitude String? @db.VarChar
latitude String? @db.VarChar
created_by Int
created_date DateTime @db.Timestamptz(6)
updated_date DateTime? @db.Timestamptz(6)
updated_by Int?
id_client Int
code String? @db.VarChar
m_user_m_hospital_created_byTom_user m_user @relation("m_hospital_created_byTom_user", fields: [created_by], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user_m_hospital_updated_byTom_user m_user? @relation("m_hospital_updated_byTom_user", fields: [updated_by], references: [id], onDelete: NoAction, onUpdate: NoAction)
t_logbook t_logbook[]
}
model m_role {
id Int @id(map: "mst_role_pkey") @default(autoincrement())
name String @db.VarChar
created_date DateTime @db.Timestamptz(6)
created_by Int
updated_date DateTime? @db.Timestamptz(6)
updated_by Int?
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user[]
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model m_score_option {
id Int @id(map: "m_score_dropdown_pkey") @default(autoincrement())
score Float
id_action Int?
id_client Int
m_action m_action? @relation(fields: [id_action], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_score_dropdown_id_action_fkey")
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_score_dropdown_id_client_fkey")
}
model m_semester {
id Int @id @default(autoincrement())
name String @db.VarChar
id_stage Int
id_client Int
m_action_semester m_action_semester[]
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_stage m_stage @relation(fields: [id_stage], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user[]
t_logbook t_logbook[]
}
model m_session {
id_user Int?
session_id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
created_at DateTime? @db.Timestamptz(6)
updated_at DateTime? @db.Timestamptz(6)
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user? @relation(fields: [id_user], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_user")
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model m_stage {
id Int @id @default(autoincrement())
name String @db.VarChar
label_color String @db.VarChar
id_institution Int
created_date DateTime @db.Timestamptz(6)
created_by Int
updated_date DateTime? @db.Timestamptz(6)
updated_by Int?
code String? @db.VarChar(20)
id_client Int
m_semester m_semester[]
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_stase m_stase[]
}
model m_stase {
id Int @id @default(autoincrement())
name String @db.VarChar
id_stage Int
id_client Int
sequence Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_stage m_stage @relation(fields: [id_stage], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_stase_id_semester_fkey")
m_user m_user[]
t_logbook t_logbook[]
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model m_user {
id Int @id(map: "mst_user_pkey") @default(autoincrement())
display_name String @db.VarChar
username String? @db.VarChar
email String? @db.VarChar
password String? @db.VarChar(255)
id_role Int
is_deleted Boolean @default(false)
created_date DateTime @db.Timestamptz(6)
created_by Int?
updated_date DateTime? @db.Timestamptz(6)
updated_by Int?
phone String? @db.VarChar
address String? @db.VarChar
date_of_birth DateTime? @db.Timestamptz(6)
code String? @db.VarChar
picture String?
id_institution Int?
id_sub_category Int?
id_semester Int?
id_stase Int?
id_client Int
gender String? @db.VarChar
id_year Int?
status String @default("Active") @db.VarChar
inisial_code String? @db.VarChar
is_show Boolean @default(true)
m_hospital_m_hospital_created_byTom_user m_hospital[] @relation("m_hospital_created_byTom_user")
m_hospital_m_hospital_updated_byTom_user m_hospital[] @relation("m_hospital_updated_byTom_user")
m_session m_session[]
m_client_m_user_id_clientTom_client m_client @relation("m_user_id_clientTom_client", fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_client_m_user_id_institutionTom_client m_client? @relation("m_user_id_institutionTom_client", fields: [id_institution], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_semester m_semester? @relation(fields: [id_semester], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_stase m_stase? @relation(fields: [id_stase], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_action_category m_action_category? @relation(fields: [id_sub_category], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_academic_year_m_user_id_yearTom_academic_year m_academic_year? @relation("m_user_id_yearTom_academic_year", fields: [id_year], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user_m_user_created_byTom_user m_user? @relation("m_user_created_byTom_user", fields: [created_by], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "mst_user_created_by_fkey")
other_m_user_m_user_created_byTom_user m_user[] @relation("m_user_created_byTom_user")
m_role m_role @relation(fields: [id_role], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "mst_user_id_role_fkey")
m_user_m_user_updated_byTom_user m_user? @relation("m_user_updated_byTom_user", fields: [updated_by], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "mst_user_updated_by_fkey")
other_m_user_m_user_updated_byTom_user m_user[] @relation("m_user_updated_byTom_user")
m_user_action m_user_action[]
t_audit_trails t_audit_trails[]
t_logbook t_logbook[]
t_logbook_status t_logbook_status[]
t_menu_t_menu_created_byTom_user t_menu[] @relation("t_menu_created_byTom_user")
t_menu_t_menu_updated_byTom_user t_menu[] @relation("t_menu_updated_byTom_user")
t_notif t_notif[]
}
model m_user_action {
id Int @id(map: "m_action_user_pkey") @default(autoincrement())
id_action_hidden Int
id_user Int
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_action_user_id_client_fkey")
m_action m_action @relation(fields: [id_action_hidden], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user @relation(fields: [id_user], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model t_audit_trails {
id Int @id @default(autoincrement())
activity String
ip_user String? @db.VarChar
id_user Int
timestamp DateTime @db.Timestamptz(6)
type String @default("visit") @db.VarChar
meta Json?
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user @relation(fields: [id_user], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model t_logbook {
id Int @id @default(autoincrement())
title String?
notes String?
date DateTime @db.Timestamptz(6)
location String? @db.VarChar
id_hospital Int?
id_category Int?
id_action Int
is_presentation Boolean @default(false)
created_by Int
created_date DateTime @db.Timestamptz(6)
updated_by Int?
updated_date DateTime? @db.Timestamptz(6)
id_user Int?
id_client Int
verified Boolean? @default(false)
operation_code String? @db.VarChar
id_another_role Int?
id_semester Int?
id_stase Int?
schedule_status String @default("pending") @db.VarChar
exam_result String @default("Lolos") @db.VarChar
id_academic_year Int?
verified_status String @default("pending") @db.VarChar
m_academic_year m_academic_year? @relation(fields: [id_academic_year], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_action m_action @relation(fields: [id_action], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_action_category m_action_category? @relation(fields: [id_category], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_hospital m_hospital? @relation(fields: [id_hospital], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_another_role m_another_role? @relation(fields: [id_another_role], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "t_logbook_id_operation_type_fkey")
m_semester m_semester? @relation(fields: [id_semester], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_stase m_stase? @relation(fields: [id_stase], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user? @relation(fields: [id_user], references: [id], onDelete: NoAction, onUpdate: NoAction)
t_logbook_asm t_logbook_asm[]
t_logbook_attachment t_logbook_attachment[]
t_logbook_emr t_logbook_emr[]
t_logbook_status t_logbook_status[]
t_notif t_notif[]
}
model t_logbook_asm {
id Int @id(map: "t_logbook_assesment_pkey") @default(autoincrement())
id_logbook Int
id_asm_param Int
score Float
created_by DateTime @db.Timestamptz(6)
created_date Int
updated_date DateTime? @db.Timestamptz(6)
updated_by Int?
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_asm_param m_asm_param @relation(fields: [id_asm_param], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "t_logbook_assesment_id_assesment_indicator_fkey")
t_logbook t_logbook @relation(fields: [id_logbook], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "t_logbook_assesment_id_logbook_fkey")
}
model t_logbook_attachment {
id Int @id @default(autoincrement())
id_logbook Int
url_file String?
name String? @db.VarChar
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
t_logbook t_logbook @relation(fields: [id_logbook], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
model t_logbook_emr {
id Int @id(map: "t_logbook_medical_record_pkey") @default(autoincrement())
id_logbook Int
emr_number String? @db.VarChar
diagnosis String? @db.VarChar
treatment String? @db.VarChar
age Int?
gender String? @db.VarChar
id_client Int?
month Int?
patient_name String? @db.VarChar
t_logbook_emr m_client? @relation("t_logbook_emrTot_logbook_emr", fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
t_logbook t_logbook @relation(fields: [id_logbook], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "t_logbook_medical_record_id_logbook_fkey")
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model t_logbook_status {
id Int @id(map: "t_logbook_participants_pkey") @default(autoincrement())
id_user Int
id_logbook Int
id_action_role Int
status String @default("pending") @db.VarChar
date_time DateTime? @db.Timestamptz(6)
id_client Int
m_user m_user @relation(fields: [id_user], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "t_logbook_participants_id_user_fkey")
m_action_role m_action_role @relation(fields: [id_action_role], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
t_logbook t_logbook @relation(fields: [id_logbook], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "t_logbook_participants_id_logbook_fkey")
}
model t_menu {
id Int @id @default(autoincrement())
id_user String @db.VarChar
created_by Int
updated_date DateTime? @db.Timestamptz(6)
updated_by Int?
id_action Int
id_client Int
m_user_t_menu_created_byTom_user m_user @relation("t_menu_created_byTom_user", fields: [created_by], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user_t_menu_updated_byTom_user m_user? @relation("t_menu_updated_byTom_user", fields: [updated_by], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model t_notif {
id Int @id @default(autoincrement())
message String
date DateTime @db.Timestamptz(6)
type String @db.VarChar
id_user Int
url String @db.VarChar
id_role Int
read Boolean @default(false)
id_client Int
id_logbook Int?
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction)
t_logbook t_logbook? @relation(fields: [id_logbook], references: [id], onDelete: NoAction, onUpdate: NoAction)
m_user m_user @relation(fields: [id_user], references: [id], onDelete: NoAction, onUpdate: NoAction)
}
model m_another_role {
id Int @id(map: "m_operation_type_pkey") @default(autoincrement())
role_name String @db.VarChar
id_client Int
m_client m_client @relation(fields: [id_client], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "m_operation_type_id_client_fkey")
t_logbook t_logbook[]
}

View File

@ -20,7 +20,6 @@ declare module "app/db/db" {
declare module "pkgs/utils/global" { declare module "pkgs/utils/global" {
import { Logger } from "pino"; import { Logger } from "pino";
import { RadixRouter } from "radix3"; import { RadixRouter } from "radix3";
import { Database } from "bun:sqlite"; import { Database } from "bun:sqlite";
type SingleRoute = { type SingleRoute = {
url: string; url: string;

1
app/srv/global.d.ts vendored
View File

@ -1 +0,0 @@
declare module "@surfy/multipart-parser";

BIN
bun.lockb

Binary file not shown.

View File

@ -8,10 +8,24 @@ import { prepareAPITypes } from "./server/prep-api-ts";
import { config } from "./utils/config"; import { config } from "./utils/config";
import { g } from "./utils/global"; import { g } from "./utils/global";
import { createLogger } from "./utils/logger"; import { createLogger } from "./utils/logger";
import { dirAsync, existsAsync } from "fs-jetpack";
import { dir } from "utils/dir";
import { $ } from "execa";
g.mode = process.argv.includes("dev") ? "dev" : "prod"; g.mode = process.argv.includes("dev") ? "dev" : "prod";
g.datadir = g.mode === "prod" ? "../data" : ".data"; g.datadir = g.mode === "prod" ? "../data" : ".data";
if (!(await existsAsync(dir("app")))) {
await dirAsync(dir("app"));
}
if (!(await existsAsync(dir("app/db")))) {
await $`unzip -o pkgs/zip/db.zip -d app/db`;
}
if (!(await existsAsync(dir("app/srv")))) {
await $`unzip -o pkgs/zip/srv.zip -d app/srv`;
}
if (!process.env.PORT) { if (!process.env.PORT) {
g.port = 3000; g.port = 3000;
await Bun.write(".env", `PORT=${g.port}`); await Bun.write(".env", `PORT=${g.port}`);

View File

@ -18,7 +18,6 @@ export const ensureNotRunning = async () => {
}, },
}); });
s.end(); s.end();
console.log("hello");
done(false); done(false);
} catch (e) { } catch (e) {
done(true); done(true);