Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
projmelon_65160130
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160130
projmelon_65160130
Commits
3eee1fd8
Commit
3eee1fd8
authored
3 months ago
by
65160130
Browse files
Options
Downloads
Patches
Plain Diff
add showAddTreatmentForm
parent
caf37599
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
controllers/DentistController.js
+72
-11
72 additions, 11 deletions
controllers/DentistController.js
with
72 additions
and
11 deletions
controllers/DentistController.js
+
72
−
11
View file @
3eee1fd8
...
...
@@ -16,6 +16,8 @@ class DentistController {
}
}
//แสดงประวัติการรักษา
static
async
showTreatmentHistory
(
req
,
res
)
{
const
patientId
=
req
.
params
.
id
;
...
...
@@ -49,30 +51,84 @@ class DentistController {
}
}
// แสดงหน้าฟอร์มเพิ่มประวัติการรักษา
static
async
showAddTreatmentForm
(
req
,
res
)
{
const
queuedetail_id
=
req
.
params
.
queuedetail_id
;
// ตรวจสอบว่า queuedetail_id ถูกต้องหรือไม่
if
(
!
queuedetail_id
)
{
console
.
error
(
"
queuedetail_id is missing or invalid.
"
);
return
res
.
status
(
400
).
send
(
"
Invalid queuedetail_id.
"
);
}
try
{
// ดึงข้อมูลจาก queuedetail โดยใช้ queuedetail_id
const
queueDetail
=
await
QueueDetail
.
getQueueDetailById
(
queuedetail_id
);
if
(
!
queueDetail
)
{
return
res
.
status
(
404
).
send
(
'
ไม่พบข้อมูลการรักษา
'
);
}
// ส่งข้อมูลที่ดึงมาให้หน้า EJS
// ใช้ patient_id ที่ได้จาก queueDetail
const
patientId
=
queueDetail
.
patient_id
;
if
(
!
patientId
)
{
console
.
error
(
"
Patient ID is missing.
"
);
return
res
.
status
(
400
).
send
(
"
Patient ID is missing.
"
);
}
// ตรวจสอบว่า `patient_id` นี้มีการจองใหม่ที่ยังไม่ได้บันทึกการรักษาหรือไม่
const
treatmentHistory
=
await
TreatmentHistory
.
getTreatmentHistory
(
patientId
);
// ถ้าการบันทึกของ queuedetail_id อยู่ใน treatmentHistory
if
(
treatmentHistory
&&
treatmentHistory
.
length
>
0
)
{
// ตรวจสอบการจองล่าสุดจาก patient_id
const
newQueueDetail
=
await
QueueDetail
.
getQueueDetailsByPatientId
(
patientId
);
if
(
!
newQueueDetail
)
{
// ถ้าไม่มีการจองใหม่
return
res
.
render
(
'
addtreatmenthis
'
,
{
message
:
'
ไม่พบการจองใหม่สำหรับผู้ป่วยนี้
'
,
patient_id
:
patientId
,
});
}
// เปรียบเทียบว่า newQueueDetail ถูกบันทึกใน treatmentHistory หรือไม่
const
isAlreadyBooked
=
treatmentHistory
.
some
(
th
=>
th
.
queuedetail_id
===
newQueueDetail
.
queuedetail_id
);
if
(
isAlreadyBooked
)
{
// ถ้าการจองนี้ถูกบันทึกแล้วใน `treatmenthistory`
return
res
.
render
(
'
addtreatmenthis
'
,
{
message
:
'
ไม่พบการจองใหม่สำหรับผู้ป่วยนี้
'
,
patient_id
:
patientId
,
});
}
// ถ้ามีการจองใหม่ที่ยังไม่ได้บันทึก ให้แสดงข้อมูลการจอง
res
.
render
(
'
addtreatmenthis
'
,
{
queuedetail_id
:
queueDetail
.
queuedetail_id
,
treatment_date
:
queueDetail
.
treatment_date
,
patient_name
:
queueDetail
.
patient_name
,
treatment_name
:
queueDetail
.
treatment_name
,
queuedetail_id
:
newQueueDetail
.
queuedetail_id
,
treatment_date
:
newQueueDetail
.
treatment_date
,
patient_name
:
newQueueDetail
.
patient_name
,
treatment_name
:
newQueueDetail
.
treatment_name
,
});
}
else
{
// หากไม่มีการจองใหม่ที่ยังไม่ได้บันทึกการรักษา
return
res
.
render
(
'
addtreatmenthis
'
,
{
message
:
'
ไม่พบการจองใหม่สำหรับผู้ป่วยนี้
'
,
patient_id
:
patientId
,
});
}
}
catch
(
error
)
{
console
.
error
(
"
Error fetching queue details:
"
,
error
.
message
);
res
.
status
(
500
).
send
(
"
Error fetching queue details
"
);
}
}
// เพิ่มประวัติการรักษาใหม่
static
async
addTreatmentHistory
(
req
,
res
)
{
const
{
queuedetail_id
,
dentist_name
,
tm_details
,
followUpdate
}
=
req
.
body
;
...
...
@@ -88,6 +144,8 @@ class DentistController {
}
}
//แสดงฟอร์มแก้ไขข้อมูล
static
async
showEditTreatmentForm
(
req
,
res
)
{
const
treatmenthistoryId
=
req
.
params
.
id
;
...
...
@@ -107,6 +165,7 @@ class DentistController {
}
//อัปเดตข้อมูล
static
async
updateTreatmentHistory
(
req
,
res
)
{
const
{
treatmenthistory_id
,
dentist_name
,
tm_details
,
followUpdate
}
=
req
.
body
;
...
...
@@ -129,6 +188,8 @@ class DentistController {
}
}
// ลบประวัติการรักษา
static
async
deleteTreatmentHistory
(
req
,
res
)
{
const
treatmenthistoryId
=
req
.
params
.
id
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment