|
@@ -2150,76 +2150,157 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
|
2150
|
2150
|
return advice, err
|
2151
|
2151
|
}
|
2152
|
2152
|
|
2153
|
|
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
|
|
2153
|
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64) ([]*MScheduleDoctorAdviceVM, error) {
|
2154
|
2154
|
var vms []*MScheduleDoctorAdviceVM
|
2155
|
2155
|
adviceWhere := ""
|
2156
|
2156
|
adviceCondition := []interface{}{}
|
2157
|
2157
|
if adviceType == 0 {
|
2158
|
2158
|
if patientType == 0 {
|
2159
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
2160
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2159
|
+ if patient_id > 0 {
|
|
2160
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
|
|
2161
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2162
|
+ } else {
|
|
2163
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
|
2164
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2165
|
+ }
|
2161
|
2166
|
|
2162
|
2167
|
} else if patientType == 1 {
|
2163
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
2164
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2168
|
+ if patient_id > 0 {
|
|
2169
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
|
|
2170
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2171
|
+ } else {
|
|
2172
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
|
2173
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2174
|
+ }
|
2165
|
2175
|
|
2166
|
2176
|
} else if patientType == 2 {
|
2167
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
2168
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2177
|
+ if patient_id > 0 {
|
|
2178
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
|
|
2179
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2180
|
+ } else {
|
|
2181
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
|
2182
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2183
|
+ }
|
|
2184
|
+
|
2169
|
2185
|
}
|
2170
|
2186
|
|
2171
|
2187
|
} else if adviceType == 1 {
|
2172
|
2188
|
if patientType == 0 {
|
2173
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
2174
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2189
|
+ if patient_id > 0 {
|
|
2190
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
|
|
2191
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2192
|
+ } else {
|
|
2193
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
|
2194
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2195
|
+ }
|
2175
|
2196
|
|
2176
|
2197
|
} else if patientType == 1 {
|
2177
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
2178
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2198
|
+ if patient_id > 0 {
|
|
2199
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
|
|
2200
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2201
|
+ } else {
|
|
2202
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
|
2203
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2204
|
+ }
|
2179
|
2205
|
|
2180
|
2206
|
} else if patientType == 2 {
|
2181
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
2182
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2207
|
+ if patient_id > 0 {
|
|
2208
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
|
|
2209
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2210
|
+ } else {
|
|
2211
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
|
2212
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2213
|
+ }
|
2183
|
2214
|
|
2184
|
2215
|
}
|
2185
|
2216
|
|
2186
|
2217
|
} else if adviceType == 3 {
|
2187
|
2218
|
if patientType == 0 {
|
2188
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
2189
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2219
|
+ if patient_id > 0 {
|
|
2220
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ? "
|
|
2221
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2222
|
+ } else {
|
|
2223
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
|
2224
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2225
|
+ }
|
2190
|
2226
|
|
2191
|
2227
|
} else if patientType == 1 {
|
2192
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
2193
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2228
|
+ if patient_id > 0 {
|
|
2229
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
|
|
2230
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2231
|
+ } else {
|
|
2232
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
|
2233
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2234
|
+ }
|
|
2235
|
+
|
2194
|
2236
|
} else if patientType == 2 {
|
2195
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
2196
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2237
|
+ if patient_id > 0 {
|
|
2238
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0 and patient_id = ?"
|
|
2239
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2240
|
+ } else {
|
|
2241
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
|
2242
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2243
|
+ }
|
|
2244
|
+
|
2197
|
2245
|
}
|
2198
|
2246
|
|
2199
|
2247
|
} else if adviceType == 2 && len(deliverWay) > 0 {
|
2200
|
2248
|
if patientType == 0 {
|
2201
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
2202
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2249
|
+ if patient_id > 0 {
|
|
2250
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
|
|
2251
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
|
|
2252
|
+ } else {
|
|
2253
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
|
2254
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2255
|
+ }
|
2203
|
2256
|
|
2204
|
2257
|
} else if patientType == 1 {
|
2205
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
2206
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
2258
|
+ if patient_id > 0 {
|
|
2259
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? and patient_id = ?"
|
|
2260
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
|
|
2261
|
+ } else {
|
|
2262
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
|
2263
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
2264
|
+ }
|
|
2265
|
+
|
2207
|
2266
|
} else if patientType == 2 {
|
2208
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
2209
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2267
|
+ if patient_id > 0 {
|
|
2268
|
+
|
|
2269
|
+ } else {
|
|
2270
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
|
2271
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
2272
|
+ }
|
|
2273
|
+
|
2210
|
2274
|
}
|
2211
|
2275
|
|
2212
|
2276
|
} else if adviceType == 2 && len(deliverWay) <= 0 {
|
2213
|
2277
|
if patientType == 0 {
|
2214
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
2215
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2278
|
+ if patient_id > 0 {
|
|
2279
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
|
|
2280
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2281
|
+ } else {
|
|
2282
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
|
2283
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2284
|
+ }
|
2216
|
2285
|
|
2217
|
2286
|
} else if patientType == 1 {
|
2218
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
|
2219
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2287
|
+ if patient_id > 0 {
|
|
2288
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
|
|
2289
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
2290
|
+ } else {
|
|
2291
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
|
|
2292
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
2293
|
+ }
|
|
2294
|
+
|
2220
|
2295
|
} else if patientType == 2 {
|
2221
|
|
- adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
2222
|
|
- adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2296
|
+ if patient_id > 0 {
|
|
2297
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and patient_id = ?"
|
|
2298
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
2299
|
+ } else {
|
|
2300
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
|
2301
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
2302
|
+ }
|
|
2303
|
+
|
2223
|
2304
|
}
|
2224
|
2305
|
|
2225
|
2306
|
}
|
|
@@ -2249,7 +2330,7 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
|
2249
|
2330
|
return vms, err
|
2250
|
2331
|
}
|
2251
|
2332
|
|
2252
|
|
-func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
|
|
2333
|
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64, patient_id int64) ([]*HisMScheduleDoctorAdviceVM, error) {
|
2253
|
2334
|
|
2254
|
2335
|
var vms []*HisMScheduleDoctorAdviceVM
|
2255
|
2336
|
if len(deliverWay) > 0 {
|
|
@@ -2260,19 +2341,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
|
2260
|
2341
|
if partitionType > 0 {
|
2261
|
2342
|
db = db.Where("partition_id = ?", partitionType)
|
2262
|
2343
|
}
|
2263
|
|
- db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
2264
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
2265
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
2266
|
|
- Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2267
|
|
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
2268
|
|
- Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
2269
|
|
- return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
2270
|
|
- }).
|
2271
|
|
- Where("status = 1 AND user_org_id = ?", orgID)
|
2272
|
|
- if scheduleDate != 0 {
|
2273
|
|
- db = db.Where("schedule_date = ?", scheduleDate)
|
|
2344
|
+ if patient_id > 0 {
|
|
2345
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id =?", orgID, patient_id).
|
|
2346
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2347
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2348
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2349
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
|
|
2350
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2351
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2352
|
+ }).
|
|
2353
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2354
|
+ if scheduleDate != 0 {
|
|
2355
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2356
|
+ }
|
|
2357
|
+ err = db.Find(&vms).Error
|
|
2358
|
+ } else {
|
|
2359
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2360
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2361
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2362
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2363
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
|
2364
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2365
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2366
|
+ }).
|
|
2367
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2368
|
+ if scheduleDate != 0 {
|
|
2369
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2370
|
+ }
|
|
2371
|
+ err = db.Find(&vms).Error
|
2274
|
2372
|
}
|
2275
|
|
- err = db.Find(&vms).Error
|
|
2373
|
+
|
2276
|
2374
|
} else {
|
2277
|
2375
|
db := readDb.Table("xt_schedule")
|
2278
|
2376
|
if scheduleType > 0 {
|
|
@@ -2281,19 +2379,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
|
2281
|
2379
|
if partitionType > 0 {
|
2282
|
2380
|
db = db.Where("partition_id = ?", partitionType)
|
2283
|
2381
|
}
|
2284
|
|
- db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
2285
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
2286
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
2287
|
|
- Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2288
|
|
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
|
2289
|
|
- Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
2290
|
|
- return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
2291
|
|
- }).
|
2292
|
|
- Where("status = 1 AND user_org_id = ?", orgID)
|
2293
|
|
- if scheduleDate != 0 {
|
2294
|
|
- db = db.Where("schedule_date = ?", scheduleDate)
|
|
2382
|
+ if patient_id > 0 {
|
|
2383
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
|
|
2384
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2385
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2386
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2387
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2388
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2389
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2390
|
+ }).
|
|
2391
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2392
|
+ if scheduleDate != 0 {
|
|
2393
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2394
|
+ }
|
|
2395
|
+ err = db.Find(&vms).Error
|
|
2396
|
+ } else {
|
|
2397
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2398
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2399
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2400
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2401
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
|
|
2402
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2403
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2404
|
+ }).
|
|
2405
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2406
|
+ if scheduleDate != 0 {
|
|
2407
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2408
|
+ }
|
|
2409
|
+ err = db.Find(&vms).Error
|
2295
|
2410
|
}
|
2296
|
|
- err = db.Find(&vms).Error
|
|
2411
|
+
|
2297
|
2412
|
}
|
2298
|
2413
|
|
2299
|
2414
|
return vms, err
|
|
@@ -2423,25 +2538,65 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
|
2423
|
2538
|
return
|
2424
|
2539
|
}
|
2425
|
2540
|
|
2426
|
|
-func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
|
|
2541
|
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64, patient_id int64) ([]*HisMScheduleProjectVM, error) {
|
2427
|
2542
|
var vms []*HisMScheduleProjectVM
|
2428
|
2543
|
if patientType == 0 {
|
2429
|
|
- db := readDb.
|
2430
|
|
- Table("xt_schedule").
|
2431
|
|
- Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
2432
|
|
- Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
2433
|
|
- return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
2434
|
|
- }).
|
2435
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
2436
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
2437
|
|
- Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
2438
|
|
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
2439
|
|
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
2440
|
|
- }).Where("status = 1 AND user_org_id = ?", orgID)
|
2441
|
|
- if scheduleDate != 0 {
|
2442
|
|
- db = db.Where("schedule_date = ?", scheduleDate)
|
|
2544
|
+
|
|
2545
|
+ if patient_id > 0 {
|
|
2546
|
+ db := readDb.
|
|
2547
|
+ Table("xt_schedule").
|
|
2548
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2549
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2550
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2551
|
+ }).
|
|
2552
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2553
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2554
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2555
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2556
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2557
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2558
|
+ if scheduleDate != 0 {
|
|
2559
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2560
|
+ }
|
|
2561
|
+ err = db.Find(&vms).Error
|
|
2562
|
+ } else {
|
|
2563
|
+ if patient_id > 0 {
|
|
2564
|
+ db := readDb.
|
|
2565
|
+ Table("xt_schedule").
|
|
2566
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id= ?", orgID, patient_id).
|
|
2567
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2568
|
+ return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2569
|
+ }).
|
|
2570
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2571
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2572
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
|
|
2573
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2574
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2575
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2576
|
+ if scheduleDate != 0 {
|
|
2577
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2578
|
+ }
|
|
2579
|
+ err = db.Find(&vms).Error
|
|
2580
|
+ } else {
|
|
2581
|
+ db := readDb.
|
|
2582
|
+ Table("xt_schedule").
|
|
2583
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2584
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2585
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2586
|
+ }).
|
|
2587
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2588
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2589
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2590
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2591
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2592
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2593
|
+ if scheduleDate != 0 {
|
|
2594
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2595
|
+ }
|
|
2596
|
+ err = db.Find(&vms).Error
|
|
2597
|
+ }
|
2443
|
2598
|
}
|
2444
|
|
- err = db.Find(&vms).Error
|
|
2599
|
+
|
2445
|
2600
|
}
|
2446
|
2601
|
|
2447
|
2602
|
if patientType > 0 {
|