Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 1 year ago
parent
commit
1fa6377ccb

+ 4 - 4
controllers/base_api_controller.go View File

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 11
84
-		subscibe.OrgId = 10138 //机构id 10344
84
+		subscibe.OrgId = 10344 //机构id 10344
85 85
 		subscibe.PeriodStart = 1547447814
86 86
 		subscibe.PeriodEnd = 1550039814
87 87
 		subscibe.State = 1
@@ -91,7 +91,7 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 10138 //机构id小英9675或4
94
+		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
95 95
 		adminUserInfo.CurrentAppId = 3244  //4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 11
329
-		subscibe.OrgId = 10138 //机构id小英10344或4
329
+		subscibe.OrgId = 10344 //机构id小英10344或4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -336,7 +336,7 @@ func (this *BaseServeAPIController) Prepare() {
336 336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337 337
 		subscibes[4] = &subscibe
338 338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 10138 //机构id小英9675或4
339
+		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
340 340
 		adminUserInfo.CurrentAppId = 3244  //4
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes

+ 11 - 10
controllers/dialysis_api_controller.go View File

@@ -2536,13 +2536,14 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2536 2536
 		if dialysisFinish.ID == 0 {
2537 2537
 			service.CreateDialysisFinish(finish)
2538 2538
 		}
2539
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 {
2539
+
2540
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 {
2540 2541
 			var dewater_amount float64
2541 2542
 			dewater_amount = 0
2542 2543
 			if dry_weight > 0 {
2543 2544
 				dewater_amount = weight_before - dry_weight - additional_weight
2544 2545
 
2545
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 {
2546
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 {
2546 2547
 					dewater_amount = dewater_amount * 1000
2547 2548
 				}
2548 2549
 
@@ -2586,8 +2587,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2586 2587
 			// 插入透析处方
2587 2588
 			if dialysisPrescribe == nil && dialysisSolution != nil {
2588 2589
 				var newprescribe models.DialysisPrescription
2589
-				newprescribe.UserOrgId = dialysisSolution.UserOrgId
2590
-				newprescribe.PatientId = dialysisSolution.PatientId
2590
+				newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
2591
+				newprescribe.PatientId = patient
2591 2592
 				newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
2592 2593
 				newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
2593 2594
 				newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
@@ -2659,8 +2660,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2659 2660
 			if dialysisPrescribe == nil && dialysisSolution == nil {
2660 2661
 				if lastDialysisPrescribe != nil {
2661 2662
 					var newprescribe models.DialysisPrescription
2662
-					newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
2663
-					newprescribe.PatientId = lastDialysisPrescribe.PatientId
2663
+					newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
2664
+					newprescribe.PatientId = patient
2664 2665
 					newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
2665 2666
 					newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
2666 2667
 					newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
@@ -2889,8 +2890,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2889 2890
 		// 插入透析处方
2890 2891
 		if dialysisPrescribe == nil && dialysisSolution != nil {
2891 2892
 			var newprescribe models.DialysisPrescription
2892
-			newprescribe.UserOrgId = dialysisSolution.UserOrgId
2893
-			newprescribe.PatientId = dialysisSolution.PatientId
2893
+			newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
2894
+			newprescribe.PatientId = patient
2894 2895
 			newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
2895 2896
 			newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
2896 2897
 			newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
@@ -2961,8 +2962,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2961 2962
 		if dialysisPrescribe == nil && dialysisSolution == nil {
2962 2963
 			if lastDialysisPrescribe != nil {
2963 2964
 				var newprescribe models.DialysisPrescription
2964
-				newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
2965
-				newprescribe.PatientId = lastDialysisPrescribe.PatientId
2965
+				newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
2966
+				newprescribe.PatientId = patient
2966 2967
 				newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
2967 2968
 				newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
2968 2969
 				newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi

+ 2 - 2
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -2600,9 +2600,9 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2600 2600
 	if evaluation.DryWeight > 0 {
2601 2601
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
2602 2602
 
2603
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 {
2603
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 {
2604 2604
 
2605
-			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 {
2605
+			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 {
2606 2606
 				dewater_amount = dewater_amount * 1000
2607 2607
 			}
2608 2608
 

+ 2 - 1
controllers/patient_api_controller.go View File

@@ -109,6 +109,7 @@ func (c *PatientApiController) GetPatientsList() {
109 109
 	isscheduling, _ := c.GetInt64("isscheduling", 0)
110 110
 	isprescription, _ := c.GetInt64("isprescription", 0)
111 111
 	patientSoureType, _ := c.GetInt64("patientSoureType")
112
+	nurse, _ := c.GetInt64("nurse")
112 113
 	if page <= 0 {
113 114
 		page = 1
114 115
 	}
@@ -147,7 +148,7 @@ func (c *PatientApiController) GetPatientsList() {
147 148
 
148 149
 	var patients []*models.Patients
149 150
 	var total int64
150
-	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime, patientSoureType)
151
+	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime, patientSoureType, nurse)
151 152
 
152 153
 	c.ServeSuccessJSON(map[string]interface{}{
153 154
 		"patients": patients,

+ 1 - 1
controllers/self_drug_api_congtroller.go View File

@@ -3917,7 +3917,7 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3917 3917
 
3918 3918
 		//获取期末结余
3919 3919
 		endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
3920
-
3920
+		fmt.Println("endFlow2222222222222222", endFlow)
3921 3921
 		item.DrugEndFlow = endFlow
3922 3922
 		//获取期初结余入库数量
3923 3923
 		//startDrugInfo, _ := service.GetDrugWarehouseInfoStart(item.ID, orgId, startTime)

+ 40 - 0
controllers/sign_api_controller.go View File

@@ -86,6 +86,8 @@ func SignApiRegistRouters() {
86 86
 
87 87
 	beego.Router("/api/device/tocheckinformation", &SignApiController{}, "Get:ToCheckInformation")
88 88
 
89
+	beego.Router("/api/device/toautodrug", &SignApiController{}, "Get:ToAutoDrug")
90
+
89 91
 }
90 92
 
91 93
 // 短信服务接口
@@ -1143,3 +1145,41 @@ func (this *SignApiController) ToCheckInformation() {
1143 1145
 		"informationOne": informationOne,
1144 1146
 	})
1145 1147
 }
1148
+
1149
+func (this *SignApiController) ToAutoDrug() {
1150
+
1151
+	//advice, _ := service.GetAutoDrugList(9919)
1152
+	//
1153
+	//for _, item := range advice {
1154
+	//	//查找该患者是否出库过
1155
+	//	outList, _ := service.GetDrugAutoWarehouseOutList(item.PatientId, item.UserOrgId, item.DrugId, item.AdviceDate)
1156
+	//	if outList.ID == 0 {
1157
+	//		service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1158
+	//	}
1159
+	//}
1160
+
1161
+	prescriptionList, _ := service.GetAllPrescriptionList(10579)
1162
+
1163
+	for _, item := range prescriptionList {
1164
+		var DialysisMachineName string
1165
+		if len(item.DialysisDialyszers) > 0 {
1166
+			DialysisMachineName = item.DialysisDialyszers
1167
+		}
1168
+		if len(item.DialyzerPerfusionApparatus) > 0 {
1169
+			DialysisMachineName = DialysisMachineName + "," + item.DialyzerPerfusionApparatus
1170
+		}
1171
+
1172
+		if len(item.DialysisIrrigation) > 0 {
1173
+			DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
1174
+		}
1175
+
1176
+		if len(item.DialysisStrainer) > 0 {
1177
+			DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
1178
+		}
1179
+		DialysisMachineName = DialysisMachineName
1180
+		service.UpdateSchPatient(item.PatientId, item.RecordDate, item.UserOrgId, DialysisMachineName)
1181
+	}
1182
+	this.ServeSuccessJSON(map[string]interface{}{
1183
+		"msg": "ok",
1184
+	})
1185
+}

+ 41 - 11
service/patient_service.go View File

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"XT_New/utils"
5 6
 	"encoding/json"
6 7
 	"fmt"
7 8
 	"strconv"
@@ -12,7 +13,7 @@ import (
12 13
 )
13 14
 
14 15
 // GetPatientList 返回患者的列表
15
-func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64) (patients []*models.Patients, total int64, err error) {
16
+func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64, nurse int64) (patients []*models.Patients, total int64, err error) {
16 17
 
17 18
 	db := readDb.Table("xt_patients as p").Where("p.status=1")
18 19
 	if orgID > 0 {
@@ -68,6 +69,9 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
68 69
 	if patientSoureType > 0 {
69 70
 		db = db.Where("p.patient_source =?", patientSoureType)
70 71
 	}
72
+	if nurse > 0 {
73
+		db = db.Where("p.head_nurse_id = ?", nurse)
74
+	}
71 75
 
72 76
 	offset := (page - 1) * limit
73 77
 	if lapseto == 2 || lapseto == 3 {
@@ -75,7 +79,13 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
75 79
 
76 80
 	}
77 81
 	if lapseto != 2 && lapseto != 3 {
78
-		err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
82
+		if orgID != 10579 {
83
+			err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
84
+		}
85
+
86
+		if orgID == 10579 {
87
+			err = db.Order("p.dialysis_no asc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
88
+		}
79 89
 
80 90
 	}
81 91
 
@@ -2925,17 +2935,30 @@ func UpdateDialysisBefor(dislysis models.XtAssessmentBeforeDislysis, id int64) e
2925 2935
 
2926 2936
 func GetAllSchedulesByPatientInfo(org_id int64, patient_id int64, mode_id int64) ([]Schedule, error) {
2927 2937
 	var record []Schedule
2928
-	loc, _ := time.LoadLocation("Local")
2929
-	date, _ := time.ParseInLocation("2006-01-02 15:04:05", time.Now().Format("2006-01-02")+" 00:00:00", loc)
2930
-
2931
-	err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >= ? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", date, patient_id, org_id, mode_id).Find(&record).Error
2932
-	if err != nil {
2933
-		if err == gorm.ErrRecordNotFound {
2934
-			return nil, nil
2935
-		} else {
2936
-			return nil, err
2938
+	if org_id == 10597 {
2939
+		timeNowStr := time.Now().Format("2006-01-02")
2940
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2941
+		err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", timeNewDate.Unix(), patient_id, org_id, mode_id).Find(&record).Error
2942
+		if err != nil {
2943
+			if err == gorm.ErrRecordNotFound {
2944
+				return nil, nil
2945
+			} else {
2946
+				return nil, err
2947
+			}
2948
+		}
2949
+	} else {
2950
+		timeNowStr := time.Now().Format("2006-01-02")
2951
+		timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
2952
+		err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >= ? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", timeNewDate.Unix(), patient_id, org_id, mode_id).Find(&record).Error
2953
+		if err != nil {
2954
+			if err == gorm.ErrRecordNotFound {
2955
+				return nil, nil
2956
+			} else {
2957
+				return nil, err
2958
+			}
2937 2959
 		}
2938 2960
 	}
2961
+
2939 2962
 	return record, nil
2940 2963
 }
2941 2964
 
@@ -3285,3 +3308,10 @@ func GetPatientDetailInformedConsent(patient_id int64, org_id int64) (models.XtP
3285 3308
 	err := XTReadDB().Where("id = ? and status=1 and user_org_id =?", patient_id, org_id).Find(&patients).Error
3286 3309
 	return patients, err
3287 3310
 }
3311
+
3312
+func GetAllPrescriptionList(org_id int64) (prescription []*models.DialysisPrescription, err error) {
3313
+
3314
+	err = XTReadDB().Where("user_org_id = ? and status =1", org_id).Find(&prescription).Error
3315
+
3316
+	return prescription, err
3317
+}

+ 4 - 4
service/self_drug_service.go View File

@@ -2841,13 +2841,13 @@ func GetStartLastFLow(goodid int64, orgid int64, startime int64, storehouse_id i
2841 2841
 func GetStartLastFLowTwenty(goodid int64, orgid int64, startime int64) (models.VmStockFlowTwenty, error) {
2842 2842
 
2843 2843
 	flwo := models.VmStockFlowTwenty{}
2844
-	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime < ?", goodid, orgid, startime).Last(&flwo).Error
2844
+	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime < ?", goodid, orgid, startime).Order("ctime desc").Last(&flwo).Error
2845 2845
 	return flwo, err
2846 2846
 }
2847 2847
 
2848 2848
 func GetEndLastFlow(goodid int64, orgid int64, endtime int64, storehouse_id int64) (models.VmStockFlowTwenty, error) {
2849 2849
 	flwo := models.VmStockFlowTwenty{}
2850
-	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime <= ? and storehouse_id= ?", goodid, orgid, endtime, storehouse_id).Last(&flwo).Error
2850
+	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime <= ? and storehouse_id= ?", goodid, orgid, endtime, storehouse_id).Order("ctime desc").Last(&flwo).Error
2851 2851
 	return flwo, err
2852 2852
 }
2853 2853
 
@@ -2884,14 +2884,14 @@ func GetDrugNewPurchaseStockQuery(good_type int64, keyword string, page int64, l
2884 2884
 func GetDrugStartFlow(drug_id int64, user_org_id int64, startime int64) (models.DrugFlowTwenty, error) {
2885 2885
 
2886 2886
 	flow := models.DrugFlowTwenty{}
2887
-	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<? and status = 1", drug_id, user_org_id, startime).Last(&flow).Error
2887
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<? and status = 1", drug_id, user_org_id, startime).Order("ctime desc").Last(&flow).Error
2888 2888
 	return flow, err
2889 2889
 }
2890 2890
 
2891 2891
 func GetDrugEndFlow(drug_id int64, user_org_id int64, endtime int64) (models.DrugFlowTwenty, error) {
2892 2892
 
2893 2893
 	flow := models.DrugFlowTwenty{}
2894
-	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<=? and status = 1", drug_id, user_org_id, endtime).Last(&flow).Error
2894
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<=? and status = 1", drug_id, user_org_id, endtime).Order("ctime desc").Last(&flow).Error
2895 2895
 	return flow, err
2896 2896
 }
2897 2897
 

+ 22 - 0
service/sign_service.go View File

@@ -2074,3 +2074,25 @@ func UpdateBaseList(id int64, firstleterr string) error {
2074 2074
 	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status =1", id, firstleterr).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
2075 2075
 	return err
2076 2076
 }
2077
+
2078
+func GetAutoDrugList(user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2079
+
2080
+	err = XTReadDB().Where("user_org_id =? and status =1 and advice_date = 1700582400 and drug_id =239", user_org_id).Find(&advice).Error
2081
+
2082
+	return advice, err
2083
+}
2084
+
2085
+func GetDrugAutoWarehouseOutList(patient_id int64, user_org_id int64, drug_id int64, advice_date int64) (models.DrugWarehouseOutInfo, error) {
2086
+
2087
+	info := models.DrugWarehouseOutInfo{}
2088
+
2089
+	err2 := XTReadDB().Where("patient_id = ? and org_id = ? and drug_id = ? and sys_record_time =? and status=1", patient_id, user_org_id, drug_id, advice_date).Find(&info).Error
2090
+
2091
+	return info, err2
2092
+}
2093
+
2094
+func UpdateSchPatient(patient_id int64, schedule_date int64, user_org_id int64, DialysisMachineName string) error {
2095
+
2096
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("patient_id =? and schedule_date =? and user_org_id =?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"dialysis_machine_name": DialysisMachineName}).Error
2097
+	return err
2098
+}