|
@@ -2020,7 +2020,7 @@ func FindAllDoctorAdviceByIds(orgID int64, ids []string) (advice []models.Doctor
|
2020
|
2020
|
}
|
2021
|
2021
|
|
2022
|
2022
|
func ExectionBloodMobileAdvice(orgid int64, ids []string, execution_time int64, execution_staff int64) error {
|
2023
|
|
- fmt.Println("ids2323232323323223233223wode", ids)
|
|
2023
|
+
|
2024
|
2024
|
advice := models.DoctorAdviceThrity{}
|
2025
|
2025
|
err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1}).Error
|
2026
|
2026
|
return err
|
|
@@ -2135,3 +2135,107 @@ func GetDialysisInformationSetting(user_org_id int64) (infor []*models.XtDialysi
|
2135
|
2135
|
|
2136
|
2136
|
return infor, err
|
2137
|
2137
|
}
|
|
2138
|
+
|
|
2139
|
+func GetDialysisInformationIsNoCheck(user_org_id int64, limit int64, page int64, application_status int64) (infor []*models.DialysisInformation, total int64, err error) {
|
|
2140
|
+
|
|
2141
|
+ db := XTReadDB().Model(&infor).Where("status= 1")
|
|
2142
|
+ if application_status > 0 {
|
|
2143
|
+ db = db.Where("application_status = ?", application_status)
|
|
2144
|
+ }
|
|
2145
|
+ if user_org_id > 0 {
|
|
2146
|
+ db = db.Where("user_org_id = ?", user_org_id)
|
|
2147
|
+ }
|
|
2148
|
+ err = db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Find(&infor).Error
|
|
2149
|
+ return infor, total, err
|
|
2150
|
+}
|
|
2151
|
+
|
|
2152
|
+func CheckDialysisInformation(id int64, application_status int64, timenow int64, checker int64) (models.DialysisInformation, error) {
|
|
2153
|
+
|
|
2154
|
+ information := models.DialysisInformation{}
|
|
2155
|
+
|
|
2156
|
+ err := XTWriteDB().Model(&information).Where("id=? and status = 1", id).Updates(map[string]interface{}{"application_status": application_status, "check_time": timenow, "checker": checker}).Error
|
|
2157
|
+
|
|
2158
|
+ return information, err
|
|
2159
|
+
|
|
2160
|
+}
|
|
2161
|
+
|
|
2162
|
+func GetDialysisWatchByKeywordFlow(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) ([]*models.DialysisScheduleFlow, error, int64) {
|
|
2163
|
+ var patients []*models.Patients
|
|
2164
|
+ getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
|
|
2165
|
+ if getPatientErr != nil {
|
|
2166
|
+ return nil, getPatientErr, 0
|
|
2167
|
+ }
|
|
2168
|
+ patientIDs := make([]int64, len(patients))
|
|
2169
|
+ for index, patient := range patients {
|
|
2170
|
+ patientIDs[index] = patient.ID
|
|
2171
|
+ }
|
|
2172
|
+
|
|
2173
|
+ db := readDb.Model(&models.DialysisScheduleFlow{})
|
|
2174
|
+ if start > 0 && end > 0 {
|
|
2175
|
+ db = db.Preload("DeviceNumber", "org_id = ?", orgID).
|
|
2176
|
+ // Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
|
|
2177
|
+ Preload("TreatmentMode", "status = 1").
|
|
2178
|
+ Preload("DialysisFinish", "status = 1 AND user_org_id = ? and record_date >= ? and record_date<=?", orgID, start, end).
|
|
2179
|
+ Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
|
|
2180
|
+ } else {
|
|
2181
|
+ db = db.Preload("DeviceNumber", "org_id = ?", orgID).
|
|
2182
|
+ Preload("TreatmentMode", "status = 1").
|
|
2183
|
+ Preload("DialysisFinish", "status = 1 AND user_org_id = ?", orgID).
|
|
2184
|
+ Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
|
|
2185
|
+ }
|
|
2186
|
+
|
|
2187
|
+ db = db.Where("xt_schedule.status = 1 AND patient_id in (?)", patientIDs)
|
|
2188
|
+ if schedulType > 0 {
|
|
2189
|
+ db = db.Where("schedule_type = ?", schedulType)
|
|
2190
|
+ }
|
|
2191
|
+ if start > 0 {
|
|
2192
|
+ db = db.Where("schedule_date >= ?", start)
|
|
2193
|
+ }
|
|
2194
|
+ if end > 0 {
|
|
2195
|
+ db = db.Where("schedule_date<=?", end)
|
|
2196
|
+ }
|
|
2197
|
+ if partitionType > 0 {
|
|
2198
|
+ db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ?", partitionType)
|
|
2199
|
+ }
|
|
2200
|
+ var schedules []*models.DialysisScheduleFlow
|
|
2201
|
+ total := int64(0)
|
|
2202
|
+ err := db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
|
|
2203
|
+ return schedules, err, total
|
|
2204
|
+}
|
|
2205
|
+
|
|
2206
|
+func GetDialysisWatchFlow(orgID int64, schedulDate int64, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) (schedule []*models.DialysisScheduleFlow, err error, total int64) {
|
|
2207
|
+ db := readDb.Model(&models.DialysisScheduleFlow{})
|
|
2208
|
+ if start > 0 && end > 0 {
|
|
2209
|
+ db = db.Preload("DeviceNumber", "org_id = ?", orgID).
|
|
2210
|
+ Preload("TreatmentMode", "status = 1").
|
|
2211
|
+ Preload("DialysisFinish", "status = 1 AND user_org_id = ? and record_date>=? and record_date<=?", orgID, start, end).
|
|
2212
|
+ Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
|
|
2213
|
+ db = db.Where("xt_schedule.status = 1")
|
|
2214
|
+ }
|
|
2215
|
+ if schedulDate > 0 {
|
|
2216
|
+ db = db.Preload("DeviceNumber", "org_id = ?", orgID).
|
|
2217
|
+ Preload("TreatmentMode", "status = 1").
|
|
2218
|
+ Preload("DialysisFinish", "status = 1 AND user_org_id = ? and record_date>=? and record_date<=?", orgID, schedulDate, schedulDate).
|
|
2219
|
+ Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
|
|
2220
|
+ db = db.Where("xt_schedule.status = 1")
|
|
2221
|
+ db = db.Where("schedule_date = ?", schedulDate)
|
|
2222
|
+ }
|
|
2223
|
+ if schedulType > 0 {
|
|
2224
|
+ db = db.Where("schedule_type = ?", schedulType)
|
|
2225
|
+ }
|
|
2226
|
+ if start > 0 {
|
|
2227
|
+ db = db.Where("schedule_date >= ?", start)
|
|
2228
|
+ }
|
|
2229
|
+ if end > 0 {
|
|
2230
|
+ db = db.Where("schedule_date <= ?", end)
|
|
2231
|
+ }
|
|
2232
|
+ if orgID > 0 {
|
|
2233
|
+ db = db.Where("user_org_id = ?", orgID)
|
|
2234
|
+ }
|
|
2235
|
+ if partitionType > 0 {
|
|
2236
|
+ db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ?", partitionType)
|
|
2237
|
+ }
|
|
2238
|
+ offset := (page - 1) * limit
|
|
2239
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Order("bed_id desc").Find(&schedule).Error
|
|
2240
|
+ return schedule, err, total
|
|
2241
|
+}
|