|
@@ -7237,3 +7237,306 @@ func GetPatientDryWeight(org_id int64, patient_id int64) (weight []*models.SgjPa
|
7237
|
7237
|
|
7238
|
7238
|
return weight, err
|
7239
|
7239
|
}
|
|
7240
|
+
|
|
7241
|
+func MobileGetLongScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64, cost_type int64, execution_frequency string) ([]*MScheduleDoctorAdviceVM, error) {
|
|
7242
|
+
|
|
7243
|
+ var vms []*MScheduleDoctorAdviceVM
|
|
7244
|
+ adviceWhere := ""
|
|
7245
|
+ adviceCondition := []interface{}{}
|
|
7246
|
+ if adviceType == 1 {
|
|
7247
|
+ if patientType == 0 {
|
|
7248
|
+ if patient_id > 0 {
|
|
7249
|
+ if execution_state > 0 {
|
|
7250
|
+ if cost_type > 0 {
|
|
7251
|
+ if len(execution_frequency) > 0 {
|
|
7252
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_state = ? and is_settle = ? and execution_frequency = ?"
|
|
7253
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type, execution_frequency)
|
|
7254
|
+ } else {
|
|
7255
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_state = ? and is_settle = ?"
|
|
7256
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type)
|
|
7257
|
+ }
|
|
7258
|
+
|
|
7259
|
+ } else {
|
|
7260
|
+ if len(execution_frequency) > 0 {
|
|
7261
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_state = ? and execution_frequency = ?"
|
|
7262
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, execution_frequency)
|
|
7263
|
+ } else {
|
|
7264
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_state = ?"
|
|
7265
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state)
|
|
7266
|
+ }
|
|
7267
|
+
|
|
7268
|
+ }
|
|
7269
|
+
|
|
7270
|
+ } else {
|
|
7271
|
+ if cost_type > 0 {
|
|
7272
|
+ if len(execution_frequency) > 0 {
|
|
7273
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and is_settle = ? and execution_frequency = ?"
|
|
7274
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type, execution_frequency)
|
|
7275
|
+ } else {
|
|
7276
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and is_settle = ? "
|
|
7277
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type)
|
|
7278
|
+ }
|
|
7279
|
+
|
|
7280
|
+ } else {
|
|
7281
|
+ if len(execution_frequency) > 0 {
|
|
7282
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_frequency = ?"
|
|
7283
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_frequency)
|
|
7284
|
+ } else {
|
|
7285
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? "
|
|
7286
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id)
|
|
7287
|
+ }
|
|
7288
|
+
|
|
7289
|
+ }
|
|
7290
|
+
|
|
7291
|
+ }
|
|
7292
|
+
|
|
7293
|
+ } else {
|
|
7294
|
+ if execution_state > 0 {
|
|
7295
|
+ if cost_type > 0 {
|
|
7296
|
+ if len(execution_frequency) > 0 {
|
|
7297
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and execution_state = ? and is_settle = ? and execution_frequency = ?"
|
|
7298
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type, execution_frequency)
|
|
7299
|
+ } else {
|
|
7300
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and execution_state = ? and is_settle = ?"
|
|
7301
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type)
|
|
7302
|
+ }
|
|
7303
|
+
|
|
7304
|
+ } else {
|
|
7305
|
+ if len(execution_frequency) > 0 {
|
|
7306
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and execution_state = ? and execution_frequency = ?"
|
|
7307
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, execution_frequency)
|
|
7308
|
+ } else {
|
|
7309
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and execution_state = ?"
|
|
7310
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state)
|
|
7311
|
+ }
|
|
7312
|
+
|
|
7313
|
+ }
|
|
7314
|
+
|
|
7315
|
+ } else {
|
|
7316
|
+ if cost_type > 0 {
|
|
7317
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and is_settle = ? "
|
|
7318
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, cost_type)
|
|
7319
|
+ } else {
|
|
7320
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 "
|
|
7321
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID)
|
|
7322
|
+ }
|
|
7323
|
+
|
|
7324
|
+ }
|
|
7325
|
+
|
|
7326
|
+ }
|
|
7327
|
+
|
|
7328
|
+ } else if patientType == 1 {
|
|
7329
|
+ if patient_id > 0 {
|
|
7330
|
+ if execution_state > 0 {
|
|
7331
|
+ if cost_type > 0 {
|
|
7332
|
+ if len(execution_frequency) > 0 {
|
|
7333
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and execution_state = ? and is_settle = ? and execution_frequency = ?"
|
|
7334
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state, cost_type, execution_frequency)
|
|
7335
|
+ } else {
|
|
7336
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and execution_state = ? and is_settle = ?"
|
|
7337
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state, cost_type)
|
|
7338
|
+ }
|
|
7339
|
+
|
|
7340
|
+ } else {
|
|
7341
|
+ if len(execution_frequency) > 0 {
|
|
7342
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and execution_state = ? and execution_frequency = ?"
|
|
7343
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state, execution_frequency)
|
|
7344
|
+ } else {
|
|
7345
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and execution_state = ?"
|
|
7346
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state)
|
|
7347
|
+ }
|
|
7348
|
+
|
|
7349
|
+ }
|
|
7350
|
+
|
|
7351
|
+ } else {
|
|
7352
|
+ if cost_type > 0 {
|
|
7353
|
+ if len(execution_frequency) > 0 {
|
|
7354
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and is_settle = ?and execution_frequency = ?"
|
|
7355
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, cost_type, execution_frequency)
|
|
7356
|
+ } else {
|
|
7357
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and is_settle = ?"
|
|
7358
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, cost_type)
|
|
7359
|
+ }
|
|
7360
|
+
|
|
7361
|
+ } else {
|
|
7362
|
+ if len(execution_frequency) > 0 {
|
|
7363
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and execution_frequency = ?"
|
|
7364
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_frequency)
|
|
7365
|
+ } else {
|
|
7366
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ?"
|
|
7367
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id)
|
|
7368
|
+ }
|
|
7369
|
+
|
|
7370
|
+ }
|
|
7371
|
+
|
|
7372
|
+ }
|
|
7373
|
+
|
|
7374
|
+ } else {
|
|
7375
|
+ if execution_state > 0 {
|
|
7376
|
+ if cost_type > 0 {
|
|
7377
|
+ if len(execution_frequency) > 0 {
|
|
7378
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and execution_state=? and is_settle = ?and execution_frequency = ?"
|
|
7379
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state, cost_type, execution_frequency)
|
|
7380
|
+ } else {
|
|
7381
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and execution_state=? and is_settle = ?"
|
|
7382
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state, cost_type)
|
|
7383
|
+ }
|
|
7384
|
+
|
|
7385
|
+ } else {
|
|
7386
|
+ if len(execution_frequency) > 0 {
|
|
7387
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and execution_state=?and execution_frequency = ?"
|
|
7388
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state, execution_frequency)
|
|
7389
|
+ } else {
|
|
7390
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and execution_state=?"
|
|
7391
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state)
|
|
7392
|
+ }
|
|
7393
|
+
|
|
7394
|
+ }
|
|
7395
|
+
|
|
7396
|
+ } else {
|
|
7397
|
+ if cost_type > 0 {
|
|
7398
|
+ if len(execution_frequency) > 0 {
|
|
7399
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and is_settle = ? and execution_frequency = ?"
|
|
7400
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, cost_type, execution_frequency)
|
|
7401
|
+ } else {
|
|
7402
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and is_settle = ? "
|
|
7403
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, cost_type)
|
|
7404
|
+ }
|
|
7405
|
+
|
|
7406
|
+ } else {
|
|
7407
|
+ if len(execution_frequency) > 0 {
|
|
7408
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and execution_frequency = ?"
|
|
7409
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_frequency)
|
|
7410
|
+ } else {
|
|
7411
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? "
|
|
7412
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId)
|
|
7413
|
+ }
|
|
7414
|
+
|
|
7415
|
+ }
|
|
7416
|
+
|
|
7417
|
+ }
|
|
7418
|
+
|
|
7419
|
+ }
|
|
7420
|
+
|
|
7421
|
+ } else if patientType == 2 {
|
|
7422
|
+ if patient_id > 0 {
|
|
7423
|
+ if execution_state > 0 {
|
|
7424
|
+ if cost_type > 0 {
|
|
7425
|
+ if len(execution_frequency) > 0 {
|
|
7426
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and execution_state = ? and is_settle = ?and execution_frequency = ?"
|
|
7427
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type, execution_frequency)
|
|
7428
|
+ } else {
|
|
7429
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and execution_state = ? and is_settle = ?"
|
|
7430
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type)
|
|
7431
|
+ }
|
|
7432
|
+
|
|
7433
|
+ } else {
|
|
7434
|
+ if len(execution_frequency) > 0 {
|
|
7435
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and execution_state = ? and execution_frequency = ?"
|
|
7436
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, execution_frequency)
|
|
7437
|
+ } else {
|
|
7438
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and execution_state = ?"
|
|
7439
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state)
|
|
7440
|
+ }
|
|
7441
|
+
|
|
7442
|
+ }
|
|
7443
|
+
|
|
7444
|
+ } else {
|
|
7445
|
+ if cost_type > 0 {
|
|
7446
|
+ if len(execution_frequency) > 0 {
|
|
7447
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and is_settle = ? and execution_frequency = ?"
|
|
7448
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type, execution_frequency)
|
|
7449
|
+ } else {
|
|
7450
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and is_settle = ?"
|
|
7451
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type)
|
|
7452
|
+ }
|
|
7453
|
+
|
|
7454
|
+ } else {
|
|
7455
|
+ if len(execution_frequency) > 0 {
|
|
7456
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ? and execution_frequency = ?"
|
|
7457
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_frequency)
|
|
7458
|
+ } else {
|
|
7459
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ?"
|
|
7460
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id)
|
|
7461
|
+ }
|
|
7462
|
+
|
|
7463
|
+ }
|
|
7464
|
+
|
|
7465
|
+ }
|
|
7466
|
+ } else {
|
|
7467
|
+ if execution_state > 0 {
|
|
7468
|
+
|
|
7469
|
+ if cost_type > 0 {
|
|
7470
|
+ if len(execution_frequency) > 0 {
|
|
7471
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1AND execution_staff = 0 and execution_state = ? and is_settle = ? and execution_frequency = ?"
|
|
7472
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type, execution_frequency)
|
|
7473
|
+ } else {
|
|
7474
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1AND execution_staff = 0 and execution_state = ? and is_settle = ?"
|
|
7475
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type)
|
|
7476
|
+ }
|
|
7477
|
+
|
|
7478
|
+ } else {
|
|
7479
|
+ if len(execution_frequency) > 0 {
|
|
7480
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and execution_state = ? and execution_frequency = ?"
|
|
7481
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, execution_frequency)
|
|
7482
|
+ } else {
|
|
7483
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and execution_state = ?"
|
|
7484
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state)
|
|
7485
|
+ }
|
|
7486
|
+
|
|
7487
|
+ }
|
|
7488
|
+
|
|
7489
|
+ } else {
|
|
7490
|
+
|
|
7491
|
+ if cost_type > 0 {
|
|
7492
|
+ if len(execution_frequency) > 0 {
|
|
7493
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and is_settle = ? and execution_frequency = ?"
|
|
7494
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, cost_type, execution_frequency)
|
|
7495
|
+ } else {
|
|
7496
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and is_settle = ?"
|
|
7497
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, cost_type)
|
|
7498
|
+ }
|
|
7499
|
+
|
|
7500
|
+ } else {
|
|
7501
|
+ if len(execution_frequency) > 0 {
|
|
7502
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and execution_frequency = ?"
|
|
7503
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_frequency)
|
|
7504
|
+ } else {
|
|
7505
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0"
|
|
7506
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID)
|
|
7507
|
+ }
|
|
7508
|
+
|
|
7509
|
+ }
|
|
7510
|
+
|
|
7511
|
+ }
|
|
7512
|
+
|
|
7513
|
+ }
|
|
7514
|
+
|
|
7515
|
+ }
|
|
7516
|
+
|
|
7517
|
+ }
|
|
7518
|
+
|
|
7519
|
+ db := readDb.Table("xt_schedule")
|
|
7520
|
+ if scheduleType > 0 {
|
|
7521
|
+ db = db.Where("schedule_type = ?", scheduleType)
|
|
7522
|
+ }
|
|
7523
|
+ if partitonType > 0 {
|
|
7524
|
+ db = db.Where("partition_id = ?", partitonType)
|
|
7525
|
+ }
|
|
7526
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
7527
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
7528
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
7529
|
+ }).
|
|
7530
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
7531
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
7532
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
7533
|
+ Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
|
|
7534
|
+ Preload("DoctorAdvices", adviceCondition...).
|
|
7535
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
7536
|
+ if scheduleDate != 0 {
|
|
7537
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
7538
|
+ }
|
|
7539
|
+
|
|
7540
|
+ err := db.Find(&vms).Error
|
|
7541
|
+ return vms, err
|
|
7542
|
+}
|