|
@@ -614,27 +614,25 @@ func GetManyDrugs(orgid int64, keyword string) (map[int64]models.PharmacyBaseDru
|
614
|
614
|
// 查询(
|
615
|
615
|
func GetTodayMedicine(stime, etime, orgid, is_medicine int64, keyword string) (finlly []*models.ListOfDrugs, err error) {
|
616
|
616
|
InitDrugidIsNil(orgid, stime, etime)
|
617
|
|
-
|
618
|
|
- fmt.Println("startime==========================", stime)
|
619
|
617
|
var tmp []*models.TmpLLL
|
620
|
618
|
if is_medicine == 0 {
|
621
|
619
|
if keyword != "" {
|
622
|
620
|
keyword = "%" + keyword + "%"
|
623
|
621
|
err = XTReadDB().Raw("select distinct drug_id from his_doctor_advice_info where "+
|
624
|
|
- "status = 1 and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
622
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
625
|
623
|
"drug_id in (select id from xt_base_drug where org_id = ? and drug_name like ? and is_pharmacy = 1) "+
|
626
|
624
|
"union "+
|
627
|
625
|
"select distinct drug_id from xt_doctor_advice where "+
|
628
|
|
- "status = 1 and (advice_type = 2 or advice_type = 3) and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
626
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
629
|
627
|
"drug_id in (select id from xt_base_drug where org_id = ? and drug_name like ? and is_pharmacy = 1)",
|
630
|
628
|
stime, etime, orgid, is_medicine, orgid, keyword, stime, etime, orgid, is_medicine, orgid, keyword).Scan(&tmp).Error
|
631
|
629
|
} else {
|
632
|
630
|
err = XTReadDB().Raw("select distinct drug_id from his_doctor_advice_info where "+
|
633
|
|
- "status = 1 and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
631
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
634
|
632
|
"drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1) "+
|
635
|
633
|
"union "+
|
636
|
634
|
"select distinct drug_id from xt_doctor_advice where "+
|
637
|
|
- "status = 1 and (advice_type = 2 or advice_type = 3) and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
635
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
638
|
636
|
"drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1) ",
|
639
|
637
|
stime, etime, orgid, is_medicine, orgid, stime, etime, orgid, is_medicine, orgid).Scan(&tmp).Error
|
640
|
638
|
}
|
|
@@ -645,20 +643,20 @@ func GetTodayMedicine(stime, etime, orgid, is_medicine int64, keyword string) (f
|
645
|
643
|
if keyword != "" {
|
646
|
644
|
keyword = "%" + keyword + "%"
|
647
|
645
|
err = XTReadDB().Raw("select distinct drug_id from his_doctor_advice_info where "+
|
648
|
|
- "status = 1 and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
646
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
649
|
647
|
"drug_id in (select id from xt_base_drug where org_id = ? and drug_name like ? and is_pharmacy = 1) "+
|
650
|
648
|
"union "+
|
651
|
649
|
"select distinct drug_id from xt_doctor_advice where "+
|
652
|
|
- "status = 1 and (advice_type = 2 or advice_type = 3) and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
650
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
653
|
651
|
"drug_id in (select id from xt_base_drug where org_id = ? and drug_name like ? and is_pharmacy = 1)",
|
654
|
652
|
stime, etime, orgid, is_medicine, orgid, keyword, stime, etime, orgid, is_medicine, orgid, keyword).Scan(&tmp).Error
|
655
|
653
|
} else {
|
656
|
654
|
err = XTReadDB().Raw("select distinct drug_id from his_doctor_advice_info where "+
|
657
|
|
- "status = 1 and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
655
|
+ "status = 1 and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
658
|
656
|
"drug_id in (select id from xt_base_drug where org_id = ? and status = 1) "+
|
659
|
657
|
"union "+
|
660
|
658
|
"select distinct drug_id from xt_doctor_advice where "+
|
661
|
|
- "status = 1 and (advice_type = 2 or advice_type = 3) and created_time >= ? and created_time <= ? and user_org_id = ? and is_medicine = ? and "+
|
|
659
|
+ "status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and user_org_id = ? and is_medicine = ? and "+
|
662
|
660
|
"drug_id in (select id from xt_base_drug where org_id = ? and status = 1) ",
|
663
|
661
|
stime, etime, orgid, is_medicine, orgid, stime, etime, orgid, is_medicine, orgid).Scan(&tmp).Error
|
664
|
662
|
}
|
|
@@ -1065,6 +1063,19 @@ func UpdateIsAdvice(id int64) (err error) {
|
1065
|
1063
|
return err
|
1066
|
1064
|
}
|
1067
|
1065
|
|
|
1066
|
+func GetHisPrescriptionByStartTime(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
|
|
1067
|
+
|
|
1068
|
+ err = XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date>=? and record_date<=? and status=1 and is_medicine =1", org_id, patient_id, start_time, end_time).Find(&prescription).Error
|
|
1069
|
+ return prescription, err
|
|
1070
|
+}
|
|
1071
|
+
|
|
1072
|
+func ModiftyPrescpiton(id int64) (models.HisPrescription, error) {
|
|
1073
|
+
|
|
1074
|
+ prescription := models.HisPrescription{}
|
|
1075
|
+ err := XTWriteDB().Model(&prescription).Where("id = ? and status=1", id).Updates(map[string]interface{}{"is_medicine": 0}).Error
|
|
1076
|
+ return prescription, err
|
|
1077
|
+}
|
|
1078
|
+
|
1068
|
1079
|
// 患者退药按钮点击
|
1069
|
1080
|
func DrugWithdrawal(orgid, patient_id, stime, etime, creater int64) (err error) {
|
1070
|
1081
|
//开事务
|