28169 4 miesięcy temu
rodzic
commit
d2d0c983ae

+ 134 - 3
controllers/his_api_controller.go Wyświetl plik

@@ -106,7 +106,93 @@ func HisManagerApiRegistRouters() {
106 106
 
107 107
 	beego.Router("/api/getfapiaonumber", &HisApiController{}, "get:GetFaPiaoNumber")
108 108
 
109
+	//beego.Router("/api/associationprescription", &HisApiController{}, "get:AssociationHisPrescription")
110
+	//beego.Router("/api/checkhispatient", &HisApiController{}, "get:CheckHisPatient")
111
+
109 112
 }
113
+
114
+//func (c *HisApiController) CheckHisPatient() {
115
+//	record_date := c.GetString("record_date")
116
+//	patient_id, _ := c.GetInt64("patient_id")
117
+//
118
+//	timeLayout := "2006-01-02"
119
+//	loc, _ := time.LoadLocation("Local")
120
+//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
121
+//	if err != nil {
122
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
123
+//		return
124
+//	}
125
+//	recordDateTime := theTime.Unix()
126
+//	adminInfo := c.GetAdminUserInfo()
127
+//	patients, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
128
+//	if len(patients) > 1 {
129
+//		ps, _ := service.GetHisPrescriptionByHisPatientID(recordDateTime, adminInfo.CurrentOrgId, patient_id)
130
+//		if len(ps) > 0 {
131
+//			c.ServeSuccessJSON(map[string]interface{}{
132
+//				"status": 1,
133
+//				"msg":    "关联",
134
+//				"ps":     ps,
135
+//			})
136
+//		} else {
137
+//			c.ServeSuccessJSON(map[string]interface{}{
138
+//				"status": 0,
139
+//				"msg":    "无需关联",
140
+//			})
141
+//		}
142
+//	} else {
143
+//		c.ServeSuccessJSON(map[string]interface{}{
144
+//			"status": 0,
145
+//			"msg":    "无需关联",
146
+//		})
147
+//		return
148
+//	}
149
+//}
150
+//func (c *HisApiController) AssociationHisPrescription() {
151
+//	record_date, _ := c.GetInt64("record_date")
152
+//	his_patient_id, _ := c.GetInt64("his_patient_id")
153
+//	patient_id, _ := c.GetInt64("patient_id")
154
+//	p_ids := c.GetString("p_ids")
155
+//	p_ids_arr := strings.Split(p_ids, ",")
156
+//	his_patient, _ := service.GetHisPatientByIdThree(his_patient_id)
157
+//	if his_patient_id == 0 || his_patient.ID == 0 {
158
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
159
+//		return
160
+//	}
161
+//	err := service.UpdateHisPrescriptionHisIDByPID(his_patient_id, patient_id, record_date, c.GetAdminUserInfo().CurrentOrgId, p_ids_arr)
162
+//	if err == nil {
163
+//		c.ServeSuccessJSON(map[string]interface{}{
164
+//			"msg": "关联处方成功",
165
+//		})
166
+//		return
167
+//	} else {
168
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
169
+//		return
170
+//	}
171
+//}
172
+
173
+//func (c *HisApiController) AssociationHisPrescription() {
174
+//	record_date, _ := c.GetInt64("record_date")
175
+//	his_patient_id, _ := c.GetInt64("his_patient_id")
176
+//	patient_id, _ := c.GetInt64("patient_id")
177
+//	p_ids := c.GetString("p_ids")
178
+//	p_ids_arr := strings.Split(p_ids, ",")
179
+//	his_patient, _ := service.GetHisPatientByIdThree(his_patient_id)
180
+//	if his_patient_id == 0 || his_patient.ID == 0 {
181
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
182
+//		return
183
+//	}
184
+//	err := service.UpdateHisPrescriptionHisIDByPID(his_patient_id, patient_id, record_date, c.GetAdminUserInfo().CurrentOrgId, p_ids_arr)
185
+//	if err == nil {
186
+//		c.ServeSuccessJSON(map[string]interface{}{
187
+//			"msg": "关联处方成功",
188
+//		})
189
+//		return
190
+//	} else {
191
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
192
+//		return
193
+//	}
194
+//}
195
+
110 196
 func (c *HisApiController) GetFaPiaoNumber() {
111 197
 	max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
112 198
 	count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
@@ -1845,11 +1931,16 @@ func (c *HisApiController) CreateHisPrescription() {
1845 1931
 								//查询该药品是否存在开药记录
1846 1932
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
1847 1933
 
1934
+								fmt.Println("wooooooooooooo", advicelist.ID)
1935
+								fmt.Println("prescribingNumberUnit", prescribingNumberUnit)
1936
+								fmt.Println("prescribingNumberUnit", drug.MinUnit)
1937
+								fmt.Println("prescribingNumberUnit", drug.MaxUnit)
1848 1938
 								//新增处方
1849 1939
 								if advicelist.ID == 0 {
1850 1940
 									all_count, _ := strconv.ParseFloat(totals, 64)
1851 1941
 									if prescribingNumberUnit == drug.MinUnit {
1852
-
1942
+										fmt.Println("prescribing_number", prescribing_number)
1943
+										fmt.Println("all_count", all_count)
1853 1944
 										if drug.IsUse != 1 {
1854 1945
 											if drug.IsProject == 0 || drug.IsProject == 2 {
1855 1946
 												if all_count == 0 {
@@ -2307,7 +2398,7 @@ func (c *HisApiController) CreateHisPrescription() {
2307 2398
 															var sum_in_count int64
2308 2399
 															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
2309 2400
 															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
2310
-
2401
+															fmt.Println("sum_in_count", sum_in_count)
2311 2402
 															//如果修改的数量大于有库存的第一个批次
2312 2403
 															if number_count > sum_in_count {
2313 2404
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
@@ -9088,7 +9179,7 @@ func (c *HisApiController) GetFaPiaoData() {
9088 9179
 		"name":                                order.PsnName,            //姓名
9089 9180
 		"gender":                              patient.Gender,           //性别
9090 9181
 		"psn_cash_money":                      order.PsnCashPay,         //个人支付
9091
-		"pay_way":                             "门诊",                     //结算方式
9182
+		"pay_way":                             "门诊",                   //结算方式
9092 9183
 		"medfee_sumamt":                       order.MedfeeSumamt,       //总费用
9093 9184
 		"admin_user_name":                     admin.UserName,           //收款员
9094 9185
 		"order":                               order,
@@ -10793,12 +10884,25 @@ func (c *HisApiController) GetHisMonthChargePatientInfo() {
10793 10884
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
10794 10885
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
10795 10886
 
10887
+	month_p_info, _ := service.FindPatientPrescriptionInfoTen(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
10888
+
10796 10889
 	lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
10797 10890
 
10798 10891
 	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
10799 10892
 	//获取所有科室信息
10800 10893
 	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
10801 10894
 
10895
+	var dia string
10896
+	for _, item := range month_p_info {
10897
+		if len(dia) == 0 {
10898
+			dia = item.Diagnosis
10899
+		} else {
10900
+			dia = dia + "," + item.Diagnosis
10901
+		}
10902
+	}
10903
+
10904
+	dia_arr := removeDuplicates(strings.Split(dia, ","))
10905
+	dia_arr = removeEmptyStrings(dia_arr)
10802 10906
 	c.ServeSuccessJSON(map[string]interface{}{
10803 10907
 		"his_info":            his_patient_info,
10804 10908
 		"xt_info":             xt_patient_info,
@@ -10810,10 +10914,37 @@ func (c *HisApiController) GetHisMonthChargePatientInfo() {
10810 10914
 		"doctors":             doctors,
10811 10915
 		"department":          department,
10812 10916
 		"settle_total":        settle_total,
10917
+		"dia_arr":             dia_arr,
10813 10918
 	})
10814 10919
 	return
10815 10920
 }
10816 10921
 
10922
+func removeEmptyStrings(input []string) []string {
10923
+	var output []string
10924
+
10925
+	for _, s := range input {
10926
+		if s != "" {
10927
+			output = append(output, s)
10928
+		}
10929
+	}
10930
+
10931
+	return output
10932
+}
10933
+
10934
+func removeDuplicates(input []string) []string {
10935
+	seen := make(map[string]bool)
10936
+	output := []string{}
10937
+
10938
+	for _, s := range input {
10939
+		if _, exists := seen[s]; !exists {
10940
+			seen[s] = true
10941
+			output = append(output, s)
10942
+		}
10943
+	}
10944
+
10945
+	return output
10946
+}
10947
+
10817 10948
 func (c *HisApiController) GetHisMonthPatientInfo() {
10818 10949
 	patient_id, _ := c.GetInt64("patient_id")
10819 10950
 	his_patient_id, _ := c.GetInt64("his_patient_id")

+ 164 - 0
controllers/self_drug_api_congtroller.go Wyświetl plik

@@ -115,6 +115,11 @@ func SelfDrugRouters() {
115 115
 	beego.Router("/api/stock/getdrugovercount", &SelfDrugApiController{}, "Get:GetDrugOverCount")
116 116
 
117 117
 	beego.Router("/api/stock/getdruginfolist", &SelfDrugApiController{}, "Get:GetDrugInventoryWarehouseInfoList")
118
+
119
+	beego.Router("/api/drug/getdrugflowdetailbyid", &SelfDrugApiController{}, "Get:GetDrugFlowDetailById")
120
+
121
+	//康允新版本
122
+	beego.Router("/api/stock/getpurchaseDrugQueryList", &SelfDrugApiController{}, "Get:GetPurchaseDrugQueryList")
118 123
 }
119 124
 
120 125
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -4091,3 +4096,162 @@ func (this *SelfDrugApiController) GetInventoryDetailPrintList() {
4091 4096
 		"inventoryList": inventoryList,
4092 4097
 	})
4093 4098
 }
4099
+
4100
+func (this *SelfDrugApiController) GetDrugFlowDetailById() {
4101
+
4102
+	drug_id, _ := this.GetInt64("drug_id")
4103
+
4104
+	list, _ := service.GetDrugFlowDetailById(drug_id)
4105
+
4106
+	drugMedical, _ := service.GetBaseDrugMedical(drug_id)
4107
+
4108
+	for index, _ := range list {
4109
+		if list[index].ConsumableType == 3 || list[index].ConsumableType == 2 || list[index].ConsumableType == 11 || list[index].ConsumableType == 12 || list[index].ConsumableType == 15 {
4110
+			var count int64
4111
+			if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
4112
+				list[index].Count = list[index].Count * drugMedical.MinNumber
4113
+			}
4114
+
4115
+			if index == 0 {
4116
+				count = list[index].FlushOverCount - list[index].Count
4117
+				service.UpdateDrugOverCount(list[index+1].ID, count)
4118
+			}
4119
+
4120
+			if index >= 1 {
4121
+				lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
4122
+				count = lastStockFlow.FlushOverCount - list[index].Count
4123
+				service.UpdateDrugOverCount(list[index].ID, count)
4124
+			}
4125
+
4126
+		}
4127
+		if list[index].ConsumableType == 7 || list[index].ConsumableType == 4 || list[index].ConsumableType == 1 || list[index].ConsumableType == 10 || list[index].ConsumableType == 13 {
4128
+			if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
4129
+				list[index].Count = list[index].Count * drugMedical.MinNumber
4130
+			}
4131
+			if index == 0 {
4132
+				var count int64
4133
+				count = list[index].OverCount + list[index].Count
4134
+				service.UpdateDrugOverCount(list[index+1].ID, count)
4135
+			}
4136
+
4137
+			if index >= 1 {
4138
+				var count int64
4139
+				lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
4140
+				count = lastStockFlow.FlushOverCount + list[index].Count
4141
+				service.UpdateDrugOverCount(list[index].ID, count)
4142
+			}
4143
+
4144
+		}
4145
+
4146
+	}
4147
+}
4148
+
4149
+func (this *SelfDrugApiController) GetPurchaseDrugQueryList() {
4150
+
4151
+	good_type, _ := this.GetInt64("good_type")
4152
+
4153
+	keyword := this.GetString("keyword")
4154
+
4155
+	page, _ := this.GetInt64("page")
4156
+
4157
+	limit, _ := this.GetInt64("limit")
4158
+
4159
+	start_time := this.GetString("start_time")
4160
+	end_time := this.GetString("end_time")
4161
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4162
+	timeLayout := "2006-01-02"
4163
+	loc, _ := time.LoadLocation("Local")
4164
+
4165
+	var startTime int64
4166
+
4167
+	if len(start_time) > 0 {
4168
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4169
+		if err != nil {
4170
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4171
+			return
4172
+		}
4173
+		startTime = theTime.Unix()
4174
+	}
4175
+
4176
+	var endTime int64
4177
+	if len(end_time) > 0 {
4178
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
4179
+		if err != nil {
4180
+			utils.ErrorLog(err.Error())
4181
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4182
+			return
4183
+		}
4184
+		endTime = theTime.Unix()
4185
+	}
4186
+	var ids []int64
4187
+	var infoIds []int64
4188
+
4189
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
4190
+	for _, it := range manufacturers {
4191
+		ids = append(ids, it.ID)
4192
+	}
4193
+	infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
4194
+	for _, it := range infoList {
4195
+		infoIds = append(infoIds, it.DrugId)
4196
+	}
4197
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4198
+	list, total, err := service.GetDrugNewPurchaseStockQueryList(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
4199
+
4200
+	for _, item := range list {
4201
+
4202
+		//获取期初结余
4203
+		flow, _ := service.GetDrugStartFlow(item.ID, orgId, startTime)
4204
+
4205
+		item.DrugStatFlow = flow
4206
+
4207
+		//获取期末结余
4208
+		endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
4209
+
4210
+		item.DrugEndFlow = endFlow
4211
+		//获取期初结余入库数量
4212
+
4213
+		//期中增加
4214
+		drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
4215
+		for _, it := range drugWarehouse {
4216
+			item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
4217
+		}
4218
+
4219
+		//期中减少
4220
+		outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
4221
+		for _, it := range outInfo {
4222
+			item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
4223
+		}
4224
+
4225
+		//期中退库
4226
+		cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
4227
+		for _, it := range cancelstartInfo {
4228
+			item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
4229
+		}
4230
+
4231
+		//获取期中盘盈
4232
+		profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
4233
+		for _, it := range profit {
4234
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
4235
+		}
4236
+
4237
+		//获取期中盘亏
4238
+		endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
4239
+		for _, it := range endLosses {
4240
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
4241
+		}
4242
+	}
4243
+	if err != nil {
4244
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
4245
+		return
4246
+	}
4247
+	var drugType = "药品类型"
4248
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4249
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
4250
+
4251
+	this.ServeSuccessJSON(map[string]interface{}{
4252
+		"list":             list,
4253
+		"manufacturerList": manufacturerList,
4254
+		"total":            total,
4255
+		"drugTypeList":     drugTypeList,
4256
+	})
4257
+}

+ 1 - 0
models/drug_stock.go Wyświetl plik

@@ -455,6 +455,7 @@ type DrugFlow struct {
455 455
 	RetailPrice               float64                `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
456 456
 	XtDrugWarehouseOutInfo    XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
457 457
 	OrderId                   int64                  `gorm:"column:order_id" json:"order_id" form:"order_id"`
458
+	FlushOverCount            int64                  `gorm:"column:flush_over_count" json:"flush_over_count" form:"flush_over_count"`
458 459
 }
459 460
 
460 461
 func (DrugFlow) TableName() string {

+ 1 - 0
models/new_stock_models.go Wyświetl plik

@@ -402,6 +402,7 @@ type VmBaseDrugTwenty struct {
402 402
 	RetailPrice                      float64           `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
403 403
 	MinPrice                         float64           `gorm:"column:min_price" json:"min_price" form:"min_price"`
404 404
 	LastPrice                        float64           `gorm:"column:last_price" json:"last_price" form:"last_price"`
405
+	DrugAlias                        string            `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
405 406
 	Manufacturer                     int64             `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
406 407
 	Dealer                           int64             `gorm:"column:dealer" json:"dealer" form:"dealer"`
407 408
 	Status                           int64             `gorm:"column:status" json:"status" form:"status"`

+ 30 - 28
service/pharmacy_service.go Wyświetl plik

@@ -839,36 +839,38 @@ func DispensingMedicineOne(orgid, patient_id, stime, etime, creater int64) (err
839 839
 	}
840 840
 
841 841
 	advice, err := GetDocAdviceList(orgid, patient_id, stime, etime)
842
-
843
-	if len(advice) > 0 {
844
-		for _, item := range advice {
845
-			err = DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
846
-			//查询默认仓库
847
-			storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
848
-			//查询默认仓库剩余多少库存
849
-			var sum_count int64
850
-			stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, item.DrugId)
851
-			for _, its := range stockInfo {
852
-				baseDrug, _ := GetBaseDrugMedical(its.DrugId)
853
-				if its.MaxUnit == baseDrug.MaxUnit {
854
-					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
842
+	//响水不走这里
843
+	if orgid != 10188 {
844
+		if len(advice) > 0 {
845
+			for _, item := range advice {
846
+				err = DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
847
+				//查询默认仓库
848
+				storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
849
+				//查询默认仓库剩余多少库存
850
+				var sum_count int64
851
+				stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, item.DrugId)
852
+				for _, its := range stockInfo {
853
+					baseDrug, _ := GetBaseDrugMedical(its.DrugId)
854
+					if its.MaxUnit == baseDrug.MaxUnit {
855
+						its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
856
+					}
857
+					sum_count += its.StockMaxNumber + its.StockMinNumber
855 858
 				}
856
-				sum_count += its.StockMaxNumber + its.StockMinNumber
857
-			}
858
-			UpdateBaseDrugSumTwo(item.DrugId, sum_count, orgid)
859
-			//扣减库存
860
-			UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
859
+				UpdateBaseDrugSumTwo(item.DrugId, sum_count, orgid)
860
+				//扣减库存
861
+				UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
861 862
 
862
-			over, _ := FindOverCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut)
863
-			UpdateActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount)
864
-			if err != nil {
865
-				err = fmt.Errorf("!:%v", err)
866
-				return
867
-			}
868
-			err = UpdateIsAdvice(item.ID)
869
-			if err != nil {
870
-				err = fmt.Errorf("!:%v", err)
871
-				return
863
+				over, _ := FindOverCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut)
864
+				UpdateActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount)
865
+				if err != nil {
866
+					err = fmt.Errorf("!:%v", err)
867
+					return
868
+				}
869
+				err = UpdateIsAdvice(item.ID)
870
+				if err != nil {
871
+					err = fmt.Errorf("!:%v", err)
872
+					return
873
+				}
872 874
 			}
873 875
 		}
874 876
 	}

+ 15 - 0
service/secondary_service.go Wyświetl plik

@@ -1162,6 +1162,12 @@ func UpdateOverCount(id int64, count int64) (err error) {
1162 1162
 	return err
1163 1163
 }
1164 1164
 
1165
+func UpdateDrugOverCount(id int64, count int64) (err error) {
1166
+
1167
+	err = XTWriteDB().Model(models.DrugFlow{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"flush_over_count": count}).Error
1168
+	return err
1169
+}
1170
+
1165 1171
 func GetLastOverCount(id int64) (models.VmStockFlow, error) {
1166 1172
 
1167 1173
 	stockFlow := models.VmStockFlow{}
@@ -1170,3 +1176,12 @@ func GetLastOverCount(id int64) (models.VmStockFlow, error) {
1170 1176
 
1171 1177
 	return stockFlow, err
1172 1178
 }
1179
+
1180
+func GetLastDrugOverCount(id int64) (models.DrugFlow, error) {
1181
+
1182
+	stockFlow := models.DrugFlow{}
1183
+
1184
+	err := XTReadDB().Where("id=? and status=1", id).Find(&stockFlow).Error
1185
+
1186
+	return stockFlow, err
1187
+}

+ 24 - 0
service/self_drug_service.go Wyświetl plik

@@ -2881,6 +2881,30 @@ func GetDrugNewPurchaseStockQuery(good_type int64, keyword string, page int64, l
2881 2881
 	return druginfo, total, err
2882 2882
 }
2883 2883
 
2884
+func GetDrugNewPurchaseStockQueryList(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
2885
+
2886
+	db := XTReadDB().Model(&druginfo).Where("status = 1")
2887
+	offset := (page - 1) * limit
2888
+	likeKey := "%" + keyword + "%"
2889
+	if good_type > 0 {
2890
+		db = db.Where("drug_type = ?", good_type)
2891
+	}
2892
+
2893
+	if orgid > 0 {
2894
+		db = db.Where("org_id = ?", orgid)
2895
+	}
2896
+
2897
+	if len(keyword) > 0 {
2898
+		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
2899
+	}
2900
+	if len(infos) > 0 {
2901
+		db = db.Where("id in(?)", infos)
2902
+	}
2903
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("drug_alias desc").Find(&druginfo).Error
2904
+
2905
+	return druginfo, total, err
2906
+}
2907
+
2884 2908
 func GetDrugStartFlow(drug_id int64, user_org_id int64, startime int64) (models.DrugFlowTwenty, error) {
2885 2909
 
2886 2910
 	flow := models.DrugFlowTwenty{}

+ 7 - 0
service/user_service.go Wyświetl plik

@@ -214,3 +214,10 @@ func GetAllHisDoctor(orgid int64) (appRole []*models.App_Role, err error) {
214 214
 	err = UserReadDB().Where("org_id = ?  AND status = 1 AND  (user_type = ? OR user_type = ?) ", orgid, 2, 1).Find(&appRole).Error
215 215
 	return appRole, err
216 216
 }
217
+
218
+func GetDrugFlowDetailById(drug_id int64) (flow []*models.DrugFlow, err error) {
219
+
220
+	err = XTReadDB().Model(&flow).Where("drug_id = ? and status =1 and user_org_id =10402", drug_id).Order("id asc").Find(&flow).Error
221
+
222
+	return flow, err
223
+}