|
@@ -4,6 +4,7 @@ import (
|
4
|
4
|
"XT_New/models"
|
5
|
5
|
p_service "XT_New/service"
|
6
|
6
|
"XT_New/utils"
|
|
7
|
+ "fmt"
|
7
|
8
|
"time"
|
8
|
9
|
|
9
|
10
|
"github.com/jinzhu/gorm"
|
|
@@ -47,6 +48,13 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
|
47
|
48
|
if err != nil {
|
48
|
49
|
return nil, err
|
49
|
50
|
}
|
|
51
|
+ for _, item := range schedules {
|
|
52
|
+ dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
|
|
53
|
+ fmt.Println(dialysis_count)
|
|
54
|
+ item.Patient.TotalDialysis = dialysis_count
|
|
55
|
+ fmt.Println(item.Patient.TotalDialysis)
|
|
56
|
+
|
|
57
|
+ }
|
50
|
58
|
return schedules, nil
|
51
|
59
|
}
|
52
|
60
|
|
|
@@ -173,3 +181,8 @@ func GetOrgInfoTemplate(orgID int64) (models.GobalTemplate, error) {
|
173
|
181
|
err = p_service.XTReadDB().Model(&models.GobalTemplate{}).Where("org_id=? and status=1", orgID).First(&templateInfo).Error
|
174
|
182
|
return templateInfo, err
|
175
|
183
|
}
|
|
184
|
+
|
|
185
|
+func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
|
|
186
|
+ err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
|
|
187
|
+ return
|
|
188
|
+}
|