|
@@ -139,6 +139,7 @@ type MDialysisScheduleVMForList struct {
|
139
|
139
|
Advices []models.VMDoctorAdviceForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
140
|
140
|
TreatmentSummary *models.VMTreatmentSummaryForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
|
141
|
141
|
DialysisSolution *models.DialysisSolution `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
|
|
142
|
+ DoubleCheck *models.DoubleCheck `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dobule_check"`
|
142
|
143
|
}
|
143
|
144
|
|
144
|
145
|
func (MDialysisScheduleVMForList) TableName() string {
|
|
@@ -446,6 +447,7 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
|
446
|
447
|
var vm MDialysisScheduleVM
|
447
|
448
|
|
448
|
449
|
key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedualDate, 10) + ":schedual_detail"
|
|
450
|
+ redis.Set(key, "", time.Second)
|
449
|
451
|
schedual_detail_str, _ := redis.Get(key).Result()
|
450
|
452
|
|
451
|
453
|
if len(schedual_detail_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -829,6 +831,15 @@ func MobileGetSchedualDialysisRecordTen(orgID int64, patientID int64, recordDate
|
829
|
831
|
return &record, nil
|
830
|
832
|
}
|
831
|
833
|
|
|
834
|
+//func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
|
|
835
|
+// var record models.DialysisOrder
|
|
836
|
+//
|
|
837
|
+// err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
|
|
838
|
+//
|
|
839
|
+//
|
|
840
|
+// return &record,err
|
|
841
|
+//}
|
|
842
|
+
|
832
|
843
|
// 透析记录
|
833
|
844
|
func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
|
834
|
845
|
var record models.DialysisOrder
|
|
@@ -836,8 +847,8 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
|
836
|
847
|
defer redis.Close()
|
837
|
848
|
|
838
|
849
|
key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
|
839
|
|
- redis.Set(key, "", time.Second)
|
840
|
850
|
dialysis_order_str, _ := redis.Get(key).Result()
|
|
851
|
+
|
841
|
852
|
if len(dialysis_order_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
842
|
853
|
err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
|
843
|
854
|
if err != nil {
|
|
@@ -1358,6 +1369,7 @@ type MDoctorAdviceVM struct {
|
1358
|
1369
|
TemplateId string `gorm:"column:template_id" json:"template_id"`
|
1359
|
1370
|
Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
1360
|
1371
|
IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
|
|
1372
|
+ IsSettle int64 `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
|
1361
|
1373
|
}
|
1362
|
1374
|
|
1363
|
1375
|
func (MDoctorAdviceVM) TableName() string {
|
|
@@ -2928,6 +2940,15 @@ func GetAssessmentBefor(orgid int64, patientid int64, recorddate int64) (*models
|
2928
|
2940
|
return &evaluation, nil
|
2929
|
2941
|
}
|
2930
|
2942
|
|
|
2943
|
+func GetAssessmentBeforThrity(orgid int64, patientid int64, recorddate int64) (models.PredialysisEvaluation, error) {
|
|
2944
|
+
|
|
2945
|
+ evaluation := models.PredialysisEvaluation{}
|
|
2946
|
+
|
|
2947
|
+ err := XTReadDB().Model(&evaluation).Where("user_org_id = ? and patient_id = ? and assessment_date = ? and status = 1", orgid, patientid, recorddate).Find(&evaluation).Error
|
|
2948
|
+
|
|
2949
|
+ return evaluation, err
|
|
2950
|
+}
|
|
2951
|
+
|
2931
|
2952
|
func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
|
2932
|
2953
|
redis := RedisClient()
|
2933
|
2954
|
defer redis.Close()
|
|
@@ -3110,7 +3131,7 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
|
3110
|
3131
|
return advice, err
|
3111
|
3132
|
}
|
3112
|
3133
|
|
3113
|
|
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64) ([]*MScheduleDoctorAdviceVM, error) {
|
|
3134
|
+func MobileGetScheduleDoctorAdvicesSix(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64) ([]*MScheduleDoctorAdviceVM, error) {
|
3114
|
3135
|
var vms []*MScheduleDoctorAdviceVM
|
3115
|
3136
|
adviceWhere := ""
|
3116
|
3137
|
adviceCondition := []interface{}{}
|
|
@@ -4142,3 +4163,364 @@ func GetFistMonitor(orgid int64, patient_id int64, dialysis_date int64) (models.
|
4142
|
4163
|
err := XTReadDB().Where("org_id = ? and patient_id = ? and monitoring_date = ? and status = 1", orgid, patient_id, dialysis_date).Find(&record).Error
|
4143
|
4164
|
return record, err
|
4144
|
4165
|
}
|
|
4166
|
+
|
|
4167
|
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64) ([]*MScheduleDoctorAdviceVM, error) {
|
|
4168
|
+ var vms []*MScheduleDoctorAdviceVM
|
|
4169
|
+ adviceWhere := ""
|
|
4170
|
+ adviceCondition := []interface{}{}
|
|
4171
|
+ if adviceType == 0 {
|
|
4172
|
+ if patientType == 0 {
|
|
4173
|
+ if patient_id > 0 {
|
|
4174
|
+ if execution_state > 0 {
|
|
4175
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
|
|
4176
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4177
|
+ } else {
|
|
4178
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
|
|
4179
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4180
|
+ }
|
|
4181
|
+
|
|
4182
|
+ } else {
|
|
4183
|
+ if execution_state > 0 {
|
|
4184
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ?"
|
|
4185
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4186
|
+ } else {
|
|
4187
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
|
4188
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4189
|
+ }
|
|
4190
|
+
|
|
4191
|
+ }
|
|
4192
|
+
|
|
4193
|
+ } else if patientType == 1 {
|
|
4194
|
+ if patient_id > 0 {
|
|
4195
|
+ if execution_state > 0 {
|
|
4196
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
|
|
4197
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
|
|
4198
|
+ } else {
|
|
4199
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
|
|
4200
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
4201
|
+ }
|
|
4202
|
+
|
|
4203
|
+ } else {
|
|
4204
|
+ if execution_state > 0 {
|
|
4205
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
|
|
4206
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
|
|
4207
|
+ } else {
|
|
4208
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
|
4209
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
4210
|
+ }
|
|
4211
|
+
|
|
4212
|
+ }
|
|
4213
|
+
|
|
4214
|
+ } else if patientType == 2 {
|
|
4215
|
+ if patient_id > 0 {
|
|
4216
|
+ if execution_state > 0 {
|
|
4217
|
+ 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 = ?) and execution_state = ?"
|
|
4218
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4219
|
+ } else {
|
|
4220
|
+ 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 = ?)"
|
|
4221
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4222
|
+ }
|
|
4223
|
+
|
|
4224
|
+ } else {
|
|
4225
|
+ if execution_state > 0 {
|
|
4226
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
|
|
4227
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4228
|
+ } else {
|
|
4229
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
|
4230
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4231
|
+ }
|
|
4232
|
+
|
|
4233
|
+ }
|
|
4234
|
+
|
|
4235
|
+ }
|
|
4236
|
+
|
|
4237
|
+ } else if adviceType == 1 {
|
|
4238
|
+ if patientType == 0 {
|
|
4239
|
+ if patient_id > 0 {
|
|
4240
|
+ if execution_state > 0 {
|
|
4241
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ?"
|
|
4242
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4243
|
+ } else {
|
|
4244
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
|
|
4245
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4246
|
+ }
|
|
4247
|
+
|
|
4248
|
+ } else {
|
|
4249
|
+ if execution_state > 0 {
|
|
4250
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and execution_state = ?"
|
|
4251
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4252
|
+ } else {
|
|
4253
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
|
4254
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4255
|
+ }
|
|
4256
|
+
|
|
4257
|
+ }
|
|
4258
|
+
|
|
4259
|
+ } else if patientType == 1 {
|
|
4260
|
+ if patient_id > 0 {
|
|
4261
|
+ if execution_state > 0 {
|
|
4262
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ? and execution_state = ?"
|
|
4263
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
|
|
4264
|
+ } else {
|
|
4265
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
|
|
4266
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
4267
|
+ }
|
|
4268
|
+
|
|
4269
|
+ } else {
|
|
4270
|
+ if execution_state > 0 {
|
|
4271
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and execution_state=?"
|
|
4272
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
|
|
4273
|
+ } else {
|
|
4274
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
|
4275
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
4276
|
+ }
|
|
4277
|
+
|
|
4278
|
+ }
|
|
4279
|
+
|
|
4280
|
+ } else if patientType == 2 {
|
|
4281
|
+ if patient_id > 0 {
|
|
4282
|
+ if execution_state > 0 {
|
|
4283
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ? and execution_state = ?"
|
|
4284
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4285
|
+ } else {
|
|
4286
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
|
|
4287
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4288
|
+ }
|
|
4289
|
+
|
|
4290
|
+ } else {
|
|
4291
|
+ if execution_state > 0 {
|
|
4292
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and execution_state = ?"
|
|
4293
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4294
|
+ } else {
|
|
4295
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
|
4296
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4297
|
+ }
|
|
4298
|
+
|
|
4299
|
+ }
|
|
4300
|
+
|
|
4301
|
+ }
|
|
4302
|
+
|
|
4303
|
+ } else if adviceType == 3 {
|
|
4304
|
+ if patientType == 0 {
|
|
4305
|
+ if patient_id > 0 {
|
|
4306
|
+ if execution_state > 0 {
|
|
4307
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ? and execution_state = ?"
|
|
4308
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4309
|
+ } else {
|
|
4310
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ? "
|
|
4311
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4312
|
+ }
|
|
4313
|
+
|
|
4314
|
+ } else {
|
|
4315
|
+ if execution_state > 0 {
|
|
4316
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and execution_state =? "
|
|
4317
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4318
|
+ } else {
|
|
4319
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
|
4320
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4321
|
+ }
|
|
4322
|
+
|
|
4323
|
+ }
|
|
4324
|
+
|
|
4325
|
+ } else if patientType == 1 {
|
|
4326
|
+ if patient_id > 0 {
|
|
4327
|
+ if execution_state > 0 {
|
|
4328
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ? and execution_state = ?"
|
|
4329
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
|
|
4330
|
+ } else {
|
|
4331
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
|
|
4332
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
4333
|
+ }
|
|
4334
|
+
|
|
4335
|
+ } else {
|
|
4336
|
+ if execution_state > 0 {
|
|
4337
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and execution_state =? "
|
|
4338
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
|
|
4339
|
+ } else {
|
|
4340
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
|
4341
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
4342
|
+ }
|
|
4343
|
+
|
|
4344
|
+ }
|
|
4345
|
+
|
|
4346
|
+ } else if patientType == 2 {
|
|
4347
|
+ if patient_id > 0 {
|
|
4348
|
+ if execution_state > 0 {
|
|
4349
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0 and patient_id = ? and execution_state = ?"
|
|
4350
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4351
|
+ } else {
|
|
4352
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0 and patient_id = ?"
|
|
4353
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4354
|
+ }
|
|
4355
|
+
|
|
4356
|
+ } else {
|
|
4357
|
+ if execution_state > 0 {
|
|
4358
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0 and execution_state= ?"
|
|
4359
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4360
|
+ } else {
|
|
4361
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
|
4362
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4363
|
+ }
|
|
4364
|
+
|
|
4365
|
+ }
|
|
4366
|
+
|
|
4367
|
+ }
|
|
4368
|
+
|
|
4369
|
+ } else if adviceType == 2 && len(deliverWay) > 0 {
|
|
4370
|
+ if patientType == 0 {
|
|
4371
|
+ if patient_id > 0 {
|
|
4372
|
+ if execution_state > 0 {
|
|
4373
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ? and execution_state = ?"
|
|
4374
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id, execution_state)
|
|
4375
|
+ } else {
|
|
4376
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
|
|
4377
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
|
|
4378
|
+ }
|
|
4379
|
+
|
|
4380
|
+ } else {
|
|
4381
|
+ if execution_state > 0 {
|
|
4382
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and execution_state = ?"
|
|
4383
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, execution_state)
|
|
4384
|
+ } else {
|
|
4385
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
|
4386
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
4387
|
+ }
|
|
4388
|
+
|
|
4389
|
+ }
|
|
4390
|
+
|
|
4391
|
+ } else if patientType == 1 {
|
|
4392
|
+ if patient_id > 0 {
|
|
4393
|
+ if execution_state > 0 {
|
|
4394
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? and patient_id = ? and execution_state = ?"
|
|
4395
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id, execution_state)
|
|
4396
|
+ } else {
|
|
4397
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? and patient_id = ?"
|
|
4398
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
|
|
4399
|
+ }
|
|
4400
|
+
|
|
4401
|
+ } else {
|
|
4402
|
+ if execution_state > 0 {
|
|
4403
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? and execution_state = ?"
|
|
4404
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, execution_state)
|
|
4405
|
+ } else {
|
|
4406
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
|
4407
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
4408
|
+ }
|
|
4409
|
+
|
|
4410
|
+ }
|
|
4411
|
+
|
|
4412
|
+ } else if patientType == 2 {
|
|
4413
|
+ if patient_id > 0 {
|
|
4414
|
+ if execution_state > 0 {
|
|
4415
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ? and patient_id = ? and execution_state = ?"
|
|
4416
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id, execution_state)
|
|
4417
|
+ } else {
|
|
4418
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ? and patient_id = ?"
|
|
4419
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
|
|
4420
|
+ }
|
|
4421
|
+
|
|
4422
|
+ } else {
|
|
4423
|
+ if execution_state > 0 {
|
|
4424
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ? and execution_state = ?"
|
|
4425
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, execution_state)
|
|
4426
|
+ } else {
|
|
4427
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
|
4428
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
4429
|
+ }
|
|
4430
|
+
|
|
4431
|
+ }
|
|
4432
|
+
|
|
4433
|
+ }
|
|
4434
|
+
|
|
4435
|
+ } else if adviceType == 2 && len(deliverWay) <= 0 {
|
|
4436
|
+ if patientType == 0 {
|
|
4437
|
+ if patient_id > 0 {
|
|
4438
|
+ if execution_state > 0 {
|
|
4439
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ? and execution_state = ?"
|
|
4440
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4441
|
+ } else {
|
|
4442
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
|
|
4443
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4444
|
+ }
|
|
4445
|
+
|
|
4446
|
+ } else {
|
|
4447
|
+ if execution_state > 0 {
|
|
4448
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and execution_state = ?"
|
|
4449
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4450
|
+ } else {
|
|
4451
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
|
4452
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4453
|
+ }
|
|
4454
|
+
|
|
4455
|
+ }
|
|
4456
|
+
|
|
4457
|
+ } else if patientType == 1 {
|
|
4458
|
+ if patient_id > 0 {
|
|
4459
|
+ if execution_state > 0 {
|
|
4460
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ? and execution_state = ?"
|
|
4461
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
|
|
4462
|
+ } else {
|
|
4463
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
|
|
4464
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
|
|
4465
|
+ }
|
|
4466
|
+
|
|
4467
|
+ } else {
|
|
4468
|
+ if execution_state > 0 {
|
|
4469
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and execution_state = ?"
|
|
4470
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
|
|
4471
|
+ } else {
|
|
4472
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
|
|
4473
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
4474
|
+ }
|
|
4475
|
+
|
|
4476
|
+ }
|
|
4477
|
+
|
|
4478
|
+ } else if patientType == 2 {
|
|
4479
|
+ if patient_id > 0 {
|
|
4480
|
+ if execution_state > 0 {
|
|
4481
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and patient_id = ? and execution_state = ?"
|
|
4482
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
|
|
4483
|
+ } else {
|
|
4484
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and patient_id = ?"
|
|
4485
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
|
|
4486
|
+ }
|
|
4487
|
+
|
|
4488
|
+ } else {
|
|
4489
|
+ if execution_state > 0 {
|
|
4490
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and execution_state = ?"
|
|
4491
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
|
|
4492
|
+ } else {
|
|
4493
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
|
4494
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
4495
|
+ }
|
|
4496
|
+
|
|
4497
|
+ }
|
|
4498
|
+
|
|
4499
|
+ }
|
|
4500
|
+
|
|
4501
|
+ }
|
|
4502
|
+
|
|
4503
|
+ db := readDb.Table("xt_schedule")
|
|
4504
|
+ if scheduleType > 0 {
|
|
4505
|
+ db = db.Where("schedule_type = ?", scheduleType)
|
|
4506
|
+ }
|
|
4507
|
+ if partitonType > 0 {
|
|
4508
|
+ db = db.Where("partition_id = ?", partitonType)
|
|
4509
|
+ }
|
|
4510
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
4511
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
4512
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
4513
|
+ }).
|
|
4514
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
4515
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
4516
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
4517
|
+ Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
|
|
4518
|
+ Preload("DoctorAdvices", adviceCondition...).
|
|
4519
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
4520
|
+ if scheduleDate != 0 {
|
|
4521
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
4522
|
+ }
|
|
4523
|
+
|
|
4524
|
+ err := db.Find(&vms).Error
|
|
4525
|
+ return vms, err
|
|
4526
|
+}
|