张保健 4 gadus atpakaļ
vecāks
revīzija
725ab89eef

+ 1 - 1
conf/app.conf Parādīt failu

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 2 - 1
controllers/dialysis_api_controller.go Parādīt failu

@@ -3107,7 +3107,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
3107 3107
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3108 3108
 				record.UltrafiltrationRate = ultrafiltration_rate
3109 3109
 			}
3110
-			if template.TemplateId == 6 && adminInfo.CurrentOrgId == 9671 {
3110
+			if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10121 {
3111 3111
 
3112 3112
 				dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
3113 3113
 				ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
@@ -3142,6 +3142,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
3142 3142
 	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 {
3143 3143
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
3144 3144
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3145
+
3145 3146
 			record.UltrafiltrationVolume = ultrafiltration_volume
3146 3147
 		}
3147 3148
 

+ 1 - 1
controllers/dialysis_record_api_controller.go Parādīt failu

@@ -773,7 +773,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
773 773
 				}
774 774
 
775 775
 				//针对福建医师汇
776
-				if template.TemplateId == 6 && adminUserInfo.CurrentOrgId == 9671 {
776
+				if template.TemplateId == 6 && adminUserInfo.CurrentOrgId == 10121 {
777 777
 					if evaluation.ID > 0 {
778 778
 						dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
779 779
 						ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)

+ 13 - 15
controllers/drug_stock_api_contorller.go Parādīt failu

@@ -136,27 +136,25 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
136 136
 
137 137
 				warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
138 138
 
139
-				if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
140
-					utils.ErrorLog("price")
139
+				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
140
+					utils.ErrorLog("last_price")
141 141
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
142 142
 					return
143 143
 				}
144
-				price, _ := strconv.ParseFloat(items["price"].(string), 64)
145
-				total := float64(warehousing_count) * price
144
+				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
145
+				total := float64(warehousing_count) * last_price
146 146
 
147
-				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
-					utils.ErrorLog("retail_price")
149
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
-					return
151
-				}
152
-				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
-				retail_price_total := float64(warehousing_count) * retail_price
147
+				//if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
+				//	utils.ErrorLog("retail_price")
149
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
+				//	return
151
+				//}
152
+				//retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
+				retail_price_total := float64(warehousing_count) * last_price
154 154
 
155 155
 				var productDates int64
156 156
 				var expiryDates int64
157 157
 
158
-				fmt.Println()
159
-
160 158
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
161 159
 					expiryDates = 0
162 160
 				} else {
@@ -207,7 +205,7 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
207 205
 					ProductDate:      productDates,
208 206
 					ExpiryDate:       expiryDates,
209 207
 					WarehousingCount: warehousing_count,
210
-					Price:            price,
208
+					Price:            last_price,
211 209
 					TotalPrice:       total,
212 210
 					Status:           1,
213 211
 					Ctime:            ctime,
@@ -216,7 +214,7 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
216 214
 					Type:             types,
217 215
 					Manufacturer:     manufacturer_id,
218 216
 					Dealer:           dealer_id,
219
-					RetailPrice:      retail_price,
217
+					//RetailPrice:      retail_price,
220 218
 					RetailTotalPrice: retail_price_total,
221 219
 				}
222 220
 				warehousingInfo = append(warehousingInfo, warehouseInfo)

+ 55 - 2
controllers/manager_center_api_controller.go Parādīt failu

@@ -78,6 +78,8 @@ func ManagerCenterRegistRouters() {
78 78
 	beego.Router("/api/diagnose/list", &ManagerCenterApiController{}, "get:GetDiagnoseList")
79 79
 	beego.Router("/api/diagnose/delete", &ManagerCenterApiController{}, "post:DeleteDiagnose")
80 80
 	beego.Router("/api/diagnose/get", &ManagerCenterApiController{}, "get:GetDiagnose")
81
+	beego.Router("/api/drug/getalldruglist", &ManagerCenterApiController{}, "get:GetAllDrugList")
82
+	beego.Router("/api/drug/postsearchdruglist", &ManagerCenterApiController{}, "get:GetSearchDrugList")
81 83
 
82 84
 }
83 85
 
@@ -134,6 +136,11 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
134 136
 	loc, _ := time.LoadLocation("Local")
135 137
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
136 138
 	drug_remark := c.GetString("drug_remark")
139
+	dosage := c.GetString("dosage")
140
+	unval := c.GetString("unval")
141
+	packing_unit := c.GetString("packing_unit")
142
+	packing_price, _ := c.GetFloat("packing_price")
143
+	drug_day := c.GetString("drug_day")
137 144
 	adminInfo := c.GetAdminUserInfo()
138 145
 
139 146
 	drugLib := &models.BaseDrugLib{
@@ -190,6 +197,11 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
190 197
 		SocialSecurityDirectoryCode: social_security_directory_code,
191 198
 		RecordDate:                  theTime.Unix(),
192 199
 		DrugRemark:                  drug_remark,
200
+		Dosage:                      dosage,
201
+		Unval:                       unval,
202
+		PackingUnit:                 packing_unit,
203
+		PackingPrice:                packing_price,
204
+		DrugDay:                     drug_day,
193 205
 	}
194 206
 
195 207
 	total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
@@ -197,7 +209,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
197 209
 	drug_code = "54000000" + drug_code
198 210
 	drugLib.DrugCode = drug_code
199 211
 
200
-	count := service.FindBaseDrugLibRecordCount(drugLib)
212
+	count := service.FindBaseDrugLibRecordCountOne(drugLib)
201 213
 
202 214
 	if count == 0 {
203 215
 		err := service.CreateBaseDrugLib(drugLib)
@@ -274,6 +286,11 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
274 286
 	loc, _ := time.LoadLocation("Local")
275 287
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
276 288
 	drug_remark := c.GetString("drug_remark")
289
+	dosage := c.GetString("dosage")
290
+	unval := c.GetString("unval")
291
+	packing_unit := c.GetString("packing_unit")
292
+	packing_price, _ := c.GetFloat("packing_price")
293
+	drug_day := c.GetString("drug_day")
277 294
 	adminInfo := c.GetAdminUserInfo()
278 295
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
279 296
 
@@ -333,6 +350,11 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
333 350
 		SocialSecurityDirectoryCode: social_security_directory_code,
334 351
 		RecordDate:                  theTime.Unix(),
335 352
 		DrugRemark:                  drug_remark,
353
+		Dosage:                      dosage,
354
+		Unval:                       unval,
355
+		PackingPrice:                packing_price,
356
+		PackingUnit:                 packing_unit,
357
+		DrugDay:                     drug_day,
336 358
 	}
337 359
 
338 360
 	err := service.UpdateBaseDrugLib(drugLib)
@@ -355,7 +377,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
355 377
 	//查询是否存在
356 378
 	_, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
357 379
 	if errTwo == gorm.ErrRecordNotFound {
358
-		fmt.Println("进来了吗1")
380
+
359 381
 		c.ServeSuccessJSON(map[string]interface{}{
360 382
 			"msg": "修改成功",
361 383
 		})
@@ -2129,3 +2151,34 @@ func (c *ManagerCenterApiController) GetDiagnose() {
2129 2151
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2130 2152
 	}
2131 2153
 }
2154
+
2155
+func (c *ManagerCenterApiController) GetAllDrugList() {
2156
+
2157
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2158
+
2159
+	list, err := service.GetAllDrugList(orgId)
2160
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2161
+	if err == nil {
2162
+		c.ServeSuccessJSON(map[string]interface{}{
2163
+			"list":             list,
2164
+			"manufacturerList": manufacturerList,
2165
+		})
2166
+	} else {
2167
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2168
+	}
2169
+}
2170
+
2171
+func (c *ManagerCenterApiController) GetSearchDrugList() {
2172
+	keyword := c.GetString("keyword")
2173
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2174
+	list, err := service.GetSearchDrugList(keyword, orgId)
2175
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2176
+	if err == nil {
2177
+		c.ServeSuccessJSON(map[string]interface{}{
2178
+			"list":             list,
2179
+			"manufacturerList": manufacturerList,
2180
+		})
2181
+	} else {
2182
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2183
+	}
2184
+}

+ 3 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go Parādīt failu

@@ -2312,6 +2312,7 @@ func (this *DialysisAPIController) GetLastMonitorRecord() {
2312 2312
 }
2313 2313
 
2314 2314
 func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2315
+
2315 2316
 	thisTime := time.Now()
2316 2317
 	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
2317 2318
 	timeLayout := "2006-01-02 15:04:05"
@@ -2337,8 +2338,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2337 2338
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2338 2339
 
2339 2340
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2340
-			if template.TemplateId == 6 && adminInfo.Org.Id != 9671 {
2341
-
2341
+			if template.TemplateId == 6 && adminInfo.Org.Id != 9538 {
2342 2342
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2343 2343
 				record.UltrafiltrationRate = ultrafiltration_rate
2344 2344
 			}
@@ -2382,6 +2382,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2382 2382
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2383 2383
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2384 2384
 			record.UltrafiltrationVolume = ultrafiltration_volume
2385
+
2385 2386
 		}
2386 2387
 	}
2387 2388
 

+ 44 - 0
controllers/schedule_api_controller.go Parādīt failu

@@ -64,6 +64,8 @@ func ScheduleApiRegistRouters() {
64 64
 	beego.Router("/api/schedule/schedulesone", &ScheduleApiController{}, "Get:GetScheduleOne")
65 65
 	beego.Router("/api/schedule/postscheduletemplate", &ScheduleApiController{}, "Get:SaveScheduleTemplate")
66 66
 	beego.Router("/api/schedule/getscheduletemplate", &ScheduleApiController{}, "Get:GetScheduleTemplate")
67
+	beego.Router("/api/order/changefuncprint", &ScheduleApiController{}, "Get:ChangeFuncPrint")
68
+	beego.Router("/api/order/getdataprint", &ScheduleApiController{}, "Get:GetDataPrint")
67 69
 }
68 70
 
69 71
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -2623,3 +2625,45 @@ func (c *ScheduleApiController) GetScheduleTemplate() {
2623 2625
 	})
2624 2626
 	return
2625 2627
 }
2628
+
2629
+func (c *ScheduleApiController) ChangeFuncPrint() {
2630
+
2631
+	adminUserInfo := c.GetAdminUserInfo()
2632
+	orgId := adminUserInfo.CurrentOrgId
2633
+	is_open, _ := c.GetInt64("is_open")
2634
+	dataPrint := models.XtDataPrint{
2635
+		UserOrgId: orgId,
2636
+		IsOpen:    is_open,
2637
+		Status:    1,
2638
+		Ctime:     time.Now().Unix(),
2639
+	}
2640
+
2641
+	_, errcode := service.GetDataPrintByOrgId(orgId)
2642
+	fmt.Println("errcode222234444555556t66", errcode)
2643
+	if errcode == gorm.ErrRecordNotFound {
2644
+		service.CreateDataPrint(&dataPrint)
2645
+		c.ServeSuccessJSON(map[string]interface{}{
2646
+			"dataPrint": dataPrint,
2647
+		})
2648
+		return
2649
+	} else if errcode == nil {
2650
+		service.UpdteDataPrint(orgId, &dataPrint)
2651
+		c.ServeSuccessJSON(map[string]interface{}{
2652
+			"dataPrint": dataPrint,
2653
+		})
2654
+		return
2655
+	}
2656
+
2657
+}
2658
+
2659
+func (c *ScheduleApiController) GetDataPrint() {
2660
+
2661
+	adminUserInfo := c.GetAdminUserInfo()
2662
+	orgId := adminUserInfo.CurrentOrgId
2663
+
2664
+	dataPrint, _ := service.GetDataPrint(orgId)
2665
+	c.ServeSuccessJSON(map[string]interface{}{
2666
+		"dataPrint": dataPrint,
2667
+	})
2668
+	return
2669
+}

+ 268 - 163
controllers/stock_in_api_controller.go Parādīt failu

@@ -2607,21 +2607,85 @@ func (this *StockManagerApiController) AddDrugInformation() {
2607 2607
 
2608 2608
 		drug.DrugName = drug_name
2609 2609
 
2610
-		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
2611
-			utils.ErrorLog("drug_alias")
2610
+		if goodNameM["unval"] == nil || reflect.TypeOf(goodNameM["unval"]).String() != "string" {
2611
+			utils.ErrorLog("unval")
2612 2612
 			return
2613 2613
 		}
2614 2614
 
2615
-		drug_alias, _ := goodNameM["drug_alias"].(string)
2615
+		unval, _ := goodNameM["unval"].(string)
2616
+		if len(drug_name) == 0 { //名字为空则生成一条导入错误日志
2617
+			err_log := models.ExportErrLog{
2618
+				LogType:    4,
2619
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2620
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零不能为空",
2621
+				Status:     1,
2622
+				CreateTime: time.Now().Unix(),
2623
+				UpdateTime: time.Now().Unix(),
2624
+				ExportTime: time.Now().Unix(),
2625
+			}
2626
+			service.CreateExportErrLog(&err_log)
2627
+			continue
2628
+		}
2616 2629
 
2617
-		drug.DrugAlias = drug_alias
2630
+		drug.Unval = unval
2631
+
2632
+		min_unit := goodNameM["min_unit"].(string)
2633
+		if len(min_unit) == 0 { //名字为空则生成一条导入错误日志
2634
+			err_log := models.ExportErrLog{
2635
+				LogType:    4,
2636
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2637
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零单位不能为空",
2638
+				Status:     1,
2639
+				CreateTime: time.Now().Unix(),
2640
+				UpdateTime: time.Now().Unix(),
2641
+				ExportTime: time.Now().Unix(),
2642
+			}
2643
+			service.CreateExportErrLog(&err_log)
2644
+			continue
2645
+		}
2646
+
2647
+		drug.MinUnit = min_unit
2648
+
2649
+		dosage, _ := goodNameM["dosage"].(string)
2650
+		if len(dosage) == 0 { //名字为空则生成一条导入错误日志
2651
+			err_log := models.ExportErrLog{
2652
+				LogType:    4,
2653
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2654
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
2655
+				Status:     1,
2656
+				CreateTime: time.Now().Unix(),
2657
+				UpdateTime: time.Now().Unix(),
2658
+				ExportTime: time.Now().Unix(),
2659
+			}
2660
+			service.CreateExportErrLog(&err_log)
2661
+			continue
2662
+		}
2663
+
2664
+		drug.Dosage = dosage
2665
+
2666
+		max_unit_id := goodNameM["max_unit"].(string)
2667
+		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2668
+			err_log := models.ExportErrLog{
2669
+				LogType:    4,
2670
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2671
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量单位不能为空",
2672
+				Status:     1,
2673
+				CreateTime: time.Now().Unix(),
2674
+				UpdateTime: time.Now().Unix(),
2675
+				ExportTime: time.Now().Unix(),
2676
+			}
2677
+			service.CreateExportErrLog(&err_log)
2678
+			continue
2679
+		}
2618 2680
 
2619
-		drug_spec, _ := goodNameM["drug_spec"].(string)
2620
-		if len(drug_spec) == 0 { //名字为空则生成一条导入错误日志
2681
+		drug.MaxUnit = max_unit_id
2682
+
2683
+		packing_unit := goodNameM["packing_unit"].(string)
2684
+		if len(packing_unit) == 0 { //名字为空则生成一条导入错误日志
2621 2685
 			err_log := models.ExportErrLog{
2622 2686
 				LogType:    4,
2623 2687
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2624
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的药品规格不能为空",
2688
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的包装单位不能为空",
2625 2689
 				Status:     1,
2626 2690
 				CreateTime: time.Now().Unix(),
2627 2691
 				UpdateTime: time.Now().Unix(),
@@ -2631,7 +2695,58 @@ func (this *StockManagerApiController) AddDrugInformation() {
2631 2695
 			continue
2632 2696
 		}
2633 2697
 
2634
-		drug.DrugSpec = drug_spec
2698
+		drug.PackingUnit = packing_unit
2699
+
2700
+		delivery_way := goodNameM["delivery_way"].(string)
2701
+		if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
2702
+			err_log := models.ExportErrLog{
2703
+				LogType:    4,
2704
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2705
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
2706
+				Status:     1,
2707
+				CreateTime: time.Now().Unix(),
2708
+				UpdateTime: time.Now().Unix(),
2709
+				ExportTime: time.Now().Unix(),
2710
+			}
2711
+			service.CreateExportErrLog(&err_log)
2712
+			continue
2713
+		}
2714
+
2715
+		drug.DeliveryWay = delivery_way
2716
+
2717
+		execution_frequency := goodNameM["execution_frequency"].(string)
2718
+		if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
2719
+			err_log := models.ExportErrLog{
2720
+				LogType:    4,
2721
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2722
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
2723
+				Status:     1,
2724
+				CreateTime: time.Now().Unix(),
2725
+				UpdateTime: time.Now().Unix(),
2726
+				ExportTime: time.Now().Unix(),
2727
+			}
2728
+			service.CreateExportErrLog(&err_log)
2729
+			continue
2730
+		}
2731
+
2732
+		drug.ExecutionFrequency = execution_frequency
2733
+
2734
+		drug_day := goodNameM["drug_day"].(string)
2735
+		if len(drug_day) == 0 { //名字为空则生成一条导入错误日志
2736
+			err_log := models.ExportErrLog{
2737
+				LogType:    4,
2738
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2739
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
2740
+				Status:     1,
2741
+				CreateTime: time.Now().Unix(),
2742
+				UpdateTime: time.Now().Unix(),
2743
+				ExportTime: time.Now().Unix(),
2744
+			}
2745
+			service.CreateExportErrLog(&err_log)
2746
+			continue
2747
+		}
2748
+
2749
+		drug.DrugDay = drug_day
2635 2750
 
2636 2751
 		drug_type := goodNameM["drug_type"].(string)
2637 2752
 		if len(drug_type) == 0 { //名字为空则生成一条导入错误日志
@@ -2828,12 +2943,12 @@ func (this *StockManagerApiController) AddDrugInformation() {
2828 2943
 		}
2829 2944
 		drug.MedicalInsuranceLevel = medical_insurance_level_id
2830 2945
 
2831
-		max_unit_id := goodNameM["max_unit"].(string)
2946
+		unit_matrixing := goodNameM["unit_matrixing"].(string)
2832 2947
 		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2833 2948
 			err_log := models.ExportErrLog{
2834 2949
 				LogType:    4,
2835 2950
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2836
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的最大不能为空",
2951
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
2837 2952
 				Status:     1,
2838 2953
 				CreateTime: time.Now().Unix(),
2839 2954
 				UpdateTime: time.Now().Unix(),
@@ -2843,14 +2958,15 @@ func (this *StockManagerApiController) AddDrugInformation() {
2843 2958
 			continue
2844 2959
 		}
2845 2960
 
2846
-		drug.MaxUnit = max_unit_id
2961
+		drug.UnitMatrixing = unit_matrixing
2962
+		retail_prices := goodNameM["retail_price"].(string)
2963
+		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2847 2964
 
2848
-		min_unit := goodNameM["min_unit"].(string)
2849
-		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2965
+		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2850 2966
 			err_log := models.ExportErrLog{
2851 2967
 				LogType:    4,
2852 2968
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2853
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的最小单位不能为空",
2969
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零售价不能为空",
2854 2970
 				Status:     1,
2855 2971
 				CreateTime: time.Now().Unix(),
2856 2972
 				UpdateTime: time.Now().Unix(),
@@ -2860,32 +2976,16 @@ func (this *StockManagerApiController) AddDrugInformation() {
2860 2976
 			continue
2861 2977
 		}
2862 2978
 
2863
-		drug.MinUnit = min_unit
2864
-
2865
-		unit_matrixing := goodNameM["unit_matrixing"].(string)
2866
-		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2867
-			err_log := models.ExportErrLog{
2868
-				LogType:    4,
2869
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2870
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
2871
-				Status:     1,
2872
-				CreateTime: time.Now().Unix(),
2873
-				UpdateTime: time.Now().Unix(),
2874
-				ExportTime: time.Now().Unix(),
2875
-			}
2876
-			service.CreateExportErrLog(&err_log)
2877
-			continue
2878
-		}
2979
+		drug.RetailPrice = retail_price
2879 2980
 
2880
-		drug.UnitMatrixing = unit_matrixing
2881
-		retail_prices := goodNameM["retail_price"].(string)
2882
-		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2981
+		packing_prices := goodNameM["packing_price"].(string)
2982
+		packing_price, _ := strconv.ParseFloat(packing_prices, 64)
2883 2983
 
2884
-		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2984
+		if packing_price <= 0 { //名字为空则生成一条导入错误日志
2885 2985
 			err_log := models.ExportErrLog{
2886 2986
 				LogType:    4,
2887 2987
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2888
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的零售价不能为空",
2988
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的包装零售价不能为空",
2889 2989
 				Status:     1,
2890 2990
 				CreateTime: time.Now().Unix(),
2891 2991
 				UpdateTime: time.Now().Unix(),
@@ -2903,7 +3003,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2903 3003
 			err_log := models.ExportErrLog{
2904 3004
 				LogType:    4,
2905 3005
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2906
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的上次进价不能为空",
3006
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的进价不能为空",
2907 3007
 				Status:     1,
2908 3008
 				CreateTime: time.Now().Unix(),
2909 3009
 				UpdateTime: time.Now().Unix(),
@@ -2968,6 +3068,77 @@ func (this *StockManagerApiController) AddDrugInformation() {
2968 3068
 			}
2969 3069
 		}
2970 3070
 
3071
+		drug_dose := goodNameM["drug_dose"].(string)
3072
+
3073
+		if len(drug_dose) == 0 {
3074
+			err_log := models.ExportErrLog{
3075
+				LogType:    4,
3076
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3077
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量不能为空",
3078
+				Status:     1,
3079
+				CreateTime: time.Now().Unix(),
3080
+				UpdateTime: time.Now().Unix(),
3081
+				ExportTime: time.Now().Unix(),
3082
+			}
3083
+			service.CreateExportErrLog(&err_log)
3084
+			continue
3085
+		}
3086
+		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3087
+		drug.DrugDose = drugDoses
3088
+
3089
+		var units = "单位"
3090
+		var unit_id int64
3091
+		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3092
+
3093
+		if len(drugDoseUnit) == 0 {
3094
+			err_log := models.ExportErrLog{
3095
+				LogType:    4,
3096
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3097
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量单位不能为空",
3098
+				Status:     1,
3099
+				CreateTime: time.Now().Unix(),
3100
+				UpdateTime: time.Now().Unix(),
3101
+				ExportTime: time.Now().Unix(),
3102
+			}
3103
+			service.CreateExportErrLog(&err_log)
3104
+			continue
3105
+		}
3106
+
3107
+		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3108
+		if len(drugDoseUnit) != 0 {
3109
+			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3110
+			if errcodedataconfig == gorm.ErrRecordNotFound {
3111
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3112
+				dataconfig := models.Dataconfig{
3113
+					ParentId:       dataConfig.ID,
3114
+					Module:         "hemodialysis",
3115
+					OrgId:          orgId,
3116
+					Name:           drugDoseUnit,
3117
+					FieldName:      "",
3118
+					Value:          childConfig.Value + 1,
3119
+					CreatedTime:    "",
3120
+					UpdatedTime:    "",
3121
+					CreateUserId:   adminUser.AdminUser.Id,
3122
+					Status:         1,
3123
+					Remark:         "",
3124
+					DeleteIdSystem: 0,
3125
+					Title:          "",
3126
+					Content:        "",
3127
+					Order:          0,
3128
+					Code:           "",
3129
+					FieldType:      0,
3130
+				}
3131
+				service.CreateDataConfig(&dataconfig)
3132
+			}
3133
+		}
3134
+		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3135
+		for _, it := range list {
3136
+			if drugDoseUnit == it.Name {
3137
+				unit_id = int64(it.Value)
3138
+			}
3139
+		}
3140
+		drug.DrugDoseUnit = unit_id
3141
+
2971 3142
 		drug.DrugClassify = strconv.FormatInt(drug_classify_id, 10)
2972 3143
 
2973 3144
 		manufacturer := goodNameM["manufacturer"].(string)
@@ -3033,14 +3204,61 @@ func (this *StockManagerApiController) AddDrugInformation() {
3033 3204
 		}
3034 3205
 		drug.Dealer = dealer_id
3035 3206
 
3036
-		pinyin := goodNameM["pinyin"].(string)
3207
+		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3037 3208
 
3038
-		drug.Pinyin = pinyin
3039
-		wubi := goodNameM["wubi"].(string)
3040
-		drug.Wubi = wubi
3209
+		drug.LmtUsedFlag = lmt_used_flags
3210
+
3211
+		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
3212
+			utils.ErrorLog("drug_alias")
3213
+			return
3214
+		}
3041 3215
 
3042
-		drug_alias_pinyin := goodNameM["drug_alias_pinyin"].(string)
3043
-		drug.DrugAliasPinyin = drug_alias_pinyin
3216
+		drug_alias, _ := goodNameM["drug_alias"].(string)
3217
+
3218
+		drug.DrugAlias = drug_alias
3219
+
3220
+		drug_category := goodNameM["drug_category"].(string)
3221
+
3222
+		var drugCategory = "药品类别"
3223
+		var drug_category_id int64
3224
+
3225
+		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3226
+
3227
+		if len(drug_category) != 0 {
3228
+			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3229
+			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3230
+				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3231
+				dataconfig := models.DictDataconfig{
3232
+					ParentId:       drugCategoryConfig.ID,
3233
+					Module:         "system",
3234
+					OrgId:          orgId,
3235
+					Name:           drug_category,
3236
+					FieldName:      "",
3237
+					Value:          drugCategoryConfigSix.Value + 1,
3238
+					CreatedTime:    "",
3239
+					UpdatedTime:    "",
3240
+					CreateUserId:   adminUser.AdminUser.Id,
3241
+					Status:         1,
3242
+					Remark:         "",
3243
+					DeleteIdSystem: 0,
3244
+					Title:          "",
3245
+					Content:        "",
3246
+					Order:          0,
3247
+					Code:           "",
3248
+				}
3249
+				service.CreatedDicConfig(&dataconfig)
3250
+			}
3251
+		}
3252
+
3253
+		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
3254
+		fmt.Println("drugCategoryList", drugCategoryList)
3255
+		for _, it := range drugCategoryList {
3256
+			if drug_category == it.Name {
3257
+				drug_category_id = int64(it.Value)
3258
+			}
3259
+		}
3260
+
3261
+		drug.DrugCategory = drug_category_id
3044 3262
 
3045 3263
 		statistics_category := goodNameM["statistics_category"].(string)
3046 3264
 
@@ -3153,9 +3371,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
3153 3371
 		limit_remark := goodNameM["limit_remark"].(string)
3154 3372
 		drug.LimitRemark = limit_remark
3155 3373
 
3156
-		drug_alias_wubi := goodNameM["drug_alias_wubi"].(string)
3157
-		drug.DrugAliasWubi = drug_alias_wubi
3158
-
3159 3374
 		drug_control := goodNameM["drug_control"].(string)
3160 3375
 
3161 3376
 		var drugControl = "开药控制"
@@ -3196,123 +3411,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
3196 3411
 		}
3197 3412
 		drug.DrugControl = drug_control_id
3198 3413
 
3199
-		drug_category := goodNameM["drug_category"].(string)
3200
-
3201
-		var drugCategory = "药品类别"
3202
-		var drug_category_id int64
3203
-
3204
-		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3205
-
3206
-		if len(drug_category) != 0 {
3207
-			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3208
-			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3209
-				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3210
-				dataconfig := models.DictDataconfig{
3211
-					ParentId:       drugCategoryConfig.ID,
3212
-					Module:         "system",
3213
-					OrgId:          orgId,
3214
-					Name:           drug_category,
3215
-					FieldName:      "",
3216
-					Value:          drugCategoryConfigSix.Value + 1,
3217
-					CreatedTime:    "",
3218
-					UpdatedTime:    "",
3219
-					CreateUserId:   adminUser.AdminUser.Id,
3220
-					Status:         1,
3221
-					Remark:         "",
3222
-					DeleteIdSystem: 0,
3223
-					Title:          "",
3224
-					Content:        "",
3225
-					Order:          0,
3226
-					Code:           "",
3227
-				}
3228
-				service.CreatedDicConfig(&dataconfig)
3229
-			}
3230
-		}
3231
-
3232
-		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
3233
-		fmt.Println("drugCategoryList", drugCategoryList)
3234
-		for _, it := range drugCategoryList {
3235
-			if drug_category == it.Name {
3236
-				drug_category_id = int64(it.Value)
3237
-			}
3238
-		}
3239
-
3240
-		drug.DrugCategory = drug_category_id
3241
-
3242
-		drug_dose := goodNameM["drug_dose"].(string)
3243
-
3244
-		if len(drug_dose) == 0 {
3245
-			err_log := models.ExportErrLog{
3246
-				LogType:    4,
3247
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3248
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3249
-				Status:     1,
3250
-				CreateTime: time.Now().Unix(),
3251
-				UpdateTime: time.Now().Unix(),
3252
-				ExportTime: time.Now().Unix(),
3253
-			}
3254
-			service.CreateExportErrLog(&err_log)
3255
-			continue
3256
-		}
3257
-		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3258
-		drug.DrugDose = drugDoses
3259
-
3260
-		var units = "单位"
3261
-		var unit_id int64
3262
-		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3263
-
3264
-		if len(drugDoseUnit) == 0 {
3265
-			err_log := models.ExportErrLog{
3266
-				LogType:    4,
3267
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3268
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3269
-				Status:     1,
3270
-				CreateTime: time.Now().Unix(),
3271
-				UpdateTime: time.Now().Unix(),
3272
-				ExportTime: time.Now().Unix(),
3273
-			}
3274
-			service.CreateExportErrLog(&err_log)
3275
-			continue
3276
-		}
3277
-
3278
-		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3279
-		if len(drugDoseUnit) != 0 {
3280
-			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3281
-			if errcodedataconfig == gorm.ErrRecordNotFound {
3282
-				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3283
-				dataconfig := models.Dataconfig{
3284
-					ParentId:       dataConfig.ID,
3285
-					Module:         "hemodialysis",
3286
-					OrgId:          orgId,
3287
-					Name:           drugDoseUnit,
3288
-					FieldName:      "",
3289
-					Value:          childConfig.Value + 1,
3290
-					CreatedTime:    "",
3291
-					UpdatedTime:    "",
3292
-					CreateUserId:   adminUser.AdminUser.Id,
3293
-					Status:         1,
3294
-					Remark:         "",
3295
-					DeleteIdSystem: 0,
3296
-					Title:          "",
3297
-					Content:        "",
3298
-					Order:          0,
3299
-					Code:           "",
3300
-					FieldType:      0,
3301
-				}
3302
-				service.CreateDataConfig(&dataconfig)
3303
-			}
3304
-		}
3305
-		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3306
-		for _, it := range list {
3307
-			if drugDoseUnit == it.Name {
3308
-				unit_id = int64(it.Value)
3309
-			}
3310
-		}
3311
-		drug.DrugDoseUnit = unit_id
3312
-
3313
-		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3314
-
3315
-		drug.LmtUsedFlag = lmt_used_flags
3316 3414
 		drugList = append(drugList, &drug)
3317 3415
 	}
3318 3416
 
@@ -3365,10 +3463,17 @@ func (this *StockManagerApiController) AddDrugInformation() {
3365 3463
 				DrugDose:                    item.DrugDose,
3366 3464
 				DrugDoseUnit:                item.DrugDoseUnit,
3367 3465
 				LmtUsedFlag:                 item.LmtUsedFlag,
3466
+				Dosage:                      item.Dosage,
3467
+				Unval:                       item.Unval,
3468
+				PackingUnit:                 item.PackingUnit,
3469
+				PackingPrice:                item.PackingPrice,
3470
+				DrugDay:                     item.DrugDay,
3471
+				DeliveryWay:                 item.DeliveryWay,
3472
+				ExecutionFrequency:          item.ExecutionFrequency,
3368 3473
 			}
3369 3474
 
3370 3475
 			//查询同种药品同种规格是否存在
3371
-			_, drugerror := service.IsExistDrugByName(item.DrugName, item.DrugSpec, orgId)
3476
+			_, drugerror := service.IsExistDrugByNameOne(item.DrugName, item.Dosage, item.MaxUnit, item.Unval, item.MinUnit, item.PackingUnit, orgId)
3372 3477
 
3373 3478
 			if drugerror == gorm.ErrRecordNotFound {
3374 3479
 				service.CreateDrugsInfomation(&goodInfo)

+ 5 - 0
models/drug.go Parādīt failu

@@ -65,6 +65,11 @@ type BaseDrugLib struct {
65 65
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
66 66
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
67 67
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
68
+	Dosage       string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
69
+	Unval        string  `gorm:"column:unval" json:"unval" form:"unval"`
70
+	PackingUnit  string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
71
+	PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
72
+	DrugDay      string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
68 73
 }
69 74
 
70 75
 func (BaseDrugLib) TableName() string {

+ 15 - 0
models/schedule_models.go Parādīt failu

@@ -22,6 +22,7 @@ type VmSchedules struct {
22 22
 	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
23 23
 	DialysisPrescription DialysisPrescription   `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
24 24
 	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
25
+	DialysisSolution     []*DialysisSolution    `json:"dialysissolution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
25 26
 }
26 27
 
27 28
 func (VmSchedules) TableName() string {
@@ -137,6 +138,7 @@ type WeekSchedule struct {
137 138
 	DialysisPrescription DialysisSolution       `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
138 139
 	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
139 140
 	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
141
+	DialysisSolution     []*DialysisSolution    `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
140 142
 }
141 143
 
142 144
 func (WeekSchedule) TableName() string {
@@ -155,3 +157,16 @@ type ScheduleTemplate struct {
155 157
 func (ScheduleTemplate) TableName() string {
156 158
 	return "xt_schedule_template"
157 159
 }
160
+
161
+type XtDataPrint struct {
162
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
163
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
164
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
165
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
166
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
167
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
168
+}
169
+
170
+func (XtDataPrint) TableName() string {
171
+	return "xt_data_print"
172
+}

+ 11 - 0
service/manage_center_service.go Parādīt failu

@@ -158,6 +158,11 @@ func FindBaseDrugLibRecordCount(lib *models.BaseDrugLib) (count int64) {
158 158
 	return
159 159
 }
160 160
 
161
+func FindBaseDrugLibRecordCountOne(lib *models.BaseDrugLib) (count int64) {
162
+	readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_name = ? and dosage = ? and max_unit = ? and unval = ? and min_unit = ? and packing_unit = ? and manufacturer = ? and status = 1", lib.OrgId, lib.DrugName, lib.Dosage, lib.MaxUnit, lib.Unval, lib.MinUnit, lib.PackingUnit, lib.Manufacturer).Count(&count)
163
+	return
164
+}
165
+
161 166
 func FindAllDrugLibRecordTotal(org_id int64) (count int64) {
162 167
 	readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND status = 1", org_id).Count(&count)
163 168
 	return
@@ -357,3 +362,9 @@ func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
357 362
 	err := readDb.Model(&models.DictDataconfig{}).Where(" (user_org_id = ? Or user_org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
358 363
 	return err, data.Code
359 364
 }
365
+
366
+func GetAllDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
367
+
368
+	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
369
+	return drug, err
370
+}

+ 1 - 1
service/patientmanage_service.go Parādīt failu

@@ -865,7 +865,7 @@ func GetDialysisrecord(patientID int64, start int64, end int64, limit int64, pag
865 865
 			return readUserDb.Where("org_id=? and status = 1", orgID)
866 866
 		}).
867 867
 		Joins("JOIN xt_schedule as s ON s.patient_id=? and FROM_UNIXTIME(s.schedule_date, '%Y-%m-%d')=FROM_UNIXTIME(do.dialysis_date, '%Y-%m-%d')", patientID).
868
-		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
868
+		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id and s.status = 1", orgID).
869 869
 		Where("do.patient_id=? and do.user_org_id=? and do.stage = 2 and do.status=1", patientID, orgID).Group("s.schedule_date")
870 870
 
871 871
 	if start > 0 {

+ 38 - 3
service/schedule_service.go Parādīt failu

@@ -579,7 +579,7 @@ func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64)
579 579
 
580 580
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
581 581
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
582
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Find(&list).Error
582
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", "status = 1 and user_org_id = ?", orgid).Find(&list).Error
583 583
 
584 584
 	return list, err
585 585
 }
@@ -602,7 +602,7 @@ func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int
602 602
 
603 603
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
604 604
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
605
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Find(&list).Error
605
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", "user_org_id =? and status = 1", orgid).Find(&list).Error
606 606
 
607 607
 	return list, err
608 608
 }
@@ -777,7 +777,9 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
777 777
 		Preload("DeviceNumber", "status = 1 ").
778 778
 		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
779 779
 			return db.Where("status = 1").Order("id asc")
780
-		}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
780
+		}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
781
+		return db.Where("status = 1").Order("id asc")
782
+	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
781 783
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
782 784
 	}).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
783 785
 		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
@@ -908,3 +910,36 @@ func GetScheduleTemplate(orgid int64) (models.ScheduleTemplate, error) {
908 910
 	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&template).Error
909 911
 	return template, err
910 912
 }
913
+
914
+func GetDataPrintByOrgId(orgid int64) (*models.XtDataPrint, error) {
915
+
916
+	dataPrint := models.XtDataPrint{}
917
+
918
+	err := XTReadDB().Model(&dataPrint).Where("user_org_id = ? and status = 1", orgid).Find(&dataPrint).Error
919
+
920
+	if err == gorm.ErrRecordNotFound {
921
+		return nil, err
922
+	}
923
+	if err != nil {
924
+		return nil, err
925
+	}
926
+	return &dataPrint, nil
927
+}
928
+
929
+func CreateDataPrint(dataPrint *models.XtDataPrint) error {
930
+
931
+	err := XTWriteDB().Create(&dataPrint).Error
932
+	return err
933
+}
934
+
935
+func UpdteDataPrint(orgid int64, dataPrint *models.XtDataPrint) error {
936
+
937
+	err := XTWriteDB().Model(&dataPrint).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_open": dataPrint.IsOpen}).Error
938
+	return err
939
+}
940
+
941
+func GetDataPrint(orgid int64) (models.XtDataPrint, error) {
942
+	dataPrint := models.XtDataPrint{}
943
+	err := XTReadDB().Model(&dataPrint).Where("user_org_id = ? and status = 1", orgid).Find(&dataPrint).Error
944
+	return dataPrint, err
945
+}

+ 44 - 14
service/stock_service.go Parādīt failu

@@ -551,19 +551,24 @@ func (VMDrugWarehouseInfo) TableName() string {
551 551
 }
552 552
 
553 553
 type Drug struct {
554
-	ID              int64  `gorm:"column:id" json:"id" form:"id"`
555
-	DrugName        string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
556
-	DrugSpec        string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
557
-	DrugType        int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
558
-	DrugStockLimit  string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
559
-	DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
560
-	DrugDosageForm  int64  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
561
-	Manufacturer    int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
562
-	Status          int64  `gorm:"column:status" json:"status" form:"status"`
563
-	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
564
-	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
565
-	OrgId           int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
566
-	DrugCode        string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
554
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
555
+	DrugName        string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
556
+	DrugSpec        string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
557
+	DrugType        int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
558
+	DrugStockLimit  string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
559
+	DrugOriginPlace string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
560
+	DrugDosageForm  int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
561
+	Manufacturer    int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
562
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
563
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
564
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
565
+	OrgId           int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
566
+	DrugCode        string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
567
+	Dosage          string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
568
+	Unval           string  `gorm:"column:unval" json:"unval" form:"unval"`
569
+	PackingUnit     string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
570
+	PackingPrice    float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
571
+	DrugDay         string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
567 572
 }
568 573
 
569 574
 func (Drug) TableName() string {
@@ -2327,6 +2332,19 @@ func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.B
2327 2332
 	return &drug, nil
2328 2333
 }
2329 2334
 
2335
+func IsExistDrugByNameOne(drugname string, dosage string, maxunit string, unival string, minunit string, packtunit string, orgid int64) (*models.BaseDrugLib, error) {
2336
+	var drug models.BaseDrugLib
2337
+	var err error
2338
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and dosage = ?  and max_unit = ? and unval = ? and min_unit=? and packing_unit = ? and status =1 and org_id = ?", drugname, dosage, maxunit, unival, minunit, packtunit, orgid).Find(&drug).Error
2339
+	if err == gorm.ErrRecordNotFound {
2340
+		return nil, err
2341
+	}
2342
+	if err != nil {
2343
+		return nil, err
2344
+	}
2345
+	return &drug, nil
2346
+}
2347
+
2330 2348
 func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2331 2349
 	err := XTWriteDB().Create(&info).Error
2332 2350
 	return err
@@ -2334,7 +2352,7 @@ func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2334 2352
 
2335 2353
 func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
2336 2354
 
2337
-	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag}).Error
2355
+	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag, "delivery_way": drug.DeliveryWay, "execution_frequency": drug.ExecutionFrequency, "dosage": drug.Dosage, "unval": drug.Unval, "packing_unit": drug.PackingUnit, "packing_price": drug.PackingPrice, "drug_day": drug.DrugDay}).Error
2338 2356
 	return err
2339 2357
 }
2340 2358
 
@@ -2539,3 +2557,15 @@ func GetWarehouseOrderInfoList(orgid int64) (list []*models.WarehousingInfo, err
2539 2557
 	err = XTReadDB().Model(&list).Where("org_id = ? and status = 1", orgid).Order("id asc").Group("good_id").Find(&list).Error
2540 2558
 	return list, err
2541 2559
 }
2560
+
2561
+func GetSearchDrugList(keywords string, orgid int64) (drug []*models.BaseDrugLib, err error) {
2562
+
2563
+	db := XTReadDB().Model(&drug).Where("org_id=? and status=1 ", orgid)
2564
+	if len(keywords) > 0 {
2565
+		likekey := "%" + keywords + "%"
2566
+		err = db.Where("(drug_name LIKE ?)", likekey).Find(&drug).Error
2567
+	} else {
2568
+		err = db.Find(&drug).Error
2569
+	}
2570
+	return
2571
+}

+ 23 - 23
service/warhouse_service.go Parādīt failu

@@ -2,14 +2,14 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
-	_"fmt"
6
-	"strings"
7
-	"time"
8
-	"math"
9 5
 	"XT_New/utils"
10
-	"strconv"
11 6
 	"errors"
7
+	_ "fmt"
12 8
 	"github.com/jinzhu/gorm"
9
+	"math"
10
+	"strconv"
11
+	"strings"
12
+	"time"
13 13
 )
14 14
 
15 15
 // 药品出库
@@ -58,24 +58,25 @@ func DrugsDelivery(orgID int64, advice *models.DoctorAdvice) (err error) {
58 58
 			} else {
59 59
 				out = warehouseOut
60 60
 			}
61
-		} 
61
+		}
62 62
 
63 63
 		// 出库流程
64 64
 		// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
65
-		drup,_ := FindBaseDrugLibRecord(orgID,advice.DrugId)
65
+		drup, _ := FindBaseDrugLibRecord(orgID, advice.DrugId)
66 66
 		if drup.ID > 0 {
67 67
 			prescribingNumber := advice.PrescribingNumber
68
-			DrugDeliverInfo(orgID ,prescribingNumber ,&out ,&drup ,advice)
68
+			DrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice)
69 69
 		} else {
70 70
 			return errors.New("药品信息不存在")
71 71
 		}
72
-			
72
+
73 73
 	}
74 74
 
75 75
 	return
76
-} 
76
+}
77
+
77 78
 // 药品出库 递归方式
78
-func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.DrugWarehouseOut,drup *models.BaseDrugLib,advice *models.DoctorAdvice) (err error) {
79
+func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DoctorAdvice) (err error) {
79 80
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
80 81
 	var deliver_number int64 = 0
81 82
 	var stock_number int64 = 0
@@ -90,13 +91,13 @@ func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.
90 91
 
91 92
 	// 根据先进先出原则,查询最先入库的批次,进行出库
92 93
 	// 如果没有对应的库存,则报错
93
-	warehouse,err := FindLastWarehousingInfoByID(advice.DrugId)
94
+	warehouse, err := FindLastWarehousingInfoByID(advice.DrugId)
94 95
 	if err != nil {
95 96
 		return err
96 97
 	}
97 98
 
98 99
 	// 将该批次的剩余库存数量转换为拆零数量
99
-	stock_number = warehouse.StockMaxNumber * drup.MinNumber + warehouse.StockMinNumber
100
+	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
100 101
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
101 102
 	if stock_number >= deliver_number {
102 103
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
@@ -132,7 +133,7 @@ func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.
132 133
 				OrgId:                   orgID,
133 134
 				DrugId:                  advice.DrugId,
134 135
 				Count:                   deliver_number,
135
-				CountUnit:				 drup.MinUnit,
136
+				CountUnit:               drup.MinUnit,
136 137
 			}
137 138
 			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
138 139
 			if errTwo != nil {
@@ -172,7 +173,7 @@ func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.
172 173
 		}
173 174
 
174 175
 		return nil
175
-	}  else {
176
+	} else {
176 177
 		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
177 178
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
178 179
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -192,7 +193,7 @@ func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.
192 193
 		// count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
193 194
 		warehouseOutInfo.Count = stock_number
194 195
 		warehouseOutInfo.CountUnit = drup.MinUnit
195
-		
196
+
196 197
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
197 198
 		if errOne != nil {
198 199
 			return errOne
@@ -208,7 +209,7 @@ func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.
208 209
 				OrgId:                   orgID,
209 210
 				DrugId:                  advice.DrugId,
210 211
 				Count:                   stock_number,
211
-				CountUnit:				 drup.MinUnit,
212
+				CountUnit:               drup.MinUnit,
212 213
 			}
213 214
 			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
214 215
 			if errTwo != nil {
@@ -227,9 +228,9 @@ func DrugDeliverInfo(orgID int64,prescribingNumber float64,warehouseout *models.
227 228
 		prescribingNumber_two_temp := deliver_number - stock_number
228 229
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
229 230
 		advice.PrescribingNumberUnit = drup.MinUnit
230
-		DrugDeliverInfo(orgID ,prescribingNumber,warehouseout,drup ,advice )
231
+		DrugDeliverInfo(orgID, prescribingNumber, warehouseout, drup, advice)
231 232
 	}
232
-	return nil
233
+	return
233 234
 }
234 235
 
235 236
 // 耗材出库
@@ -522,9 +523,7 @@ func ConsumablesDeliveryDelete(orgID int64,patient_id int64,record_time int64,go
522 523
 		}
523 524
 
524 525
 		// 删除出库完成后,要增加对应批次的库存数量
525
-			
526
-		warehouse.StockNumber = warehouse.StockMaxNumber - maxNumber
527
-		warehouse.Mtime = time.Now().Unix()
526
+	
528 527
 		
529 528
 
530 529
 		errThree := UpDateWarehouseInfoByStockDelete(ware.WarehouseInfoId,delete_count)
@@ -533,11 +532,12 @@ func ConsumablesDeliveryDelete(orgID int64,patient_id int64,record_time int64,go
533 532
 		}
534 533
 
535 534
 		// 增加了对应的库存后,看看还有多少需要退库的
536
-		good_yc.Count = goods_yc - delete_count 
535
+		good_yc.Count = goods_yc.Count - delete_count 
537 536
 		if good_yc.Count == 0 {
538 537
 			return nil
539 538
 		}
540 539
 	}
540
+	
541 541
 	if good_yd.Count == 0 {
542 542
 		return nil 
543 543
 	}  else {