Преглед изворни кода

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

csx пре 3 година
родитељ
комит
271f550f37

+ 1 - 1
controllers/data_api_controller.go Прегледај датотеку

@@ -1227,7 +1227,7 @@ func (c *DataApiController) CreateSingleAdviceTemplate() {
1227 1227
 		AdviceName:            advice_name,
1228 1228
 		AdviceDesc:            advice_desc,
1229 1229
 		SingleDose:            single_dose,
1230
-		SingleDoseUnit:        single_dose_unit,
1230
+		SingleDoseUnit:        service.TypeConversion02(single_dose_unit),
1231 1231
 		PrescribingNumber:     prescribing_number,
1232 1232
 		PrescribingNumberUnit: prescribing_number_unit,
1233 1233
 		DeliveryWay:           delivery_way,

+ 2 - 1
controllers/drug_stock_api_contorller.go Прегледај датотеку

@@ -1696,6 +1696,7 @@ func (c *StockDrugApiController) GetDrugWarehouseOutList() {
1696 1696
 	types, _ := c.GetInt64("type", 0)
1697 1697
 	keywords := c.GetString("keywords")
1698 1698
 	storehouse_id, _ := c.GetInt64("storehouse_id")
1699
+	way_type, _ := c.GetInt64("way_type")
1699 1700
 	timeLayout := "2006-01-02"
1700 1701
 	loc, _ := time.LoadLocation("Local")
1701 1702
 	var startTime int64
@@ -1739,7 +1740,7 @@ func (c *StockDrugApiController) GetDrugWarehouseOutList() {
1739 1740
 
1740 1741
 	}
1741 1742
 
1742
-	warehouseOutList, total, err := service.FindAllDrugWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id)
1743
+	warehouseOutList, total, err := service.FindAllDrugWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id, way_type)
1743 1744
 
1744 1745
 	houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
1745 1746
 	fmt.Println(err)

+ 40 - 0
controllers/gobal_config_api_controller.go Прегледај датотеку

@@ -116,6 +116,8 @@ func GobalConfigRegistRouters() {
116 116
 	beego.Router("/api/changestocksetting/isopen", &GobalConfigApiController{}, "Get:ChangeStockSetting")
117 117
 
118 118
 	beego.Router("/api/changeadviceconfig", &GobalConfigApiController{}, "Get:ChangeAdviceConfig")
119
+
120
+	beego.Router("/api/changeprescriptionconfig", &GobalConfigApiController{}, "Get:ChangePrescriptionConfig")
119 121
 }
120 122
 
121 123
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1563,11 +1565,14 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1563 1565
 
1564 1566
 	stockSetting, _ := service.FindStockSettingById(adminUserInfo.CurrentOrgId)
1565 1567
 	adviceSetting, _ := service.FindAdviceSettingById(adminUserInfo.CurrentOrgId)
1568
+
1569
+	prescriptionConfig, _ := service.FindPrescriptionConfigById(adminUserInfo.CurrentOrgId)
1566 1570
 	c.ServeSuccessJSON(map[string]interface{}{
1567 1571
 		"is_open_xt_his":         config.IsOpen,
1568 1572
 		"is_open_xt_his_project": project_config.IsOpen,
1569 1573
 		"is_open_stock":          stockSetting.IsType,
1570 1574
 		"is_open_advice":         adviceSetting.IsAdviceOpen,
1575
+		"is_prescription_advice": prescriptionConfig.IsOpen,
1571 1576
 	})
1572 1577
 
1573 1578
 }
@@ -2395,3 +2400,38 @@ func (c *GobalConfigApiController) ChangeAdviceConfig() {
2395 2400
 	}
2396 2401
 
2397 2402
 }
2403
+
2404
+func (c *GobalConfigApiController) ChangePrescriptionConfig() {
2405
+
2406
+	is_open_prescription_xt_his, _ := c.GetInt64("is_open_prescription_xt_his")
2407
+
2408
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2409
+
2410
+	_, errcode := service.GetPrescriptionConfig(orgId)
2411
+
2412
+	if errcode == gorm.ErrRecordNotFound {
2413
+
2414
+		config := models.XtPrescriptionConfig{
2415
+			UserOrgId: orgId,
2416
+			IsOpen:    is_open_prescription_xt_his,
2417
+			Status:    1,
2418
+			Ctime:     time.Now().Unix(),
2419
+		}
2420
+		service.CreatePrescriptionConfig(config)
2421
+		c.ServeSuccessJSON(map[string]interface{}{
2422
+			"msg": 1,
2423
+		})
2424
+	} else if errcode == nil {
2425
+		config := models.XtPrescriptionConfig{
2426
+			UserOrgId: orgId,
2427
+			IsOpen:    is_open_prescription_xt_his,
2428
+			Status:    1,
2429
+			Ctime:     time.Now().Unix(),
2430
+		}
2431
+		service.UpdatePrescriptionConfig(orgId, config)
2432
+		c.ServeSuccessJSON(map[string]interface{}{
2433
+			"msg": 1,
2434
+		})
2435
+	}
2436
+
2437
+}

+ 65 - 12
controllers/his_api_controller.go Прегледај датотеку

@@ -4547,9 +4547,41 @@ func (c *HisApiController) GetUploadInfo() {
4547 4547
 	reg_type, _ := c.GetInt64("p_type")
4548 4548
 	order_id, _ := c.GetInt64("order_id")
4549 4549
 
4550
-	his, _ := service.GetHisPatientByIdThree(his_patient_id)
4550
+	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
4551
+	tmp_decimal := c.GetString("tmp_decimal")
4552
+	var decimal float64 //本次使用的押金
4553
+	var errmsg error
4554
+	tx := service.XTWriteDB().Begin() //开了事务
4555
+	//只检测扣费函数SpendDeposit有没有返回错误,如果有则回滚所有以TX结尾的方法(去掉TX即为原先的方法)
4556
+	defer func() {
4557
+		if errmsg != nil {
4558
+			utils.ErrorLog("事务失败,原因为: %v", errmsg.Error())
4559
+			tx.Rollback()
4560
+		} else {
4561
+			tx.Commit()
4562
+		}
4563
+	}()
4564
+	if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
4565
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
4566
+		return
4567
+	}
4568
+	if len(tmp_decimal) > 0 {
4569
+		if tmp_decimal[0] == 45 {
4570
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
4571
+			return
4572
+		}
4573
+	}
4574
+	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
4575
+	fmt.Println(errs)
4576
+	//if errs != nil {
4577
+	//	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
4578
+	//	return
4579
+	//}
4580
+	decimal = tt
4551 4581
 
4552
-	tempOrder, _ := service.GetHisOrderByID(order_id)
4582
+	his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)
4583
+
4584
+	tempOrder, _ := service.GetHisOrderByIDTX(order_id, tx)
4553 4585
 
4554 4586
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
4555 4587
 	if err != nil {
@@ -4765,16 +4797,28 @@ func (c *HisApiController) GetUploadInfo() {
4765 4797
 				Type:             types,
4766 4798
 				ItemId:           item_id,
4767 4799
 			}
4768
-			service.CreateOrderInfo(info)
4800
+			service.CreateOrderInfoTX(info, tx)
4769 4801
 		}
4770 4802
 		his.Diagnosis = diagnosis_id
4771 4803
 		his.SickType = sick_type
4772 4804
 		his.RegisterType = reg_type
4773 4805
 		his.MedicalTreatmentType = reg_type
4774
-		service.UpdataHisPateint(&his)
4775
-		err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
4776
-		err = service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id)
4777
-		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
4806
+		service.UpdataHisPateintTX(&his, tx)
4807
+		err = service.UpDatePrescriptionNumberTX(adminUser.CurrentOrgId, ids, chrg_bchno, tx)
4808
+		err = service.UpDateHisPrescriptionInfoNumberTX(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id, tx)
4809
+		err = service.UpdataOrderStatusTwoTX(chrg_bchno, adminUser.CurrentOrgId, tx)
4810
+		//判断是否使用了押金
4811
+		if dec_way == "true" {
4812
+
4813
+			tmpstring := strconv.FormatInt(order.ID, 10)
4814
+			//扣押金
4815
+			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
4816
+			if errmsg != nil {
4817
+				c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
4818
+				//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4819
+				return
4820
+			}
4821
+		}
4778 4822
 		if err == nil {
4779 4823
 			c.ServeSuccessJSON(map[string]interface{}{
4780 4824
 				"msg": "结算成功",
@@ -4819,15 +4863,24 @@ func (c *HisApiController) Refund() {
4819 4863
 	order_id, _ := c.GetInt64("order_id")
4820 4864
 	order, _ := service.GetHisOrderByID(order_id)
4821 4865
 	adminUser := c.GetAdminUserInfo()
4866
+	orgid := c.GetAdminUserInfo().CurrentOrgId
4822 4867
 	err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
4823
-	if err == nil {
4824
-		c.ServeSuccessJSON(map[string]interface{}{
4825
-			"msg": "退费成功",
4826
-		})
4827
-	} else {
4868
+	if err != nil {
4828 4869
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4829 4870
 		return
4830 4871
 	}
4872
+	tmp := strconv.FormatInt(order.ID, 10)
4873
+	//当押金不为零时产生退费记录
4874
+	if order.Decimal != 0 {
4875
+		err = service.MoneyIncrease(orgid, order.PatientId, tmp, order.Decimal)
4876
+		if err != nil {
4877
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4878
+			return
4879
+		}
4880
+	}
4881
+	c.ServeSuccessJSON(map[string]interface{}{
4882
+		"msg": "退费成功",
4883
+	})
4831 4884
 }
4832 4885
 
4833 4886
 func (c *HisApiController) RefundNumber() {

+ 57 - 12
controllers/his_deposit_controller.go Прегледај датотеку

@@ -20,6 +20,7 @@ type HisDepositApiController struct {
20 20
 
21 21
 func HisDepositApiRegistRouters() {
22 22
 	//beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT")                         //测试接口
23
+	beego.Router("/api/his/gethisusertoalive", &HisDepositApiController{}, "get:GetHisUserToAlive")  //获取病例中心,有效患者名称(去除了转出和死亡的)
23 24
 	beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser")                //获取病例中心,有效患者名称
24 25
 	beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit")               //新增押金
25 26
 	beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode")        //获取新增押金编号
@@ -58,9 +59,27 @@ func HisDepositApiRegistRouters() {
58 59
 //	return
59 60
 //}
60 61
 
62
+//获取病例中心,有效患者名称(去除了转出和死亡的)
63
+func (this *HisDepositApiController) GetHisUserToAlive() {
64
+	orgid := this.GetAdminUserInfo().CurrentOrgId
65
+	list, err := service.GetHisUserToAlive(orgid)
66
+	if err != nil {
67
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
68
+		return
69
+	}
70
+	this.ServeSuccessJSON(map[string]interface{}{
71
+		"list": list,
72
+	})
73
+	return
74
+}
75
+
61 76
 //获取病例中心,有效患者名称
62 77
 func (this *HisDepositApiController) GetHisUser() {
63 78
 	orgid := this.GetAdminUserInfo().CurrentOrgId
79
+	token := this.Ctx.Request.Header.Get("Cookie")
80
+	fmt.Println(token)
81
+	this.Ctx.SetCookie("ppp", "lilili")
82
+	this.Ctx.SetCookie("ppp01", "lilili01")
64 83
 	list, err := service.GetHisUser(orgid)
65 84
 	if err != nil {
66 85
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
@@ -205,7 +224,9 @@ func (this *HisDepositApiController) RechargeDetails() {
205 224
 		}
206 225
 	}
207 226
 	if start_time == "" && end_time == "" {
208
-		stime, etime = service.GetMondayOfWeek()
227
+		//如果为空查询全部的
228
+		_, etime = service.GetMondayOfWeek()
229
+		stime = 0
209 230
 	} else {
210 231
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
211 232
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -259,7 +280,8 @@ func (this *HisDepositApiController) RechargeSummary() {
259 280
 		}
260 281
 	}
261 282
 	if start_time == "" && end_time == "" {
262
-		stime, etime = service.GetMondayOfWeek()
283
+		_, etime = service.GetMondayOfWeek()
284
+		stime = 0
263 285
 	} else {
264 286
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
265 287
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -372,6 +394,8 @@ func (this *HisDepositApiController) DepositFlow() {
372 394
 	check := map[string][]string{
373 395
 		"id":             {"must", "int", "id"},
374 396
 		"deposit_status": {"must", "int", "deposit_status"},
397
+		"page":           {"must", "string", "page"},
398
+		"limit":          {"must", "string", "limit"},
375 399
 	}
376 400
 	_, err := checks(this, &check)
377 401
 	if err != nil {
@@ -383,19 +407,23 @@ func (this *HisDepositApiController) DepositFlow() {
383 407
 	tmp, _ := service.GetHisUserName(orgid, id)
384 408
 	name := tmp.Name
385 409
 	deposit_status, _ := this.GetInt64("deposit_status", 0) //押金类型
386
-	if deposit_status > 3 {
410
+	if deposit_status > 4 {
387 411
 		utils.ErrorLog("押金类型错误,deposit_status:", deposit_status)
388 412
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金类型错误")
389 413
 		return
390 414
 	}
391 415
 	start_time := this.GetString("start_time", "") //开始时间
392 416
 	end_time := this.GetString("end_time", "")     //结束时间
417
+	page, _ := this.GetInt64("page")               //页码
418
+	limit, _ := this.GetInt64("limit")             //每一页查出来的条数
393 419
 	timeLayout := "2006-01-02"
394 420
 	loc, _ := time.LoadLocation("Local")
395 421
 	var stime int64 //开始时间
396 422
 	var etime int64 //结束时间
397 423
 	if start_time == "" && end_time == "" {
398
-		stime, etime = service.GetMonth()
424
+		//如果为空则查全部的
425
+		_, etime = service.GetMonth()
426
+		stime = 0
399 427
 	} else {
400 428
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
401 429
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -405,7 +433,7 @@ func (this *HisDepositApiController) DepositFlow() {
405 433
 	//获取该角色当前时间段的余额
406 434
 	decimal := service.GetMoneyforTime(id, orgid, etime)
407 435
 	//获取列表
408
-	deposirhistory, errs := service.GetFlowList(id, orgid, stime, etime, deposit_status)
436
+	deposirhistory, total, errs := service.GetFlowList(page, limit, id, orgid, stime, etime, deposit_status)
409 437
 	if errs != nil {
410 438
 		utils.ErrorLog("获取列表失败,原因为:", errs.Error())
411 439
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
@@ -423,6 +451,7 @@ func (this *HisDepositApiController) DepositFlow() {
423 451
 		"list":    deposirhistory,
424 452
 		"name":    name,
425 453
 		"decimal": decimal,
454
+		"total":   total,
426 455
 	})
427 456
 	return
428 457
 }
@@ -475,6 +504,7 @@ func (this *HisDepositApiController) GetUserList() {
475 504
 //扣费明细查询
476 505
 func (this *HisDepositApiController) DeductionDetails() {
477 506
 	orgid := this.GetAdminUserInfo().CurrentOrgId
507
+	//orgid = 9675
478 508
 	timeLayout := "2006-01-02"
479 509
 	loc, _ := time.LoadLocation("Local")
480 510
 	keyword := this.GetString("keyword")
@@ -498,7 +528,8 @@ func (this *HisDepositApiController) DeductionDetails() {
498 528
 		}
499 529
 	}
500 530
 	if start_time == "" && end_time == "" {
501
-		stime, etime = service.GetMondayOfWeek()
531
+		_, etime = service.GetMondayOfWeek()
532
+		stime = 0
502 533
 	} else {
503 534
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
504 535
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -526,7 +557,8 @@ func (this *HisDepositApiController) DeductionDetails() {
526 557
 		details.Decimal = list[i].Deposit
527 558
 		details.ChargeDate = fmt.Sprintf(time.Unix(list[i].Ctime, 0).Format("2006-01-02 15:04:05"))
528 559
 		details.Chargetype = service.CodeToChargetype(orgid, details.Code)
529
-		details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, details.Code)
560
+		details.Total = service.MedicalTotal(orgid, tmp_id)
561
+		details.ButtonShow = service.IsButtonShow(list[i].DepositCode, orgid, list[i].HisPatientId)
530 562
 		detailslist = append(detailslist, details)
531 563
 	}
532 564
 
@@ -540,6 +572,7 @@ func (this *HisDepositApiController) DeductionDetails() {
540 572
 //扣费汇总
541 573
 func (this *HisDepositApiController) DeSummary() {
542 574
 	orgid := this.GetAdminUserInfo().CurrentOrgId
575
+	orgid = 9675
543 576
 	timeLayout := "2006-01-02"
544 577
 	loc, _ := time.LoadLocation("Local")
545 578
 	keyword := this.GetString("keyword")
@@ -563,7 +596,8 @@ func (this *HisDepositApiController) DeSummary() {
563 596
 		}
564 597
 	}
565 598
 	if start_time == "" && end_time == "" {
566
-		stime, etime = service.GetMondayOfWeek()
599
+		_, etime = service.GetMondayOfWeek()
600
+		stime = 0
567 601
 	} else {
568 602
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
569 603
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -583,7 +617,8 @@ func (this *HisDepositApiController) DeSummary() {
583 617
 		sum = sum.Add(list[i].Deposit)
584 618
 		details.Name = namemap[list[i].HisPatientId]
585 619
 		details.Decimal = list[i].Deposit
586
-		details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, list[i].DepositCode)
620
+		tmp_id, _ := strconv.ParseInt(list[i].DepositCode, 10, 64)
621
+		details.Total = service.MedicalTotal(orgid, tmp_id)
587 622
 		detailslist = append(detailslist, details)
588 623
 	}
589 624
 	maplist := make(map[string]models.DeductionSummary)
@@ -611,7 +646,7 @@ func (this *HisDepositApiController) DeSummary() {
611 646
 		Finlist = append(Finlist, maplist[tmpslice[i]])
612 647
 	}
613 648
 	this.ServeSuccessJSON(map[string]interface{}{
614
-		"list": detailslist,
649
+		"list": Finlist,
615 650
 		"sum":  sum,
616 651
 	})
617 652
 	return
@@ -835,6 +870,8 @@ func (this *HisDepositApiController) RefundList() {
835 870
 	check := map[string][]string{
836 871
 		"refundtype":  {"must", "int", "refundtype"},
837 872
 		"examinetype": {"must", "int", "examinetype"},
873
+		"page":        {"must", "string", "page"},
874
+		"limit":       {"must", "string", "limit"},
838 875
 	}
839 876
 	_, err := checks(this, &check)
840 877
 	if err != nil {
@@ -847,6 +884,8 @@ func (this *HisDepositApiController) RefundList() {
847 884
 	keyword := this.GetString("keyword")           //获取搜索框
848 885
 	refundtype, _ := this.GetInt64("refundtype")   //获取退款类型
849 886
 	examinetype, _ := this.GetInt64("examinetype") //获取审核状态
887
+	page, _ := this.GetInt64("page")               //页码
888
+	limit, _ := this.GetInt64("limit")             //每一页查出来的条数
850 889
 	start_time := this.GetString("start_time")
851 890
 	end_time := this.GetString("end_time")
852 891
 	var stime int64 //开始时间
@@ -868,6 +907,7 @@ func (this *HisDepositApiController) RefundList() {
868 907
 	}
869 908
 	if start_time == "" && end_time == "" {
870 909
 		stime, etime = service.GetMondayOfWeek()
910
+		stime = 0
871 911
 	} else {
872 912
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
873 913
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -875,7 +915,8 @@ func (this *HisDepositApiController) RefundList() {
875 915
 		etime = etmp.Unix()
876 916
 	}
877 917
 	depo := []models.RefundList{}
878
-	depo, err = service.RefundList(orgid, stime, etime, refundtype, examinetype, keyword, slicekey)
918
+	var total int64
919
+	depo, total, err = service.RefundList(page, limit, orgid, stime, etime, refundtype, examinetype, keyword, slicekey)
879 920
 	if err != nil {
880 921
 		utils.ErrorLog("查询失败,原因为:", err.Error())
881 922
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -891,10 +932,14 @@ func (this *HisDepositApiController) RefundList() {
891 932
 		}
892 933
 		if depo[i].DepositStatus == 4 {
893 934
 			depo[i].Name = "-"
935
+			tmpcode, _ := strconv.ParseInt(depo[i].DepositCode, 10, 64)
936
+			depo[i].DepositCode = service.FindcodeToid(tmpcode)
894 937
 		}
938
+
895 939
 	}
896 940
 	this.ServeSuccessJSON(map[string]interface{}{
897
-		"list": depo,
941
+		"list":  depo,
942
+		"total": total,
898 943
 	})
899 944
 	return
900 945
 }

+ 67 - 12
controllers/his_hospital_api_controller.go Прегледај датотеку

@@ -4,6 +4,7 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
+	"XT_New/utils"
7 8
 	"fmt"
8 9
 	"github.com/astaxie/beego"
9 10
 	"github.com/shopspring/decimal"
@@ -742,6 +743,7 @@ func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
742 743
 		IsMedicineInsurance: 1,
743 744
 		PType:               1,
744 745
 		MedfeeSumamt:        total,
746
+		PsnPartAmt:          total,
745 747
 	}
746 748
 	err := service.CreateOrder(order)
747 749
 	if err != nil {
@@ -768,8 +770,41 @@ func (c *HisHospitalApiController) GetSettleInfo() {
768 770
 	private_price, _ := c.GetFloat("private_price")
769 771
 	fapiao_code := c.GetString("fapiao_code")
770 772
 	fapiao_number := c.GetString("fapiao_number")
771
-	record, _ := service.GetInHospitalRecord(in_hospital_id)
772
-	order, _ := service.GetHisOrderByID(order_id)
773
+
774
+	id, _ := c.GetInt64("patient_id")
775
+	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
776
+	tmp_decimal := c.GetString("tmp_decimal")
777
+	var decimal float64 //本次使用的押金
778
+	var errmsg error
779
+	tx := service.XTWriteDB().Begin() //开了事务
780
+	//只检测扣费函数SpendDeposit有没有返回错误,如果有则回滚所有以TX结尾的方法(去掉TX即为原先的方法)
781
+	defer func() {
782
+		if errmsg != nil {
783
+			utils.ErrorLog("事务失败,原因为: %v", errmsg.Error())
784
+			tx.Rollback()
785
+		} else {
786
+			tx.Commit()
787
+		}
788
+	}()
789
+	if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
790
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
791
+		return
792
+	}
793
+	if len(tmp_decimal) > 0 {
794
+		if tmp_decimal[0] == 45 {
795
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
796
+			return
797
+		}
798
+	}
799
+	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
800
+	if errs != nil {
801
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
802
+		return
803
+	}
804
+	decimal = tt
805
+
806
+	record, _ := service.GetInHospitalRecordTX(in_hospital_id, tx)
807
+	order, _ := service.GetHisOrderByIDTX(order_id, tx)
773 808
 	chrg_bchno := order.Number
774 809
 	if record.ID == 0 {
775 810
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -793,9 +828,21 @@ func (c *HisHospitalApiController) GetSettleInfo() {
793 828
 	order.PrivatePrice = private_price
794 829
 	order.MdtrtId = record.Number
795 830
 	order.MedfeeSumamt = order.MedfeeSumamt
831
+	order.Decimal = decimal
796 832
 	//order.SetlTime =
797
-	err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
798
-	err = service.UpDateOrder(order)
833
+	err := service.UpdataOrderStatusTwoTX(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId, tx)
834
+	err = service.UpDateOrderTX(order, tx)
835
+	//判断是否使用了押金
836
+	if dec_way == "true" {
837
+		tmpstring := strconv.FormatInt(order.ID, 10)
838
+		//扣押金
839
+		errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
840
+		if errmsg != nil {
841
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
842
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
843
+			return
844
+		}
845
+	}
799 846
 	if err == nil {
800 847
 		c.ServeSuccessJSON(map[string]interface{}{
801 848
 			"msg": "结算成功",
@@ -807,19 +854,27 @@ func (c *HisHospitalApiController) GetSettleInfo() {
807 854
 }
808 855
 func (c *HisHospitalApiController) ZHRefund() {
809 856
 	order_id, _ := c.GetInt64("order_id")
857
+	order, _ := service.GetHisOrderByID(order_id)
810 858
 	adminUser := c.GetAdminUserInfo()
811
-	var order models.HisOrder
812
-	order, _ = service.GetHisOrderByID(order_id)
813
-
859
+	orgid := c.GetAdminUserInfo().CurrentOrgId
814 860
 	err := service.UpdataHospitalOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
815
-	if err == nil {
816
-		c.ServeSuccessJSON(map[string]interface{}{
817
-			"msg": "退费成功",
818
-		})
819
-	} else {
861
+	if err != nil {
820 862
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
821 863
 		return
822 864
 	}
865
+	tmp := strconv.FormatInt(order.ID, 10)
866
+	//当押金不为零时产生退费记录
867
+	if order.Decimal != 0 {
868
+		err = service.MoneyIncrease(orgid, order.PatientId, tmp, order.Decimal)
869
+		if err != nil {
870
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
871
+			return
872
+		}
873
+	}
874
+
875
+	c.ServeSuccessJSON(map[string]interface{}{
876
+		"msg": "退费成功",
877
+	})
823 878
 
824 879
 }
825 880
 func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {

+ 539 - 6
controllers/his_summary_controller.go Прегледај датотеку

@@ -15,7 +15,7 @@ func HisSummaryApiRegistRouters() {
15 15
 
16 16
 	beego.Router("/api/gethissummarydetaillist", &HisSummaryApiController{}, "Get:GetHisSummaryDetailList")
17 17
 	beego.Router("/api/his/getgatherdetailist", &HisSummaryApiController{}, "Get:GetGatherDetaiList")
18
-
18
+	beego.Router("/api/his/getdetailpatients", &HisSummaryApiController{}, "Get:GetDetailPatients")
19 19
 }
20 20
 
21 21
 func (this *HisSummaryApiController) GetHisSummaryDetailList() {
@@ -42,9 +42,24 @@ func (this *HisSummaryApiController) GetHisSummaryDetailList() {
42 42
 	endRecordDateTime := endTime.Unix()
43 43
 
44 44
 	list, err := service.GetHisSummaryDetailList(keyword, item_type, patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
45
+	patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
46
+
47
+	his_patient, _ := service.GetHisSummaryPatientInfo(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
48
+
49
+	order, _ := service.GetHisLastOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
50
+
51
+	his_record_patient, _ := service.GetHisSummaryPatientInfoSix(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
52
+
53
+	//获取所有的科室
54
+	hisDepatment, _ := service.GetHisDepatment(adminUser.CurrentOrgId)
45 55
 	if err == nil {
46 56
 		this.ServeSuccessJSON(map[string]interface{}{
47
-			"list": list,
57
+			"list":               list,
58
+			"patient":            patient,
59
+			"his_patient":        his_patient,
60
+			"hisDepatment":       hisDepatment,
61
+			"order":              order,
62
+			"his_record_patient": his_record_patient,
48 63
 		})
49 64
 		return
50 65
 	} else {
@@ -77,13 +92,531 @@ func (this *HisSummaryApiController) GetGatherDetaiList() {
77 92
 	}
78 93
 	endRecordDateTime := endTime.Unix()
79 94
 
80
-	list, err := service.GetAdviceGatherDetaiList(keyword, item_type, patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
95
+	list, err := service.GetHisSummaryDetailList(keyword, item_type, patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
96
+	patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
97
+
98
+	his_patient, _ := service.GetHisSummaryPatientInfo(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
99
+
100
+	order, _ := service.GetHisLastOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
101
+
102
+	his_record_patient, _ := service.GetHisSummaryPatientInfoSix(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
103
+
104
+	//获取所有的科室
105
+	hisDepatment, _ := service.GetHisDepatment(adminUser.CurrentOrgId)
106
+
107
+	var medicalInsuranceLevel = "医保等级"
108
+	medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
109
+	medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, adminUser.CurrentOrgId)
110
+	var drugType = "药品类型"
111
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
112
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminUser.CurrentOrgId)
113
+	var costClassify = "费用类别"
114
+	costClassifyParent, _ := service.GetDrugDataConfig(0, costClassify)
115
+	costClassifyList, _ := service.GetParentDataConfig(costClassifyParent.ID, adminUser.CurrentOrgId)
116
+	doctorlist, _ := service.GetAllDoctorSix(adminUser.CurrentOrgId, adminUser.CurrentAppId)
117
+
118
+	//获取最后一次排班
119
+	schedule, _ := service.GetHisSchedule(patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
120
+	bedNumber, _ := service.GetAllBedNumberSix(adminUser.CurrentOrgId)
121
+	orderInfo, _ := service.GetHisLastOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
122
+
123
+	if err == nil {
124
+		this.ServeSuccessJSON(map[string]interface{}{
125
+			"list":                      list,
126
+			"patient":                   patient,
127
+			"his_patient":               his_patient,
128
+			"hisDepatment":              hisDepatment,
129
+			"order":                     order,
130
+			"his_record_patient":        his_record_patient,
131
+			"medicalInsuranceLevelList": medicalInsuranceLevelList,
132
+			"drugTypeList":              drugTypeList,
133
+			"costClassifyList":          costClassifyList,
134
+			"doctorlist":                doctorlist,
135
+			"schedule":                  schedule,
136
+			"bedNumber":                 bedNumber,
137
+			"orderInfo":                 orderInfo,
138
+		})
139
+		return
140
+	} else {
141
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
142
+		return
81 143
 
82
-	detailList, _ := service.GetProjectGatherDetailList(keyword, item_type, patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
144
+	}
145
+}
146
+
147
+//func (this *HisSummaryApiController) GetGatherDetaiList() {
148
+//
149
+//	start_time := this.GetString("start_time")
150
+//	end_time := this.GetString("end_time")
151
+//	keyword := this.GetString("keyword")
152
+//	item_type, _ := this.GetInt64("type")
153
+//	patient_id, _ := this.GetInt64("patient_id")
154
+//	adminUser := this.GetAdminUserInfo()
155
+//
156
+//	timeLayout := "2006-01-02"
157
+//	loc, _ := time.LoadLocation("Local")
158
+//	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
159
+//	if err != nil {
160
+//
161
+//	}
162
+//	startRecordDateTime := startTime.Unix()
163
+//
164
+//	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
165
+//	if err != nil {
166
+//
167
+//	}
168
+//	endRecordDateTime := endTime.Unix()
169
+//
170
+//	//查询该病人这段时间的记录单号
171
+//	orderInfo, _ := service.GetGatherHisOrder(keyword, item_type, patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
172
+//
173
+//	org_id := this.GetAdminUserInfo().CurrentOrgId
174
+//	appid := this.GetAdminUserInfo().CurrentAppId
175
+//	var order_info []*service.HisOrderInfo
176
+//
177
+//	var MdtrtId string
178
+//
179
+//	patient, _ := service.GetPatientByID(org_id, patient_id)
180
+//	for _, item := range orderInfo {
181
+//		orderinfo, _ := service.GetHisOrderDetailByNumber(item.Number, org_id)
182
+//		MdtrtId = item.MdtrtId
183
+//		for _, it := range orderinfo {
184
+//
185
+//			order_info = append(order_info, it)
186
+//		}
187
+//	}
188
+//	his, _ := service.GetHisPatientInfoFive(org_id, patient_id, startRecordDateTime, endRecordDateTime)
189
+//
190
+//	record, _ := service.GetInHospitalRecordByNumber(MdtrtId)
191
+//
192
+//	//获取所有客户
193
+//	adminInfo, _ := service.GetAllDoctorSix(org_id, appid)
194
+//
195
+//	//获取最后一次排班
196
+//	schedule, _ := service.GetHisSchedule(patient_id, org_id, startRecordDateTime, endRecordDateTime)
197
+//
198
+//	bedNumber, _ := service.GetAllBedNumberSix(org_id)
199
+//	var bedCostTotal float64 = 0 //床位总费
200
+//
201
+//	var operationCostTotal float64 = 0 //手术费
202
+//
203
+//	var otherCostTotal float64 = 0 //其他费用
204
+//
205
+//	var materialCostTotal float64 = 0 //材料费
206
+//
207
+//	var westernMedicineCostTotal float64 = 0 //西药费
208
+//
209
+//	var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
210
+//
211
+//	var checkCostTotal float64 = 0 //检查费
212
+//
213
+//	var laboratoryCostTotal float64 = 0 //化验费
214
+//
215
+//	var treatCostTotal float64 = 0 //治疗费用
216
+//
217
+//	var zhenChaCostTotal float64 = 0 //其他费用
218
+//
219
+//	decimal.DivisionPrecision = 2
220
+//	var BalanceAccountsType int64
221
+//	if his.ID > 0 {
222
+//		BalanceAccountsType = his.BalanceAccountsType
223
+//	} else {
224
+//		BalanceAccountsType = record.BalanceAccountsType
225
+//	}
226
+//
227
+//	his_patient, _ := service.GetHisSummaryPatientInfo(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
228
+//
229
+//	//获取所有的科室
230
+//	hisDepatment, _ := service.GetHisDepatment(adminUser.CurrentOrgId)
231
+//
232
+//	//统计
233
+//	prescription, _ := service.GetHisPrescriptionTenty(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, keyword, item_type)
234
+//
235
+//	//orderlist, _ := service.GetHisChargeOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, keyword, item_type)
236
+//
237
+//	var medicalInsuranceLevel = "医保等级"
238
+//	medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
239
+//	medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, adminUser.CurrentOrgId)
240
+//	if BalanceAccountsType != 2 && BalanceAccountsType > 0 {
241
+//		for _, item := range order_info {
242
+//			if org_id == 10215 {
243
+//				if item.MedChrgitmType == "01" { //床位费
244
+//					bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
245
+//				}
246
+//				if item.MedChrgitmType == "02" { //诊察费
247
+//					zhenChaCostTotal, _ = decimal.NewFromFloat(zhenChaCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
248
+//
249
+//				}
250
+//				if item.MedChrgitmType == "03" { //检查费
251
+//					checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
252
+//
253
+//				}
254
+//
255
+//				if item.MedChrgitmType == "04" { //化验费
256
+//					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
257
+//				}
258
+//
259
+//				if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
260
+//					treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
261
+//
262
+//				}
263
+//
264
+//				if item.MedChrgitmType == "06" { //手术费
265
+//					operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
266
+//				}
267
+//
268
+//				if item.MedChrgitmType == "08" { //材料费
269
+//					materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
270
+//				}
271
+//
272
+//				if item.MedChrgitmType == "09" { //西药费
273
+//					westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
274
+//				}
275
+//
276
+//				if item.MedChrgitmType == "11" { //中成费
277
+//					chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
278
+//				}
279
+//
280
+//				if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
281
+//					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
282
+//				}
283
+//
284
+//			} else if org_id == 10188 || org_id == 10217 {
285
+//				if item.MedChrgitmType == "01" { //床位费
286
+//					bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
287
+//
288
+//				}
289
+//				if item.MedChrgitmType == "02" { //诊察费
290
+//					zhenChaCostTotal, _ = decimal.NewFromFloat(zhenChaCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
291
+//				}
292
+//				if item.MedChrgitmType == "03" { //检查费
293
+//					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
294
+//				}
295
+//
296
+//				if item.MedChrgitmType == "04" { //化验费
297
+//					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
298
+//				}
299
+//
300
+//				if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
301
+//					treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
302
+//				}
303
+//
304
+//				if item.MedChrgitmType == "06" { //手术费
305
+//					operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
306
+//				}
307
+//
308
+//				if item.MedChrgitmType == "08" { //材料费
309
+//					materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
310
+//				}
311
+//
312
+//				if item.MedChrgitmType == "09" { //西药费
313
+//					westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
314
+//				}
315
+//
316
+//				if item.MedChrgitmType == "11" { //中成费
317
+//					chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
318
+//				}
319
+//
320
+//				if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
321
+//					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
322
+//				}
323
+//
324
+//			} else {
325
+//
326
+//				if item.MedChrgitmType == "01" { //床位费
327
+//					bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
328
+//
329
+//				}
330
+//
331
+//				if item.MedChrgitmType == "03" { //检查费
332
+//					checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
333
+//				}
334
+//
335
+//				if item.MedChrgitmType == "04" { //化验费
336
+//					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
337
+//
338
+//				}
339
+//
340
+//				if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
341
+//					treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
342
+//				}
343
+//
344
+//				if item.MedChrgitmType == "06" { //手术费
345
+//					operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
346
+//				}
347
+//
348
+//				if item.MedChrgitmType == "08" { //材料费
349
+//					materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
350
+//				}
351
+//
352
+//				if item.MedChrgitmType == "09" { //西药费
353
+//					westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
354
+//				}
355
+//
356
+//				if item.MedChrgitmType == "11" { //中成费
357
+//					chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
358
+//				}
359
+//
360
+//				if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
361
+//					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
362
+//
363
+//				}
364
+//
365
+//			}
366
+//		}
367
+//		this.ServeSuccessJSON(map[string]interface{}{
368
+//			"order":                               orderInfo,
369
+//			"order_info":                          order_info,
370
+//			"patient":                             patient,
371
+//			"admin_info":                          adminInfo,
372
+//			"his_hospital":                        record,
373
+//			"bedCostTotal":                        bedCostTotal,
374
+//			"operationCostTotal":                  operationCostTotal,
375
+//			"otherCostTotal":                      otherCostTotal,
376
+//			"materialCostTotal":                   materialCostTotal,
377
+//			"westernMedicineCostTotal":            westernMedicineCostTotal,
378
+//			"chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
379
+//			"checkCostTotal":                      checkCostTotal,
380
+//			"zhenChaCostTotal":                    zhenChaCostTotal,
381
+//			"laboratoryCostTotal":                 laboratoryCostTotal,
382
+//			"treatCostTotal":                      treatCostTotal,
383
+//			"his_patient":                         his_patient,
384
+//			"hisDepatment":                        hisDepatment,
385
+//			"prescription":                        prescription,
386
+//			"schedule":                            schedule,
387
+//			"bedNumber":                           bedNumber,
388
+//		})
389
+//	} else {
390
+//		for _, item := range order_info {
391
+//
392
+//			item.FulamtOwnpayAmt = item.DetItemFeeSumamt
393
+//			if item.HisDoctorAdviceInfo.ID > 0 && item.HisPrescriptionProject.ID == 0 { //药品
394
+//				item.MedChrgitmType = "09"
395
+//			}
396
+//			if item.HisPrescriptionProject.ID > 0 && item.HisDoctorAdviceInfo.ID == 0 {
397
+//				if item.HisPrescriptionProject.Type == 2 {
398
+//					if this.GetAdminUserInfo().CurrentOrgId == 10215 {
399
+//						switch item.HisPrescriptionProject.VMHisProject.CostClassify {
400
+//						case 0:
401
+//							item.MedChrgitmType = "0"
402
+//							break
403
+//						case 1:
404
+//							item.MedChrgitmType = "14"
405
+//							break
406
+//						case 2:
407
+//							item.MedChrgitmType = "05"
408
+//
409
+//							break
410
+//						case 3:
411
+//							item.MedChrgitmType = "03"
412
+//
413
+//							break
414
+//						case 4:
415
+//							item.MedChrgitmType = "03"
416
+//
417
+//							break
418
+//						case 5:
419
+//							item.MedChrgitmType = "08"
420
+//
421
+//							break
422
+//						case 6:
423
+//							item.MedChrgitmType = "14"
424
+//
425
+//							break
426
+//						case 7:
427
+//							item.MedChrgitmType = "14"
428
+//
429
+//							break
430
+//						case 8:
431
+//							item.MedChrgitmType = "03"
432
+//							break
433
+//						case 9:
434
+//							item.MedChrgitmType = "14"
435
+//							break
436
+//						case 10:
437
+//							item.MedChrgitmType = "14"
438
+//							break
439
+//						case 11:
440
+//							item.MedChrgitmType = "06"
441
+//							break
442
+//						case 12:
443
+//							item.MedChrgitmType = "12"
444
+//							break
445
+//						case 13:
446
+//							item.MedChrgitmType = "01"
447
+//							break
448
+//						case 14:
449
+//							item.MedChrgitmType = "04"
450
+//							break
451
+//						case 15:
452
+//							item.MedChrgitmType = "14"
453
+//							break
454
+//
455
+//						}
456
+//
457
+//					} else {
458
+//						switch item.HisPrescriptionProject.VMHisProject.CostClassify {
459
+//
460
+//						case 1:
461
+//							item.MedChrgitmType = "14"
462
+//							break
463
+//						case 2:
464
+//							item.MedChrgitmType = "05"
465
+//
466
+//							break
467
+//						case 3:
468
+//							item.MedChrgitmType = "04"
469
+//
470
+//							break
471
+//						case 4:
472
+//							item.MedChrgitmType = "14"
473
+//
474
+//							break
475
+//						case 5:
476
+//							item.MedChrgitmType = "08"
477
+//
478
+//							break
479
+//						case 6:
480
+//							item.MedChrgitmType = "14"
481
+//
482
+//							break
483
+//						case 7:
484
+//							item.MedChrgitmType = "14"
485
+//
486
+//							break
487
+//						case 8:
488
+//							item.MedChrgitmType = "03"
489
+//							break
490
+//						case 9:
491
+//							item.MedChrgitmType = "14"
492
+//							break
493
+//						}
494
+//					}
495
+//				} else if item.HisPrescriptionProject.Type == 3 {
496
+//					item.MedChrgitmType = "08"
497
+//				}
498
+//			}
499
+//		}
500
+//
501
+//		for _, item := range order_info {
502
+//			if org_id == 10215 {
503
+//				if item.MedChrgitmType == "01" { //床位费
504
+//					bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
505
+//				}
506
+//				if item.MedChrgitmType == "02" { //诊察费
507
+//					zhenChaCostTotal, _ = decimal.NewFromFloat(zhenChaCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
508
+//				}
509
+//
510
+//				if item.MedChrgitmType == "03" { //检查费
511
+//					checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
512
+//				}
513
+//
514
+//				if item.MedChrgitmType == "04" { //化验费
515
+//					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
516
+//				}
517
+//
518
+//				if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
519
+//					treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
520
+//				}
521
+//
522
+//				if item.MedChrgitmType == "06" { //手术费
523
+//					operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
524
+//				}
525
+//
526
+//				if item.MedChrgitmType == "08" { //材料费
527
+//					materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
528
+//				}
529
+//
530
+//				if item.MedChrgitmType == "09" { //西药费
531
+//					westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
532
+//				}
533
+//
534
+//				if item.MedChrgitmType == "11" { //中成费
535
+//					chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
536
+//				}
537
+//
538
+//				if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
539
+//					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
540
+//				}
541
+//
542
+//			} else {
543
+//
544
+//				if item.MedChrgitmType == "01" { //床位费
545
+//					bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
546
+//				}
547
+//
548
+//				if item.MedChrgitmType == "03" { //检查费
549
+//					checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
550
+//				}
551
+//
552
+//				if item.MedChrgitmType == "04" { //化验费
553
+//					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
554
+//				}
555
+//
556
+//				if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
557
+//					treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
558
+//				}
559
+//
560
+//				if item.MedChrgitmType == "06" { //手术费
561
+//					operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
562
+//				}
563
+//
564
+//				if item.MedChrgitmType == "08" { //材料费
565
+//					materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
566
+//				}
567
+//
568
+//				if item.MedChrgitmType == "09" { //西药费
569
+//					westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
570
+//				}
571
+//
572
+//				if item.MedChrgitmType == "11" { //中成费
573
+//					chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
574
+//				}
575
+//
576
+//				if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
577
+//					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
578
+//				}
579
+//
580
+//			}
581
+//
582
+//		}
583
+//
584
+//		this.ServeSuccessJSON(map[string]interface{}{
585
+//			"order":                               orderInfo,
586
+//			"order_info":                          order_info,
587
+//			"patient":                             patient,
588
+//			"admin_info":                          adminInfo,
589
+//			"his_hospital":                        record,
590
+//			"bedCostTotal":                        bedCostTotal,
591
+//			"operationCostTotal":                  operationCostTotal,
592
+//			"otherCostTotal":                      otherCostTotal,
593
+//			"materialCostTotal":                   materialCostTotal,
594
+//			"westernMedicineCostTotal":            westernMedicineCostTotal,
595
+//			"chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
596
+//			"checkCostTotal":                      checkCostTotal,
597
+//			"zhenChaCostTotal":                    zhenChaCostTotal,
598
+//			"laboratoryCostTotal":                 laboratoryCostTotal,
599
+//			"treatCostTotal":                      treatCostTotal,
600
+//			"his_patient":                         his_patient,
601
+//			"hisDepatment":                        hisDepatment,
602
+//			"prescription":                        prescription,
603
+//			"balanceAccountsType":                 BalanceAccountsType,
604
+//			"medicalInsuranceLevelList":           medicalInsuranceLevelList,
605
+//			"schedule":                            schedule,
606
+//			"bedNumber":                           bedNumber,
607
+//		})
608
+//
609
+//	}
610
+//}
611
+
612
+func (this *HisSummaryApiController) GetDetailPatients() {
613
+
614
+	keyword := this.GetString("keyword")
615
+	orgId := this.GetAdminUserInfo().CurrentOrgId
616
+	patients, err := service.GetDetailPatients(keyword, orgId)
83 617
 	if err == nil {
84 618
 		this.ServeSuccessJSON(map[string]interface{}{
85
-			"detailList": detailList,
86
-			"list":       list,
619
+			"patient": patients,
87 620
 		})
88 621
 		return
89 622
 	} else {

+ 0 - 1
controllers/mobile_api_controllers/login_api_controller.go Прегледај датотеку

@@ -148,7 +148,6 @@ func (this *LoginAPIController) LoginByPwd() {
148 148
 		token := utils.GenerateLoginToken(mobile)
149 149
 		expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
150 150
 		this.Ctx.SetCookie("token_cookie", token, expiration, "/")
151
-
152 151
 		var configList interface{}
153 152
 		var dict_config_list interface{}
154 153
 

+ 45 - 20
controllers/mobile_api_controllers/patient_api_controller.go Прегледај датотеку

@@ -724,9 +724,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
724 724
 								prescribing_number_total = count
725 725
 							}
726 726
 
727
-							fmt.Println("开医嘱数量", prescribing_number_total)
728
-							fmt.Println("剩余库存", total)
729
-
730 727
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
731 728
 								c.ServeSuccessJSON(map[string]interface{}{
732 729
 									"msg":    "3",
@@ -744,27 +741,55 @@ func (c *PatientApiController) ExecDoctorAdvice() {
744 741
 								return
745 742
 							}
746 743
 							if prescribing_number_total <= total {
747
-								if medical.IsUse == 2 {
748
-									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
749
-									//查询默认仓库
750
-									houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
751
-									//查询默认仓库剩余多少库存
752
-									list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
753
-									var sum_count int64
754
-									var sum_in_count int64
755
-									for _, it := range list {
756
-										baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
757
-										if it.MaxUnit == baseDrug.MaxUnit {
758
-											it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
759
-											it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
744
+
745
+								//查询是否出库按钮开启
746
+								adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
747
+								if adviceSetting.IsAdviceOpen == 1 {
748
+									//查询是否出库按钮开启
749
+									prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
750
+									if prescriptionConfig.IsOpen == 1 {
751
+										if medical.IsUse == 2 {
752
+											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
753
+											//查询默认仓库
754
+											houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
755
+											//查询默认仓库剩余多少库存
756
+											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
757
+											var sum_count int64
758
+											var sum_in_count int64
759
+											for _, it := range list {
760
+												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
761
+												if it.MaxUnit == baseDrug.MaxUnit {
762
+													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
763
+													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
764
+												}
765
+												sum_count += it.StockMaxNumber + it.StockMinNumber
766
+												sum_in_count += it.WarehousingCount
767
+											}
768
+											service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
760 769
 										}
761
-										sum_count += it.StockMaxNumber + it.StockMinNumber
762
-										sum_in_count += it.WarehousingCount
763 770
 									}
764
-									service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
771
+								} else {
772
+									if medical.IsUse == 2 {
773
+										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
774
+										//查询默认仓库
775
+										houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
776
+										//查询默认仓库剩余多少库存
777
+										list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
778
+										var sum_count int64
779
+										var sum_in_count int64
780
+										for _, it := range list {
781
+											baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
782
+											if it.MaxUnit == baseDrug.MaxUnit {
783
+												it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
784
+												it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
785
+											}
786
+											sum_count += it.StockMaxNumber + it.StockMinNumber
787
+											sum_in_count += it.WarehousingCount
788
+										}
789
+										service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
790
+									}
765 791
 								}
766 792
 							}
767
-
768 793
 						}
769 794
 					}
770 795
 				}

+ 33 - 24
controllers/new_mobile_api_controllers/new_login_api_controller.go Прегледај датотеку

@@ -443,38 +443,47 @@ func (this *NewLoginApiController) LoginByCs() {
443 443
 						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
444 444
 						return
445 445
 					}
446
-					orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
447
-					orgJSONBytes, _ := json.Marshal(orgJSON)
448 446
 					var org models.Org
449
-					if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
450
-						utils.ErrorLog("解析机构失败:%v", err)
451
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
452
-						return
447
+					if respJSON["data"].(map[string]interface{})["org"] != nil {
448
+						orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
449
+						orgJSONBytes, _ := json.Marshal(orgJSON)
450
+						if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
451
+							utils.ErrorLog("解析机构失败:%v", err)
452
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
453
+							return
454
+						}
453 455
 					}
454
-					appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
455
-					appJSONBytes, _ := json.Marshal(appJSON)
456 456
 					var app models.OrgApp
457
-					if err := json.Unmarshal(appJSONBytes, &app); err != nil {
458
-						utils.ErrorLog("解析应用失败:%v", err)
459
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
460
-						return
457
+					if respJSON["data"].(map[string]interface{})["app"] != nil {
458
+						appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
459
+						appJSONBytes, _ := json.Marshal(appJSON)
460
+						if err := json.Unmarshal(appJSONBytes, &app); err != nil {
461
+							utils.ErrorLog("解析应用失败:%v", err)
462
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
463
+							return
464
+						}
461 465
 					}
462
-					appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
463
-					appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
464 466
 					var appRole models.App_Role
465
-					if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
466
-						utils.ErrorLog("解析AppRole失败:%v", err)
467
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
468
-						return
467
+					if respJSON["data"].(map[string]interface{})["app_role"] != nil {
468
+						appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
469
+						appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
470
+						if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
471
+							utils.ErrorLog("解析AppRole失败:%v", err)
472
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
473
+							return
474
+						}
469 475
 					}
470
-					subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
471
-					subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
472 476
 					var subscibe models.ServeSubscibe
473
-					if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
474
-						utils.ErrorLog("解析Subscibe失败:%v", err)
475
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
476
-						return
477
+					if respJSON["data"].(map[string]interface{})["subscibe"] != nil {
478
+						subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
479
+						subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
480
+						if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
481
+							utils.ErrorLog("解析Subscibe失败:%v", err)
482
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
483
+							return
484
+						}
477 485
 					}
486
+
478 487
 					service.GetOrgSubscibeState(&subscibe)
479 488
 					templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
480 489
 

+ 108 - 31
controllers/patient_api_controller.go Прегледај датотеку

@@ -1281,16 +1281,29 @@ func (c *PatientApiController) CreateGroupAdvice() {
1281 1281
 			singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
1282 1282
 			advice.SingleDose = singleDose
1283 1283
 		}
1284
+		if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
1285
+			singleDose := adviceNameM["single_dose"].(float64)
1286
+			advice.SingleDose = singleDose
1287
+		}
1284 1288
 
1285 1289
 		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
1286 1290
 			singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
1287 1291
 			advice.SingleDoseUnit = singleDoseUnit
1288 1292
 		}
1293
+		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "float64" {
1294
+			tmp := adviceNameM["single_dose_unit"].(float64)
1295
+			singleDoseUnit := service.TypeConversion(tmp)
1296
+			advice.SingleDoseUnit = singleDoseUnit
1297
+		}
1289 1298
 
1290 1299
 		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
1291 1300
 			prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
1292 1301
 			advice.PrescribingNumber = prescribingNumber
1293 1302
 		}
1303
+		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {
1304
+			prescribingNumber := adviceNameM["prescribing_number"].(float64)
1305
+			advice.PrescribingNumber = prescribingNumber
1306
+		}
1294 1307
 
1295 1308
 		if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
1296 1309
 			prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
@@ -1778,41 +1791,92 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1778 1791
 					return
1779 1792
 				}
1780 1793
 				if prescribing_number_total <= total {
1781
-					if medical.IsUse == 2 {
1782
-						service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1783
-						//查询默认仓库
1784
-						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1785
-						//查询默认仓库剩余多少库存
1786
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1787
-						var sum_count int64
1788
-						var sum_in_count int64
1789
-						for _, it := range list {
1790
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1791
-							if it.MaxUnit == baseDrug.MaxUnit {
1792
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1793
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1794
+
1795
+					//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
1796
+
1797
+					adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
1798
+					if adviceSetting.IsAdviceOpen == 1 {
1799
+
1800
+						//查询是否出库按钮开启
1801
+						prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
1802
+						if prescriptionConfig.IsOpen == 1 {
1803
+							if medical.IsUse == 2 {
1804
+								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1805
+								//查询默认仓库
1806
+								houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1807
+								//查询默认仓库剩余多少库存
1808
+								list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1809
+								var sum_count int64
1810
+								var sum_in_count int64
1811
+								for _, it := range list {
1812
+									baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1813
+									if it.MaxUnit == baseDrug.MaxUnit {
1814
+										it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1815
+										it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1816
+									}
1817
+									sum_count += it.StockMaxNumber + it.StockMinNumber
1818
+									sum_in_count += it.WarehousingCount
1819
+								}
1820
+								service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1821
+								break
1822
+								c.ServeSuccessJSON(map[string]interface{}{
1823
+									"msg":    "1",
1824
+									"advice": advice,
1825
+								})
1826
+								return
1827
+							}
1828
+							if medical.IsUse == 1 {
1829
+								c.ServeSuccessJSON(map[string]interface{}{
1830
+									"msg":    "1",
1831
+									"advice": advice,
1832
+								})
1833
+								return
1834
+							}
1835
+						} else {
1836
+							if medical.IsUse == 1 {
1837
+								c.ServeSuccessJSON(map[string]interface{}{
1838
+									"msg":    "1",
1839
+									"advice": advice,
1840
+								})
1841
+								return
1794 1842
 							}
1795
-							sum_count += it.StockMaxNumber + it.StockMinNumber
1796
-							sum_in_count += it.WarehousingCount
1797 1843
 						}
1798
-						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1799
-						break
1800
-						c.ServeSuccessJSON(map[string]interface{}{
1801
-							"msg":    "1",
1802
-							"advice": advice,
1803
-						})
1804
-						return
1805
-					}
1806
-					if medical.IsUse == 1 {
1807
-						c.ServeSuccessJSON(map[string]interface{}{
1808
-							"msg":    "1",
1809
-							"advice": advice,
1810
-						})
1811
-						return
1812
-					}
1813 1844
 
1845
+					} else {
1846
+						if medical.IsUse == 2 {
1847
+							service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1848
+							//查询默认仓库
1849
+							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1850
+							//查询默认仓库剩余多少库存
1851
+							list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1852
+							var sum_count int64
1853
+							var sum_in_count int64
1854
+							for _, it := range list {
1855
+								baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1856
+								if it.MaxUnit == baseDrug.MaxUnit {
1857
+									it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1858
+									it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1859
+								}
1860
+								sum_count += it.StockMaxNumber + it.StockMinNumber
1861
+								sum_in_count += it.WarehousingCount
1862
+							}
1863
+							service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1864
+							break
1865
+							c.ServeSuccessJSON(map[string]interface{}{
1866
+								"msg":    "1",
1867
+								"advice": advice,
1868
+							})
1869
+							return
1870
+						}
1871
+						if medical.IsUse == 1 {
1872
+							c.ServeSuccessJSON(map[string]interface{}{
1873
+								"msg":    "1",
1874
+								"advice": advice,
1875
+							})
1876
+							return
1877
+						}
1878
+					}
1814 1879
 				}
1815
-
1816 1880
 			}
1817 1881
 		}
1818 1882
 
@@ -3073,11 +3137,20 @@ func adviceFormData(advice *models.DoctorAdvice, data []byte, action string) (co
3073 3137
 		singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
3074 3138
 		advice.SingleDose = singleDose
3075 3139
 	}
3140
+	if dataBody["single_dose"] != nil && reflect.TypeOf(dataBody["single_dose"]).String() == "float64" {
3141
+		singleDose := dataBody["single_dose"].(float64)
3142
+		advice.SingleDose = singleDose
3143
+	}
3076 3144
 
3077 3145
 	if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
3078 3146
 		singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
3079 3147
 		advice.SingleDoseUnit = singleDoseUnit
3080 3148
 	}
3149
+	if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "float64" {
3150
+		tmp := dataBody["single_dose_unit"].(float64)
3151
+		singleDoseUnit := service.TypeConversion(tmp)
3152
+		advice.SingleDoseUnit = singleDoseUnit
3153
+	}
3081 3154
 
3082 3155
 	if dataBody["drug_spec"] != nil && reflect.TypeOf(dataBody["drug_spec"]).String() == "string" {
3083 3156
 		drugSpec, _ := strconv.ParseFloat(dataBody["drug_spec"].(string), 64)
@@ -3093,6 +3166,10 @@ func adviceFormData(advice *models.DoctorAdvice, data []byte, action string) (co
3093 3166
 		prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
3094 3167
 		advice.PrescribingNumber = prescribingNumber
3095 3168
 	}
3169
+	if dataBody["prescribing_number"] != nil && reflect.TypeOf(dataBody["prescribing_number"]).String() == "float64" {
3170
+		prescribingNumber := dataBody["prescribing_number"].(float64)
3171
+		advice.PrescribingNumber = prescribingNumber
3172
+	}
3096 3173
 
3097 3174
 	if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
3098 3175
 		prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)

+ 3 - 0
controllers/role_controller.go Прегледај датотеку

@@ -1211,6 +1211,7 @@ func (this *RoleAPIController) EditAdmin() {
1211 1211
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
1212 1212
 		return
1213 1213
 	}
1214
+	appRole.OrgId = this.GetAdminUserInfo().CurrentOrgId
1214 1215
 	appRole.Department = department
1215 1216
 	appRole.DepartmentId = department_id
1216 1217
 	appRole.UserName = name
@@ -1255,6 +1256,8 @@ func (this *RoleAPIController) EditAdmin() {
1255 1256
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
1256 1257
 
1257 1258
 	} else {
1259
+		//判断当前角色是否为机构管理员
1260
+
1258 1261
 		this.ServeSuccessJSON(map[string]interface{}{
1259 1262
 			"approle": appRole,
1260 1263
 		})

+ 2 - 1
controllers/stock_in_api_controller.go Прегледај датотеку

@@ -1530,6 +1530,7 @@ func (c *StockManagerApiController) GetWarehouseOutList() {
1530 1530
 	types, _ := c.GetInt64("type", 0)
1531 1531
 	keywords := c.GetString("keywords")
1532 1532
 	storehouse_id, _ := c.GetInt64("storehouse_id")
1533
+	way_type, _ := c.GetInt64("way_type")
1533 1534
 	timeLayout := "2006-01-02"
1534 1535
 	loc, _ := time.LoadLocation("Local")
1535 1536
 	var startTime int64
@@ -1571,7 +1572,7 @@ func (c *StockManagerApiController) GetWarehouseOutList() {
1571 1572
 		}
1572 1573
 
1573 1574
 	}
1574
-	warehouseOutList, total, err := service.FindAllWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id)
1575
+	warehouseOutList, total, err := service.FindAllWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id, way_type)
1575 1576
 	houselist, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
1576 1577
 	fmt.Println(err)
1577 1578
 	if err == nil {

+ 15 - 0
models/device_models.go Прегледај датотеку

@@ -1120,3 +1120,18 @@ func (PatientDialysisOrder) TableName() string {
1120 1120
 
1121 1121
 	return "xt_dialysis_order"
1122 1122
 }
1123
+
1124
+type ScheduleDeviceNumber struct {
1125
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
1126
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1127
+	Number  string `gorm:"column:number" json:"number" form:"number"`
1128
+	GroupId int64  `gorm:"column:group_id" json:"group_id" form:"group_id"`
1129
+	ZoneId  int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1130
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
1131
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1132
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1133
+}
1134
+
1135
+func (ScheduleDeviceNumber) TableName() string {
1136
+	return "xt_device_number"
1137
+}

+ 36 - 24
models/his_charge_models.go Прегледај датотеку

@@ -1,15 +1,16 @@
1 1
 package models
2 2
 
3 3
 type HisChargePrescriptionProject struct {
4
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
5
-	ProjectId  int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
-	Status     int64  `gorm:"column:status" json:"status" form:"status"`
8
-	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
-	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
-	Count      string `gorm:"column:count" json:"count" form:"count"`
11
-	Type       int64  `gorm:"column:type" json:"type" form:"type"`
12
-
4
+	ID                int64             `gorm:"column:id" json:"id" form:"id"`
5
+	ProjectId         int64             `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
+	UserOrgId         int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
+	Status            int64             `gorm:"column:status" json:"status" form:"status"`
8
+	PatientId         int64             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
+	RecordDate        int64             `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
+	Count             string            `gorm:"column:count" json:"count" form:"count"`
11
+	Type              int64             `gorm:"column:type" json:"type" form:"type"`
12
+	Unit              string            `gorm:"column:unit" json:"unit" form:"unit"`
13
+	Remark            string            `gorm:"column:remark" json:"remark" form:"remark"`
13 14
 	HisChargeProject  HisChargeProject  `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
14 15
 	HisChargeGoodInfo HisChargeGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
15 16
 }
@@ -19,13 +20,16 @@ func (HisChargePrescriptionProject) TableName() string {
19 20
 }
20 21
 
21 22
 type HisChargeDoctorAdviceInfo struct {
22
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
23
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
24
-	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
25
-	AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
26
-	Status     int64  `gorm:"column:status" json:"status" form:"status"`
27
-	DrugId     int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
28
-	Drug       Drug   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
23
+	ID                    int64  `gorm:"column:id" json:"id" form:"id"`
24
+	UserOrgId             int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
25
+	PatientId             int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
26
+	AdviceName            string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
27
+	PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
28
+	Status                int64  `gorm:"column:status" json:"status" form:"status"`
29
+	DrugId                int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
30
+	Remark                string `gorm:"column:remark" json:"remark" form:"remark"`
31
+	AdviceDate            int64  `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
32
+	Drug                  Drug   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
29 33
 }
30 34
 
31 35
 func (HisChargeDoctorAdviceInfo) TableName() string {
@@ -92,6 +96,10 @@ type HisChargeOrder struct {
92 96
 	OrderStatus        int64                 `gorm:"column:order_status" json:"order_status" form:"order_status"`
93 97
 	MdtrtId            string                `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
94 98
 	PatientId          int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
99
+	HifesPay           float64               `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
100
+	MafPay             float64               `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
101
+	FundPaySumamt      float64               `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
102
+	AcctPay            float64               `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
95 103
 	HisChargeOrderInfo []*HisChargeOrderInfo `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`
96 104
 }
97 105
 
@@ -160,9 +168,11 @@ func (HisChargeSettleOrder) TableName() string {
160 168
 }
161 169
 
162 170
 type HisChargeProject struct {
163
-	ID          int64  `gorm:"column:id" json:"id" form:"id"`
164
-	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
165
-	Unit        string `gorm:"column:unit" json:"unit" form:"unit"`
171
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
172
+	ProjectName     string `gorm:"column:project_name" json:"project_name" form:"project_name"`
173
+	Unit            string `gorm:"column:unit" json:"unit" form:"unit"`
174
+	MedicalCoverage int64  `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
175
+	CostClassify    int64  `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
166 176
 }
167 177
 
168 178
 func (HisChargeProject) TableName() string {
@@ -170,11 +180,13 @@ func (HisChargeProject) TableName() string {
170 180
 }
171 181
 
172 182
 type HisChargeGoodInfo struct {
173
-	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
174
-	GoodName           string `gorm:"column:good_name" json:"good_name" form:"good_name"`
175
-	GoodUnit           int64  `gorm:"column:good_unit" json:"good_unit"`
176
-	SpecificationnName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
177
-	RegisterNumber     string `gorm:"column:register_number" json:"register_number" form:"register_number"`
183
+	ID                    int64  `gorm:"column:id" json:"id" form:"id"`
184
+	GoodName              string `gorm:"column:good_name" json:"good_name" form:"good_name"`
185
+	GoodUnit              int64  `gorm:"column:good_unit" json:"good_unit"`
186
+	SpecificationnName    string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
187
+	RegisterNumber        string `gorm:"column:register_number" json:"register_number" form:"register_number"`
188
+	PackingUnit           string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
189
+	MedicalInsuranceLevel int64  `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
178 190
 }
179 191
 
180 192
 func (HisChargeGoodInfo) TableName() string {

+ 1 - 0
models/his_deposit_models.go Прегледај датотеку

@@ -131,6 +131,7 @@ type Details struct {
131 131
 	Total      decimal.Decimal `json:"total"`       //医疗费总额
132 132
 	Decimal    decimal.Decimal `json:"decimal"`     //押金支付金额
133 133
 	ChargeDate string          `json:"charge_date"` //收费日期
134
+	ButtonShow int64           `json:"button_show"` //查看详情按钮是否显示,0隐藏,1显示
134 135
 }
135 136
 
136 137
 //扣费汇总

+ 246 - 0
models/his_summary_models.go Прегледај датотеку

@@ -1,5 +1,7 @@
1 1
 package models
2 2
 
3
+import "time"
4
+
3 5
 type HisPrescriptionModeTemplate struct {
4 6
 	ID        int64  `gorm:"column:id" json:"id" form:"id"`
5 7
 	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -132,3 +134,247 @@ type HisPrescriptionProjectModeTemplate struct {
132 134
 func (HisPrescriptionProjectModeTemplate) TableName() string {
133 135
 	return "his_prescription_project_mode_template"
134 136
 }
137
+
138
+type VmHisOrderInfo struct {
139
+	ID                     int64                       `gorm:"column:id" json:"id" form:"id"`
140
+	OrderNumber            string                      `gorm:"column:order_number" json:"order_number" form:"order_number"`
141
+	UploadDate             int64                       `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
142
+	AdviceId               int64                       `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
143
+	DetItemFeeSumamt       float64                     `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
144
+	Cnt                    float64                     `gorm:"column:cnt" json:"cnt" form:"cnt"`
145
+	Pric                   float64                     `gorm:"column:pric" json:"pric" form:"pric"`
146
+	PatientId              int64                       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
147
+	PricUplmtAmt           float64                     `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
148
+	SelfpayProp            float64                     `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
149
+	FulamtOwnpayAmt        float64                     `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
150
+	OverlmtAmt             float64                     `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
151
+	PreselfpayAmt          float64                     `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
152
+	BasMednFlag            string                      `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
153
+	MedChrgitmType         string                      `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
154
+	HiNegoDrugFlag         string                      `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
155
+	Status                 int64                       `gorm:"column:status" json:"status" form:"status"`
156
+	Memo                   string                      `gorm:"column:memo" json:"memo" form:"memo"`
157
+	FeedetlSn              string                      `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
158
+	Mtime                  int64                       `gorm:"column:mtime" json:"mtime" form:"mtime"`
159
+	InscpScpAmt            float64                     `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
160
+	DrtReimFlag            string                      `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
161
+	Ctime                  int64                       `gorm:"column:ctime" json:"ctime" form:"ctime"`
162
+	ListSpItemFlag         string                      `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
163
+	ChldMedcFlag           string                      `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
164
+	LmtUsedFlag            string                      `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
165
+	ChrgitmLv              string                      `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
166
+	UserOrgId              int64                       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
167
+	HisPatientId           int64                       `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
168
+	OrderId                int64                       `gorm:"column:order_id" json:"order_id" form:"order_id"`
169
+	ProjectId              int64                       `gorm:"column:project_id" json:"project_id" form:"project_id"`
170
+	Type                   int64                       `gorm:"column:type" json:"type" form:"type"`
171
+	ItemId                 int64                       `gorm:"column:item_id" json:"item_id" form:"item_id"`
172
+	SettleType             int64                       `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
173
+	HisPrescriptionProject []*VmHisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"vmproject"`
174
+	HisDoctorAdviceInfo    []*VmHisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"vmadvice"`
175
+}
176
+
177
+func (VmHisOrderInfo) TableName() string {
178
+	return "his_order_info"
179
+}
180
+
181
+type VmHisPrescriptionProject struct {
182
+	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
183
+	ProjectId          int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
184
+	Price              float64 `gorm:"column:price" json:"price" form:"price"`
185
+	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
186
+	Status             int64   `gorm:"column:status" json:"status" form:"status"`
187
+	Ctime              int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
188
+	Mtime              int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
189
+	PatientId          int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
190
+	HisPatientId       int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
191
+	RecordDate         int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
192
+	PrescriptionId     int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
193
+	Count              string  `gorm:"column:count" json:"count" form:"count"`
194
+	FeedetlSn          string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
195
+	MedListCodg        string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
196
+	SingleDose         string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
197
+	DeliveryWay        string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
198
+	ExecutionFrequency string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
199
+	Day                string  `gorm:"column:day" json:"day" form:"day"`
200
+	Remark             string  `gorm:"column:remark" json:"remark" form:"remark"`
201
+	Unit               string  `gorm:"column:unit" json:"unit" form:"unit"`
202
+	Type               int64   `gorm:"column:type" json:"type" form:"type"`
203
+	Doctor             int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
204
+	ExecutionTime      int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
205
+	ExecutionStaff     int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
206
+	ExecutionState     int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
207
+	CheckTime          int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
208
+	CheckState         int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
209
+	Checker            int64   `gorm:"column:checker" json:"checker" form:"checker"`
210
+	StartTime          int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
211
+	TeamId             int64   `gorm:"column:team_id" json:"team_id" form:"team_id"`
212
+	FrequencyType      int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
213
+	DayCount           int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
214
+	WeekDay            string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
215
+}
216
+
217
+func (VmHisPrescriptionProject) TableName() string {
218
+	return "his_prescription_project"
219
+}
220
+
221
+type VmHisDoctorAdviceInfo struct {
222
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
223
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
224
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
225
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
226
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
227
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
228
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
229
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
230
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
231
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
232
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
233
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
234
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
235
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
236
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
237
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
238
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
239
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
240
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
241
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
242
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
243
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
244
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
245
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
246
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
247
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
248
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
249
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
250
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
251
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
252
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
253
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
254
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
255
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
256
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
257
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
258
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
259
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
260
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
261
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
262
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
263
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
264
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
265
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
266
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
267
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
268
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
269
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
270
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
271
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
272
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
273
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
274
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
275
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
276
+	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
277
+	AdviceId              int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
278
+}
279
+
280
+func (VmHisDoctorAdviceInfo) TableName() string {
281
+	return "his_doctor_advice_info"
282
+}
283
+
284
+type GatherHisOrder struct {
285
+	ID                      int64     `gorm:"column:id" json:"id" form:"id"`
286
+	UserOrgId               int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
287
+	HisPatientId            int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
288
+	SettleAccountsDate      int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
289
+	Ctime                   int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
290
+	Mtime                   int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
291
+	Status                  int64     `gorm:"column:status" json:"status" form:"status"`
292
+	Number                  string    `gorm:"column:number" json:"number" form:"number"`
293
+	PatientId               int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
294
+	Infcode                 int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
295
+	WarnMsg                 string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
296
+	Cainfo                  string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
297
+	ErrMsg                  string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
298
+	RespondTime             string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
299
+	InfRefmsgid             string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
300
+	OrderStatus             int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
301
+	MdtrtId                 string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
302
+	SetlId                  string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
303
+	PsnNo                   string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
304
+	PsnName                 string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
305
+	PsnCertType             string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
306
+	Certno                  string    `gorm:"column:certno" json:"certno" form:"certno"`
307
+	Gend                    string    `gorm:"column:gend" json:"gend" form:"gend"`
308
+	Naty                    string    `gorm:"column:naty" json:"naty" form:"naty"`
309
+	Brdy                    time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
310
+	Age                     float64   `gorm:"column:age" json:"age" form:"age"`
311
+	Insutype                string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
312
+	PsnType                 string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
313
+	CvlservFlag             string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
314
+	SetlTime                string    `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
315
+	MdtrtCertType           string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
316
+	MedType                 string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
317
+	MedfeeSumamt            float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
318
+	FulamtOwnpayAmt         float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
319
+	OverlmtSelfPay          float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
320
+	PreselfpayAmt           float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
321
+	InscpScpAmt             float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
322
+	ActPayDedc              float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
323
+	HifpPay                 float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
324
+	CvlservPay              float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
325
+	PoolPropSelfpay         float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
326
+	HifesPay                float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
327
+	HifmiPay                float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
328
+	HifobPay                float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
329
+	MafPay                  float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
330
+	OthPay                  float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
331
+	FundPaySumamt           float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
332
+	PsnPartAmt              float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
333
+	AcctPay                 float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
334
+	PsnCashPay              float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
335
+	HospPartAmt             float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
336
+	Balc                    float64   `gorm:"column:balc" json:"balc" form:"balc"`
337
+	AcctMulaidPay           float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
338
+	MedinsSetlId            string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
339
+	ClrOptins               string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
340
+	ClrWay                  string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
341
+	ClrType                 string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
342
+	SetlDetail              string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
343
+	PayWay                  int64     `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
344
+	PayPrice                float64   `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
345
+	PayCardNo               string    `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
346
+	DiscountPrice           float64   `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
347
+	PreferentialPrice       float64   `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
348
+	RealityPrice            float64   `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
349
+	FoundPrice              float64   `gorm:"column:found_price" json:"found_price" form:"found_price"`
350
+	MedicalInsurancePrice   float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
351
+	PrivatePrice            float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
352
+	IsMedicineInsurance     int64     `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
353
+	SettleType              int64     `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
354
+	SettleStartTime         int64     `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
355
+	SettleEndTime           int64     `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
356
+	Creator                 int64     `gorm:"column:creator" json:"creator" form:"creator"`
357
+	Modify                  int64     `gorm:"column:modify" json:"modify" form:"modify"`
358
+	SzChargeInfo            string    `gorm:"column:sz_charge_info" json:"sz_charge_info" form:"sz_charge_info"`
359
+	SzProjectInfo           string    `gorm:"column:sz_project_info" json:"sz_project_info" form:"sz_project_info"`
360
+	SzMedicineInsuranceInfo string    `gorm:"column:sz_medicine_insurance_info" json:"sz_medicine_insurance_info" form:"sz_medicine_insurance_info"`
361
+	AccountPrice            float64   `gorm:"column:account_price" json:"account_price" form:"account_price"`
362
+	MzNumber                string    `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
363
+	OrgSetlNumber           string    `gorm:"column:org_setl_number" json:"org_setl_number" form:"org_setl_number"`
364
+	YiliaoNumber            string    `gorm:"column:yiliao_number" json:"yiliao_number" form:"yiliao_number"`
365
+	RefundLog               string    `gorm:"column:refund_log" json:"refund_log" form:"refund_log"`
366
+	DetailLog               string    `gorm:"column:detail_log" json:"detail_log" form:"detail_log"`
367
+	RequestLog              string    `gorm:"column:request_log" json:"request_log" form:"request_log"`
368
+	RefundRequestLog        string    `gorm:"column:refund_request_log" json:"refund_request_log" form:"refund_request_log"`
369
+	FaPiaoCode              string    `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
370
+	FaPiaoNumber            string    `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
371
+	PType                   int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
372
+	IsPre                   int64     `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
373
+	Diagnosis               string    `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
374
+	FaPiaoBatchnumberId     int64     `gorm:"column:fa_piao_batchnumber_id" json:"fa_piao_batchnumber_id" form:"fa_piao_batchnumber_id"`
375
+	Decimal                 float64   `gorm:"column:decimal" json:"decimal" form:"decimal"`
376
+}
377
+
378
+func (GatherHisOrder) TableName() string {
379
+	return "his_order"
380
+}

+ 13 - 0
models/stock_models.go Прегледај датотеку

@@ -1358,3 +1358,16 @@ type XtAdviceSetting struct {
1358 1358
 func (XtAdviceSetting) TableName() string {
1359 1359
 	return "xt_advice_setting"
1360 1360
 }
1361
+
1362
+type XtPrescriptionConfig struct {
1363
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1364
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1365
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1366
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1367
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1368
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1369
+}
1370
+
1371
+func (XtPrescriptionConfig) TableName() string {
1372
+	return "xt_prescription_config"
1373
+}

+ 6 - 0
service/device_service.go Прегледај датотеку

@@ -761,3 +761,9 @@ func GetPatientIdOne(patient_id int64, orgId int64) (models.XtPatientsNew, error
761 761
 
762 762
 	}
763 763
 }
764
+
765
+func GetAllBedNumberSix(orgId int64) (devicenumber []*models.ScheduleDeviceNumber, err error) {
766
+
767
+	err = XTReadDB().Where("org_id = ? and status = 1", orgId).Find(&devicenumber).Error
768
+	return devicenumber, err
769
+}

+ 147 - 16
service/his_deposit_service.go Прегледај датотеку

@@ -28,6 +28,12 @@ func GetHisUser(orgid int64) (hisname []models.GetHisName, err error) {
28 28
 	return
29 29
 }
30 30
 
31
+//获取his中的有效患者去除了转出和死亡的
32
+func GetHisUserToAlive(orgid int64) (hisname []models.GetHisName, err error) {
33
+	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and lapseto = 1", orgid).Find(&hisname).Error
34
+	return
35
+}
36
+
31 37
 //获取his中的有效患者
32 38
 func GetHisUserName(orgid, id int64) (hisname models.GetHisName, err error) {
33 39
 	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and id = ?", orgid, id).Find(&hisname).Error
@@ -203,6 +209,7 @@ func GetMonth() (int64, int64) {
203 209
 	return timeMonthStartUnix1, timeMonthEndUnix1
204 210
 }
205 211
 
212
+//获取创建者的姓名
206 213
 func GetCreateidName(id int64) string {
207 214
 	var tmp models.CreateUser
208 215
 	XTReadDB().Select("name").Where("id = ?", id).Find(&tmp)
@@ -221,14 +228,7 @@ func UpDecimalHistory(id int64) (err error) {
221 228
 			tx.Commit()
222 229
 		}
223 230
 	}()
224
-	//改状态
225
-	err = tx.Model(models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
226
-		"trial_status": 1,
227
-		"mtime":        time.Now().Unix(),
228
-	}).Error
229
-	if err != nil {
230
-		return
231
-	}
231
+
232 232
 	//查记录x2
233 233
 	var history models.DepositHistory
234 234
 	var detmp models.Deposit
@@ -240,6 +240,15 @@ func UpDecimalHistory(id int64) (err error) {
240 240
 	if err != nil {
241 241
 		return
242 242
 	}
243
+	//改状态,=====剩余押金
244
+	err = tx.Model(models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
245
+		"trial_status":    1,
246
+		"surplus_deposit": detmp.Deposit.Add(history.Deposit),
247
+		"mtime":           time.Now().Unix(),
248
+	}).Error
249
+	if err != nil {
250
+		return
251
+	}
243 252
 	//相加
244 253
 	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", detmp.ID).Updates(map[string]interface{}{
245 254
 		"mtime":   time.Now().Unix(),
@@ -282,12 +291,13 @@ func GetMoneyforTime(id, orgid, etime int64) decimal.Decimal {
282 291
 }
283 292
 
284 293
 //押金流水
285
-func GetFlowList(id, orgid, stime, etime, deposit_status int64) (deposit []models.DepositHistory, err error) {
294
+func GetFlowList(page, limit, id, orgid, stime, etime, deposit_status int64) (deposit []models.DepositHistory, total int64, err error) {
286 295
 	s := "status = 1 and trial_status = 1 and user_org_id = ? and his_patient_id = ? and mtime >= ? and mtime <= ?"
296
+	offset := (page - 1) * limit
287 297
 	if deposit_status != 0 {
288
-		s = s + " and deposit_status = " + string(deposit_status)
298
+		s = s + " and deposit_status = " + strconv.FormatInt(deposit_status, 10)
289 299
 	}
290
-	err = XTReadDB().Model(&models.DepositHistory{}).Where(s, orgid, id, stime, etime).Order("mtime desc").Find(&deposit).Error
300
+	err = XTReadDB().Model(&models.DepositHistory{}).Where(s, orgid, id, stime, etime).Count(&total).Offset(offset).Order("mtime desc").Limit(limit).Find(&deposit).Error
291 301
 	return
292 302
 }
293 303
 
@@ -298,7 +308,7 @@ func GetUserList(page, limit, orgid int64, keyword string, slicekey []int64) (m
298 308
 	if len(keyword) > 0 {
299 309
 		db = db.Where(" his_patient_id = ? ", keyword)
300 310
 	}
301
-	err = db.Count(&total).Offset(offset).Order("mtime desc").Find(&m).Error
311
+	err = db.Count(&total).Offset(offset).Order("mtime desc").Limit(limit).Find(&m).Error
302 312
 	return
303 313
 }
304 314
 
@@ -320,17 +330,23 @@ func DeductionList(orgid, stime, etime int64, keyword string, slicekey []int64)
320 330
 }
321 331
 
322 332
 //获取医疗费总额
323
-func MedicalTotal(orgid, patient_id int64, code string) decimal.Decimal {
333
+func MedicalTotal(orgid, id int64) decimal.Decimal {
324 334
 	tmp := models.HisChargeSettleOrder{}
325
-	XTReadDB().Model(&models.HisChargeSettleOrder{}).Where("mdtrt_id = ? and patient_id = ? and user_org_id = ? and status = 1 and order_status = 2", code, patient_id, orgid).Find(&tmp)
335
+	//and status = 1 and order_status = 2
336
+	XTReadDB().Model(&models.HisChargeSettleOrder{}).Where("id = ? and user_org_id = ? ", id, orgid).Find(&tmp)
326 337
 	return decimal.NewFromFloat(tmp.MedfeeSumamt)
327 338
 }
328 339
 
329 340
 //根据就诊号查询出医收费类型
330 341
 func CodeToChargetype(orgid int64, code string) (s string) {
331 342
 	tmp := models.HisPrintPatient{}
343
+	tmp_hhcr := models.HisHospitalCheckRecordTwo{}
332 344
 	XTReadDB().Model(&models.HisPrintPatient{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp)
333 345
 	//tmp.BalanceAccountsType
346
+	if tmp.BalanceAccountsType == 0 {
347
+		XTReadDB().Model(&models.HisHospitalCheckRecordTwo{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp_hhcr)
348
+		tmp.BalanceAccountsType = tmp_hhcr.BalanceAccountsType
349
+	}
334 350
 	switch tmp.BalanceAccountsType {
335 351
 	case 1:
336 352
 		s = "医保"
@@ -351,6 +367,7 @@ func CodeToChargetype(orgid int64, code string) (s string) {
351 367
 	default:
352 368
 		s = "类型未定义"
353 369
 	}
370
+
354 371
 	return
355 372
 }
356 373
 
@@ -430,6 +447,9 @@ func RefundApplication(orgid, his_patient_id, trial_status, createid int64, code
430 447
 	tmp := models.Deposit{}
431 448
 	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_patient_id, orgid).Find(&tmp).Error
432 449
 	if err != nil {
450
+		if err.Error() == "record not found" {
451
+			err = fmt.Errorf("没有可退押金,保存失败")
452
+		}
433 453
 		return
434 454
 	}
435 455
 	//判断是否可以退款
@@ -638,8 +658,9 @@ func ChangeRefund(orgid, his_patient_id, trial_status, id int64, code string, de
638 658
 }
639 659
 
640 660
 //退款分页
641
-func RefundList(orgid, stime, etime, refundtype, examinetype int64, keyword string, slicekey []int64) (depo []models.RefundList, err error) {
661
+func RefundList(page, limit, orgid, stime, etime, refundtype, examinetype int64, keyword string, slicekey []int64) (depo []models.RefundList, total int64, err error) {
642 662
 	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and user_org_id = ? ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
663
+	offset := (page - 1) * limit
643 664
 	//退款类型
644 665
 	switch refundtype {
645 666
 	case 0:
@@ -670,7 +691,7 @@ func RefundList(orgid, stime, etime, refundtype, examinetype int64, keyword stri
670 691
 		keyword = "%" + keyword + "%"
671 692
 		db = db.Where(tmp, keyword)
672 693
 	}
673
-	err = db.Order("ctime desc").Find(&depo).Error
694
+	err = db.Count(&total).Offset(offset).Order("ctime desc").Limit(limit).Find(&depo).Error
674 695
 	return
675 696
 
676 697
 }
@@ -747,6 +768,22 @@ func FindnumberToid(id int64) (number string) {
747 768
 	return tmp.Number
748 769
 }
749 770
 
771
+//扣费明细列表,查看详情按钮是否显示,0隐藏,1显示
772
+func IsButtonShow(code string, orgid, his_patient_id int64) (tmp int64) {
773
+	var total int
774
+	XTReadDB().Model(&models.RefundList{}).Where(" user_org_id = ? and his_patient_id = ? and deposit_code = ? and deposit_status = 4 and status = 1", orgid, his_patient_id, code).Count(&total)
775
+	if total == 0 {
776
+		return 1
777
+	} else {
778
+		//预防万一,多加一个验证
779
+		if total%2 == 0 {
780
+			return 1
781
+		} else {
782
+			return 0
783
+		}
784
+	}
785
+}
786
+
750 787
 //把其他的类型转换成decimal.Decimal类型
751 788
 func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
752 789
 	switch i.(type) {
@@ -763,3 +800,97 @@ func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
763 800
 	}
764 801
 	return
765 802
 }
803
+
804
+func TypeConversion(tmp float64) (s string) {
805
+	switch tmp {
806
+	case 1:
807
+		s = "g"
808
+	case 2:
809
+		s = "mg"
810
+	case 3:
811
+		s = "u"
812
+	case 4:
813
+		s = "ml"
814
+	case 5:
815
+		s = "万U"
816
+	case 6:
817
+		s = "枚"
818
+	case 7:
819
+		s = "粒"
820
+	case 8:
821
+		s = "片"
822
+	case 9:
823
+		s = "支"
824
+	case 10:
825
+		s = "μg"
826
+	case 11:
827
+		s = "iu"
828
+	case 12:
829
+		s = "包"
830
+	case 13:
831
+		s = "袋"
832
+	case 14:
833
+		s = "万"
834
+	case 15:
835
+		s = "万iu"
836
+	case 16:
837
+		s = "丸"
838
+	case 17:
839
+		s = "盒"
840
+	case 18:
841
+		s = "瓶"
842
+	case 19:
843
+		s = "瓶(袋)"
844
+	case 20:
845
+		s = "次"
846
+	}
847
+	return s
848
+}
849
+
850
+func TypeConversion02(tmp string) (s string) {
851
+	switch tmp {
852
+	case "1":
853
+		s = "g"
854
+	case "2":
855
+		s = "mg"
856
+	case "3":
857
+		s = "u"
858
+	case "4":
859
+		s = "ml"
860
+	case "5":
861
+		s = "万U"
862
+	case "6":
863
+		s = "枚"
864
+	case "7":
865
+		s = "粒"
866
+	case "8":
867
+		s = "片"
868
+	case "9":
869
+		s = "支"
870
+	case "10":
871
+		s = "μg"
872
+	case "11":
873
+		s = "iu"
874
+	case "12":
875
+		s = "包"
876
+	case "13":
877
+		s = "袋"
878
+	case "14":
879
+		s = "万"
880
+	case "15":
881
+		s = "万iu"
882
+	case "16":
883
+		s = "丸"
884
+	case "17":
885
+		s = "盒"
886
+	case "18":
887
+		s = "瓶"
888
+	case "19":
889
+		s = "瓶(袋)"
890
+	case "20":
891
+		s = "次"
892
+	default:
893
+		s = tmp
894
+	}
895
+	return s
896
+}

+ 4 - 0
service/his_hospital_service.go Прегледај датотеку

@@ -271,6 +271,10 @@ func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err er
271 271
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
272 272
 	return
273 273
 }
274
+func GetInHospitalRecordTX(id int64, tx *gorm.DB) (record models.HisHospitalCheckRecord, err error) {
275
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
276
+	return
277
+}
274 278
 
275 279
 func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
276 280
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error

+ 21 - 18
service/his_service.go Прегледај датотеку

@@ -1251,6 +1251,10 @@ func UpDateOrder(order models.HisOrder) (err error) {
1251 1251
 	err = writeDb.Save(&order).Error
1252 1252
 	return
1253 1253
 }
1254
+func UpDateOrderTX(order models.HisOrder, tx *gorm.DB) (err error) {
1255
+	err = writeDb.Save(&order).Error
1256
+	return
1257
+}
1254 1258
 
1255 1259
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
1256 1260
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
@@ -1728,24 +1732,23 @@ func (HisPrescriptionProject) TableName() string {
1728 1732
 }
1729 1733
 
1730 1734
 type HisOrderInfo struct {
1731
-	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1732
-	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1733
-	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1734
-	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1735
-	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1736
-	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
1737
-	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
1738
-	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1739
-	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1740
-	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1741
-	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1742
-	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1743
-	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1744
-	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1745
-	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1746
-	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1747
-	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1748
-
1735
+	ID                     int64                  `gorm:"column:id" json:"id" form:"id"`
1736
+	OrderNumber            string                 `gorm:"column:order_number" json:"order_number" form:"order_number"`
1737
+	UploadDate             int64                  `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1738
+	AdviceId               int64                  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1739
+	DetItemFeeSumamt       float64                `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1740
+	Cnt                    float64                `gorm:"column:cnt" json:"cnt" form:"cnt"`
1741
+	Pric                   float64                `gorm:"column:pric" json:"pric" form:"pric"`
1742
+	PatientId              int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1743
+	MedChrgitmType         string                 `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1744
+	Status                 int64                  `gorm:"column:status" json:"status" form:"status"`
1745
+	FeedetlSn              string                 `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1746
+	ChldMedcFlag           string                 `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1747
+	ChrgitmLv              string                 `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1748
+	UserOrgId              int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1749
+	ProjectId              int64                  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1750
+	ItemId                 int64                  `gorm:"column:item_id" json:"item_id" form:"item_id"`
1751
+	FulamtOwnpayAmt        float64                `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1749 1752
 	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1750 1753
 	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1751 1754
 }

+ 180 - 147
service/his_summary_service.go Прегледај датотеку

@@ -8,147 +8,21 @@ import (
8 8
 
9 9
 func GetHisSummaryDetailList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (patients []*models.ChargePatient, err error) {
10 10
 
11
-	if len(keyword) == 0 {
12
-		switch item_type {
13
-		case 0:
14
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
15
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
16
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
17
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
18
-							Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
19
-								return db.Preload("Drug", "status = 1").Where("status = 1")
20
-							}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
21
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
22
-								return db.Select("id,project_name,unit").Where("status = 1 ")
23
-							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
24
-								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
25
-							}).Where("status = 1 ")
26
-						})
27
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
28
-			}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
29
-
30
-			break
31
-		case 1:
32
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
33
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
34
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
35
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id > 0 AND project_id = 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
36
-							return db.Preload("Drug", "status = 1").Where("status = 1")
37
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
38
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
39
-								return db.Select("id,project_name,unit").Where("status = 1 ")
40
-							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
41
-								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
42
-							}).Where("status = 1 ")
43
-						})
44
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
45
-			}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
46
-
47
-			break
48
-		case 2:
49
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and order.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
50
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
51
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
52
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
53
-							return db.Preload("Drug", "status = 1").Where("status = 1")
54
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
55
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
56
-								return db.Select("id,project_name,unit").Where("status = 1 ")
57
-							}).Where("status = 1 ")
58
-						})
59
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
60
-			}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
61
-
62
-			break
63
-		case 3:
64
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
65
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
66
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
67
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
68
-							return db.Preload("Drug", "status = 1").Where("status = 1")
69
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
70
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
71
-								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
72
-							}).Where("status = 1 ")
73
-						})
74
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
75
-			}).Where("p.status = 1  AND p.user_org_id = ? and p.id =?", org_id, patient_id).Group("id").Find(&patients).Error
76
-
77
-			break
78
-
79
-		}
80
-
81
-	} else {
82
-		keyword := "%" + keyword + "%"
83
-		switch item_type {
84
-		case 0:
85
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
86
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
87
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
88
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
89
-							return db.Preload("Drug", "status = 1").Where("status = 1")
90
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
91
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
92
-								return db.Select("id,project_name,unit").Where("status = 1 ")
93
-							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
94
-								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
95
-							}).Where("status = 1 ")
96
-						})
97
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
98
-			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
99
-
100
-			break
101
-		case 1:
102
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and AND orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
103
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
104
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
105
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id > 0 AND project_id = 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
106
-							return db.Preload("Drug", "status = 1").Where("status = 1")
107
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
108
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
109
-								return db.Select("id,project_name,unit").Where("status = 1 ")
110
-							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
111
-								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
112
-							}).Where("status = 1 ")
113
-						})
114
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
115
-			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
116
-
117
-			break
118
-		case 2:
119
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and  orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
120
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
121
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
122
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
123
-							return db.Preload("Drug", "status = 1").Where("status = 1")
124
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
125
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
126
-								return db.Select("id,project_name,unit").Where("status = 1 ")
127
-							}).Where("status = 1 ")
128
-						})
129
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
130
-			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
131
-
132
-			break
133
-		case 3:
134
-			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
135
-				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
136
-					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
137
-						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
138
-							return db.Preload("Drug", "status = 1").Where("status = 1")
139
-						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
140
-							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
141
-								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
142
-							}).Where("status = 1 ")
143
-						})
144
-					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
145
-			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
146
-
147
-			break
148
-
149
-		}
150
-
151
-	}
11
+	err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
12
+		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
13
+			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
14
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
15
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
16
+						return db.Preload("Drug", "status = 1").Where("status = 1 ")
17
+					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
18
+					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type,unit,remark").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
19
+						return db.Select("id,project_name,unit,medical_coverage,cost_classify").Where("status = 1 ")
20
+					}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
21
+						return db.Select("id,good_name,good_unit,specification_name,packing_unit,medical_insurance_level").Where("status = 1 ")
22
+					}).Where("status = 1 ")
23
+				})
24
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
25
+	}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
152 26
 
153 27
 	return
154 28
 
@@ -264,12 +138,12 @@ func DelelteHisPrescriptionInfoModeTemplate(id int64, user_org_id int64) (err er
264 138
 	return
265 139
 }
266 140
 
267
-func GetAdviceGatherDetaiList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (orderInfo []*models.HisOrderInfo, err error) {
141
+func GetAdviceGatherDetaiList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (orderInfo []*models.VmHisOrderInfo, err error) {
268 142
 
269 143
 	db := XTReadDB().Model(&orderInfo).Where("status = 1")
270 144
 
271 145
 	if org_id > 0 {
272
-		db = db.Where("user_org_id = ?", org_id)
146
+		db = db.Where("user_org_id = ? and advice_id > 0", org_id)
273 147
 	}
274 148
 	if start_time > 0 {
275 149
 		db = db.Where("ctime >=?", start_time)
@@ -277,15 +151,15 @@ func GetAdviceGatherDetaiList(keyword string, item_type int64, patient_id int64,
277 151
 	if end_time > 0 {
278 152
 		db = db.Where("ctime <=?", end_time)
279 153
 	}
280
-	err = db.Group("advice_id").Find(&orderInfo).Error
154
+	err = db.Preload("VmHisDoctorAdviceInfo", "patient_id = ? and advice_date>=? and advice_date<=?", patient_id, start_time, end_time).Group("advice_id").Scan(&orderInfo).Error
281 155
 	return orderInfo, err
282 156
 }
283 157
 
284
-func GetProjectGatherDetailList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (orderInfo []*models.HisOrderInfo, err error) {
158
+func GetProjectGatherDetailList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (orderInfo []*models.VmHisOrderInfo, err error) {
285 159
 	db := XTReadDB().Model(&orderInfo).Where("status = 1")
286 160
 
287 161
 	if org_id > 0 {
288
-		db = db.Where("user_org_id = ?", org_id)
162
+		db = db.Where("user_org_id = ? and project_id > 0", org_id)
289 163
 	}
290 164
 	if start_time > 0 {
291 165
 		db = db.Where("ctime >=?", start_time)
@@ -293,6 +167,165 @@ func GetProjectGatherDetailList(keyword string, item_type int64, patient_id int6
293 167
 	if end_time > 0 {
294 168
 		db = db.Where("ctime <=?", end_time)
295 169
 	}
296
-	err = db.Group("project_id").Find(&orderInfo).Error
170
+	err = db.Group("project_id").Preload("HisPrescriptionProject", "patient_id = ? and record_date>=? and record_date<=?", patient_id, start_time, end_time).Find(&orderInfo).Error
297 171
 	return orderInfo, err
298 172
 }
173
+
174
+func GetGatherHisOrder(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (order []*models.GatherHisOrder, err error) {
175
+
176
+	db := XTReadDB().Model(&order).Where("status = 1")
177
+
178
+	if org_id > 0 {
179
+		db = db.Where("user_org_id = ?", org_id)
180
+	}
181
+	if start_time > 0 {
182
+		db = db.Where("settle_accounts_date >=?", start_time)
183
+	}
184
+	if end_time > 0 {
185
+		db = db.Where("settle_accounts_date<=?", end_time)
186
+	}
187
+
188
+	if patient_id > 0 {
189
+		db = db.Where("patient_id = ?", patient_id)
190
+	}
191
+
192
+	if len(keyword) > 0 {
193
+
194
+	}
195
+
196
+	err = db.Find(&order).Error
197
+
198
+	return order, err
199
+}
200
+
201
+func GetGatherHisOrderTwo(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (models.GatherHisOrder, error) {
202
+
203
+	hisOrder := models.GatherHisOrder{}
204
+	db := XTReadDB().Model(&hisOrder).Where("status = 1")
205
+
206
+	if org_id > 0 {
207
+		db = db.Where("user_org_id = ?", org_id)
208
+	}
209
+	if start_time > 0 {
210
+		db = db.Where("settle_accounts_date >=?", start_time)
211
+	}
212
+	if end_time > 0 {
213
+		db = db.Where("settle_accounts_date<=?", end_time)
214
+	}
215
+
216
+	if patient_id > 0 {
217
+		db = db.Where("patient_id = ?", patient_id)
218
+	}
219
+
220
+	if len(keyword) > 0 {
221
+
222
+	}
223
+
224
+	err = db.Last(&hisOrder).Error
225
+
226
+	return hisOrder, err
227
+}
228
+
229
+func GetHisSummaryPatientInfo(org_id int64, patient_id int64, start_time int64, end_time int64) (info models.HisPatient, err error) {
230
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? AND  record_date <= ? AND patient_id = ?", org_id, start_time, end_time, patient_id).Last(&info).Error
231
+	return
232
+}
233
+
234
+func GetHisSummaryPatientInfoSix(org_id int64, patient_id int64, start_time int64, end_time int64) (info models.HisHospitalCheckRecord, err error) {
235
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? AND  record_date <= ? AND patient_id = ?", org_id, start_time, end_time, patient_id).Last(&info).Error
236
+	return
237
+}
238
+
239
+func GetDetailPatients(keywords string, org_id int64) (patients []*models.ChargePatientTwo, err error) {
240
+	if len(keywords) == 0 {
241
+		err = readDb.Model(&models.ChargePatientTwo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&patients).Error
242
+	}
243
+
244
+	if len(keywords) > 0 {
245
+		keyword := "%" + keywords + "%"
246
+		err = readDb.Model(&models.ChargePatientTwo{}).Where("user_org_id = ? AND status = 1 and name like ?", org_id, keyword).Find(&patients).Error
247
+	}
248
+
249
+	return
250
+}
251
+
252
+func GetHisDepatment(user_org_id int64) (hisdepartment []*models.XtHisDepartment, err error) {
253
+
254
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&hisdepartment).Error
255
+	return hisdepartment, err
256
+}
257
+
258
+func GetHisPatientInfoFive(org_id int64, patient_id int64, startime int64, endtime int64) (info models.HisPatient, err error) {
259
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 and patient_id = ? AND record_date >= ? and record_date <=?", org_id, patient_id, startime, endtime).Last(&info).Error
260
+	return
261
+}
262
+
263
+func GetHisPrescriptionTenty(org_id int64, patient_id int64, start_time int64, end_time int64, keyword string, item_type int64) (prescription []*models.HisPrescription, err error) {
264
+
265
+	db := readDb.Model(&models.HisPrescription{}).Where("status = 1")
266
+	if org_id > 0 {
267
+		db = db.Where("user_org_id = ?", org_id)
268
+	}
269
+	if start_time > 0 {
270
+		db = db.Where("record_date >=?", start_time)
271
+	}
272
+	if end_time > 0 {
273
+		db = db.Where("record_date <=?", end_time)
274
+	}
275
+	if patient_id > 0 {
276
+		db = db.Where("patient_id = ?", patient_id)
277
+	}
278
+	if len(keyword) > 0 {
279
+		err = db.Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
280
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
281
+		}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
282
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
283
+		}).Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).Find(&prescription).Error
284
+	} else {
285
+		err = db.Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
286
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
287
+		}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
288
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
289
+		}).
290
+			Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).Find(&prescription).Error
291
+	}
292
+
293
+	return
294
+}
295
+
296
+func GetHisLastOrder(org_id int64, patient_id int64, start_time int64, end_time int64) (models.HisOrder, error) {
297
+
298
+	order := models.HisOrder{}
299
+
300
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and ctime>=? and ctime<=? and fa_piao_number<> ''", org_id, patient_id, start_time, end_time).Last(&order).Error
301
+	return order, err
302
+}
303
+
304
+func GetHisSchedule(patient_id int64, org_id int64, start_time int64, end_time int64) (schedule []*models.XtSchedule, err error) {
305
+
306
+	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and schedule_date >=? and schedule_date<=? and status = 1", patient_id, org_id, start_time, end_time).Find(&schedule).Error
307
+	return schedule, err
308
+}
309
+
310
+func GetHisChargeOrder(org_id int64, patient_id int64, start_time int64, end_time int64, keyword string, item_type int64) (order []*models.HisChargeOrder, err error) {
311
+
312
+	db := XTReadDB().Model(&order).Where("status = 1")
313
+
314
+	if org_id > 0 {
315
+		db = db.Where("user_org_id = ?", org_id)
316
+	}
317
+	if patient_id > 0 {
318
+		db = db.Where("patient_id = ?", patient_id)
319
+	}
320
+
321
+	if start_time > 0 {
322
+		db = db.Where("settle_accounts_date>=?", start_time)
323
+	}
324
+	if end_time > 0 {
325
+		db = db.Where("settle_accounts_date<=?", end_time)
326
+	}
327
+	err = db.Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
328
+		return db.Where("status = 1").Preload("HisChargePrescriptionProject", "status=1").Preload("HisChargeDoctorAdviceInfo", "status=1")
329
+	}).Error
330
+	return order, err
331
+}

+ 25 - 0
service/role_service.go Прегледај датотеку

@@ -279,6 +279,21 @@ func SaveAppRole(appRole *models.App_Role) error {
279 279
 		tx.Rollback()
280 280
 		return err
281 281
 	}
282
+	var tmp models.Org
283
+	//根据机构id查询管理员id
284
+	tx.Model(&models.Org{}).Where("status = 1 and id = ?", appRole.OrgId).Find(&tmp)
285
+	//如果相等则修改管理员的姓名
286
+	if tmp.Creator == appRole.AdminUserId {
287
+		err = tx.Model(&models.AdminUser{}).Where("id = ?", appRole.AdminUserId).Updates(map[string]interface{}{
288
+			"mtime": time.Now().Unix(),
289
+			"name":  appRole.UserName,
290
+		}).Error
291
+		if err != nil {
292
+			tx.Rollback()
293
+			return err
294
+		}
295
+	}
296
+
282 297
 	return tx.Commit().Error
283 298
 }
284 299
 
@@ -593,6 +608,7 @@ func SaveFuncRolePurviewIds(orgID int64, appID int64, roleID int64, funcPurviewI
593 608
 }
594 609
 
595 610
 func ModifyAdminUserInfo(adminUserID int64, orgID int64, appID int64, name string, avatar string, newPassword string) error {
611
+
596 612
 	tx := writeUserDb.Begin()
597 613
 	editInfoErr := tx.Exec("update sgj_user_admin_role set user_name = ?, avatar = ?, mtime = ? where admin_user_id = ? and org_id = ?", name, avatar, time.Now().Unix(), adminUserID, orgID).Error
598 614
 	if editInfoErr != nil {
@@ -606,6 +622,15 @@ func ModifyAdminUserInfo(adminUserID int64, orgID int64, appID int64, name strin
606 622
 			return editPwdErr
607 623
 		}
608 624
 	}
625
+	//这里加上
626
+	err := tx.Model(&models.AdminUser{}).Where("id = ?", adminUserID).Updates(map[string]interface{}{
627
+		"mtime": time.Now().Unix(),
628
+		"name":  name,
629
+	}).Error
630
+	if err != nil {
631
+		tx.Rollback()
632
+		return err
633
+	}
609 634
 	tx.Commit()
610 635
 	return nil
611 636
 }

+ 1 - 0
service/self_drug_service.go Прегледај датотеку

@@ -551,6 +551,7 @@ type Drugs struct {
551 551
 	Dose                  float64  `gorm:"column:dose" json:"dose" form:"dose"`
552 552
 	DoseUnit              string   `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
553 553
 	MaxUnit               string   `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
554
+	DrugDoseUnit          int64    `grom:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
554 555
 }
555 556
 
556 557
 func (Drugs) TableName() string {

+ 59 - 2
service/stock_service.go Прегледај датотеку

@@ -1530,7 +1530,7 @@ func FindAllWarehouseOutList(orgId int64, page int64, limit int64, startTime int
1530 1530
 
1531 1531
 }
1532 1532
 
1533
-func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64) (list []*models.WarehouseOut, total int64, err error) {
1533
+func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64) (list []*models.WarehouseOut, total int64, err error) {
1534 1534
 	db := readDb.Model(&models.WarehouseOut{})
1535 1535
 	db = db.Where("xt_warehouse_out.org_id = ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.type = ?", orgId, types)
1536 1536
 
@@ -1549,6 +1549,18 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
1549 1549
 	if storehouse_id > 0 {
1550 1550
 		db = db.Where("xt_warehouse_out.storehouse_id = ?", storehouse_id)
1551 1551
 	}
1552
+	if way_type == 0 {
1553
+		db = db.Where("xt_warehouse_out.is_sys = 0 || xt_warehouse_out.is_sys = 1 || xt_warehouse_out.is_sys = 12")
1554
+	}
1555
+	if way_type == 1 {
1556
+		db = db.Where("xt_warehouse_out.is_sys = 0")
1557
+	}
1558
+	if way_type == 2 {
1559
+		db = db.Where("xt_warehouse_out.is_sys = 1")
1560
+	}
1561
+	if way_type == 3 {
1562
+		db = db.Where("xt_warehouse_out.is_sys = 12")
1563
+	}
1552 1564
 	db = db.Count(&total)
1553 1565
 	offset := (page - 1) * limit
1554 1566
 	if orgId == 10191 {
@@ -1586,7 +1598,7 @@ func FindAllDrugWarehouseOutList(orgId int64, page int64, limit int64, startTime
1586 1598
 
1587 1599
 }
1588 1600
 
1589
-func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64) (list []*models.DrugWarehouseOut, total int64, err error) {
1601
+func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64) (list []*models.DrugWarehouseOut, total int64, err error) {
1590 1602
 	db := readDb.Model(&models.DrugWarehouseOut{})
1591 1603
 	db = db.Where("xt_drug_warehouse_out.org_id = ? AND xt_drug_warehouse_out.status = 1 ", orgId)
1592 1604
 
@@ -1606,6 +1618,19 @@ func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startT
1606 1618
 	if storehouse_id > 0 {
1607 1619
 		db = db.Where("xt_drug_warehouse_out.storehouse_id = ?", storehouse_id)
1608 1620
 	}
1621
+
1622
+	if way_type == 0 {
1623
+		db = db.Where("xt_drug_warehouse_out.is_sys = 0 || xt_drug_warehouse_out.is_sys = 1 || xt_drug_warehouse_out.is_sys = 12")
1624
+	}
1625
+	if way_type == 1 {
1626
+		db = db.Where("xt_drug_warehouse_out.is_sys = 0")
1627
+	}
1628
+	if way_type == 2 {
1629
+		db = db.Where("xt_drug_warehouse_out.is_sys = 1")
1630
+	}
1631
+	if way_type == 3 {
1632
+		db = db.Where("xt_drug_warehouse_out.is_sys = 12")
1633
+	}
1609 1634
 	db = db.Count(&total)
1610 1635
 	offset := (page - 1) * limit
1611 1636
 	if orgId == 10191 {
@@ -6513,3 +6538,35 @@ func FindAdviceSettingById(orgid int64) (models.XtAdviceSetting, error) {
6513 6538
 	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
6514 6539
 	return setting, err
6515 6540
 }
6541
+
6542
+func GetPrescriptionConfig(orgid int64) (*models.XtPrescriptionConfig, error) {
6543
+
6544
+	config := models.XtPrescriptionConfig{}
6545
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6546
+	if err == gorm.ErrRecordNotFound {
6547
+		return nil, err
6548
+	}
6549
+	if err != nil {
6550
+		return nil, err
6551
+	}
6552
+	return &config, nil
6553
+}
6554
+
6555
+func CreatePrescriptionConfig(prescriptionConfig models.XtPrescriptionConfig) error {
6556
+
6557
+	err := XTWriteDB().Create(&prescriptionConfig).Error
6558
+	return err
6559
+}
6560
+
6561
+func UpdatePrescriptionConfig(orgid int64, config models.XtPrescriptionConfig) error {
6562
+
6563
+	err := XTWriteDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": config.IsOpen, "mtime": time.Now().Unix()}).Error
6564
+	return err
6565
+}
6566
+
6567
+func FindPrescriptionConfigById(orgid int64) (models.XtPrescriptionConfig, error) {
6568
+	config := models.XtPrescriptionConfig{}
6569
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6570
+
6571
+	return config, err
6572
+}

+ 7 - 2
service/warhouse_service.go Прегледај датотеку

@@ -4325,7 +4325,8 @@ func AutoDrugDeliverInfoTwenty(orgID int64, prescribingNumber int64, warehouseou
4325 4325
 
4326 4326
 		maxNumber = deliver_number / drup.MinNumber
4327 4327
 		minNumber = deliver_number % drup.MinNumber
4328
-
4328
+		fmt.Println("maxNumber2323232233232332332323232323233232", maxNumber)
4329
+		fmt.Println("minNumber3223233232323233232332322332", minNumber)
4329 4330
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4330 4331
 			minNumber = maxNumber
4331 4332
 		}
@@ -4353,7 +4354,11 @@ func AutoDrugDeliverInfoTwenty(orgID int64, prescribingNumber int64, warehouseou
4353 4354
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4354 4355
 		} else {
4355 4356
 			if minNumber > 0 {
4356
-				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
4357
+				if minNumber == 1 && maxNumber == 1 && drup.MaxUnit != drup.MinUnit {
4358
+					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
4359
+				} else {
4360
+					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
4361
+				}
4357 4362
 			}
4358 4363
 
4359 4364
 			if minNumber == 0 && maxNumber != 1 {