|
@@ -35,6 +35,7 @@ type HisPatient struct {
|
35
|
35
|
HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"prescription"`
|
36
|
36
|
PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
37
|
37
|
Number string `gorm:"column:number" json:"number" form:"number"`
|
|
38
|
+ VMHisOrders []*VMHisOrder `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"orders"`
|
38
|
39
|
VMHisOrder VMHisOrder `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"order"`
|
39
|
40
|
}
|
40
|
41
|
|
|
@@ -106,6 +107,9 @@ type VMHisOrder struct {
|
106
|
107
|
Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
107
|
108
|
MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
|
108
|
109
|
MzNumber string `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
|
|
110
|
+
|
|
111
|
+ FaPiaoCode string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
|
|
112
|
+ FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
|
109
|
113
|
}
|
110
|
114
|
|
111
|
115
|
func (VMHisOrder) TableName() string {
|
|
@@ -154,8 +158,8 @@ func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64,
|
154
|
158
|
}
|
155
|
159
|
|
156
|
160
|
db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
157
|
|
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
158
|
|
- err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
|
|
161
|
+ db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
|
|
162
|
+ err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
|
159
|
163
|
return
|
160
|
164
|
}
|
161
|
165
|
|
|
@@ -189,8 +193,8 @@ func GetHisPatientList(org_id int64, keywords string, record_date int64) (patien
|
189
|
193
|
db := readDb.Model(&Patients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
|
190
|
194
|
Joins("join his_patient as hp ON hp.patient_id = xt_patients.id AND hp.record_date = ? AND hp.status = 1 AND hp.user_org_id = ?", record_date, org_id)
|
191
|
195
|
db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
192
|
|
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
193
|
|
- err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Find(&patients).Error
|
|
196
|
+ db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
|
|
197
|
+ err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Find(&patients).Error
|
194
|
198
|
return
|
195
|
199
|
}
|
196
|
200
|
|
|
@@ -261,8 +265,8 @@ func GetNewHisPatientList(org_id int64, record_date int64) (patients []*PatientT
|
261
|
265
|
return
|
262
|
266
|
}
|
263
|
267
|
|
264
|
|
-func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*Patients, err error) {
|
265
|
|
- db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
|
268
|
+func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*PatientTwo, err error) {
|
|
269
|
+ db := readDb.Model(&PatientTwo{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
266
|
270
|
|
267
|
271
|
if sch_type != 0 {
|
268
|
272
|
db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_type = ?", record_date, org_id, sch_type)
|
|
@@ -271,7 +275,6 @@ func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int
|
271
|
275
|
}
|
272
|
276
|
|
273
|
277
|
db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
274
|
|
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
275
|
278
|
err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
|
276
|
279
|
return
|
277
|
280
|
}
|
|
@@ -301,6 +304,11 @@ func GetNewHisPatientInfoTwo(org_id int64, id int64, record_date int64) (info mo
|
301
|
304
|
return
|
302
|
305
|
}
|
303
|
306
|
|
|
307
|
+func GetHisPatientCount(org_id int64, patient_id int64, record_date int64) (total int64, err error) {
|
|
308
|
+ err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Count(&total).Error
|
|
309
|
+ return
|
|
310
|
+}
|
|
311
|
+
|
304
|
312
|
func GetXTPatientInfo(org_id int64, patient_id int64) (info models.Patients, err error) {
|
305
|
313
|
err = readDb.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, patient_id).First(&info).Error
|
306
|
314
|
return
|
|
@@ -392,7 +400,7 @@ func DelelteProject(id int64, user_org_id int64) (err error) {
|
392
|
400
|
return
|
393
|
401
|
}
|
394
|
402
|
|
395
|
|
-func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
|
|
403
|
+func GetHisPrescription(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
396
|
404
|
err = readDb.Model(&models.HisPrescription{}).
|
397
|
405
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
398
|
406
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -401,14 +409,14 @@ func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (pres
|
401
|
409
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
402
|
410
|
}).
|
403
|
411
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
404
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
412
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
405
|
413
|
}).
|
406
|
|
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? ", org_id, record_date, patient_id).
|
|
414
|
+ Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ?", org_id, record_date, patient_id, p_type).
|
407
|
415
|
Find(&prescription).Error
|
408
|
416
|
return
|
409
|
417
|
}
|
410
|
418
|
|
411
|
|
-func GetNewHisPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
|
|
419
|
+func GetNewHisPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
412
|
420
|
err = readDb.Model(&models.HisPrescription{}).
|
413
|
421
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
414
|
422
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -417,14 +425,14 @@ func GetNewHisPrescription(org_id int64, patient_id int64, his_patient_id int64,
|
417
|
425
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
418
|
426
|
}).
|
419
|
427
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
420
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
428
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
421
|
429
|
}).
|
422
|
|
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? ", org_id, record_date, patient_id, his_patient_id).
|
|
430
|
+ Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, his_patient_id, p_type).
|
423
|
431
|
Find(&prescription).Error
|
424
|
432
|
return
|
425
|
433
|
}
|
426
|
434
|
|
427
|
|
-func GetChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
|
|
435
|
+func GetChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
428
|
436
|
err = readDb.Model(&models.HisPrescription{}).
|
429
|
437
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
430
|
438
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -433,14 +441,14 @@ func GetChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id
|
433
|
441
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
434
|
442
|
}).
|
435
|
443
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
436
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
444
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
437
|
445
|
}).
|
438
|
|
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 2 AND his_patient_id = ?", org_id, record_date, patient_id, his_patient_id).
|
|
446
|
+ Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 2 AND his_patient_id = ? AND p_type = ?", org_id, record_date, patient_id, his_patient_id, p_type).
|
439
|
447
|
Find(&prescription).Error
|
440
|
448
|
return
|
441
|
449
|
}
|
442
|
450
|
|
443
|
|
-func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
|
|
451
|
+func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
444
|
452
|
err = readDb.Model(&models.HisPrescription{}).
|
445
|
453
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
446
|
454
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -449,9 +457,9 @@ func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_
|
449
|
457
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
450
|
458
|
}).
|
451
|
459
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
452
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
460
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
453
|
461
|
}).
|
454
|
|
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? AND order_status <> 2 AND order_status <> 3", org_id, record_date, patient_id, his_patient_id).
|
|
462
|
+ Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? AND order_status <> 2 AND order_status <> 3 AND p_type = ?", org_id, record_date, patient_id, his_patient_id, p_type).
|
455
|
463
|
Find(&prescription).Error
|
456
|
464
|
return
|
457
|
465
|
}
|
|
@@ -465,9 +473,9 @@ func GetSettleHisPrescription(org_id int64, patient_id int64, his_patient_id int
|
465
|
473
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
466
|
474
|
}).
|
467
|
475
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
468
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
476
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
469
|
477
|
}).
|
470
|
|
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND his_patient_id = ?", org_id, record_date, patient_id, his_patient_id).
|
|
478
|
+ Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND his_patient_id = ? AND p_type <> 1", org_id, record_date, patient_id, his_patient_id).
|
471
|
479
|
Find(&prescription).Error
|
472
|
480
|
return
|
473
|
481
|
}
|
|
@@ -481,14 +489,14 @@ func GetMonthHisPrescription(org_id int64, patient_id int64, start_date int64, e
|
481
|
489
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
482
|
490
|
}).
|
483
|
491
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
484
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
492
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
485
|
493
|
}).
|
486
|
|
- Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 ", org_id, start_date, end_date, patient_id).
|
|
494
|
+ Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1", org_id, start_date, end_date, patient_id).
|
487
|
495
|
Find(&prescription).Error
|
488
|
496
|
return
|
489
|
497
|
}
|
490
|
498
|
|
491
|
|
-func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
|
|
499
|
+func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
492
|
500
|
err = readDb.Model(&models.HisPrescription{}).
|
493
|
501
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
494
|
502
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -497,14 +505,14 @@ func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64
|
497
|
505
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
498
|
506
|
}).
|
499
|
507
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
500
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
508
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
501
|
509
|
}).
|
502
|
|
- Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?", org_id, start_date, end_date, patient_id).
|
|
510
|
+ Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
|
503
|
511
|
Find(&prescription).Error
|
504
|
512
|
return
|
505
|
513
|
}
|
506
|
514
|
|
507
|
|
-func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
|
|
515
|
+func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
508
|
516
|
err = readDb.Model(&models.HisPrescription{}).
|
509
|
517
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
510
|
518
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -513,15 +521,15 @@ func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int
|
513
|
521
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
514
|
522
|
}).
|
515
|
523
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
516
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
524
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
517
|
525
|
}).
|
518
|
|
- Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? ", org_id, start_date, end_date, patient_id).
|
|
526
|
+ Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND p_type = ? ", org_id, start_date, end_date, patient_id, p_type).
|
519
|
527
|
Find(&prescription).Error
|
520
|
528
|
return
|
521
|
529
|
}
|
522
|
530
|
|
523
|
531
|
//未收费
|
524
|
|
-func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
|
|
532
|
+func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
525
|
533
|
err = readDb.Model(&models.HisPrescription{}).
|
526
|
534
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
527
|
535
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -530,15 +538,15 @@ func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_
|
530
|
538
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
531
|
539
|
}).
|
532
|
540
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
533
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
541
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
534
|
542
|
}).
|
535
|
|
- Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 ", org_id, start_date, end_date, patient_id).
|
|
543
|
+ Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
|
536
|
544
|
Find(&prescription).Error
|
537
|
545
|
return
|
538
|
546
|
}
|
539
|
547
|
|
540
|
548
|
//已收费
|
541
|
|
-func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
|
|
549
|
+func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
|
542
|
550
|
err = readDb.Model(&models.HisPrescription{}).
|
543
|
551
|
Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
|
544
|
552
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
|
|
@@ -547,9 +555,9 @@ func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_dat
|
547
|
555
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
548
|
556
|
}).
|
549
|
557
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
550
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
558
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
551
|
559
|
}).
|
552
|
|
- Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status = 2", org_id, start_date, end_date, patient_id).
|
|
560
|
+ Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status = 2 AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
|
553
|
561
|
Find(&prescription).Error
|
554
|
562
|
return
|
555
|
563
|
}
|
|
@@ -603,58 +611,75 @@ func (VMDrugCancelStockInfo) TableName() string {
|
603
|
611
|
}
|
604
|
612
|
|
605
|
613
|
type BaseDrugLib struct {
|
606
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
607
|
|
- DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
|
608
|
|
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
609
|
|
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
610
|
|
- DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
|
611
|
|
- DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
|
612
|
|
- DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
|
613
|
|
- DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
|
614
|
|
- DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
|
615
|
|
- DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
|
616
|
|
- DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
|
617
|
|
- DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
|
618
|
|
- DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
|
619
|
|
- MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
|
620
|
|
- MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
|
621
|
|
- MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
|
622
|
|
- UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
|
623
|
|
- RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
|
624
|
|
- LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
|
625
|
|
- DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
|
626
|
|
- Number string `gorm:"column:number" json:"number" form:"number"`
|
627
|
|
- DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
|
628
|
|
- DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
|
629
|
|
- DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
|
630
|
|
- MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
|
631
|
|
- Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
|
632
|
|
- PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
|
633
|
|
- StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
|
634
|
|
- Code string `gorm:"column:code" json:"code" form:"code"`
|
635
|
|
- IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
|
636
|
|
- IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
|
637
|
|
- Agent string `gorm:"column:agent" json:"agent" form:"agent"`
|
638
|
|
- DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
|
639
|
|
- LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
|
640
|
|
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
641
|
|
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
642
|
|
- SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
643
|
|
- PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
|
644
|
|
- Label int64 `gorm:"column:label" json:"label" form:"label"`
|
645
|
|
- Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
|
646
|
|
- IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
|
647
|
|
- IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
|
648
|
|
- IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
|
649
|
|
- IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
|
650
|
|
- IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
|
651
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
652
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
653
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
654
|
|
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
655
|
|
- DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
|
656
|
|
- HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
|
657
|
|
- LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
|
|
614
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
615
|
+ DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
|
|
616
|
+ Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
|
617
|
+ Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
|
618
|
+ DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
|
|
619
|
+ DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
|
|
620
|
+ DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
|
|
621
|
+ DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
|
|
622
|
+ DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
|
|
623
|
+ DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
|
|
624
|
+ DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
|
|
625
|
+ DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
|
|
626
|
+ DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
|
|
627
|
+ MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
|
|
628
|
+ MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
|
|
629
|
+ MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
|
|
630
|
+ MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
|
|
631
|
+ Dose float64 `gorm:"column:dose" json:"dose" form:"dose"`
|
|
632
|
+ DoseUnit string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
|
|
633
|
+ UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
|
|
634
|
+ RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
|
|
635
|
+ MinPrice float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
|
|
636
|
+ LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
|
|
637
|
+ DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
|
|
638
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
639
|
+ DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
|
|
640
|
+ DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
|
|
641
|
+ DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
|
|
642
|
+ MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
|
|
643
|
+ Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
|
|
644
|
+ PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
|
|
645
|
+ StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
|
|
646
|
+ Code string `gorm:"column:code" json:"code" form:"code"`
|
|
647
|
+ IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
|
|
648
|
+ IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
|
|
649
|
+ Agent string `gorm:"column:agent" json:"agent" form:"agent"`
|
|
650
|
+ DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
|
|
651
|
+ LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
|
|
652
|
+ DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
|
653
|
+ ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
|
654
|
+ SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
|
655
|
+ PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
|
|
656
|
+ Label int64 `gorm:"column:label" json:"label" form:"label"`
|
|
657
|
+ Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
|
|
658
|
+ IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
|
|
659
|
+ IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
|
|
660
|
+ IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
|
|
661
|
+ IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
|
|
662
|
+ IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
|
|
663
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
664
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
665
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
666
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
667
|
+ DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
|
|
668
|
+ Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
|
|
669
|
+ PrescriptionMark int64 `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
|
|
670
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
671
|
+ DrugRemark string `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
|
|
672
|
+ SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
|
|
673
|
+ DoseCode string `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
|
|
674
|
+ IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
|
|
675
|
+ HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
|
|
676
|
+ LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
|
|
677
|
+ Dosage string `gorm:"column:dosage" json:"dosage" form:"dosage"`
|
|
678
|
+ Unval string `gorm:"column:unval" json:"unval" form:"unval"`
|
|
679
|
+ PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
|
|
680
|
+ PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
|
|
681
|
+ DrugDay string `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
|
|
682
|
+
|
658
|
683
|
//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
|
659
|
684
|
OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
|
660
|
685
|
VMDrugSalesReturnInfo []*VMDrugSalesReturnInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
|
|
@@ -701,7 +726,7 @@ func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdvicePare
|
701
|
726
|
func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
|
702
|
727
|
err = readUserDb.Model(&models.UserAdminRole{}).Preload("XtHisDepartment", func(db *gorm.DB) *gorm.DB {
|
703
|
728
|
return readDb.Model(&models.XtHisDepartment{}).Where("status = 1 AND user_org_id = ?", org_id)
|
704
|
|
- }).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
|
|
729
|
+ }).Where("org_id = ? AND status = 1 AND user_type = 2", org_id).Find(&doctors).Error
|
705
|
730
|
return
|
706
|
731
|
}
|
707
|
732
|
|
|
@@ -740,8 +765,14 @@ func CreateOrderInfo(order *models.HisOrderInfo) (err error) {
|
740
|
765
|
return
|
741
|
766
|
}
|
742
|
767
|
|
743
|
|
-func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
|
744
|
|
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
|
|
768
|
+func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
|
|
769
|
+ err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
|
|
770
|
+ return
|
|
771
|
+
|
|
772
|
+}
|
|
773
|
+
|
|
774
|
+func FindHisPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64, p_type int64, his_patient_id int64) (info models.HisPrescriptionInfo, err error) {
|
|
775
|
+ err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? AND his_patient_id = ? ", org_id, record_date, patient_id, p_type, his_patient_id).First(&info).Error
|
745
|
776
|
return
|
746
|
777
|
|
747
|
778
|
}
|
|
@@ -757,7 +788,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
|
757
|
788
|
|
758
|
789
|
}
|
759
|
790
|
|
760
|
|
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string) (order []*models.HisOrder, err error, total int64) {
|
|
791
|
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string, p_type int64) (order []*models.HisOrder, err error, total int64) {
|
761
|
792
|
offset := (page - 1) * limit
|
762
|
793
|
db := readDb.Model(&models.HisOrder{})
|
763
|
794
|
|
|
@@ -778,12 +809,13 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int6
|
778
|
809
|
db = db.Where("his_order.settle_accounts_date<=?", end_time)
|
779
|
810
|
}
|
780
|
811
|
|
781
|
|
- db = db.Where("his_order.status = 1 AND his_order.user_org_id = ?", user_org_id)
|
|
812
|
+ db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ?", user_org_id, p_type)
|
782
|
813
|
|
783
|
814
|
db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
|
784
|
815
|
Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
|
785
|
|
- Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id)
|
786
|
|
-
|
|
816
|
+ Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
|
|
817
|
+ Preload("HisHospitalCheckRecord", "status = 1 AND user_org_id = ?", user_org_id)
|
|
818
|
+ db = db.Preload("HisFundSettleListResult", "status = 1")
|
787
|
819
|
db = db.Count(&total)
|
788
|
820
|
err = db.Limit(limit).Offset(offset).Order("setl_time desc,ctime").Find(&order).Error
|
789
|
821
|
return
|
|
@@ -805,6 +837,12 @@ func UpDatePrescriptionInfoNumber(user_org_id int64, id int64, number string, re
|
805
|
837
|
return
|
806
|
838
|
}
|
807
|
839
|
|
|
840
|
+func UpDateHisPrescriptionInfoNumber(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64) (err error) {
|
|
841
|
+ err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
|
|
842
|
+
|
|
843
|
+ return
|
|
844
|
+}
|
|
845
|
+
|
808
|
846
|
type HisOrder struct {
|
809
|
847
|
ID int64 `gorm:"column:id" json:"id" form:"id"`
|
810
|
848
|
UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
@@ -832,6 +870,9 @@ type HisOrder struct {
|
832
|
870
|
HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
|
833
|
871
|
HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
|
834
|
872
|
HisPrescription []*models.HisPrescription `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
|
|
873
|
+
|
|
874
|
+ FaPiaoCode string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
|
|
875
|
+ FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
|
835
|
876
|
}
|
836
|
877
|
|
837
|
878
|
func (HisOrder) TableName() string {
|
|
@@ -853,7 +894,7 @@ func GetHisPrescriptionThree(org_id int64, patient_id int64, number string) (pre
|
853
|
894
|
err = readDb.Model(&models.HisPrescription{}).
|
854
|
895
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
|
855
|
896
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
856
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
897
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
857
|
898
|
}).
|
858
|
899
|
Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
|
859
|
900
|
Where("user_org_id = ? AND status = 1 AND patient_id = ? AND batch_number=?", org_id, patient_id, number).
|
|
@@ -903,7 +944,7 @@ func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescrip
|
903
|
944
|
}
|
904
|
945
|
|
905
|
946
|
func GetHisPrescriptionOrderInfo(id int64, org_id int64) (prescriptionOrder HisPrescriptionInfo, err error) {
|
906
|
|
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ? ", id, org_id).
|
|
947
|
+ err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, org_id).
|
907
|
948
|
Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
|
908
|
949
|
Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
|
909
|
950
|
Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
|
|
@@ -915,7 +956,7 @@ func GetHisPrescriptionFour(org_id int64, patient_id int64, record_date int64, n
|
915
|
956
|
err = readDb.Model(&models.HisPrescription{}).
|
916
|
957
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
|
917
|
958
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
918
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
959
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
|
919
|
960
|
}).
|
920
|
961
|
Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND prescription_number=?", org_id, record_date, patient_id, number).
|
921
|
962
|
Find(&prescription).Error
|
|
@@ -929,7 +970,7 @@ func GetMedicalInsuranceConfig(org_id int64) (medicalInsuranceConfig models.Medi
|
929
|
970
|
}
|
930
|
971
|
|
931
|
972
|
func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
|
932
|
|
- err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
|
|
973
|
+ err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix()}).Error
|
933
|
974
|
err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
|
934
|
975
|
err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
|
935
|
976
|
|
|
@@ -1019,6 +1060,9 @@ type XtHisOrder struct {
|
1019
|
1060
|
HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
|
1020
|
1061
|
HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
|
1021
|
1062
|
HisPrescription []*models.HisPrescription `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
|
|
1063
|
+
|
|
1064
|
+ FaPiaoCode string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
|
|
1065
|
+ FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
|
1022
|
1066
|
}
|
1023
|
1067
|
|
1024
|
1068
|
func (XtHisOrder) TableName() string {
|
|
@@ -1029,7 +1073,7 @@ func GetHisPrescriptionNight(org_id int64, patient_id int64, record_date int64,
|
1029
|
1073
|
err = readDb.Model(&models.HisPrescription{}).
|
1030
|
1074
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? and prescription_id =?", org_id, prescription_id).
|
1031
|
1075
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1032
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
1076
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
|
1033
|
1077
|
}).
|
1034
|
1078
|
Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
|
1035
|
1079
|
Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
|
|
@@ -1048,18 +1092,32 @@ func DelelteAddition(id int64, user_org_id int64) (err error) {
|
1048
|
1092
|
return
|
1049
|
1093
|
}
|
1050
|
1094
|
|
|
1095
|
+func GetNewHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
|
|
1096
|
+ offset := (page - 1) * limit
|
|
1097
|
+ db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 ", org_id, record_date)
|
|
1098
|
+ if len(keywords) > 0 {
|
|
1099
|
+ keywords = "%" + keywords + "%"
|
|
1100
|
+ db = db.Joins("JOIN xt_patients as p On his_prescription_info.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
|
|
1101
|
+ }
|
|
1102
|
+ db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
|
|
1103
|
+ db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND p_type <> 1", org_id)
|
|
1104
|
+ db = db.Count(&total)
|
|
1105
|
+ err = db.Limit(limit).Offset(offset).Find(&patients).Error
|
|
1106
|
+ return
|
|
1107
|
+}
|
|
1108
|
+
|
1051
|
1109
|
func GetHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMSchedule, err error, total int64) {
|
1052
|
1110
|
offset := (page - 1) * limit
|
1053
|
1111
|
db := readDb.Model(&VMSchedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
|
1054
|
1112
|
if len(keywords) > 0 {
|
1055
|
1113
|
keywords = "%" + keywords + "%"
|
1056
|
1114
|
db = db.Joins("JOIN xt_patients as p On xt_schedule.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
|
1057
|
|
- db = db.Joins("JOIN his_prescription_info as info On xt_schedule.patient_id = info.patient_id AND info.user_org_id = ? AND info.record_date = ? AND info.prescription_number like ?", org_id, record_date, keywords)
|
|
1115
|
+ db = db.Joins("JOIN his_prescription_info as info On xt_schedule.patient_id = info.patient_id AND info.user_org_id = ? AND info.record_date = ? AND info.prescription_number like ? AND info.p_type <> 1", org_id, record_date, keywords)
|
1058
|
1116
|
}
|
1059
|
1117
|
db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
|
1060
|
1118
|
db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
|
1061
|
|
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).
|
1062
|
|
- Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1", org_id)
|
|
1119
|
+ db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND p_type <> 1", org_id).
|
|
1120
|
+ Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND p_type <> 1", org_id)
|
1063
|
1121
|
db = db.Count(&total)
|
1064
|
1122
|
err = db.Limit(limit).Offset(offset).Find(&patients).Error
|
1065
|
1123
|
return
|
|
@@ -1106,39 +1164,54 @@ func (VMHisPrescription) TableName() string {
|
1106
|
1164
|
return "his_prescription"
|
1107
|
1165
|
}
|
1108
|
1166
|
|
1109
|
|
-func GetHisPrescriptionByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
|
|
1167
|
+func GetHisPrescriptionByType(change_type int64, record_time int64, org_id int64, patient_id int64, p_type int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
|
1110
|
1168
|
if change_type == 1 { //根据日期取出上一方数据
|
1111
|
1169
|
var Id AdviceDate
|
1112
|
|
- err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
|
1113
|
|
- err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patient_id, org_id, Id.RecordDate).
|
|
1170
|
+ err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ? AND p_type = ?", patient_id, org_id, record_time, p_type).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
|
|
1171
|
+ err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND p_type = ?", patient_id, org_id, Id.RecordDate, p_type).
|
1114
|
1172
|
Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
|
1115
|
1173
|
return db.Where("status = 1 AND user_org_id = ?", org_id).
|
1116
|
1174
|
Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
|
1117
|
1175
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
1118
|
1176
|
}).
|
1119
|
1177
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1120
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
1178
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
|
1121
|
1179
|
})
|
1122
|
1180
|
}).Find(&advice).Error
|
1123
|
1181
|
|
1124
|
1182
|
} else if change_type == 2 {
|
1125
|
1183
|
var Id AdviceDate
|
1126
|
|
- err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
|
1127
|
|
- err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patient_id, org_id, Id.RecordDate).
|
|
1184
|
+ err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ? AND p_type = ?", patient_id, org_id, record_time, p_type).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
|
|
1185
|
+ err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND p_type = ?", patient_id, org_id, Id.RecordDate, p_type).
|
1128
|
1186
|
Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
|
1129
|
1187
|
return db.Where("status = 1 AND user_org_id = ?", org_id).
|
1130
|
1188
|
Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
|
1131
|
1189
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
1132
|
1190
|
}).
|
1133
|
1191
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1134
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
1192
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
|
1135
|
1193
|
})
|
1136
|
1194
|
}).Find(&advice).Error
|
1137
|
1195
|
}
|
1138
|
1196
|
return
|
1139
|
1197
|
}
|
1140
|
1198
|
|
1141
|
|
-func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
|
|
1199
|
+func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64, p_type int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
|
|
1200
|
+ err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date >= ? AND record_date <= ? AND p_type = ?", patient_id, org_id, start_time, end_time, p_type).
|
|
1201
|
+ Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
|
|
1202
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).
|
|
1203
|
+ Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
|
|
1204
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
|
1205
|
+ }).
|
|
1206
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
1207
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
|
|
1208
|
+ })
|
|
1209
|
+ }).Find(&advice).Error
|
|
1210
|
+
|
|
1211
|
+ return
|
|
1212
|
+}
|
|
1213
|
+
|
|
1214
|
+func GetMobileCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
|
1142
|
1215
|
err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date >= ? AND record_date <= ?", patient_id, org_id, start_time, end_time).
|
1143
|
1216
|
Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
|
1144
|
1217
|
return db.Where("status = 1 AND user_org_id = ?", org_id).
|
|
@@ -1146,7 +1219,7 @@ func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, pat
|
1146
|
1219
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
|
1147
|
1220
|
}).
|
1148
|
1221
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1149
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
|
1222
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
|
1150
|
1223
|
})
|
1151
|
1224
|
}).Find(&advice).Error
|
1152
|
1225
|
|
|
@@ -1227,20 +1300,21 @@ func GetHisPrescriptionByPatientID(patientID int64, orgID int64) (info models.Hi
|
1227
|
1300
|
}
|
1228
|
1301
|
|
1229
|
1302
|
type VMHisProjectTeam struct {
|
1230
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
1231
|
|
- ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
|
1232
|
|
- Price float64 `gorm:"column:price" json:"price" form:"price"`
|
1233
|
|
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
1234
|
|
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
1235
|
|
- TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
|
1236
|
|
- TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
|
1237
|
|
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
1238
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
1239
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
1240
|
|
- CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
1241
|
|
- UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
1242
|
|
- ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
1243
|
|
- VMHisProject []*VMHisProject `gorm:"-" json:"project" form:"project"`
|
|
1303
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1304
|
+ ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
|
|
1305
|
+ Price float64 `gorm:"column:price" json:"price" form:"price"`
|
|
1306
|
+ Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
|
1307
|
+ Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
|
1308
|
+ TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
|
|
1309
|
+ TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
|
|
1310
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
1311
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
1312
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1313
|
+ CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
|
1314
|
+ UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
|
1315
|
+ ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
1316
|
+ VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
|
|
1317
|
+ ItemId string `gorm:"column:item_id" json:"item_id" form:"item_id"`
|
1244
|
1318
|
}
|
1245
|
1319
|
|
1246
|
1320
|
func (VMHisProjectTeam) TableName() string {
|
|
@@ -1267,6 +1341,24 @@ func (VMHisProject) TableName() string {
|
1267
|
1341
|
return "xt_his_project"
|
1268
|
1342
|
}
|
1269
|
1343
|
|
|
1344
|
+type VMItemProjectList struct {
|
|
1345
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1346
|
+ Number int64 `gorm:"column:number" json:"number" form:"number"`
|
|
1347
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
1348
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
1349
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1350
|
+ CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
|
1351
|
+ UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
|
1352
|
+ TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
|
|
1353
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
1354
|
+ VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
|
|
1355
|
+ GoodInfo GoodInfo `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
|
|
1356
|
+}
|
|
1357
|
+
|
|
1358
|
+func (VMItemProjectList) TableName() string {
|
|
1359
|
+ return "xt_his_project_list"
|
|
1360
|
+}
|
|
1361
|
+
|
1270
|
1362
|
type VMHisPrescriptionTwo struct {
|
1271
|
1363
|
ID int64 `gorm:"column:id" json:"id" form:"id"`
|
1272
|
1364
|
UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
@@ -1284,10 +1376,10 @@ func (VMHisPrescriptionTwo) TableName() string {
|
1284
|
1376
|
func GetAllProjectTeamList(orgid int64) (project []*VMHisProjectTeam, err error) {
|
1285
|
1377
|
err = XTReadDB().Model(&VMHisProjectTeam{}).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
|
1286
|
1378
|
for _, item := range project {
|
1287
|
|
- var project_item []*VMHisProject
|
1288
|
|
- ids := strings.Split(item.ProjectId, ",")
|
1289
|
|
- XTReadDB().Model(&VMHisProject{}).Where("status = 1 AND id IN (?)", ids).Find(&project_item)
|
1290
|
|
- item.VMHisProject = append(item.VMHisProject, project_item...)
|
|
1379
|
+ var project_item []*VMItemProjectList
|
|
1380
|
+ ids := strings.Split(item.ItemId, ",")
|
|
1381
|
+ XTReadDB().Model(&VMItemProjectList{}).Where("status = 1 AND id IN (?)", ids).Preload("VMHisProject", "status = 1 AND user_org_id = ?", orgid).Preload("GoodInfo", "status = 1 AND org_id = ?", orgid).Find(&project_item)
|
|
1382
|
+ item.VMItemProjectList = append(item.VMItemProjectList, project_item...)
|
1291
|
1383
|
}
|
1292
|
1384
|
return
|
1293
|
1385
|
}
|
|
@@ -1323,28 +1415,40 @@ func (HisDoctorAdviceInfo) TableName() string {
|
1323
|
1415
|
}
|
1324
|
1416
|
|
1325
|
1417
|
type HisPrescriptionProject struct {
|
1326
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
1327
|
|
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
1328
|
|
- Price float64 `gorm:"column:price" json:"price" form:"price"`
|
1329
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
1330
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
1331
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
1332
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
1333
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
1334
|
|
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
1335
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
1336
|
|
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
1337
|
|
- Count int64 `gorm:"column:count" json:"count" form:"count"`
|
1338
|
|
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
1339
|
|
- MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
|
1340
|
|
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
1341
|
|
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
1342
|
|
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
1343
|
|
- Day string `gorm:"column:day" json:"day" form:"day"`
|
1344
|
|
- VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
|
|
1418
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1419
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
1420
|
+ Price float64 `gorm:"column:price" json:"price" form:"price"`
|
|
1421
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
1422
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1423
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
1424
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
1425
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
1426
|
+ HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
|
1427
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
1428
|
+ PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
|
1429
|
+ Count int64 `gorm:"column:count" json:"count" form:"count"`
|
|
1430
|
+ FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
|
1431
|
+ MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
|
|
1432
|
+ SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
|
1433
|
+ DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
|
1434
|
+ ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
|
1435
|
+ Day string `gorm:"column:day" json:"day" form:"day"`
|
|
1436
|
+ VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
|
|
1437
|
+ VMGoodInfo VMGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
|
|
1438
|
+
|
1345
|
1439
|
Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
1346
|
1440
|
Unit string `gorm:"column:unit" json:"unit" form:"unit"`
|
1347
|
1441
|
VMHisPrescriptionTwo VMHisPrescriptionTwo `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"prescription"`
|
|
1442
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
1443
|
+
|
|
1444
|
+ Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
|
|
1445
|
+ ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
|
|
1446
|
+ ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
|
|
1447
|
+ ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
|
|
1448
|
+ CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
|
|
1449
|
+ CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
|
|
1450
|
+ Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
|
|
1451
|
+ StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
|
1348
|
1452
|
}
|
1349
|
1453
|
|
1350
|
1454
|
func (HisPrescriptionProject) TableName() string {
|
|
@@ -1378,7 +1482,7 @@ func (HisOrderInfo) TableName() string {
|
1378
|
1482
|
|
1379
|
1483
|
func GetHisOrderDetailByNumber(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
|
1380
|
1484
|
err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
1381
|
|
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id)
|
|
1485
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
|
1382
|
1486
|
}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
|
1383
|
1487
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
|
1384
|
1488
|
}).Find(&order).Error
|
|
@@ -1531,7 +1635,7 @@ func GetNewHisOrder(user_org_id int64, mdtrt_id string, patient_id int64) (order
|
1531
|
1635
|
Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
|
1532
|
1636
|
Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
|
1533
|
1637
|
Order("ctime desc").
|
1534
|
|
- Find(&order).Error
|
|
1638
|
+ Last(&order).Error
|
1535
|
1639
|
return
|
1536
|
1640
|
}
|
1537
|
1641
|
|
|
@@ -1601,10 +1705,20 @@ func (NewTempPatients) TableName() string {
|
1601
|
1705
|
func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
|
1602
|
1706
|
db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
1603
|
1707
|
db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
|
1604
|
|
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrder", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
|
|
1708
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
|
1605
|
1709
|
})
|
1606
|
|
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
|
1607
|
|
- err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Find(&patients).Error
|
|
1710
|
+ db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
|
|
1711
|
+ err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Find(&patients).Error
|
|
1712
|
+
|
|
1713
|
+ for _, item := range patients {
|
|
1714
|
+ for _, sumItem := range item.HisPatient {
|
|
1715
|
+ if len(sumItem.VMHisOrders) > 0 {
|
|
1716
|
+ sumItem.VMHisOrder.OrderStatus = sumItem.VMHisOrders[len(sumItem.VMHisOrders)-1].OrderStatus
|
|
1717
|
+ }
|
|
1718
|
+ }
|
|
1719
|
+
|
|
1720
|
+ }
|
|
1721
|
+
|
1608
|
1722
|
return
|
1609
|
1723
|
}
|
1610
|
1724
|
|
|
@@ -1628,6 +1742,9 @@ type CustomInComeStatistics struct {
|
1628
|
1742
|
DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
|
1629
|
1743
|
PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
|
1630
|
1744
|
AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
|
|
1745
|
+
|
|
1746
|
+ FaPiaoCode string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
|
|
1747
|
+ FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
|
1631
|
1748
|
}
|
1632
|
1749
|
|
1633
|
1750
|
func (CustomInComeStatistics) TableName() string {
|
|
@@ -1667,3 +1784,77 @@ func GetDayIncomeDetailStatisticsData(org_id int64, keywords string, start_time
|
1667
|
1784
|
}
|
1668
|
1785
|
return
|
1669
|
1786
|
}
|
|
1787
|
+
|
|
1788
|
+//func GetHisPatientInfoList(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
|
|
1789
|
+// err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
|
|
1790
|
+// return
|
|
1791
|
+//}
|
|
1792
|
+
|
|
1793
|
+func CreateHisPrescriptionTemplate(template *models.HisPrescriptionTemplate) (err error) {
|
|
1794
|
+ err = writeDb.Create(&template).Error
|
|
1795
|
+ return
|
|
1796
|
+
|
|
1797
|
+}
|
|
1798
|
+
|
|
1799
|
+func CreateHisPrescriptionAdviceTemplate(s *models.HisPrescriptionAdviceTemplate) (err error) {
|
|
1800
|
+ err = writeDb.Save(&s).Error
|
|
1801
|
+ return
|
|
1802
|
+}
|
|
1803
|
+
|
|
1804
|
+func CreateHisPrescriptionInfoTemplate(s *models.HisPrescriptionInfoTemplate) (err error) {
|
|
1805
|
+ err = writeDb.Save(&s).Error
|
|
1806
|
+ return
|
|
1807
|
+}
|
|
1808
|
+
|
|
1809
|
+func CreateHisPrescriptionProjectTemplate(project *models.HisPrescriptionProjectTemplate) (err error) {
|
|
1810
|
+ err = writeDb.Save(&project).Error
|
|
1811
|
+ return
|
|
1812
|
+}
|
|
1813
|
+
|
|
1814
|
+func GetPatientSch(patient_id int64, sch_date int64, org_id int64) (sch models.Schedule, err error) {
|
|
1815
|
+ err = readDb.Model(&models.Schedule{}).Where("user_org_id = ? AND patient_id = ? AND schedule_date = ? AND status = 1", org_id, patient_id, sch_date).First(&sch).Error
|
|
1816
|
+ return
|
|
1817
|
+}
|
|
1818
|
+
|
|
1819
|
+func GetHisPrescriptionBySchMode(mode_id int64, patient_id int64, org_id int64) (prescription models.HisPrescriptionTemplate, err error) {
|
|
1820
|
+ err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1 AND mode = ? AND patient_id = ?", org_id, mode_id, patient_id).Last(&prescription).Error
|
|
1821
|
+ return
|
|
1822
|
+}
|
|
1823
|
+
|
|
1824
|
+func GetHisPrescriptionTemplate(template_id int64, org_id int64) (prescription []*models.HisPrescriptionInfoTemplate, err error) {
|
|
1825
|
+ err = readDb.Model(&models.HisPrescriptionInfoTemplate{}).
|
|
1826
|
+ Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
|
|
1827
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id)
|
|
1828
|
+ }).
|
|
1829
|
+ Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
|
|
1830
|
+ return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisProject").Preload("GoodInfo", "status=1")
|
|
1831
|
+ }).
|
|
1832
|
+ Where("status = 1 AND p_template_id = ? ", template_id).
|
|
1833
|
+ Find(&prescription).Error
|
|
1834
|
+ return
|
|
1835
|
+}
|
|
1836
|
+
|
|
1837
|
+func FindHisConsumablesByID(orgID int64, patient_id int64, recordDate int64, good_id int64) (consumables models.DialysisBeforePrepare, err error) {
|
|
1838
|
+ err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 AND good_id = ?", orgID, patient_id, recordDate, good_id).First(&consumables).Error
|
|
1839
|
+ return
|
|
1840
|
+}
|
|
1841
|
+
|
|
1842
|
+func UpdateConsumables(consumables *models.DialysisBeforePrepare) (err error) {
|
|
1843
|
+ err = writeDb.Save(&consumables).Error
|
|
1844
|
+ return
|
|
1845
|
+}
|
|
1846
|
+
|
|
1847
|
+func GetHisPrescriptionProjectsByID(id int64) (projects []*models.HisPrescriptionProject, err error) {
|
|
1848
|
+ err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("prescription_id = ? AND status = 1", id).Find(&projects).Error
|
|
1849
|
+ return
|
|
1850
|
+}
|
|
1851
|
+
|
|
1852
|
+func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
|
|
1853
|
+ err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1", user_org_id, patient_id, record_time).Find(&projects).Error
|
|
1854
|
+ return
|
|
1855
|
+}
|
|
1856
|
+
|
|
1857
|
+func GetHisPrescriptionProjectByID(id int64) (projects models.HisPrescriptionProject, err error) {
|
|
1858
|
+ err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("id = ? AND status = 1", id).First(&projects).Error
|
|
1859
|
+ return
|
|
1860
|
+}
|