28169 6 mēnešus atpakaļ
vecāks
revīzija
560780ae92
35 mainītis faili ar 2174 papildinājumiem un 255 dzēšanām
  1. Binārs
      XT_New.exe
  2. 10 10
      controllers/base_api_controller.go
  3. 7 4
      controllers/data_api_controller.go
  4. 92 11
      controllers/doctors_api_controller.go
  5. 44 0
      controllers/gobal_config_api_controller.go
  6. 57 6
      controllers/his_api_controller.go
  7. 1 1
      controllers/manager_center_api_controller.go
  8. 406 195
      controllers/mobile_api_controllers/patient_api_controller.go
  9. 138 0
      controllers/new_mobile_api_controllers/new_manage_api_controller.go
  10. 1 0
      controllers/new_mobile_api_controllers/new_manage_api_router.go
  11. 9 0
      controllers/new_mobile_api_controllers/new_self_drug_api_router.go
  12. 1 1
      controllers/orginfo_api_controller.go
  13. 79 11
      controllers/patient_api_controller.go
  14. 25 3
      controllers/pharmacy_controller.go
  15. 272 0
      controllers/self_drug_api_congtroller.go
  16. 315 0
      controllers/stock_in_api_controller.go
  17. 1 0
      models/device_models.go
  18. 2 0
      models/dialysis.go
  19. 67 0
      models/drug_stock.go
  20. 86 0
      models/good_models.go
  21. 1 0
      models/his_models.go
  22. 6 0
      models/pharmacy_models.go
  23. 3 0
      models/self_drug_models.go
  24. 77 0
      models/stock_models.go
  25. 58 1
      service/doctor_advice_service.go
  26. 4 4
      service/gobal_config_service.go
  27. 5 0
      service/manage_service.go
  28. 2 2
      service/mobile_dialysis_service.go
  29. 8 0
      service/new_warehouse_service.go
  30. 9 1
      service/patient_dataconfig_service.go
  31. 36 4
      service/patient_service.go
  32. 31 0
      service/pharmacy_service.go
  33. 112 1
      service/self_drug_service.go
  34. 205 0
      service/stock_service.go
  35. 4 0
      service/warhouse_service.go

Binārs
XT_New.exe Parādīt failu


+ 10 - 10
controllers/base_api_controller.go Parādīt failu

@@ -72,10 +72,10 @@ func (this *BaseAuthAPIController) Prepare() {
72 72
 	this.BaseAPIController.Prepare()
73 73
 	if this.GetAdminUserInfo() == nil {
74 74
 		var userAdmin models.AdminUser
75
-		userAdmin.Id = 4745
75
+		userAdmin.Id = 4608
76 76
 		userAdmin.Mobile = "13318599895"
77 77
 
78
-		userAdmin.Id = 4745 //4,809
78
+		userAdmin.Id = 4608 //4,809
79 79
 		userAdmin.Mobile = "12222222222"
80 80
 		userAdmin.IsSuperAdmin = true
81 81
 		userAdmin.Status = 1
@@ -83,7 +83,7 @@ func (this *BaseAuthAPIController) Prepare() {
83 83
 		userAdmin.ModifyTime = 1530786071
84 84
 		var subscibe models.ServeSubscibe
85 85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10138 //机构id
86
+		subscibe.OrgId = 10644 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,8 +93,8 @@ func (this *BaseAuthAPIController) Prepare() {
93 93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94 94
 		subscibes[4] = &subscibe
95 95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10138 //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 17513 //4
96
+		adminUserInfo.CurrentOrgId = 10644 //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 17260 //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
100 100
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -318,10 +318,10 @@ func (this *BaseServeAPIController) Prepare() {
318 318
 	this.BaseAPIController.Prepare()
319 319
 	if this.GetAdminUserInfo() == nil {
320 320
 		var userAdmin models.AdminUser
321
-		userAdmin.Id = 4745
321
+		userAdmin.Id = 4608
322 322
 		userAdmin.Mobile = "13318599895"
323 323
 
324
-		userAdmin.Id = 4745 //4,809
324
+		userAdmin.Id = 4608 //4,809
325 325
 		userAdmin.Mobile = "12222222222"
326 326
 		userAdmin.IsSuperAdmin = false
327 327
 		userAdmin.Status = 1
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10138 //机构id小英9675或4
332
+		subscibe.OrgId = 10644 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,8 +339,8 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10138 //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 17513 //4
342
+		adminUserInfo.CurrentOrgId = 10644 //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 17260 //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes
346 346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 7 - 4
controllers/data_api_controller.go Parādīt failu

@@ -1,16 +1,17 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
-	"XT_New/utils"
8 4
 	"encoding/json"
9 5
 	"fmt"
10 6
 	"reflect"
11 7
 	"strconv"
12 8
 	"time"
13 9
 
10
+	"XT_New/enums"
11
+	"XT_New/models"
12
+	"XT_New/service"
13
+	"XT_New/utils"
14
+
14 15
 	"github.com/astaxie/beego"
15 16
 )
16 17
 
@@ -1437,11 +1438,13 @@ func (c *DataApiController) GetAllAdviceConfigs() {
1437 1438
 	drugways, _, _ := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
1438 1439
 	efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.CurrentOrgId)
1439 1440
 	adviceTemplates, _ := service.FindOtherAllAdviceTemplate(adminUserInfo.CurrentOrgId)
1441
+	dics, _, _ := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
1440 1442
 	c.ServeSuccessJSON(map[string]interface{}{
1441 1443
 		"drugs":            drugs,
1442 1444
 		"drugways":         drugways,
1443 1445
 		"efs":              efs,
1444 1446
 		"advice_templates": adviceTemplates,
1447
+		"dics":             dics,
1445 1448
 	})
1446 1449
 }
1447 1450
 

+ 92 - 11
controllers/doctors_api_controller.go Parādīt failu

@@ -1,17 +1,18 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"strings"
8
+	"time"
9
+
4 10
 	"XT_New/enums"
5 11
 	"XT_New/models"
6 12
 	"XT_New/service"
7 13
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10 14
 	"github.com/astaxie/beego"
11 15
 	"github.com/jinzhu/gorm"
12
-	"strconv"
13
-	"strings"
14
-	"time"
15 16
 )
16 17
 
17 18
 type DoctorsApiController struct {
@@ -70,6 +71,10 @@ func DoctorApiRegistRouters() {
70 71
 
71 72
 	beego.Router("/api/schedule/getpatientbyname", &DoctorsApiController{}, "Get:GetPatientByName")
72 73
 	beego.Router("/api/schedule/getdocadvicebypatientid", &DoctorsApiController{}, "Get:GetDoctorAdviceByPatientId")
74
+
75
+	beego.Router("/api/schedule/getdoctoradvicemonthlist", &DoctorsApiController{}, "Get:GetDoctorAdivceMonthList")
76
+
77
+	beego.Router("/api/schedule/gethisprescriptionprojectmonthlist", &DoctorsApiController{}, "Get:GetHisPrescriptionProjectMonthList")
73 78
 }
74 79
 
75 80
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -1697,12 +1702,6 @@ func (c *DoctorsApiController) GetDoctorAdviceByPatientId() {
1697 1702
 	orgId := c.GetAdminUserInfo().CurrentOrgId
1698 1703
 	end_time := c.GetString("end_time")
1699 1704
 
1700
-	fmt.Println("patient_id", patient_id)
1701
-	fmt.Println("startdateunix", start_time)
1702
-	fmt.Println("enddateunix", end_time)
1703
-	fmt.Println("limit", limit)
1704
-	fmt.Println("page", page)
1705
-
1706 1705
 	timeLayout := "2006-01-02"
1707 1706
 	loc, _ := time.LoadLocation("Local")
1708 1707
 
@@ -1733,3 +1732,85 @@ func (c *DoctorsApiController) GetDoctorAdviceByPatientId() {
1733 1732
 		"total": total,
1734 1733
 	})
1735 1734
 }
1735
+
1736
+func (c *DoctorsApiController) GetDoctorAdivceMonthList() {
1737
+
1738
+	timeLayout := "2006-01-02"
1739
+	loc, _ := time.LoadLocation("Local")
1740
+
1741
+	start_time := c.GetString("start_time")
1742
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1743
+	end_time := c.GetString("end_time")
1744
+	var startTimeUnix int64
1745
+	if len(start_time) > 0 {
1746
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1747
+		if err != nil {
1748
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1749
+			return
1750
+		}
1751
+		startTimeUnix = theTime.Unix()
1752
+	}
1753
+
1754
+	var endTimeUnix int64
1755
+	if len(end_time) > 0 {
1756
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1757
+		if err != nil {
1758
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1759
+			return
1760
+		}
1761
+		endTimeUnix = theTime.Unix()
1762
+	}
1763
+
1764
+	adviceList, _ := service.GetDoctorAdivceMonthList(orgId, startTimeUnix, endTimeUnix)
1765
+
1766
+	hisAdviceList, _ := service.GetHisDoctorAdivceMonthList(orgId, startTimeUnix, endTimeUnix)
1767
+
1768
+	drugs, _ := service.GetAllBaseDrugLibList(orgId)
1769
+
1770
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1771
+
1772
+	_, config := service.FindXTHisRecordByOrgId(orgId)
1773
+
1774
+	c.ServeSuccessJSON(map[string]interface{}{
1775
+		"adviceList":       adviceList,
1776
+		"hisAdviceList":    hisAdviceList,
1777
+		"config":           config,
1778
+		"drugs":            drugs,
1779
+		"manufacturerList": manufacturerList,
1780
+	})
1781
+}
1782
+
1783
+func (c *DoctorsApiController) GetHisPrescriptionProjectMonthList() {
1784
+
1785
+	timeLayout := "2006-01-02"
1786
+	loc, _ := time.LoadLocation("Local")
1787
+
1788
+	start_time := c.GetString("start_time")
1789
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1790
+	end_time := c.GetString("end_time")
1791
+	var startTimeUnix int64
1792
+	if len(start_time) > 0 {
1793
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1794
+		if err != nil {
1795
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1796
+			return
1797
+		}
1798
+		startTimeUnix = theTime.Unix()
1799
+	}
1800
+
1801
+	var endTimeUnix int64
1802
+	if len(end_time) > 0 {
1803
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1804
+		if err != nil {
1805
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1806
+			return
1807
+		}
1808
+		endTimeUnix = theTime.Unix()
1809
+	}
1810
+
1811
+	projectMonthList, _ := service.GetHisPrescriptionProjectMonthList(orgId, startTimeUnix, endTimeUnix)
1812
+
1813
+	c.ServeSuccessJSON(map[string]interface{}{
1814
+		"projectMonthList": projectMonthList,
1815
+	})
1816
+}

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

@@ -134,6 +134,8 @@ func GobalConfigRegistRouters() {
134 134
 	beego.Router("/api/changeselfprescriptionoutopen", &GobalConfigApiController{}, "Get:ChangeSelfPrescriptionOutOpen")
135 135
 
136 136
 	beego.Router("/api/getselfprintlist", &GobalConfigApiController{}, "Get:GetSelfPrintList")
137
+
138
+	beego.Router("/api/changedrugcodeopen", &GobalConfigApiController{}, "Get:ChangeDrugCodeOpen")
137 139
 }
138 140
 
139 141
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1665,6 +1667,8 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1665 1667
 	drugSettleConfig, _ := service.FindeDrugSettleConfigById(adminUserInfo.CurrentOrgId)
1666 1668
 
1667 1669
 	goodOutConfig, _ := service.FindGoodOutConfigById(adminUserInfo.CurrentOrgId)
1670
+
1671
+	drugCodeOpen, _ := service.GetDrugCodeOpen(adminUserInfo.CurrentOrgId)
1668 1672
 	c.ServeSuccessJSON(map[string]interface{}{
1669 1673
 		"is_open_xt_his":         config.IsOpen,
1670 1674
 		"is_open_xt_his_project": project_config.IsOpen,
@@ -1674,6 +1678,7 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1674 1678
 		"is_open":                drugOutConfig.IsOpen,
1675 1679
 		"is_seetle_open":         drugSettleConfig.IsOpen,
1676 1680
 		"is_out_open":            goodOutConfig.IsOpen,
1681
+		"is_code_open":           drugCodeOpen.IsOpen,
1677 1682
 	})
1678 1683
 
1679 1684
 }
@@ -1759,6 +1764,7 @@ func (c *GobalConfigApiController) GetDrugInDetail() {
1759 1764
 	limit, _ := c.GetInt64("limit")
1760 1765
 
1761 1766
 	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1767
+
1762 1768
 	var drugType = "药品类型"
1763 1769
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1764 1770
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
@@ -2776,3 +2782,41 @@ func (this *GobalConfigApiController) GetSelfPrintList() {
2776 2782
 		"selfPrescriptionOutOpen": selfPrescriptionOutOpen,
2777 2783
 	})
2778 2784
 }
2785
+
2786
+func (this *GobalConfigApiController) ChangeDrugCodeOpen() {
2787
+
2788
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2789
+	is_open, _ := this.GetInt64("is_open")
2790
+	drugCodeOpen, _ := service.GetDrugCodeOpen(orgId)
2791
+
2792
+	if drugCodeOpen.ID == 0 {
2793
+
2794
+		codeOpen := models.XtDrugCodeOpen{
2795
+			UserOrgId: orgId,
2796
+			IsOpen:    is_open,
2797
+			Status:    1,
2798
+			Ctime:     time.Now().Unix(),
2799
+			Mtime:     time.Now().Unix(),
2800
+		}
2801
+
2802
+		service.CreateDrugOpen(codeOpen)
2803
+	}
2804
+
2805
+	if drugCodeOpen.ID == 1 {
2806
+
2807
+		codeOpen := models.XtDrugCodeOpen{
2808
+			ID:        drugCodeOpen.ID,
2809
+			UserOrgId: orgId,
2810
+			IsOpen:    is_open,
2811
+			Status:    1,
2812
+			Ctime:     time.Now().Unix(),
2813
+			Mtime:     time.Now().Unix(),
2814
+		}
2815
+
2816
+		service.SaveDrugOpen(codeOpen)
2817
+	}
2818
+
2819
+	this.ServeSuccessJSON(map[string]interface{}{
2820
+		"drugCodeOpen": drugCodeOpen,
2821
+	})
2822
+}

+ 57 - 6
controllers/his_api_controller.go Parādīt failu

@@ -3183,7 +3183,7 @@ func (c *HisApiController) CreateHisPrescription() {
3183 3183
 	var adviceList []models.HisDoctorAdviceInfo
3184 3184
 	var projectList []models.HisPrescriptionProject
3185 3185
 
3186
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 {
3186
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10164 {
3187 3187
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3188 3188
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3189 3189
 
@@ -3684,7 +3684,7 @@ func (c *HisApiController) CreateHisPrescription() {
3684 3684
 								}
3685 3685
 
3686 3686
 								//赤峰
3687
-								if adminInfo.CurrentOrgId == 10265 {
3687
+								if adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10489 {
3688 3688
 
3689 3689
 									drug, _ := service.FindNewBaseDrugLibRecord(adminInfo.CurrentOrgId, s.DrugId, tx)
3690 3690
 
@@ -3760,7 +3760,7 @@ func (c *HisApiController) CreateHisPrescription() {
3760 3760
 									projectDetail, _ := service.GetHisPrescriptonProjectById(p.ID)
3761 3761
 									p.IsOut = projectDetail.IsOut
3762 3762
 								}
3763
-								if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 10265 {
3763
+								if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10489 {
3764 3764
 									storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
3765 3765
 									if p.Type == 3 {
3766 3766
 										lastWarehouse, _ := service.FindFirstWarehousingInfoByStockThree(p.ProjectId, storeConfig.DrugStorehouseOut)
@@ -4218,6 +4218,57 @@ func (c *HisApiController) CreateHisPrescription() {
4218 4218
 									}
4219 4219
 								}
4220 4220
 
4221
+								//插入检验数据
4222
+								if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
4223
+									//新增或者编辑项目,修改对应的标签数据
4224
+									labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
4225
+									if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
4226
+										var label models.HisLabelPrintInfo
4227
+										project, _ := service.GetProjectDetail(p.ProjectId)
4228
+										if project.CostClassify == 3 { //类别为检验检查
4229
+											if p.TeamId > 0 { //检验检查组套
4230
+												tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
4231
+												if tempLabel.ID == 0 {
4232
+													team, _ := service.GetProjectTeamDetail(p.TeamId)
4233
+													label.Number = tempPrescription.PrescriptionNumber
4234
+													label.ProjectId = project.ID
4235
+													label.Status = 1
4236
+													label.IsPrint = 2
4237
+													label.DoctorId = info.DoctorId
4238
+													label.UserOrgId = p.UserOrgId
4239
+													label.PatientId = patient_id
4240
+													label.RecordDate = recordDateTime
4241
+													label.Ctime = time.Now().Unix()
4242
+													label.Mtime = time.Now().Unix()
4243
+													label.ItemId = p.TeamId
4244
+													label.FeedetlSn = p.FeedetlSn
4245
+													label.PProjectId = p.ID
4246
+													label.ProjectName = team.ProjectTeam
4247
+													label.PatientName = patient.Name
4248
+													service.CreateHisLabelRecord(&label)
4249
+												}
4250
+											} else { //单条检验检查项目
4251
+												label.Number = tempPrescription.PrescriptionNumber
4252
+												label.ProjectId = project.ID
4253
+												label.Status = 1
4254
+												label.DoctorId = info.DoctorId
4255
+												label.UserOrgId = p.UserOrgId
4256
+												label.PatientId = patient_id
4257
+												label.RecordDate = recordDateTime
4258
+												label.IsPrint = 2
4259
+												label.Ctime = time.Now().Unix()
4260
+												label.Mtime = time.Now().Unix()
4261
+												label.FeedetlSn = p.FeedetlSn
4262
+												label.PProjectId = p.ID
4263
+												label.ItemId = p.TeamId
4264
+												label.ProjectName = project.ProjectName
4265
+												label.PatientName = patient.Name
4266
+												service.CreateHisLabelRecord(&label)
4267
+											}
4268
+										}
4269
+									}
4270
+								}
4271
+
4221 4272
 								service.CreateNewHisProjectTwo(&p, tx)
4222 4273
 								var randNum int
4223 4274
 								randNum = rand.Intn(10000) + 1000
@@ -4521,7 +4572,7 @@ func (c *HisApiController) CreateHisPrescription() {
4521 4572
 								}
4522 4573
 
4523 4574
 								//赤峰
4524
-								if s.UserOrgId == 10265 {
4575
+								if s.UserOrgId == 10265 || s.UserOrgId == 10489 {
4525 4576
 									drug, _ := service.GetDrugByGoodId(s.DrugId)
4526 4577
 									info, _ := service.GetWarehoseInfoByDrugId(s.DrugId, s.UserOrgId)
4527 4578
 									if info.RetailPrice > 0 {
@@ -10345,7 +10396,7 @@ func (this *HisApiController) GetLastOrNextHisPrescription() {
10345 10396
 	adminUserInfo := this.GetAdminUserInfo()
10346 10397
 	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id, p_type)
10347 10398
 
10348
-	if adminUserInfo.CurrentOrgId == 10265 {
10399
+	if adminUserInfo.CurrentOrgId == 10265 || adminUserInfo.CurrentOrgId == 10489 {
10349 10400
 		_, config := service.FindHisStockPriceRecordByOrgId(adminUserInfo.CurrentOrgId)
10350 10401
 		if config.ID > 0 && config.IsOpen == 1 {
10351 10402
 			for _, subitems := range prescriptions {
@@ -10418,7 +10469,7 @@ func (this *HisApiController) GetCallHisPrescription() {
10418 10469
 	//
10419 10470
 	//lastWarehouse, _ := service.FindLastDrugWarehousingInfoByID(s.DrugId, storeConfig.DrugStorehouseOut)
10420 10471
 
10421
-	if adminUserInfo.CurrentOrgId == 10265 {
10472
+	if adminUserInfo.CurrentOrgId == 10265 || adminUserInfo.CurrentOrgId == 10489 {
10422 10473
 		_, config := service.FindHisStockPriceRecordByOrgId(adminUserInfo.CurrentOrgId)
10423 10474
 		if config.ID > 0 && config.IsOpen == 1 {
10424 10475
 			for _, subitems := range prescriptions {

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

@@ -1846,7 +1846,7 @@ func (c *ManagerCenterApiController) ModifyGoodInfo() {
1846 1846
 	}
1847 1847
 	err, goodInfos := service.ModifyGoodInfo(&goodInfo)
1848 1848
 
1849
-	if adminUserInfo.CurrentOrgId != 10653 {
1849
+	if adminUserInfo.CurrentOrgId != 10653 && adminUserInfo.CurrentOrgId != 10644 {
1850 1850
 		list, _ := service.GetHisPrescripionProjectList(good_id, adminUserInfo.CurrentOrgId)
1851 1851
 		if len(list) > 0 {
1852 1852
 			for _, item := range list {

+ 406 - 195
controllers/mobile_api_controllers/patient_api_controller.go Parādīt failu

@@ -716,7 +716,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
716 716
 				}
717 717
 
718 718
 				//恒泰中医院
719
-				if item.UserOrgId == 10490 || item.UserOrgId == 10602 {
719
+				if item.UserOrgId == 10490 || item.UserOrgId == 10602 || item.UserOrgId == 10697 {
720 720
 					if item.DrugId == 0 || item.DrugNameId == 0 {
721 721
 						//从字典里面查找
722 722
 						drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
@@ -745,8 +745,190 @@ func (c *PatientApiController) ExecDoctorAdvice() {
745 745
 
746 746
 				service.CreateDoctorAdviceLog(adviceLog)
747 747
 			}
748
+			advicesOne, _ := service.FindAllDoctorAdviceByGoroupNoOne(adminUserInfo.Org.Id, groupno)
749
+			for _, item := range advicesOne {
750
+
751
+				//自备药
752
+				selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
753
+
754
+				if selfPrescriptionOutOpen.IsOpen == 1 {
755
+
756
+					db := service.XTWriteDB()
757
+					tx := db.Begin()
758
+					defer func() {
759
+						if r := recover(); r != nil {
760
+							tx.Rollback()
761
+						} else {
762
+							tx.Commit()
763
+						}
764
+					}()
765
+
766
+					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
767
+
768
+					if selfBasedrug.IsSelfDrug == 1 {
769
+
770
+						//查询是否有库存
771
+						infoList, _ := service.GetSelfWarehouseInfoByWarehouseInfoTwo(item.DrugId, item.PatientId, item.UserOrgId, tx)
772
+
773
+						var total_count int64
774
+						var prescribing_number_total int64
775
+						for _, items := range infoList {
776
+							if items.MaxUnit == selfBasedrug.MaxUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
777
+								items.StockMaxNumber = items.StockMaxNumber * selfBasedrug.MinNumber
778
+							}
779
+
780
+							total_count += items.StockMaxNumber + items.StockMinNumber
781
+						}
782
+
783
+						if total_count == 0 {
784
+							c.ServeSuccessJSON(map[string]interface{}{
785
+								"msg":    "2",
786
+								"advice": item,
787
+								"ids":    ids,
788
+							})
789
+							return
790
+						}
791
+
792
+						//判断单位是否相等
793
+						if selfBasedrug.MaxUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
794
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
795
+							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
796
+							//转化为最小单位
797
+							prescribing_number_total = count * selfBasedrug.MinNumber
798
+						}
799
+
800
+						if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
801
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
802
+							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
803
+							prescribing_number_total = count
804
+
805
+						}
806
+
807
+						if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
808
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
809
+							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
810
+							prescribing_number_total = count
811
+
812
+						}
813
+
814
+						if prescribing_number_total > total_count {
815
+							c.ServeSuccessJSON(map[string]interface{}{
816
+								"msg":    "3",
817
+								"advice": item,
818
+							})
819
+							return
820
+						}
821
+						var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
822
+						//出库
823
+						if prescribing_number_total <= total_count {
824
+							timeStr := time.Now().Format("2006-01-02")
825
+							timeArr := strings.Split(timeStr, "-")
826
+							total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
827
+
828
+							total = total + 1
829
+							warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
830
+							number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
831
+							number = number + total
832
+							warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
833
+							operation_time := time.Now().Unix()
834
+
835
+							creater := c.GetMobileAdminUserInfo().AdminUser.Id
836
+							//创建一个出库单
837
+							drugWarehouseOut := models.XtSelfDrugWarehouseOut{
838
+								WarehouseOutOrderNumber: warehousing_out_order,
839
+								OperationTime:           operation_time,
840
+								OrgId:                   adminUserInfo.Org.Id,
841
+								Creater:                 creater,
842
+								Ctime:                   time.Now().Unix(),
843
+								Status:                  1,
844
+								WarehouseOutTime:        item.AdviceDate,
845
+								Type:                    0,
846
+								PatientId:               advice.PatientId,
847
+								IsCheck:                 1,
848
+								IsSys:                   1,
849
+							}
850
+
851
+							//查询今日是否有出库数据
852
+							lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
853
+
854
+							if lastWarehouseOut.ID == 0 {
855
+								service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
856
+							}
857
+
858
+							//查询今日是否有出库数据
859
+							lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
860
+
861
+							var warehousing_out_order_str string
862
+							if lastWarehouseOut.ID == 0 {
863
+								warehousing_out_order_str = warehousing_out_order
864
+							} else {
865
+								warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
866
+							}
867
+
868
+							//出库
869
+							warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
870
+								WarehouseOutId:          lastWarehouseOutOne.ID,
871
+								WarehouseOutOrderNumber: warehousing_out_order_str,
872
+								DrugId:                  item.DrugId,
873
+								Count:                   prescribing_number_total,
874
+								Price:                   0,
875
+								TotalPrice:              0,
876
+								Status:                  1,
877
+								Ctime:                   item.AdviceDate,
878
+								Mtime:                   item.AdviceDate,
879
+								Remark:                  "",
880
+								OrgId:                   item.UserOrgId,
881
+								Type:                    0,
882
+								Manufacturer:            selfBasedrug.Manufacturer,
883
+								Dealer:                  selfBasedrug.Dealer,
884
+								RetailPrice:             0,
885
+								RetailTotalPrice:        0,
886
+								CountUnit:               selfBasedrug.MinUnit,
887
+								ExpiryDate:              0,
888
+								ProductDate:             0,
889
+								Number:                  "",
890
+								BatchNumber:             "",
891
+								IsSys:                   0,
892
+								WarehouseInfoId:         0,
893
+								AdminUserId:             0,
894
+								StockCount:              "",
895
+								IsCheck:                 1,
896
+								SysRecordTime:           item.AdviceDate,
897
+								PatientId:               item.PatientId,
898
+								AdviceId:                item.ID,
899
+								ClassType:               "",
900
+							}
901
+							warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
902
+
903
+							for _, it := range warehousingOutInfo {
904
+
905
+								medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
906
+								drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
907
+								//出库逻辑
908
+								service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
909
+
910
+								//查询剩余库存
911
+								stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
912
+								var sum_count int64
913
+								for _, its := range stockInfo {
914
+									if its.MaxUnit == medical.MaxUnit {
915
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
916
+									}
917
+									sum_count += its.StockMaxNumber + its.StockMinNumber
918
+								}
919
+								service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
920
+							}
921
+						}
922
+
923
+					}
924
+
925
+				}
926
+
927
+			}
928
+
748 929
 		} else {
749 930
 			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
931
+
750 932
 			for _, item := range advices {
751 933
 				//自备药
752 934
 				selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
@@ -802,6 +984,188 @@ func (c *PatientApiController) ExecDoctorAdvice() {
802 984
 					advice = item
803 985
 				}
804 986
 			}
987
+
988
+			advicesOne, _ := service.FindDoctorAdviceByIdsOne(adminUserInfo.Org.Id, ids)
989
+			for _, item := range advicesOne {
990
+
991
+				//自备药
992
+				selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
993
+
994
+				if selfPrescriptionOutOpen.IsOpen == 1 {
995
+
996
+					db := service.XTWriteDB()
997
+					tx := db.Begin()
998
+					defer func() {
999
+						if r := recover(); r != nil {
1000
+							tx.Rollback()
1001
+						} else {
1002
+							tx.Commit()
1003
+						}
1004
+					}()
1005
+
1006
+					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
1007
+
1008
+					if selfBasedrug.IsSelfDrug == 1 {
1009
+
1010
+						//查询是否有库存
1011
+						infoList, _ := service.GetSelfWarehouseInfoByWarehouseInfoTwo(item.DrugId, item.PatientId, item.UserOrgId, tx)
1012
+
1013
+						var total_count int64
1014
+						var prescribing_number_total int64
1015
+						for _, items := range infoList {
1016
+							if items.MaxUnit == selfBasedrug.MaxUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1017
+								items.StockMaxNumber = items.StockMaxNumber * selfBasedrug.MinNumber
1018
+							}
1019
+
1020
+							total_count += items.StockMaxNumber + items.StockMinNumber
1021
+						}
1022
+
1023
+						if total_count == 0 {
1024
+							c.ServeSuccessJSON(map[string]interface{}{
1025
+								"msg":    "2",
1026
+								"advice": item,
1027
+								"ids":    ids,
1028
+							})
1029
+							return
1030
+						}
1031
+
1032
+						//判断单位是否相等
1033
+						if selfBasedrug.MaxUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1034
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1035
+							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1036
+							//转化为最小单位
1037
+							prescribing_number_total = count * selfBasedrug.MinNumber
1038
+						}
1039
+
1040
+						if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1041
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1042
+							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1043
+							prescribing_number_total = count
1044
+
1045
+						}
1046
+
1047
+						if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
1048
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1049
+							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1050
+							prescribing_number_total = count
1051
+
1052
+						}
1053
+
1054
+						if prescribing_number_total > total_count {
1055
+							c.ServeSuccessJSON(map[string]interface{}{
1056
+								"msg":    "3",
1057
+								"advice": item,
1058
+							})
1059
+							return
1060
+						}
1061
+						var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
1062
+						//出库
1063
+						if prescribing_number_total <= total_count {
1064
+							timeStr := time.Now().Format("2006-01-02")
1065
+							timeArr := strings.Split(timeStr, "-")
1066
+							total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
1067
+
1068
+							total = total + 1
1069
+							warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1070
+							number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1071
+							number = number + total
1072
+							warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1073
+							operation_time := time.Now().Unix()
1074
+
1075
+							creater := c.GetMobileAdminUserInfo().AdminUser.Id
1076
+
1077
+							//创建一个出库单
1078
+							drugWarehouseOut := models.XtSelfDrugWarehouseOut{
1079
+								WarehouseOutOrderNumber: warehousing_out_order,
1080
+								OperationTime:           operation_time,
1081
+								OrgId:                   adminUserInfo.Org.Id,
1082
+								Creater:                 creater,
1083
+								Ctime:                   time.Now().Unix(),
1084
+								Status:                  1,
1085
+								WarehouseOutTime:        item.AdviceDate,
1086
+								Type:                    0,
1087
+								PatientId:               advice.PatientId,
1088
+								IsCheck:                 1,
1089
+								IsSys:                   1,
1090
+							}
1091
+
1092
+							//查询今日是否有出库数据
1093
+							lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
1094
+
1095
+							if lastWarehouseOut.ID == 0 {
1096
+								service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
1097
+							}
1098
+
1099
+							//查询今日是否有出库数据
1100
+							lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
1101
+
1102
+							var warehousing_out_order_str string
1103
+							if lastWarehouseOut.ID == 0 {
1104
+								warehousing_out_order_str = warehousing_out_order
1105
+							} else {
1106
+								warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
1107
+							}
1108
+
1109
+							//出库
1110
+							warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
1111
+								WarehouseOutId:          lastWarehouseOutOne.ID,
1112
+								WarehouseOutOrderNumber: warehousing_out_order_str,
1113
+								DrugId:                  item.DrugId,
1114
+								Count:                   prescribing_number_total,
1115
+								Price:                   0,
1116
+								TotalPrice:              0,
1117
+								Status:                  1,
1118
+								Ctime:                   item.AdviceDate,
1119
+								Mtime:                   item.AdviceDate,
1120
+								Remark:                  "",
1121
+								OrgId:                   item.UserOrgId,
1122
+								Type:                    0,
1123
+								Manufacturer:            selfBasedrug.Manufacturer,
1124
+								Dealer:                  selfBasedrug.Dealer,
1125
+								RetailPrice:             0,
1126
+								RetailTotalPrice:        0,
1127
+								CountUnit:               selfBasedrug.MinUnit,
1128
+								ExpiryDate:              0,
1129
+								ProductDate:             0,
1130
+								Number:                  "",
1131
+								BatchNumber:             "",
1132
+								IsSys:                   0,
1133
+								WarehouseInfoId:         0,
1134
+								AdminUserId:             0,
1135
+								StockCount:              "",
1136
+								IsCheck:                 1,
1137
+								SysRecordTime:           item.AdviceDate,
1138
+								PatientId:               item.PatientId,
1139
+								AdviceId:                item.ID,
1140
+								ClassType:               "",
1141
+							}
1142
+							warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1143
+
1144
+							for _, it := range warehousingOutInfo {
1145
+
1146
+								medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1147
+								drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1148
+								//出库逻辑
1149
+								service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1150
+
1151
+								//查询剩余库存
1152
+								stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1153
+								var sum_count int64
1154
+								for _, its := range stockInfo {
1155
+									if its.MaxUnit == medical.MaxUnit {
1156
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1157
+									}
1158
+									sum_count += its.StockMaxNumber + its.StockMinNumber
1159
+								}
1160
+								service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1161
+							}
1162
+						}
1163
+
1164
+					}
1165
+
1166
+				}
1167
+
1168
+			}
805 1169
 		}
806 1170
 
807 1171
 		if advice.ExecutionState == 1 {
@@ -1361,174 +1725,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1361 1725
 		//	}
1362 1726
 		//}
1363 1727
 
1364
-		//自备药
1365
-		selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
1366
-
1367
-		if selfPrescriptionOutOpen.IsOpen == 1 {
1368
-
1369
-			db := service.XTWriteDB()
1370
-			tx := db.Begin()
1371
-			defer func() {
1372
-				if r := recover(); r != nil {
1373
-					tx.Rollback()
1374
-				} else {
1375
-					tx.Commit()
1376
-				}
1377
-			}()
1378
-
1379
-			selfBasedrug, _ := service.GetSelfBasedrugById(advice.DrugId, advice.UserOrgId, tx)
1380
-
1381
-			if selfBasedrug.IsSelfDrug == 1 {
1382
-
1383
-				//查询是否有库存
1384
-				infoList, _ := service.GetSelfWarehouseInfoByWarehouseInfoTwo(advice.DrugId, advice.PatientId, advice.UserOrgId, tx)
1385
-
1386
-				var total_count int64
1387
-				var prescribing_number_total int64
1388
-				for _, items := range infoList {
1389
-					if items.MaxUnit == selfBasedrug.MaxUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1390
-						items.StockMaxNumber = items.StockMaxNumber * selfBasedrug.MinNumber
1391
-					}
1392
-
1393
-					total_count += items.StockMaxNumber + items.StockMinNumber
1394
-				}
1395
-
1396
-				if total_count == 0 {
1397
-					c.ServeSuccessJSON(map[string]interface{}{
1398
-						"msg":    "2",
1399
-						"advice": advice,
1400
-						"ids":    ids,
1401
-					})
1402
-					return
1403
-				}
1404
-
1405
-				//判断单位是否相等
1406
-				if selfBasedrug.MaxUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1407
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
1408
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1409
-					//转化为最小单位
1410
-					prescribing_number_total = count * selfBasedrug.MinNumber
1411
-				}
1412
-
1413
-				if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1414
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
1415
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1416
-					prescribing_number_total = count
1417
-
1418
-				}
1419
-
1420
-				if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
1421
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
1422
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1423
-					prescribing_number_total = count
1424
-
1425
-				}
1426
-
1427
-				if prescribing_number_total > total_count {
1428
-					c.ServeSuccessJSON(map[string]interface{}{
1429
-						"msg":    "3",
1430
-						"advice": advice,
1431
-					})
1432
-					return
1433
-				}
1434
-				var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
1435
-				//出库
1436
-				if prescribing_number_total <= total_count {
1437
-					timeStr := time.Now().Format("2006-01-02")
1438
-					timeArr := strings.Split(timeStr, "-")
1439
-					total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
1440
-
1441
-					total = total + 1
1442
-					warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1443
-					number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1444
-					number = number + total
1445
-					warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1446
-					operation_time := time.Now().Unix()
1447
-
1448
-					creater := c.GetMobileAdminUserInfo().AdminUser.Id
1449
-					//创建一个出库单
1450
-					drugWarehouseOut := models.XtSelfDrugWarehouseOut{
1451
-						WarehouseOutOrderNumber: warehousing_out_order,
1452
-						OperationTime:           operation_time,
1453
-						OrgId:                   adminUserInfo.Org.Id,
1454
-						Creater:                 creater,
1455
-						Ctime:                   time.Now().Unix(),
1456
-						Status:                  1,
1457
-						WarehouseOutTime:        advice.AdviceDate,
1458
-						Type:                    0,
1459
-						PatientId:               advice.PatientId,
1460
-						IsCheck:                 1,
1461
-						IsSys:                   1,
1462
-					}
1463
-
1464
-					//查询今日是否有出库数据
1465
-					lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, advice.AdviceDate, tx, 1)
1466
-
1467
-					if lastWarehouseOut.ID == 0 {
1468
-						service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
1469
-					}
1470
-
1471
-					//查询今日是否有出库数据
1472
-					lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, advice.AdviceDate, tx, 1)
1473
-					//出库
1474
-					warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
1475
-						WarehouseOutId:          lastWarehouseOutOne.ID,
1476
-						WarehouseOutOrderNumber: warehousing_out_order,
1477
-						DrugId:                  advice.DrugId,
1478
-						Count:                   prescribing_number_total,
1479
-						Price:                   0,
1480
-						TotalPrice:              0,
1481
-						Status:                  1,
1482
-						Ctime:                   advice.AdviceDate,
1483
-						Mtime:                   advice.AdviceDate,
1484
-						Remark:                  "",
1485
-						OrgId:                   advice.UserOrgId,
1486
-						Type:                    0,
1487
-						Manufacturer:            selfBasedrug.Manufacturer,
1488
-						Dealer:                  selfBasedrug.Dealer,
1489
-						RetailPrice:             0,
1490
-						RetailTotalPrice:        0,
1491
-						CountUnit:               selfBasedrug.MinUnit,
1492
-						ExpiryDate:              0,
1493
-						ProductDate:             0,
1494
-						Number:                  "",
1495
-						BatchNumber:             "",
1496
-						IsSys:                   0,
1497
-						WarehouseInfoId:         0,
1498
-						AdminUserId:             0,
1499
-						StockCount:              "",
1500
-						IsCheck:                 1,
1501
-						SysRecordTime:           advice.AdviceDate,
1502
-						PatientId:               advice.PatientId,
1503
-						AdviceId:                advice.ID,
1504
-						ClassType:               "",
1505
-					}
1506
-					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1507
-
1508
-					for _, it := range warehousingOutInfo {
1509
-
1510
-						medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1511
-						drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1512
-						//出库逻辑
1513
-						service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1514
-
1515
-						//查询剩余库存
1516
-						stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1517
-						var sum_count int64
1518
-						for _, its := range stockInfo {
1519
-							if its.MaxUnit == medical.MaxUnit {
1520
-								its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1521
-							}
1522
-							sum_count += its.StockMaxNumber + its.StockMinNumber
1523
-						}
1524
-						service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1525
-					}
1526
-				}
1527
-
1528
-			}
1529
-
1530
-		}
1531
-
1532 1728
 		c.ServeSuccessJSON(map[string]interface{}{
1533 1729
 			"msg":    "1",
1534 1730
 			"advice": advice,
@@ -2235,8 +2431,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2235 2431
 
2236 2432
 				}
2237 2433
 
2238
-				////针对异常未出库问题的脚本
2239
-				//if adminInfo.Org.Id == 10644 {
2434
+				//针对异常未出库问题的脚本
2435
+				//if adminInfo.Org.Id == 10265 {
2240 2436
 				//
2241 2437
 				//	newadviceInfo := &models.HisDoctorAdviceInfo{
2242 2438
 				//		ID:                    advice.ID,
@@ -2324,11 +2520,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2324 2520
 				//	//按最小单位出库
2325 2521
 				//	//var cha_count = total_count - out_count
2326 2522
 				//
2327
-				//	var cha_count = 100
2328
-				//	fmt.Println("cha_count--------------------------------------", cha_count)
2523
+				//	var cha_count = 40
2524
+				//
2329 2525
 				//	newadviceInfo.PrescribingNumber = float64(cha_count)
2330 2526
 				//	newadviceInfo.PrescribingNumberUnit = medical.MinUnit
2331 2527
 				//	service.NewHisDrugsDelivery(advice.UserOrgId, creater, newadviceInfo, tx)
2528
+				//
2529
+				//	//查询剩余库存
2530
+				//	stockInfo, _ := service.GetSelfDrugAllStockInfo(newadviceInfo.PatientId, newadviceInfo.UserOrgId, newadviceInfo.DrugId, tx)
2531
+				//	var sum_count int64
2532
+				//	for _, its := range stockInfo {
2533
+				//		if its.MaxUnit == medical.MaxUnit {
2534
+				//			its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
2535
+				//		}
2536
+				//		sum_count += its.StockMaxNumber + its.StockMinNumber
2537
+				//	}
2538
+				//	service.UpdateSelfDrugStockCount(newadviceInfo.DrugId, newadviceInfo.UserOrgId, newadviceInfo.PatientId, sum_count, tx)
2332 2539
 				//}
2333 2540
 
2334 2541
 			}
@@ -5415,30 +5622,34 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
5415 5622
 
5416 5623
 	lastSchedule, _ := service.FindLastSchedule(adminUserInfo.Org.Id, patientInfo.ID, xttime)
5417 5624
 	projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
5418
-	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
5419
-		for _, item := range projects {
5420
-			cnt, _ := strconv.ParseFloat(item.Count, 64)
5421
-			var advice models.HisDoctorAdviceInfo
5422
-			advice.ID = item.ID
5423
-			advice.Checker = item.Checker
5424
-			advice.CheckTime = item.CheckTime
5425
-			advice.CheckState = item.CheckState
5426
-			advice.ExecutionState = item.ExecutionState
5427
-			advice.ExecutionStaff = item.ExecutionStaff
5428
-			//advice.PrescribingNumber = float64(item.Count)
5429
-			advice.PrescribingNumber = cnt
5430
-			advice.PrescribingNumberUnit = item.Unit
5431
-			advice.AdviceDoctor = item.Doctor
5432
-			if item.Type == 3 {
5433
-				advice.AdviceName = item.GoodInfo.GoodName
5434
-				advice.PrescribingNumberUnit = item.GoodInfo.PackingUnit
5435
-			} else if item.Type == 2 {
5436
-				advice.AdviceName = item.HisProject.ProjectName
5625
+
5626
+	if adminUserInfo.Org.Id != 10489 {
5627
+
5628
+		if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
5629
+			for _, item := range projects {
5630
+				cnt, _ := strconv.ParseFloat(item.Count, 64)
5631
+				var advice models.HisDoctorAdviceInfo
5632
+				advice.ID = item.ID
5633
+				advice.Checker = item.Checker
5634
+				advice.CheckTime = item.CheckTime
5635
+				advice.CheckState = item.CheckState
5636
+				advice.ExecutionState = item.ExecutionState
5637
+				advice.ExecutionStaff = item.ExecutionStaff
5638
+				//advice.PrescribingNumber = float64(item.Count)
5639
+				advice.PrescribingNumber = cnt
5640
+				advice.PrescribingNumberUnit = item.Unit
5641
+				advice.AdviceDoctor = item.Doctor
5642
+				if item.Type == 3 {
5643
+					advice.AdviceName = item.GoodInfo.GoodName
5644
+					advice.PrescribingNumberUnit = item.GoodInfo.PackingUnit
5645
+				} else if item.Type == 2 {
5646
+					advice.AdviceName = item.HisProject.ProjectName
5647
+				}
5648
+				advice.StartTime = item.StartTime
5649
+				hisAdvice = append(hisAdvice, &advice)
5437 5650
 			}
5438
-			advice.StartTime = item.StartTime
5439
-			hisAdvice = append(hisAdvice, &advice)
5440
-		}
5441 5651
 
5652
+		}
5442 5653
 	}
5443 5654
 
5444 5655
 	if len(DoctorAdvice) > 0 {

+ 138 - 0
controllers/new_mobile_api_controllers/new_manage_api_controller.go Parādīt failu

@@ -240,3 +240,141 @@ func (this *NewManageApiController) GetDeviceInformation() {
240 240
 		"devicetype":  devicetype,
241 241
 	})
242 242
 }
243
+
244
+func (this *NewManageApiController) SaveDisinfectionInfoOne() {
245
+
246
+	adminUser := this.GetMobileAdminUserInfo()
247
+	orgid := adminUser.Org.Id
248
+	bedid, _ := this.GetInt64("bed_id")
249
+	start_time := this.GetString("start_time")
250
+	disinfectime, _ := this.GetInt64("disinfec_time")
251
+	endtime := this.GetString("end_time")
252
+	scheduledate, _ := this.GetInt64("schedule_date")
253
+	zoneid, _ := this.GetInt64("zone_id")
254
+	patientid, _ := this.GetInt64("patient_id")
255
+	modeid, _ := this.GetInt64("mode_id")
256
+	scheduletype, _ := this.GetInt64("schedule_type")
257
+
258
+	wayone, _ := this.GetInt64("way")
259
+
260
+	machine_disinfectant, _ := this.GetInt64("machine_disinfectant")
261
+
262
+	disinfectant_way, _ := this.GetInt64("disinfectant_way")
263
+
264
+	disinfectant, _ := this.GetInt64("disinfectant")
265
+
266
+	bed_way, _ := this.GetInt64("bed_way")
267
+
268
+	dialysis_checked, _ := this.GetInt64("dialysis_checked")
269
+
270
+	clean, _ := this.GetInt64("clean")
271
+
272
+	germ_checked, _ := this.GetInt64("germ_checked")
273
+
274
+	timeLayout := "2006-01-02"
275
+	loc, _ := time.LoadLocation("Local")
276
+	var startdateunix int64
277
+	if len(start_time) > 0 {
278
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04", start_time, loc)
279
+		if err != nil {
280
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
281
+			return
282
+		}
283
+		startdateunix = theTime.Unix()
284
+	}
285
+	var enddateunix int64
286
+	if len(endtime) > 0 {
287
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04", endtime, loc)
288
+		if err != nil {
289
+			utils.ErrorLog(err.Error())
290
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
291
+			return
292
+		}
293
+		enddateunix = theTime.Unix()
294
+	}
295
+
296
+	//查询病人信息
297
+	patients, _ := service.GetPatientInfoMation(patientid)
298
+	var con = ""
299
+	if patients.IsInfectious == 0 {
300
+		con = ""
301
+	}
302
+	if patients.IsInfectious == 1 {
303
+		con = "无"
304
+	}
305
+	if patients.IsInfectious == 2 {
306
+		con = "有"
307
+	}
308
+	//查询病人上机信息
309
+	order, _ := service.GetPatientOrderInfo(scheduledate, patientid, orgid)
310
+	//查询病人今日透后评估数据
311
+	dislysis, _ := service.GetAssessmentAfterDissDataTwo(patientid, orgid, scheduledate)
312
+
313
+	assessmentBeforThrity, _ := service.GetAssessmentBeforThrity(orgid, patientid, scheduledate)
314
+
315
+	var weight_los float64
316
+
317
+	weight_los = assessmentBeforThrity.WeightBefore - dislysis.WeightAfter
318
+
319
+	fmt.Println("透析减少", dislysis.WeightLoss)
320
+	//			//根据床位号获取设备id
321
+	addmacher, _ := service.GetEquimentIDTwo(bedid, orgid)
322
+
323
+	_, errplan := service.GetDisinfectionTwo(addmacher.UnitType, scheduletype, orgid)
324
+
325
+	if errplan == gorm.ErrRecordNotFound {
326
+		returnData := make(map[string]interface{}, 0)
327
+		returnData["msstatus"] = "2"
328
+		this.ServeSuccessJSON(returnData)
329
+		return
330
+	} else {
331
+		information := models.DeviceInformation{
332
+			Date:                  scheduledate,
333
+			Zone:                  zoneid,
334
+			Class:                 scheduletype,
335
+			BedNumber:             bedid,
336
+			PatientId:             patientid,
337
+			DialysisMode:          modeid,
338
+			LongTime:              strconv.FormatInt(disinfectime, 10),
339
+			Disinfection:          1,
340
+			DialysisConcentration: 1,
341
+			DisinfectionStatus:    1,
342
+			Move:                  1,
343
+			UserOrgId:             orgid,
344
+			DisinfectType:         wayone,
345
+			DisinfectantType:      machine_disinfectant,
346
+			FluidPath:             disinfectant_way, //液路消毒方式
347
+			Disinfectant:          disinfectant,
348
+			Ctime:                 time.Now().Unix(),
349
+			Status:                1,
350
+			SignName:              order.FinishNurse,
351
+			EquimentId:            addmacher.ID,
352
+			DisinfectionResidue:   2,
353
+			Bed:                   addmacher.BedNumber,
354
+			StartTime:             order.StartTime,
355
+			EndTime:               order.EndTime,
356
+			Contagion:             con,
357
+			WeightLoss:            weight_los,
358
+			Hyperfiltratio:        dislysis.ActualUltrafiltration,
359
+			DialysisHour:          strconv.FormatInt(dislysis.ActualTreatmentHour, 10),
360
+			MachineRun:            1,
361
+			DisinfecStartime:      startdateunix,
362
+			DisinfecEndtime:       enddateunix,
363
+			BedWay:                bed_way,
364
+			DialysisChecked:       dialysis_checked,
365
+			Clean:                 clean,
366
+			GermChecked:           germ_checked,
367
+		}
368
+		service.DeleteInformation(patientid, scheduledate, orgid)
369
+		err := service.CreateInformationTwo(&information)
370
+		fmt.Println("报错", err)
371
+		if err != nil {
372
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
373
+			return
374
+		}
375
+		this.ServeSuccessJSON(map[string]interface{}{
376
+			"information": information,
377
+		})
378
+
379
+	}
380
+}

+ 1 - 0
controllers/new_mobile_api_controllers/new_manage_api_router.go Parādīt failu

@@ -8,4 +8,5 @@ func NewManageApiControllersRegisterRouters() {
8 8
 	beego.Router("m/api/getdisinfection", &NewManageApiController{}, "Get:GetDisInfectionTime")
9 9
 	beego.Router("/m/api/savedisinfectioninfo", &NewManageApiController{}, "Get:SaveDisInfectionInfo")
10 10
 	beego.Router("/m/api/getdeviceinformation", &NewManageApiController{}, "Get:GetDeviceInformation")
11
+	beego.Router("/m/api/savedisinfectioninfoone", &NewManageApiController{}, "Get:SaveDisinfectionInfoOne")
11 12
 }

+ 9 - 0
controllers/new_mobile_api_controllers/new_self_drug_api_router.go Parādīt failu

@@ -0,0 +1,9 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+func NewDrugApiControllersRegisterRouters() {
6
+
7
+	beego.Router("/m/api/drug/getselfmedicallist", &NewDrugApiController{}, "Get:GetSelfMedicalList")
8
+	beego.Router("/m/api/getdrugdescbydrugname", &NewDrugApiController{}, "Get:GetDrugDescByDrugName")
9
+}

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

@@ -41,7 +41,7 @@ func (c *OrgInfoApiController) GetOrgInfo() {
41 41
 			districts, _ = service.GetDistrictsByUpid(orgInfo.City)
42 42
 		}
43 43
 	}
44
-	gallery, _ := service.GetUserGallery(orgInfo.Id)
44
+	gallery, _ := service.GetUserGallery(10633)
45 45
 
46 46
 	orgInfo.OrgGallery = gallery
47 47
 	orgtypes, _ := service.GetOrgTypes()

+ 79 - 11
controllers/patient_api_controller.go Parādīt failu

@@ -160,7 +160,7 @@ func PatientApiRegistRouters() {
160 160
 
161 161
 	beego.Router("/api/patient/deletepatientlapsorecord", &DialysisApiController{}, "Get:DeletePatientLapseRecord")
162 162
 
163
-	beego.Router("/api/patient/getpatientlapselist", &DialysisApiController{}, "Get:GetPatientLapaseList")
163
+	beego.Router("/api/patient/getpatientlapeso", &DialysisApiController{}, "Get:GetPatientLapseList")
164 164
 
165 165
 }
166 166
 func (c *PatientApiController) GetExportList() {
@@ -4492,11 +4492,10 @@ func (c *PatientApiController) GetDoctorAdvices() {
4492 4492
 	endTime := c.GetString("end_time", "")
4493 4493
 	keywords := c.GetString("keywords", "")
4494 4494
 	page, _ := c.GetInt64("page")
4495
-	fmt.Println("page", page)
4496 4495
 	limit, _ := c.GetInt64("limit")
4497
-	fmt.Println("limit", limit)
4498 4496
 	adminUserInfo := c.GetAdminUserInfo()
4499 4497
 
4498
+	delivery_way_one := c.GetString("delivery_way_one", "")
4500 4499
 	operatorIDs := make([]int64, 0)
4501 4500
 
4502 4501
 	timeLayout := "2006-01-02"
@@ -4526,8 +4525,8 @@ func (c *PatientApiController) GetDoctorAdvices() {
4526 4525
 	hisconfig, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
4527 4526
 
4528 4527
 	if hisconfig.IsOpen == 1 {
4529
-		advices, total, _ := service.GetDoctorAdviceListThree(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit)
4530
-		advicestwo, _, _ := service.GetDoctorAdviceListFour(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page)
4528
+		advices, total, _ := service.GetDoctorAdviceListThree(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit, delivery_way_one)
4529
+		advicestwo, _, _ := service.GetDoctorAdviceListFour(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page, delivery_way_one)
4531 4530
 
4532 4531
 		if len(advices) > 0 {
4533 4532
 			for _, item := range advices {
@@ -4561,8 +4560,8 @@ func (c *PatientApiController) GetDoctorAdvices() {
4561 4560
 		})
4562 4561
 		return
4563 4562
 	} else {
4564
-		advices, total, _ := service.GetDoctorAdviceListOne(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit)
4565
-		advicestwo, _, _ := service.GetDoctorAdviceListTwo(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page)
4563
+		advices, total, _ := service.GetDoctorAdviceListOne(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, page, limit, delivery_way_one)
4564
+		advicestwo, _, _ := service.GetDoctorAdviceListTwo(adminUserInfo.CurrentOrgId, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords, limit, page, delivery_way_one)
4566 4565
 
4567 4566
 		if len(advices) > 0 {
4568 4567
 			for _, item := range advices {
@@ -7899,13 +7898,82 @@ func (c *DialysisApiController) DeletePatientLapseRecord() {
7899 7898
 
7900 7899
 }
7901 7900
 
7902
-func (c *DialysisApiController) GetPatientLapaseList() {
7901
+func (c *DialysisApiController) GetPatientLapseList() {
7903 7902
 
7904
-	orgId := c.GetAdminUserInfo().CurrentOrgId
7903
+	fmt.Println("除非哈哈哈哈哈")
7904
+
7905
+	list, _ := service.GetAllpatientFivty()
7906
+
7907
+	if len(list) > 0 {
7908
+
7909
+		for _, item := range list {
7905 7910
 
7906
-	list, _ := service.GetPatientAllagicListOne(orgId)
7911
+			patientLaspseRecord := models.XtPatientLaspseRecord{
7912
+				PatientId:      item.ID,
7913
+				RecordDate:     0,
7914
+				LapseDate:      item.CreatedTime,
7915
+				LapseType:      1,
7916
+				LapseClass:     0,
7917
+				LapseReason:    "",
7918
+				AdminUserId:    item.RegistrarsId,
7919
+				Remark:         "",
7920
+				UserOrgId:      item.UserOrgId,
7921
+				Ctime:          time.Now().Unix(),
7922
+				Mtime:          time.Now().Unix(),
7923
+				Status:         1,
7924
+				LapseTypeName:  "",
7925
+				HisType:        0,
7926
+				HisZone:        "",
7927
+				HisBed:         "",
7928
+				PatientAddress: "",
7929
+				StartTime:      0,
7930
+				EndTime:        0,
7931
+				StartTimeOne:   0,
7932
+				EndTimeOne:     0,
7933
+			}
7907 7934
 
7908
-	fmt.Println("lsit", list)
7935
+			service.CreatePatientRecord(patientLaspseRecord)
7936
+		}
7937
+	}
7938
+
7939
+	//list, _ := service.GetPatientLapsorecordListOne()
7940
+	//
7941
+	//if len(list) > 0 {
7942
+	//	for _, item := range list {
7943
+	//		//查询患者的信息
7944
+	//		patients, _ := service.GetPatientByIDTwoOne(item.PatientId)
7945
+	//
7946
+	//		if patients.Lapseto == 2 || patients.Lapseto == 3 {
7947
+	//
7948
+	//			patientLaspseRecord := models.XtPatientLaspseRecord{
7949
+	//				PatientId:      item.PatientId,
7950
+	//				RecordDate:     patients.DeathTime,
7951
+	//				LapseDate:      patients.DeathTime,
7952
+	//				LapseType:      patients.Lapseto,
7953
+	//				LapseClass:     patients.Lapseto,
7954
+	//				LapseReason:    patients.OutReason,
7955
+	//				AdminUserId:    0,
7956
+	//				Remark:         "",
7957
+	//				UserOrgId:      patients.UserOrgId,
7958
+	//				Ctime:          time.Now().Unix(),
7959
+	//				Mtime:          time.Now().Unix(),
7960
+	//				Status:         1,
7961
+	//				LapseTypeName:  "",
7962
+	//				HisType:        0,
7963
+	//				HisZone:        "",
7964
+	//				HisBed:         "",
7965
+	//				PatientAddress: "",
7966
+	//				StartTime:      patients.PatientStartTime,
7967
+	//				EndTime:        patients.PatientEndTime,
7968
+	//				StartTimeOne:   patients.PatientStartTime,
7969
+	//				EndTimeOne:     patients.PatientEndTime,
7970
+	//			}
7971
+	//
7972
+	//			service.CreatePatientRecord(patientLaspseRecord)
7973
+	//		}
7974
+	//	}
7975
+	//}
7976
+	//fmt.Println("lsit", list)
7909 7977
 
7910 7978
 	//for _, item := range list {
7911 7979
 	//

+ 25 - 3
controllers/pharmacy_controller.go Parādīt failu

@@ -44,6 +44,8 @@ func PharmacyApiRegistRouters() {
44 44
 	beego.Router("/api/pharmacy/getdruginventorybydrugid", &PharmacyController{}, "Get:GetDrugInventoryByDrugId")
45 45
 
46 46
 	beego.Router("/api/pharmacy/updatedruginventorywarehouseinfo", &PharmacyController{}, "Get:UpdateDrugInventoryWarehouseInfo")
47
+
48
+	beego.Router("/api/pharmacy/changedrugcode", &PharmacyController{}, "Get:ChangeDrugCode")
47 49
 }
48 50
 
49 51
 // 测试
@@ -464,6 +466,7 @@ func (this *PharmacyController) DispensingMedicine() {
464 466
 	if orgid == 10480 || orgid == 10188 || orgid == 10217 || orgid == 10164 || orgid == 10666 {
465 467
 		//发药逻辑
466 468
 
469
+		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhh尽力")
467 470
 		service.DispensingMedicineOne(orgid, patient_id, stime, etime, creater)
468 471
 
469 472
 		//针对桑植盛康
@@ -757,7 +760,7 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
757 760
 		return
758 761
 	}
759 762
 	listll, err := service.PartitionAndLayoutDrug(deliveryway, stime, etime, orgid, shift, partition, list)
760
-	fmt.Println("list1---------------------------", listll)
763
+
761 764
 	if err != nil {
762 765
 		utils.ErrorLog(err.Error())
763 766
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1166,8 +1169,6 @@ func (this *PharmacyController) UpdateDrugInventoryWarehouseInfo() {
1166 1169
 
1167 1170
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1168 1171
 
1169
-	fmt.Println("ord_total-----------------------------", ord_total)
1170
-	fmt.Println("new_total-----------------------------", new_total)
1171 1172
 	//盘亏
1172 1173
 	if ord_total > new_total {
1173 1174
 
@@ -1355,3 +1356,24 @@ func (this *PharmacyController) UpdateDrugInventoryWarehouseInfo() {
1355 1356
 		"msg": "msg",
1356 1357
 	})
1357 1358
 }
1359
+
1360
+func (this *PharmacyController) ChangeDrugCode() {
1361
+
1362
+	id, _ := this.GetInt64("id")
1363
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1364
+	data_source, _ := this.GetInt64("data_source")
1365
+	drug_code := this.GetString("drug_code")
1366
+
1367
+	fmt.Println("data_source--------------------", data_source)
1368
+	if data_source == 1 {
1369
+		fmt.Println("HHAHAHAH")
1370
+		service.ChangeHisDrugCode(id, drug_code, orgId)
1371
+	}
1372
+	if data_source == 2 {
1373
+		service.ChangeAdivceDrugCode(id, drug_code, orgId)
1374
+	}
1375
+
1376
+	this.ServeSuccessJSON(map[string]interface{}{
1377
+		"msg": "msg",
1378
+	})
1379
+}

+ 272 - 0
controllers/self_drug_api_congtroller.go Parādīt failu

@@ -182,6 +182,13 @@ func SelfDrugRouters() {
182 182
 	beego.Router("/api/drug/deleteselfwarehouseoutlist", &SelfDrugApiController{}, "Get:DeleteSelfWarehouseOutList")
183 183
 
184 184
 	beego.Router("/api/drug/getselfDrugwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetSelfDrugWarehouseOutDetailByPatientId")
185
+
186
+	beego.Router("/api/drug/getdruginventoryrecordlist", &SelfDrugApiController{}, "Get:GetDrugInventoryRecordList")
187
+
188
+	beego.Router("/api/drug/getdruginventoryrecordprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryRecordPrintList")
189
+
190
+	beego.Router("/api/drug/getdruginventorymodeprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryModePrintList")
191
+
185 192
 }
186 193
 
187 194
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -2751,6 +2758,127 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2751 2758
 			})
2752 2759
 		}
2753 2760
 	}
2761
+
2762
+	newTableData, _ := dataBody["newTableData"].([]interface{})
2763
+
2764
+	if len(newTableData) > 0 {
2765
+		for _, item := range newTableData {
2766
+			items := item.(map[string]interface{})
2767
+			drug_name := items["drug_name"].(string)
2768
+			if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
2769
+				utils.ErrorLog("drug_name")
2770
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2771
+				return
2772
+			}
2773
+			fmt.Println("drug_name", drug_name)
2774
+			specification_name := items["specification_name"].(string)
2775
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
2776
+				utils.ErrorLog("specification_name")
2777
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2778
+				return
2779
+			}
2780
+
2781
+			max_unit := items["max_unit"].(string)
2782
+			if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
2783
+				utils.ErrorLog("max_unit")
2784
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2785
+				return
2786
+			}
2787
+
2788
+			min_unit := items["min_unit"].(string)
2789
+			if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
2790
+				utils.ErrorLog("min_unit")
2791
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2792
+				return
2793
+			}
2794
+
2795
+			drug_id := int64(items["drug_id"].(float64))
2796
+
2797
+			stock_max_number := int64(items["stock_max_number"].(float64))
2798
+
2799
+			stock_min_number := int64(items["stock_min_number"].(float64))
2800
+
2801
+			last_stock_max_number := int64(items["last_stock_max_number"].(float64))
2802
+
2803
+			last_stock_min_number := int64(items["last_stock_min_number"].(float64))
2804
+
2805
+			warehousing_order := items["warehousing_order"].(string)
2806
+
2807
+			price := items["price"].(float64)
2808
+
2809
+			manufacturer_name := items["manufacturer_name"].(string)
2810
+
2811
+			batch_number := items["batch_number"].(string)
2812
+
2813
+			id := int64(items["id"].(float64))
2814
+
2815
+			orgId := this.GetAdminUserInfo().CurrentOrgId
2816
+
2817
+			type_id := int64(items["type"].(float64))
2818
+
2819
+			if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
2820
+				utils.ErrorLog("expiry_date")
2821
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2822
+				return
2823
+			}
2824
+			expiry_date := int64(items["expiry_date"].(float64))
2825
+
2826
+			product_date := int64(items["product_date"].(float64))
2827
+
2828
+			storehouse_id := int64(items["storehouse_id"].(float64))
2829
+
2830
+			warehousing_count := int64(items["warehousing_count"].(float64))
2831
+
2832
+			warehouseing_unit := items["warehouseing_unit"].(string)
2833
+
2834
+			creater := this.GetAdminUserInfo().AdminUser.Id
2835
+
2836
+			var recordDateStr = time.Now().Format("2006-01-02")
2837
+			recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
2838
+
2839
+			drugStockInventoryList := models.XtDrugStockInventoryList{
2840
+				DrugId:               drug_id,
2841
+				WarehousingOrder:     warehousing_order,
2842
+				WarehousingCount:     warehousing_count,
2843
+				BatchNumber:          batch_number,
2844
+				Price:                price,
2845
+				StockMaxNumber:       stock_max_number,
2846
+				StockMinNumber:       stock_min_number,
2847
+				Reason:               type_id,
2848
+				Creater:              creater,
2849
+				RecordDate:           recordDate.Unix(),
2850
+				UserOrgId:            orgId,
2851
+				Ctime:                time.Now().Unix(),
2852
+				Mtime:                time.Now().Unix(),
2853
+				WarehouseInfoId:      id,
2854
+				SpecificationName:    specification_name,
2855
+				ManufacturerName:     manufacturer_name,
2856
+				DrugName:             drug_name,
2857
+				ExpiryDate:           expiry_date,
2858
+				ProductDate:          product_date,
2859
+				StorehouseId:         storehouse_id,
2860
+				MaxUnit:              max_unit,
2861
+				LastStockMaxNumber:   last_stock_max_number,
2862
+				LastStockMinNumber:   last_stock_min_number,
2863
+				WarehousingCountUnit: warehouseing_unit,
2864
+				MinUnit:              min_unit,
2865
+				Status:               1,
2866
+			}
2867
+
2868
+			//查询今日的药品有没有
2869
+			drugInvetory, _ := service.GetDrugStockInventoryList(drug_id, recordDate.Unix(), orgId)
2870
+
2871
+			if drugInvetory.ID == 0 {
2872
+
2873
+				service.CreatedDrugStockInventory(drugStockInventoryList)
2874
+			}
2875
+
2876
+			if drugInvetory.ID > 0 {
2877
+				drugStockInventoryList.ID = drugInvetory.ID
2878
+				service.SaveDrugStockInventory(drugStockInventoryList)
2879
+			}
2880
+		}
2881
+	}
2754 2882
 }
2755 2883
 
2756 2884
 func (this *SelfDrugApiController) GetDamageByDrugId() {
@@ -6114,6 +6242,7 @@ func (c *SelfDrugApiController) GetAllSelfDrugWarehouseOut() {
6114 6242
 	}
6115 6243
 
6116 6244
 	list, total, _ := service.GetAllSelfDrugWarehouseOut(startTime, endTime, orgId, page, limit, patient_id, keyword, check_type)
6245
+	fmt.Println("list==================", list)
6117 6246
 	doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
6118 6247
 	c.ServeSuccessJSON(map[string]interface{}{
6119 6248
 		"list":       list,
@@ -6156,3 +6285,146 @@ func (c *SelfDrugApiController) GetSelfDrugWarehouseOutDetailByPatientId() {
6156 6285
 		"dealerList":       dealerList,
6157 6286
 	})
6158 6287
 }
6288
+
6289
+func (c *SelfDrugApiController) GetDrugInventoryRecordList() {
6290
+
6291
+	timeLayout := "2006-01-02"
6292
+	loc, _ := time.LoadLocation("Local")
6293
+	start_time := c.GetString("start_time")
6294
+	end_time := c.GetString("end_time")
6295
+
6296
+	limit, _ := c.GetInt64("limit")
6297
+	page, _ := c.GetInt64("page")
6298
+	keyword := c.GetString("keyword")
6299
+	storehouse_id, _ := c.GetInt64("storehouse_id")
6300
+
6301
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6302
+	var startTime int64
6303
+	if len(start_time) > 0 {
6304
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6305
+		if err != nil {
6306
+			fmt.Println(err)
6307
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6308
+			return
6309
+		}
6310
+		startTime = theTime.Unix()
6311
+	}
6312
+	var endTime int64
6313
+	if len(end_time) > 0 {
6314
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6315
+		if err != nil {
6316
+			utils.ErrorLog(err.Error())
6317
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6318
+			return
6319
+		}
6320
+		endTime = theTime.Unix()
6321
+	}
6322
+
6323
+	list, total, _ := service.GetDrugInventoryRecordList(limit, page, keyword, storehouse_id, startTime, endTime, orgId)
6324
+
6325
+	houseList, _ := service.GetAllStoreHouseList(orgId)
6326
+
6327
+	appId := c.GetAdminUserInfo().CurrentAppId
6328
+	doclist, _ := service.GetAllDoctorListSix(orgId, appId)
6329
+	c.ServeSuccessJSON(map[string]interface{}{
6330
+		"list":      list,
6331
+		"total":     total,
6332
+		"houseList": houseList,
6333
+		"doclist":   doclist,
6334
+	})
6335
+}
6336
+
6337
+func (c *SelfDrugApiController) GetDrugInventoryRecordPrintList() {
6338
+
6339
+	timeLayout := "2006-01-02"
6340
+	loc, _ := time.LoadLocation("Local")
6341
+	start_time := c.GetString("start_time")
6342
+	end_time := c.GetString("end_time")
6343
+
6344
+	limit, _ := c.GetInt64("limit")
6345
+	page, _ := c.GetInt64("page")
6346
+	keyword := c.GetString("keyword")
6347
+	storehouse_id, _ := c.GetInt64("storehouse_id")
6348
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6349
+
6350
+	ids := c.GetString("ids")
6351
+	idSplit := strings.Split(ids, ",")
6352
+	var startTime int64
6353
+	if len(start_time) > 0 {
6354
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6355
+		if err != nil {
6356
+			fmt.Println(err)
6357
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6358
+			return
6359
+		}
6360
+		startTime = theTime.Unix()
6361
+	}
6362
+	var endTime int64
6363
+	if len(end_time) > 0 {
6364
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6365
+		if err != nil {
6366
+			utils.ErrorLog(err.Error())
6367
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6368
+			return
6369
+		}
6370
+		endTime = theTime.Unix()
6371
+	}
6372
+
6373
+	list, total, _ := service.GetDrugInventoryRecordPrintList(limit, page, keyword, storehouse_id, orgId, startTime, endTime, idSplit)
6374
+	houseList, _ := service.GetAllStoreHouseList(orgId)
6375
+	appId := c.GetAdminUserInfo().CurrentAppId
6376
+	doclist, _ := service.GetAllDoctorListSix(orgId, appId)
6377
+	c.ServeSuccessJSON(map[string]interface{}{
6378
+		"list":      list,
6379
+		"total":     total,
6380
+		"houseList": houseList,
6381
+		"doclist":   doclist,
6382
+	})
6383
+}
6384
+
6385
+func (c *SelfDrugApiController) GetDrugInventoryModePrintList() {
6386
+
6387
+	timeLayout := "2006-01-02"
6388
+	loc, _ := time.LoadLocation("Local")
6389
+	start_time := c.GetString("start_time")
6390
+	end_time := c.GetString("end_time")
6391
+	var startTime int64
6392
+	if len(start_time) > 0 {
6393
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6394
+		if err != nil {
6395
+			fmt.Println(err)
6396
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6397
+			return
6398
+		}
6399
+		startTime = theTime.Unix()
6400
+	}
6401
+	var endTime int64
6402
+	if len(end_time) > 0 {
6403
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6404
+		if err != nil {
6405
+			utils.ErrorLog(err.Error())
6406
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6407
+			return
6408
+		}
6409
+		endTime = theTime.Unix()
6410
+	}
6411
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6412
+
6413
+	list, _ := service.GetInventoryModeList(orgId)
6414
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
6415
+
6416
+	//查询本月入库
6417
+	infoList, _ := service.GetDrugWarehosueInfoList(orgId, startTime, endTime)
6418
+
6419
+	//查询本月出库
6420
+	outList, _ := service.GetDrugWarhouseHouseOutInfo(orgId, startTime, endTime)
6421
+
6422
+	drugList, _ := service.GetAllDrugList(orgId)
6423
+	c.ServeSuccessJSON(map[string]interface{}{
6424
+		"list":             list,
6425
+		"manufacturerList": manufacturerList,
6426
+		"outList":          outList,
6427
+		"infoList":         infoList,
6428
+		"drugList":         drugList,
6429
+	})
6430
+}

+ 315 - 0
controllers/stock_in_api_controller.go Parādīt failu

@@ -167,6 +167,12 @@ func StockManagerApiRegistRouters() {
167 167
 
168 168
 	beego.Router("/api/good/updategoodinfobyuserorgid", &StockManagerApiController{}, "Get:UpdateGoodInfoByUserOrgId")
169 169
 
170
+	beego.Router("/api/good/getgoodstockinventorylist", &StockManagerApiController{}, "Get:GetGoodStockInventoryList")
171
+
172
+	beego.Router("/api/good/getstockinventoryprintlist", &StockManagerApiController{}, "Get:GetStockInventoryPrintList")
173
+
174
+	beego.Router("/api/good/getstockinventoymodeprintlist", &StockManagerApiController{}, "Get:GetStockInventoryModePrintList")
175
+
170 176
 }
171 177
 func (c *StockManagerApiController) HandleRefundStock() {
172 178
 	order_id, _ := c.GetInt64("order_id", 0)
@@ -6854,6 +6860,171 @@ func (this *StockManagerApiController) SaveStockInventoryList() {
6854 6860
 			})
6855 6861
 		}
6856 6862
 	}
6863
+
6864
+	newTableData, _ := dataBody["newTableData"].([]interface{})
6865
+	if len(newTableData) > 0 {
6866
+		for _, item := range newTableData {
6867
+			items := item.(map[string]interface{})
6868
+			good_name := items["good_name"].(string)
6869
+			if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
6870
+				utils.ErrorLog("good_name")
6871
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6872
+				return
6873
+			}
6874
+
6875
+			specification_name := items["specification_name"].(string)
6876
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
6877
+				utils.ErrorLog("specification_name")
6878
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6879
+				return
6880
+			}
6881
+
6882
+			warehousing_unit := items["warehousing_unit"].(string)
6883
+			if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
6884
+				utils.ErrorLog("warehousing_unit")
6885
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6886
+				return
6887
+			}
6888
+
6889
+			warehousing_count := int64(items["warehousing_count"].(float64))
6890
+			if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "float64" {
6891
+				utils.ErrorLog("warehousing_count")
6892
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6893
+				return
6894
+			}
6895
+
6896
+			stock_count := int64(items["stock_count"].(float64))
6897
+			if items["stock_count"] == nil || reflect.TypeOf(items["stock_count"]).String() != "float64" {
6898
+				utils.ErrorLog("stock_count")
6899
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6900
+				return
6901
+			}
6902
+
6903
+			price := items["price"].(float64)
6904
+			if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "float64" {
6905
+				utils.ErrorLog("price")
6906
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6907
+				return
6908
+			}
6909
+
6910
+			manufacturer_name := items["manufacturer_name"].(string)
6911
+			if items["manufacturer_name"] == nil || reflect.TypeOf(items["manufacturer_name"]).String() != "string" {
6912
+				utils.ErrorLog("manufacturer_name")
6913
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6914
+				return
6915
+			}
6916
+
6917
+			good_id := int64(items["good_id"].(float64))
6918
+			if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
6919
+				utils.ErrorLog("good_id")
6920
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6921
+				return
6922
+			}
6923
+
6924
+			warehousing_order := items["warehousing_order"].(string)
6925
+			if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
6926
+				utils.ErrorLog("warehousing_order")
6927
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6928
+				return
6929
+			}
6930
+
6931
+			number := items["number"].(string)
6932
+			if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
6933
+				utils.ErrorLog("number")
6934
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6935
+				return
6936
+			}
6937
+
6938
+			id := int64(items["id"].(float64))
6939
+			if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
6940
+				utils.ErrorLog("id")
6941
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6942
+				return
6943
+			}
6944
+
6945
+			if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
6946
+				utils.ErrorLog("expiry_date")
6947
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6948
+				return
6949
+			}
6950
+			expiry_date := int64(items["expiry_date"].(float64))
6951
+
6952
+			if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
6953
+				utils.ErrorLog("product_date")
6954
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6955
+				return
6956
+			}
6957
+			product_date := int64(items["product_date"].(float64))
6958
+
6959
+			stock_type := int64(items["type"].(float64))
6960
+			if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
6961
+				utils.ErrorLog("type")
6962
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6963
+				return
6964
+			}
6965
+
6966
+			last_stock_count := int64(items["last_stock_count"].(float64))
6967
+			if items["last_stock_count"] == nil || reflect.TypeOf(items["last_stock_count"]).String() != "float64" {
6968
+				utils.ErrorLog("last_stock_count")
6969
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6970
+				return
6971
+			}
6972
+
6973
+			storehouse_id := int64(items["storehouse_id"].(float64))
6974
+			if items["storehouse_id"] == nil || reflect.TypeOf(items["storehouse_id"]).String() != "float64" {
6975
+				utils.ErrorLog("storehouse_id")
6976
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6977
+				return
6978
+			}
6979
+
6980
+			creater := this.GetAdminUserInfo().AdminUser.Id
6981
+
6982
+			recordDateStr := time.Now().Format("2006-01-02")
6983
+			recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
6984
+
6985
+			user_org_id := this.GetAdminUserInfo().CurrentOrgId
6986
+
6987
+			goodStockInventory := models.XtGoodStockInventoryList{
6988
+				GoodId:            good_id,
6989
+				WarehousingOrder:  warehousing_order,
6990
+				InCount:           warehousing_count,
6991
+				BatchNumber:       number,
6992
+				Price:             price,
6993
+				BeforCount:        stock_count,
6994
+				AfterCount:        last_stock_count,
6995
+				Reason:            stock_type,
6996
+				Creater:           creater,
6997
+				RecordDate:        recordDate.Unix(),
6998
+				UserOrgId:         user_org_id,
6999
+				Ctime:             time.Now().Unix(),
7000
+				Mtime:             time.Now().Unix(),
7001
+				WarehouseInfoId:   id,
7002
+				SpecificationName: specification_name,
7003
+				ManufacturerName:  manufacturer_name,
7004
+				GoodName:          good_name,
7005
+				ExpiryDate:        expiry_date,
7006
+				ProductDate:       product_date,
7007
+				StorehouseId:      storehouse_id,
7008
+				MaxUnit:           warehousing_unit,
7009
+			}
7010
+
7011
+			//查询今日该耗材是否有记录
7012
+
7013
+			goodStock, _ := service.GetGoodStockInventoryByRecordate(good_id, recordDate.Unix(), user_org_id)
7014
+
7015
+			if goodStock.ID == 0 {
7016
+
7017
+				service.CreateGoodStockInventoryList(goodStockInventory)
7018
+			}
7019
+
7020
+			if goodStock.ID > 0 {
7021
+				goodStockInventory.ID = goodStock.ID
7022
+
7023
+				service.SaveGoodStockInventoryList(goodStockInventory)
7024
+			}
7025
+
7026
+		}
7027
+	}
6857 7028
 }
6858 7029
 
6859 7030
 func (this *StockManagerApiController) GetDamageDetailByGoodId() {
@@ -8112,3 +8283,147 @@ func (this *StockManagerApiController) UpdateGoodInfoByUserOrgId() {
8112 8283
 	//}
8113 8284
 
8114 8285
 }
8286
+
8287
+func (this *StockManagerApiController) GetGoodStockInventoryList() {
8288
+
8289
+	keyword := this.GetString("keyword")
8290
+
8291
+	limit, _ := this.GetInt64("limit")
8292
+
8293
+	page, _ := this.GetInt64("page")
8294
+
8295
+	storehouse_id, _ := this.GetInt64("storehouse_id")
8296
+
8297
+	start_time := this.GetString("start_time")
8298
+
8299
+	end_time := this.GetString("end_time")
8300
+
8301
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8302
+	appId := this.GetAdminUserInfo().CurrentAppId
8303
+
8304
+	timeLayout := "2006-01-02"
8305
+	loc, _ := time.LoadLocation("Local")
8306
+
8307
+	var startTime int64
8308
+	if len(start_time) > 0 {
8309
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8310
+		if err != nil {
8311
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8312
+			return
8313
+		}
8314
+		startTime = theTime.Unix()
8315
+
8316
+	}
8317
+	var endTime int64
8318
+	if len(end_time) > 0 {
8319
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
8320
+		if err != nil {
8321
+			utils.ErrorLog(err.Error())
8322
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8323
+			return
8324
+		}
8325
+		endTime = theTime.Unix()
8326
+	}
8327
+
8328
+	list, total, _ := service.GetGoodStockInventoryList(keyword, limit, page, storehouse_id, startTime, endTime, orgId)
8329
+	doclist, _ := service.GetAllDoctorListSix(orgId, appId)
8330
+
8331
+	storeHouseList, _ := service.GetAllStoreHouseList(orgId)
8332
+
8333
+	this.ServeSuccessJSON(map[string]interface{}{
8334
+		"list":           list,
8335
+		"total":          total,
8336
+		"storeHouseList": storeHouseList,
8337
+		"doclist":        doclist,
8338
+	})
8339
+}
8340
+
8341
+func (this *StockManagerApiController) GetStockInventoryPrintList() {
8342
+
8343
+	storehouse_id, _ := this.GetInt64("storehouse_id")
8344
+
8345
+	keyword := this.GetString("keyword")
8346
+
8347
+	limit, _ := this.GetInt64("limit")
8348
+
8349
+	page, _ := this.GetInt64("page")
8350
+
8351
+	ids := this.GetString("ids")
8352
+
8353
+	p_ids_arr := strings.Split(ids, ",")
8354
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8355
+	appId := this.GetAdminUserInfo().CurrentAppId
8356
+	list, total, _ := service.GetStockInventoryPrintList(storehouse_id, keyword, limit, page, p_ids_arr, orgId)
8357
+
8358
+	doclist, _ := service.GetAllDoctorListSix(orgId, appId)
8359
+
8360
+	storeHouseList, _ := service.GetAllStoreHouseList(orgId)
8361
+	this.ServeSuccessJSON(map[string]interface{}{
8362
+		"list":           list,
8363
+		"total":          total,
8364
+		"storeHouseList": storeHouseList,
8365
+		"doclist":        doclist,
8366
+	})
8367
+}
8368
+
8369
+func (this *StockManagerApiController) GetStockInventoryModePrintList() {
8370
+
8371
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8372
+
8373
+	start_time := this.GetString("start_time")
8374
+
8375
+	end_time := this.GetString("end_time")
8376
+
8377
+	timeLayout := "2006-01-02"
8378
+	loc, _ := time.LoadLocation("Local")
8379
+
8380
+	var startTime int64
8381
+	if len(start_time) > 0 {
8382
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8383
+		if err != nil {
8384
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8385
+			return
8386
+		}
8387
+		startTime = theTime.Unix()
8388
+
8389
+	}
8390
+	var endTime int64
8391
+	if len(end_time) > 0 {
8392
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
8393
+		if err != nil {
8394
+			utils.ErrorLog(err.Error())
8395
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8396
+			return
8397
+		}
8398
+		endTime = theTime.Unix()
8399
+	}
8400
+
8401
+	goodInfo, _ := service.FindAllGoodInfoThree(orgId)
8402
+
8403
+	//获取所有入库数量
8404
+
8405
+	list, _ := service.GetInventoryExportList(orgId)
8406
+
8407
+	infoList, _ := service.GetGoodWarehouseInfoList(startTime, endTime, orgId)
8408
+
8409
+	outinfo, _ := service.GetGoodWarhouseOutList(startTime, endTime, orgId)
8410
+
8411
+	//获取盘盈的数据
8412
+	flowProList, _ := service.GetGoodStockFlowProList(startTime, endTime, orgId)
8413
+
8414
+	//获取盘亏的数据
8415
+	flowNoProList, _ := service.GetGoodStockFlowNoProList(startTime, endTime, orgId)
8416
+
8417
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
8418
+
8419
+	this.ServeSuccessJSON(map[string]interface{}{
8420
+		"list":             list,
8421
+		"infoList":         infoList,
8422
+		"outinfo":          outinfo,
8423
+		"flowProList":      flowProList,
8424
+		"flowNoProList":    flowNoProList,
8425
+		"manufacturerList": manufacturerList,
8426
+		"goodInfo":         goodInfo,
8427
+	})
8428
+
8429
+}

+ 1 - 0
models/device_models.go Parādīt failu

@@ -694,6 +694,7 @@ type DeviceInformation struct {
694 694
 	EquimentId            int64   `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
695 695
 	Bed                   string  `gorm:"column:bed" json:"bed" form:"bed"`
696 696
 	Stime                 int64   `gorm:"column:stime" json:"stime" form:"stime"`
697
+	BedWay                int64   `gorm:"column:bed_way" json:"bed_way" form:"bed_way"`
697 698
 }
698 699
 
699 700
 func (DeviceInformation) TableName() string {

+ 2 - 0
models/dialysis.go Parādīt failu

@@ -464,6 +464,7 @@ type DoctorAdvice struct {
464 464
 	PushStartTime         int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
465 465
 	IsSettle              int64           `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
466 466
 	IsPrescription        int64           `gorm:"column:is_prescription" json:"is_prescription" form:"is_prescription"`
467
+	DrugCode              string          `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
467 468
 }
468 469
 
469 470
 func (DoctorAdvice) TableName() string {
@@ -1327,6 +1328,7 @@ type HisDoctorAdvice struct {
1327 1328
 	IsMobile              int64              `gorm:"column:is_mobile" json:"is_mobile" form:"is_mobile"`
1328 1329
 	IsSelfDrug            int64              `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
1329 1330
 	IsMedicine            int64              `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1331
+	Drug                  Drug               `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
1330 1332
 }
1331 1333
 
1332 1334
 func (HisDoctorAdvice) TableName() string {

+ 67 - 0
models/drug_stock.go Parādīt failu

@@ -743,3 +743,70 @@ type XtDrugError struct {
743 743
 func (XtDrugError) TableName() string {
744 744
 	return "xt_drug_error"
745 745
 }
746
+
747
+type XtDrugFlowList struct {
748
+	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
749
+	WarehousingId             int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
750
+	DrugId                    int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
751
+	Number                    string  `gorm:"column:number" json:"number" form:"number"`
752
+	BatchNumber               string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
753
+	Count                     int64   `gorm:"column:count" json:"count" form:"count"`
754
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
755
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
756
+	SystemTime                int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
757
+	ConsumableType            int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
758
+	IsSys                     int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
759
+	WarehousingOrder          string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
760
+	WarehouseOutId            int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
761
+	WarehouseOutOrderNumber   string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
762
+	IsEdit                    int64   `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
763
+	CancelStockId             int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
764
+	CancelOrderNumber         string  `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
765
+	Manufacturer              int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
766
+	Dealer                    int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
767
+	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
768
+	UpdateCreator             int64   `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
769
+	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
770
+	Ctime                     int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
771
+	Mtime                     int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
772
+	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
773
+	WarehousingDetailId       int64   `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
774
+	WarehouseOutDetailId      int64   `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
775
+	CancelOutDetailId         int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
776
+	ExpireDate                int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
777
+	ProductDate               int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
778
+	MaxUnit                   string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
779
+	MinUnit                   string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
780
+	StockMaxNumber            int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
781
+	StockMinNumber            int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
782
+	LastStockMaxNumber        int64   `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
783
+	LastStockMinNumber        int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
784
+	AdviceId                  int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
785
+	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
786
+	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
787
+	SupplyCancelOutId         int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
788
+	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
789
+	SecondWarehouseInfoId     int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
790
+	AdminUserId               int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
791
+	LastPrice                 float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
792
+	StockCount                string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
793
+	PharmacyId                int64   `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
794
+	IsRead                    int64   `gorm:"column:is_read" json:"is_read" form:"is_read"`
795
+	OverCount                 int64   `gorm:"column:over_count" json:"over_count" form:"over_count"`
796
+	IsCheck                   int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
797
+	RetailPrice               float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
798
+	OrderId                   int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
799
+	FlushOverCount            int64   `gorm:"column:flush_over_count" json:"flush_over_count" form:"flush_over_count"`
800
+	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
801
+	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
802
+	IsSale                    int64   `gorm:"column:is_sale" json:"is_sale" form:"is_sale"`
803
+	IsChange                  int64   `gorm:"column:is_change" json:"is_change" form:"is_change"`
804
+	SaleDate                  string  `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
805
+	Bchno                     string  `gorm:"column:bchno" json:"bchno" form:"bchno"`
806
+	BgBchno                   string  `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
807
+	DrugCode                  string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
808
+}
809
+
810
+func (XtDrugFlowList) TableName() string {
811
+	return "xt_drug_flow"
812
+}

+ 86 - 0
models/good_models.go Parādīt failu

@@ -236,6 +236,92 @@ func (GoodInfoSevenThirty) TableName() string {
236 236
 	return "xt_good_information"
237 237
 }
238 238
 
239
+type XtGoodInformationFourty struct {
240
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
241
+	GoodCode                    string  `gorm:"column:good_code" json:"good_code" form:"good_code"`
242
+	SpecificationName           string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
243
+	GoodTypeId                  int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
244
+	GoodUnit                    int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
245
+	BuyPrice                    float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
246
+	SellPrice                   float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
247
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
248
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
249
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
250
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
251
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
252
+	ExpiryDateWarnDayCount      int64   `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
253
+	StockWarnCount              int64   `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
254
+	IsReuse                     int64   `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
255
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
256
+	FilmArea                    string  `gorm:"column:film_area" json:"film_area" form:"film_area"`
257
+	IsUse                       int64   `gorm:"column:is_use" json:"is_use" form:"is_use"`
258
+	FilmMaterialQuality         string  `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
259
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
260
+	Modifier                    int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
261
+	Creater                     int64   `gorm:"column:creater" json:"creater" form:"creater"`
262
+	GoodName                    string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
263
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
264
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
265
+	GoodKind                    int64   `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
266
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
267
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
268
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
269
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
270
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
271
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
272
+	GoodStatus                  string  `gorm:"column:good_status" json:"good_status" form:"good_status"`
273
+	DefaultCount                int64   `gorm:"column:default_count" json:"default_count" form:"default_count"`
274
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
275
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
276
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
277
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
278
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
279
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
280
+	IsDoctorUse                 int64   `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
281
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
282
+	GoodNumber                  string  `gorm:"column:good_number" json:"good_number" form:"good_number"`
283
+	CommdityCode                string  `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
284
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
285
+	ProductionType              string  `gorm:"column:production_type" json:"production_type" form:"production_type"`
286
+	SpecialMedical              string  `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
287
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
288
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
289
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
290
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
291
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
292
+	DefaultCountUnit            string  `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
293
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
294
+	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
295
+	ProvincesCode               string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
296
+	IsUser                      int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
297
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
298
+	IsWarehouse                 int64   `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
299
+	BatchRetaiPrice             float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
300
+	SumCount                    int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
301
+	SumInCount                  int64   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
302
+	TotalCount                  int64   `gorm:"column:total_count" json:"total_count" form:"total_count"`
303
+	SumOutCount                 int64   `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
304
+	SumCancelCount              int64   `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
305
+	IsPrint                     int64   `gorm:"column:is_print" json:"is_print" form:"is_print"`
306
+	FirstLetter                 string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
307
+	ZuobiaoId                   string  `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
308
+	Bck01b                      string  `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
309
+	Bby01                       string  `gorm:"column:bby01" json:"bby01" form:"bby01"`
310
+	Bbx01                       string  `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
311
+	TotalCountOne               int64   `gorm:"column:total_count_one" json:"total_count_one" form:"total_count_one"`
312
+	DepartMent                  string  `gorm:"column:depart_ment" json:"depart_ment" form:"depart_ment"`
313
+	DepartMentCode              string  `gorm:"column:depart_ment_code" json:"depart_ment_code" form:"depart_ment_code"`
314
+	TotalCountTwo               int64   `gorm:"column:total_count_two" json:"total_count_two" form:"total_count_two"`
315
+	CodeName                    string  `gorm:"column:code_name" json:"code_name" form:"code_name"`
316
+	OrgName                     string  `gorm:"column:org_name" json:"org_name" form:"org_name"`
317
+	GoodTypeName                string  `gorm:"column:good_type_name" json:"good_type_name" form:"good_type_name"`
318
+	IsShow                      int64   `gorm:"column:is_show" json:"is_show" form:"is_show"`
319
+}
320
+
321
+func (XtGoodInformationFourty) TableName() string {
322
+	return "xt_good_information"
323
+}
324
+
239 325
 type GoodInfoSeven struct {
240 326
 	ID                int64  `gorm:"column:id" json:"id" form:"id"`
241 327
 	GoodName          string `gorm:"column:good_name" json:"good_name" form:"good_name"`

+ 1 - 0
models/his_models.go Parādīt failu

@@ -274,6 +274,7 @@ type HisDoctorAdviceInfo struct {
274 274
 	IsSelfDrug            int64                  `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
275 275
 	DrugWayCount          string                 `gorm:"column:drug_way_count" json:"drug_way_count" form:"drug_way_count"`
276 276
 	YbSyncStatus          int64                  `gorm:"column:yb_sync_status" json:"yb_sync_status" form:"yb_sync_status"`
277
+	DrugCode              string                 `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
277 278
 }
278 279
 
279 280
 func (HisDoctorAdviceInfo) TableName() string {

+ 6 - 0
models/pharmacy_models.go Parādīt failu

@@ -46,6 +46,7 @@ func (TmpPatientOne) TableName() string {
46 46
 
47 47
 // 药品信息
48 48
 type PharmacyContent struct {
49
+	ID             int64
49 50
 	Name           string //名称
50 51
 	SingleDosage   string //单次用量
51 52
 	Usage          string //用法
@@ -60,6 +61,7 @@ type PharmacyContent struct {
60 61
 	ExecutionStaff int64
61 62
 	ExecutionState int64
62 63
 	Price          float64
64
+	DrugCode       string
63 65
 }
64 66
 
65 67
 // 发药明细列表
@@ -145,6 +147,8 @@ type PatientInformation struct {
145 147
 	People       string `json:"people"`        //领药人
146 148
 	Quantity     int64  `json:"quantity"`      //总量拆分——数据部分
147 149
 	Unit         string `json:"unit"`          //总量拆分——单位部分
150
+	DrugCode     string
151
+	ID           int64
148 152
 }
149 153
 type HisDoctorAdviceInfoL struct {
150 154
 	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
@@ -204,6 +208,7 @@ type HisDoctorAdviceInfoL struct {
204 208
 	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
205 209
 	People                int64   `gorm:"column:people" json:"people" form:"people"`
206 210
 	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
211
+	DrugCode              string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
207 212
 }
208 213
 
209 214
 func (HisDoctorAdviceInfoL) TableName() string {
@@ -261,6 +266,7 @@ type XtDoctorAdviceL struct {
261 266
 	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
262 267
 	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
263 268
 	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
269
+	DrugCode              string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
264 270
 }
265 271
 
266 272
 func (XtDoctorAdviceL) TableName() string {

+ 3 - 0
models/self_drug_models.go Parādīt failu

@@ -497,6 +497,7 @@ type BloodDrugWarehouseInfo struct {
497 497
 	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
498 498
 	CountUnit        string  `json:"count_unit"`
499 499
 	IsCheck          string  `gorm:"column:is_check" json:"is_check" form:"is_check"`
500
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
500 501
 }
501 502
 
502 503
 type BloodDrugCancelStockInfo struct {
@@ -600,6 +601,7 @@ type BloodDrugWarehouseOutInfo struct {
600 601
 	WarehousingInfoId       int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
601 602
 	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
602 603
 	InforPrice              float64 `json:"infor_price"`
604
+	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
603 605
 }
604 606
 
605 607
 type XtMonitorConfig struct {
@@ -999,6 +1001,7 @@ type PatientDrugWarehouseInfo struct {
999 1001
 	DoseUnit       string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
1000 1002
 	Manufacturer   int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1001 1003
 	Dealer         int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1004
+	SumCount       int64  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
1002 1005
 }
1003 1006
 
1004 1007
 type NewGoodInformation struct {

+ 77 - 0
models/stock_models.go Parādīt failu

@@ -1768,3 +1768,80 @@ type XtWarehouseInfoEight struct {
1768 1768
 func (XtWarehouseInfoEight) TableName() string {
1769 1769
 	return "xt_warehouse_info"
1770 1770
 }
1771
+
1772
+type XtGoodStockInventoryList struct {
1773
+	ID                int64   `gorm:"column:id" json:"id" form:"id"`
1774
+	GoodId            int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
1775
+	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
1776
+	InCount           int64   `gorm:"column:in_count" json:"in_count" form:"in_count"`
1777
+	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1778
+	Price             float64 `gorm:"column:price" json:"price" form:"price"`
1779
+	BeforCount        int64   `gorm:"column:befor_count" json:"befor_count" form:"befor_count"`
1780
+	AfterCount        int64   `gorm:"column:after_count" json:"after_count" form:"after_count"`
1781
+	Reason            int64   `gorm:"column:reason" json:"reason" form:"reason"`
1782
+	Creater           int64   `gorm:"column:creater" json:"creater" form:"creater"`
1783
+	RecordDate        int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1784
+	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1785
+	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1786
+	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1787
+	WarehouseInfoId   int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1788
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1789
+	ManufacturerName  string  `gorm:"column:manufacturer_name" json:"manufacturer_name" form:"manufacturer_name"`
1790
+	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
1791
+	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1792
+	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
1793
+	StorehouseId      int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1794
+	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1795
+	Status            int64   `gorm:"column:status" json:"status" form:"status"`
1796
+}
1797
+
1798
+func (XtGoodStockInventoryList) TableName() string {
1799
+	return "xt_good_stock_inventory_list"
1800
+}
1801
+
1802
+type XtDrugStockInventoryList struct {
1803
+	ID                   int64   `gorm:"column:id" json:"id" form:"id"`
1804
+	DrugId               int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1805
+	WarehousingOrder     string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
1806
+	BatchNumber          string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1807
+	Price                float64 `gorm:"column:price" json:"price" form:"price"`
1808
+	Reason               int64   `gorm:"column:reason" json:"reason" form:"reason"`
1809
+	Creater              int64   `gorm:"column:creater" json:"creater" form:"creater"`
1810
+	RecordDate           int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1811
+	UserOrgId            int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1812
+	Ctime                int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1813
+	Mtime                int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1814
+	WarehouseInfoId      int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1815
+	SpecificationName    string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1816
+	ManufacturerName     string  `gorm:"column:manufacturer_name" json:"manufacturer_name" form:"manufacturer_name"`
1817
+	DrugName             string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
1818
+	ExpiryDate           int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1819
+	ProductDate          int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
1820
+	StorehouseId         int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1821
+	MaxUnit              string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1822
+	WarehousingCount     int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1823
+	WarehousingCountUnit string  `gorm:"column:warehousing_count_unit" json:"warehousing_count_unit" form:"warehousing_count_unit"`
1824
+	StockMaxNumber       int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
1825
+	StockMinNumber       int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
1826
+	LastStockMaxNumber   int64   `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
1827
+	LastStockMinNumber   int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
1828
+	MinUnit              string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
1829
+	Status               int64   `gorm:"column:status" json:"status" form:"status"`
1830
+}
1831
+
1832
+func (XtDrugStockInventoryList) TableName() string {
1833
+	return "xt_drug_stock_inventory_list"
1834
+}
1835
+
1836
+type XtDrugCodeOpen struct {
1837
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1838
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1839
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1840
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1841
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1842
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1843
+}
1844
+
1845
+func (XtDrugCodeOpen) TableName() string {
1846
+	return "xt_drug_code_open"
1847
+}

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

@@ -1,10 +1,11 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"XT_New/models"
5 4
 	"strings"
6 5
 	"time"
7 6
 
7
+	"XT_New/models"
8
+
8 9
 	"github.com/jinzhu/gorm"
9 10
 )
10 11
 
@@ -533,3 +534,59 @@ func GetDoctorAdviceByPatientId(patient_id int64, user_org_id int64, start_time
533 534
 
534 535
 	return advice, total, err
535 536
 }
537
+
538
+func GetDoctorAdivceMonthList(user_org_id int64, start_time int64, end_time int64) (list []*models.XtDoctorAdvice, err error) {
539
+
540
+	db := XTReadDB().Model(models.XtDoctorAdvice{}).Where("status=1 and (advice_type =2 or advice_type =3)")
541
+
542
+	if user_org_id > 0 {
543
+		db = db.Where("user_org_id = ?", user_org_id)
544
+	}
545
+	if start_time > 0 {
546
+		db = db.Where("advice_date >=?", start_time)
547
+	}
548
+	if end_time > 0 {
549
+		db = db.Where("advice_date<=?", end_time)
550
+	}
551
+
552
+	err = db.Find(&list).Error
553
+
554
+	return list, err
555
+}
556
+
557
+func GetHisDoctorAdivceMonthList(user_org_id int64, start_time int64, end_time int64) (list []*models.HisDoctorAdvice, err error) {
558
+
559
+	db := XTReadDB().Model(models.HisDoctorAdvice{}).Where("status=1")
560
+
561
+	if user_org_id > 0 {
562
+		db = db.Where("user_org_id = ?", user_org_id)
563
+	}
564
+	if start_time > 0 {
565
+		db = db.Where("advice_date >=?", start_time)
566
+	}
567
+	if end_time > 0 {
568
+		db = db.Where("advice_date<=?", end_time)
569
+	}
570
+
571
+	err = db.Preload("Drug", "status=1 and org_id = ?", user_org_id).Find(&list).Error
572
+
573
+	return list, err
574
+}
575
+
576
+func GetHisPrescriptionProjectMonthList(user_org_id int64, start_time int64, end_time int64) (project []*models.HisPrescriptionProject, err error) {
577
+
578
+	db := XTReadDB().Model(&models.HisPrescriptionProject{}).Where("status=1 and type =3")
579
+
580
+	if user_org_id > 0 {
581
+		db = db.Where("user_org_id = ?", user_org_id)
582
+	}
583
+	if start_time > 0 {
584
+		db = db.Where("record_date >=?", start_time)
585
+	}
586
+	if end_time > 0 {
587
+		db = db.Where("record_date<=?", end_time)
588
+	}
589
+	err = db.Preload("GoodInfo", "org_id= ? and status=1", user_org_id).Find(&project).Error
590
+
591
+	return project, err
592
+}

+ 4 - 4
service/gobal_config_service.go Parādīt failu

@@ -349,9 +349,9 @@ func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType
349 349
 	}
350 350
 
351 351
 	if manufacturerId > 0 {
352
-		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.storehouse_id,x.max_unit as count_unit,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.id desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
352
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.batch_number,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.storehouse_id,x.max_unit as count_unit,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.id desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
353 353
 	} else {
354
-		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.storehouse_id,x.max_unit as count_unit,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.id desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
354
+		err = db.Select("x.id,x.warehousing_id,x.drug_id,x.batch_number,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,t.manufacturer,x.remark,x.ctime,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.storehouse_id,x.max_unit as count_unit,t.drug_type,t.drug_name,t.drug_spec,t.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_number,s.creater").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ? and t.status =1", orgid).Joins("left join xt_drug_warehouse as s on s.id = x.warehousing_id and s.org_id = ? and s.status =1", orgid).Order("x.id desc").Count(&total).Offset(offset).Limit(limit).Scan(&drugInfo).Error
355 355
 	}
356 356
 
357 357
 	return drugInfo, total, err
@@ -426,9 +426,9 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
426 426
 
427 427
 	db = db.Joins("left join sgj_xt.xt_drug_warehouse_info as p on p.id =x.warehouse_info_id")
428 428
 	if manufacturerId > 0 {
429
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,x.patient_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater,p.price as infor_price").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
429
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,x.patient_id,x.batch_number,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater,p.price as infor_price").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
430 430
 	} else {
431
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,x.patient_id,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater,p.price as infor_price").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
431
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,x.storehouse_id,x.patient_id,x.batch_number,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater,p.price as infor_price").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
432 432
 	}
433 433
 
434 434
 	return outinfo, total, err

+ 5 - 0
service/manage_service.go Parādīt failu

@@ -931,6 +931,11 @@ func GetAllpatientFourty(orgid int64) (patients []*models.PatientsThirty, err er
931 931
 	return patients, err
932 932
 }
933 933
 
934
+func GetAllpatientFivty() (patients []*models.Patients, err error) {
935
+	err = XTReadDB().Where("status = 1").Find(&patients).Error
936
+	return patients, err
937
+}
938
+
934 939
 func GetInformation(eid int64, startdate int64, orgid int64, classtype int64) (*models.DeviceInformation, error) {
935 940
 	var information models.DeviceInformation
936 941
 	var err error

+ 2 - 2
service/mobile_dialysis_service.go Parādīt failu

@@ -1144,7 +1144,7 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
1144 1144
 	assessment_after_dislysis_last_str, _ := redis.Get(key).Result()
1145 1145
 
1146 1146
 	if len(assessment_after_dislysis_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1147
-		err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
1147
+		err := readDb.Model(&models.AssessmentAfterDislysis{}).Where(" patient_id = ? and user_org_id = ? and status = 1 and assessment_date>=1725120000 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
1148 1148
 		if err != nil {
1149 1149
 			if err == gorm.ErrRecordNotFound {
1150 1150
 				if record.ID <= 0 {
@@ -3101,7 +3101,7 @@ func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goo
3101 3101
 
3102 3102
 	var Id []*DialysisGoodsDetailDate
3103 3103
 
3104
-	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
3104
+	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 and  record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
3105 3105
 	if len(Id) > 0 {
3106 3106
 
3107 3107
 		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? and find_in_set('停用',good_status) = 0", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error

+ 8 - 0
service/new_warehouse_service.go Parādīt failu

@@ -1789,6 +1789,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1789 1789
 					AdviceId:                advice.ID,
1790 1790
 					LastPrice:               warehouse.Price,
1791 1791
 					OperateTime:             time.Now().Unix(),
1792
+					DrugCode:                advice.DrugCode,
1792 1793
 				}
1793 1794
 
1794 1795
 				errThreeTy := CreateDrugFlowOne(drugflow)
@@ -1965,6 +1966,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1965 1966
 				LastPrice:               warehouse.Price,
1966 1967
 				OverCount:               sum_count,
1967 1968
 				OperateTime:             time.Now().Unix(),
1969
+				DrugCode:                advice.DrugCode,
1968 1970
 			}
1969 1971
 			errCodeflow := CreateDrugFlowOne(flow)
1970 1972
 			if errCodeflow != nil {
@@ -2312,6 +2314,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2312 2314
 				LastPrice:               warehouse.Price,
2313 2315
 				SystemTime:              advice.AdviceDate,
2314 2316
 				OperateTime:             time.Now().Unix(),
2317
+				DrugCode:                advice.DrugCode,
2315 2318
 			}
2316 2319
 
2317 2320
 			CreateDrugFlowOne(drugflow)
@@ -2449,6 +2452,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2449 2452
 				LastPrice:               warehouse.Price,
2450 2453
 				OverCount:               sum_count,
2451 2454
 				OperateTime:             time.Now().Unix(),
2455
+				DrugCode:                advice.DrugCode,
2452 2456
 			}
2453 2457
 			errCodeFlows := CreateDrugFlowOne(flow)
2454 2458
 			if errCodeFlows != nil {
@@ -4667,6 +4671,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4667 4671
 
4668 4672
 		}
4669 4673
 
4674
+		fmt.Println("药品追溯码-------------------------------------------------------", advice.DrugCode)
4675
+
4670 4676
 		drugflow := models.DrugFlow{
4671 4677
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
4672 4678
 			WarehouseOutId:          warehouseout.ID,
@@ -4698,6 +4704,7 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4698 4704
 			AdviceId:                advice.ID,
4699 4705
 			LastPrice:               warehouse.Price,
4700 4706
 			OperateTime:             time.Now().Unix(),
4707
+			DrugCode:                advice.DrugCode,
4701 4708
 		}
4702 4709
 
4703 4710
 		CreateNewDrugFlowOne(drugflow, tx)
@@ -4886,6 +4893,7 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4886 4893
 			LastPrice:               warehouse.Price,
4887 4894
 			SystemTime:              advice.AdviceDate,
4888 4895
 			OperateTime:             time.Now().Unix(),
4896
+			DrugCode:                advice.DrugCode,
4889 4897
 		}
4890 4898
 
4891 4899
 		CreateNewDrugFlowOne(drugflow, tx)

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

@@ -1,9 +1,10 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"XT_New/models"
5 4
 	"time"
6 5
 
6
+	"XT_New/models"
7
+
7 8
 	"github.com/jinzhu/gorm"
8 9
 )
9 10
 
@@ -27,6 +28,13 @@ func GetPatientByIDOne(orgID int64, patientID int64) (models.Patients, error) {
27 28
 	return patient, err
28 29
 }
29 30
 
31
+func GetPatientByIDTwoOne(patientID int64) (models.Patients, error) {
32
+	var patient models.Patients
33
+	err = readDb.Model(&models.Patients{}).Where("id = ? and status=1", patientID).First(&patient).Error
34
+
35
+	return patient, err
36
+}
37
+
30 38
 func GetPatientCourseOfDisease(orgID int64, patientID int64, startTime int64, endTime int64) ([]*models.PatientDiseaseCourse, error) {
31 39
 	var records []*models.PatientDiseaseCourse
32 40
 	err := readDb.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and patient_id = ? and record_time >= ? and record_time <= ? and status = 1", orgID, patientID, startTime, endTime).Order("record_time desc").Find(&records).Error

+ 36 - 4
service/patient_service.go Parādīt failu

@@ -1358,11 +1358,15 @@ func GetLongDoctorAdviceList(orgID, patientID, advice_type, stop, start, end int
1358 1358
 	return
1359 1359
 }
1360 1360
 
1361
-func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int64, keywords string, page int64, limit int64) (advices []*models.DoctorAdvices, total int64, err error) {
1361
+func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int64, keywords string, page int64, limit int64, delive_way_one string) (advices []*models.DoctorAdvices, total int64, err error) {
1362 1362
 
1363 1363
 	db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
1364 1364
 	table := UserReadDB().Table("sgj_user_admin_role as r")
1365 1365
 	fmt.Print("table", table)
1366
+
1367
+	if len(delive_way_one) > 0 {
1368
+		db = db.Where("delivery_way=?", delive_way_one)
1369
+	}
1366 1370
 	if orgID > 0 {
1367 1371
 		db = db.Where("x.user_org_id=?", orgID)
1368 1372
 	}
@@ -1403,11 +1407,15 @@ func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int6
1403 1407
 	return
1404 1408
 }
1405 1409
 
1406
-func GetDoctorAdviceListTwo(orgID int64, patientID int64, advice_type int64, stop int64, start int64, end int64, keywords string, limit int64, page int64) (advices []*models.DoctorAdvices, total int64, err error) {
1410
+func GetDoctorAdviceListTwo(orgID int64, patientID int64, advice_type int64, stop int64, start int64, end int64, keywords string, limit int64, page int64, delive_way_one string) (advices []*models.DoctorAdvices, total int64, err error) {
1407 1411
 
1408 1412
 	db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
1409 1413
 	table := UserReadDB().Table("sgj_user_admin_role as r")
1410 1414
 	fmt.Println(table)
1415
+
1416
+	if len(delive_way_one) > 0 {
1417
+		db = db.Where("delivery_way=?", delive_way_one)
1418
+	}
1411 1419
 	if orgID > 0 {
1412 1420
 		db = db.Where("x.user_org_id=?", orgID)
1413 1421
 	}
@@ -1718,6 +1726,11 @@ func FindAllDoctorAdviceByGoroupNo(orgID int64, groupno int64) (advice []models.
1718 1726
 	return
1719 1727
 }
1720 1728
 
1729
+func FindAllDoctorAdviceByGoroupNoOne(orgID int64, groupno int64) (advice []models.DoctorAdvice, err error) {
1730
+	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id=?  AND groupno = ? AND status = 1 and execution_state =2", orgID, groupno).Find(&advice).Error
1731
+	return
1732
+}
1733
+
1721 1734
 func UpdateDoctorAdviceByGoroupNo(id int64, drug_id int64) error {
1722 1735
 
1723 1736
 	err := XTWriteDB().Model(&models.DoctorAdvice{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"drug_id": drug_id, "drug_name_id": drug_id, "way": 1}).Error
@@ -1734,6 +1747,11 @@ func FindDoctorAdviceByIds(orgID int64, ids []string) (advice []models.DoctorAdv
1734 1747
 	return
1735 1748
 }
1736 1749
 
1750
+func FindDoctorAdviceByIdsOne(orgID int64, ids []string) (advice []models.DoctorAdvice, err error) {
1751
+	err = readDb.Model(&models.DoctorAdvice{}).Where("id IN (?) AND user_org_id = ? AND status = 1 and execution_state =2", ids, orgID).Find(&advice).Error
1752
+	return
1753
+}
1754
+
1737 1755
 func FindDoctorAdviceByIdsTwety(orgID int64, ids []string) (advice []models.DoctorAdvice, err error) {
1738 1756
 	err = readDb.Model(&models.DoctorAdvice{}).Where("id IN (?) AND user_org_id = ? AND status = 1 and (drug_id >0 or drug_name_id >0)", ids, orgID).Find(&advice).Error
1739 1757
 	return
@@ -2158,11 +2176,15 @@ func UpdateScheduleItemByPatientId(id int64) error {
2158 2176
 	return err
2159 2177
 }
2160 2178
 
2161
-func GetDoctorAdviceListThree(orgID, patientID, advice_type, stop, start, end int64, keywords string, page int64, limit int64) (advices []*models.HisDoctorAdvice, total int64, err error) {
2179
+func GetDoctorAdviceListThree(orgID, patientID, advice_type, stop, start, end int64, keywords string, page int64, limit int64, delivery_way_one string) (advices []*models.HisDoctorAdvice, total int64, err error) {
2162 2180
 
2163 2181
 	db := readDb.Table("his_doctor_advice_info as x").Where("x.status = 1")
2164 2182
 	table := UserReadDB().Table("sgj_user_admin_role as r")
2165 2183
 	fmt.Print("table", table)
2184
+
2185
+	if len(delivery_way_one) > 0 {
2186
+		db = db.Where("delivery_way = ?", delivery_way_one)
2187
+	}
2166 2188
 	if orgID > 0 {
2167 2189
 		db = db.Where("x.user_org_id=?", orgID)
2168 2190
 	}
@@ -2203,11 +2225,14 @@ func GetDoctorAdviceListThree(orgID, patientID, advice_type, stop, start, end in
2203 2225
 	return
2204 2226
 }
2205 2227
 
2206
-func GetDoctorAdviceListFour(orgID int64, patientID int64, advice_type int64, stop int64, start int64, end int64, keywords string, limit int64, page int64) (advices []*models.HisDoctorAdvice, total int64, err error) {
2228
+func GetDoctorAdviceListFour(orgID int64, patientID int64, advice_type int64, stop int64, start int64, end int64, keywords string, limit int64, page int64, delive_way_one string) (advices []*models.HisDoctorAdvice, total int64, err error) {
2207 2229
 
2208 2230
 	db := readDb.Table("his_doctor_advice_info as x").Where("x.status = 1")
2209 2231
 	table := UserReadDB().Table("sgj_user_admin_role as r")
2210 2232
 	fmt.Println(table)
2233
+	if len(delive_way_one) > 0 {
2234
+		db = db.Where("delivery_way = ?", delive_way_one)
2235
+	}
2211 2236
 	if orgID > 0 {
2212 2237
 		db = db.Where("x.user_org_id=?", orgID)
2213 2238
 	}
@@ -4209,3 +4234,10 @@ func DeletePatientLapseRecord(id int64) error {
4209 4234
 
4210 4235
 	return err
4211 4236
 }
4237
+
4238
+func GetPatientLapsorecordListOne() (lapseto []*models.PatientLapseto, err error) {
4239
+
4240
+	err = XTReadDB().Where("status=1 and (lapseto_type=2 or lapseto_type =3)").Find(&lapseto).Error
4241
+
4242
+	return lapseto, err
4243
+}

+ 31 - 0
service/pharmacy_service.go Parādīt failu

@@ -259,6 +259,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
259 259
 
260 260
 		for _, v := range tmp {
261 261
 			pp = append(pp, &models.PharmacyContent{
262
+				ID:           v.ID,
262 263
 				Name:         v.AdviceName,
263 264
 				SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
264 265
 				Usage:        v.DeliveryWay,
@@ -270,6 +271,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
270 271
 				Remarks:      v.Remark, //备注
271 272
 				DrugId:       v.DrugId,
272 273
 				Price:        v.Price,
274
+				DrugCode:     v.DrugCode,
273 275
 			})
274 276
 		}
275 277
 
@@ -290,6 +292,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
290 292
 
291 293
 		for _, v := range tmp_advice {
292 294
 			pp = append(pp, &models.PharmacyContent{
295
+				ID:           v.ID,
293 296
 				Name:         v.AdviceName,
294 297
 				SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
295 298
 				Usage:        v.DeliveryWay,
@@ -300,6 +303,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
300 303
 				DataSources:  "临时医嘱",
301 304
 				Remarks:      v.Remark,
302 305
 				DrugId:       v.DrugId,
306
+				DrugCode:     v.DrugCode,
303 307
 			})
304 308
 		}
305 309
 		return
@@ -322,6 +326,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
322 326
 
323 327
 		for _, v := range tmp {
324 328
 			pp = append(pp, &models.PharmacyContent{
329
+				ID:             v.ID,
325 330
 				Name:           v.AdviceName,
326 331
 				SingleDosage:   config.ToString(v.SingleDose) + v.SingleDoseUnit,
327 332
 				Usage:          v.DeliveryWay,
@@ -336,6 +341,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
336 341
 				ExecutionStaff: v.ExecutionStaff,
337 342
 				ExecutionTime:  v.ExecutionTime,
338 343
 				Price:          v.Price,
344
+				DrugCode:       v.DrugCode,
339 345
 			})
340 346
 		}
341 347
 
@@ -356,6 +362,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
356 362
 
357 363
 		for _, v := range tmp_advice {
358 364
 			pp = append(pp, &models.PharmacyContent{
365
+				ID:             v.ID,
359 366
 				Name:           v.AdviceName,
360 367
 				SingleDosage:   config.ToString(v.SingleDose) + v.SingleDoseUnit,
361 368
 				Usage:          v.DeliveryWay,
@@ -369,6 +376,7 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
369 376
 				ExecutionState: v.ExecutionState,
370 377
 				ExecutionStaff: v.ExecutionStaff,
371 378
 				ExecutionTime:  v.ExecutionTime,
379
+				DrugCode:       v.DrugCode,
372 380
 				//Price:        v.Price,
373 381
 
374 382
 			})
@@ -688,6 +696,8 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
688 696
 			People:       GetUserAdminName(v.People, orgid), //领药人!!!!!!!!!!!!!!!!!!!!!!
689 697
 			Quantity:     int64(v.PrescribingNumber),
690 698
 			Unit:         v.PrescribingNumberUnit,
699
+			DrugCode:     v.DrugCode,
700
+			ID:           v.ID,
691 701
 		})
692 702
 	}
693 703
 
@@ -710,6 +720,8 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
710 720
 			People:       GetUserAdminName(v.People, orgid), //领药人
711 721
 			Quantity:     int64(v.PrescribingNumber),
712 722
 			Unit:         v.PrescribingNumberUnit,
723
+			DrugCode:     v.DrugCode,
724
+			ID:           v.ID,
713 725
 		})
714 726
 	}
715 727
 	return
@@ -2347,3 +2359,22 @@ func UpdateWarehouseInfoById(last_stock_count int64, id int64) (models.Warehousi
2347 2359
 	err := XTWriteDB().Model(&info).Where("id = ? and status =1", id).Updates(map[string]interface{}{"stock_count": last_stock_count}).Error
2348 2360
 	return info, err
2349 2361
 }
2362
+
2363
+func ChangeHisDrugCode(id int64, drug_code string, user_org_id int64) (models.HisDoctorAdviceInfo, error) {
2364
+
2365
+	adviceInfo := models.HisDoctorAdviceInfo{}
2366
+
2367
+	err := XTWriteDB().Model(&adviceInfo).Where("id = ? and user_org_id = ? and status =1", id, user_org_id).Updates(map[string]interface{}{"drug_code": drug_code}).Error
2368
+
2369
+	fmt.Println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeee", err)
2370
+	return adviceInfo, err
2371
+}
2372
+
2373
+func ChangeAdivceDrugCode(id int64, drug_code string, user_org_id int64) (models.DoctorAdvice, error) {
2374
+
2375
+	adviceInfo := models.DoctorAdvice{}
2376
+
2377
+	err := XTWriteDB().Model(&adviceInfo).Where("id = ? and user_org_id = ? and status =1", id, user_org_id).Updates(map[string]interface{}{"drug_code": drug_code}).Error
2378
+
2379
+	return adviceInfo, err
2380
+}

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

@@ -1250,7 +1250,7 @@ func GetInventoryModeList(orgid int64) (info []*models.PatientDrugWarehouseInfo,
1250 1250
 	if orgid > 0 {
1251 1251
 		db = db.Where("x.org_id = ?", orgid)
1252 1252
 	}
1253
-	err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1253
+	err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1254 1254
 	return info, err
1255 1255
 }
1256 1256
 
@@ -5175,3 +5175,114 @@ func SelfDrugAutoAddCancelInfoOne(advice *models.DoctorAdvice, creater int64) er
5175 5175
 	}
5176 5176
 	return err
5177 5177
 }
5178
+
5179
+func GetDrugInventoryRecordList(limit int64, page int64, keyword string, storehouse_id int64, startTime int64, endTime int64, orgId int64) (list []*models.XtDrugStockInventoryList, total int64, err error) {
5180
+
5181
+	likeKey := "%" + keyword + "%"
5182
+	offset := (page - 1) * limit
5183
+
5184
+	db := XTReadDB().Model(&list).Where("status=1")
5185
+
5186
+	if len(keyword) > 0 {
5187
+		db = db.Where("drug_name like ?", likeKey)
5188
+	}
5189
+
5190
+	if storehouse_id > 0 {
5191
+		db = db.Where("storehouse_id = ?", storehouse_id)
5192
+	}
5193
+
5194
+	if startTime > 0 {
5195
+		db = db.Where("record_date>=?", startTime)
5196
+	}
5197
+
5198
+	if endTime > 0 {
5199
+		db = db.Where("record_date<=?", endTime)
5200
+	}
5201
+
5202
+	if orgId > 0 {
5203
+		db = db.Where("user_org_id =?", orgId)
5204
+	}
5205
+
5206
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
5207
+
5208
+	return list, total, err
5209
+
5210
+}
5211
+
5212
+func GetDrugInventoryRecordPrintList(limit int64, page int64, keyword string, storehouse_id int64, orgId int64, startTime int64, endTime int64, idSplit []string) (list []*models.XtDrugStockInventoryList, total int64, err error) {
5213
+
5214
+	offset := (page - 1) * limit
5215
+	likeKey := "%" + keyword + "%"
5216
+
5217
+	db := XTReadDB().Model(&list).Where("status =1")
5218
+	if len(keyword) > 0 {
5219
+		db = db.Where("drug_name like ?", likeKey)
5220
+	}
5221
+
5222
+	if storehouse_id > 0 {
5223
+		db = db.Where("storehouse_id = ?", storehouse_id)
5224
+	}
5225
+
5226
+	if orgId > 0 {
5227
+		db = db.Where("user_org_id = ?", orgId)
5228
+	}
5229
+
5230
+	if startTime > 0 {
5231
+		db = db.Where("record_date>=?", startTime)
5232
+	}
5233
+	if endTime > 0 {
5234
+		db = db.Where("record_date<=?", endTime)
5235
+	}
5236
+
5237
+	if len(idSplit) > 0 {
5238
+		db = db.Where("id in(?)", idSplit)
5239
+	}
5240
+
5241
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
5242
+
5243
+	return list, total, err
5244
+
5245
+}
5246
+
5247
+func GetDrugWarehosueInfoList(org_id int64, start_time int64, end_time int64) (flow []*models.XtDrugFlowList, err error) {
5248
+
5249
+	db := XTReadDB().Model(&flow).Where("status=1 and (consumable_type=1 or consumable_type =10)")
5250
+
5251
+	if org_id > 0 {
5252
+		db = db.Where("user_org_id = ?", org_id)
5253
+	}
5254
+
5255
+	if start_time > 0 {
5256
+		db = db.Where("ctime >= ?", start_time)
5257
+	}
5258
+
5259
+	if end_time > 0 {
5260
+		db = db.Where("ctime<=?", end_time)
5261
+	}
5262
+
5263
+	err = db.Find(&flow).Error
5264
+
5265
+	return flow, err
5266
+}
5267
+
5268
+func GetDrugWarhouseHouseOutInfo(org_id int64, start_time int64, end_time int64) (flow []*models.XtDrugFlowList, err error) {
5269
+
5270
+	db := XTReadDB().Model(&flow).Where("status=1 and (consumable_type=2 or consumable_type=3 or consumable_type=11)")
5271
+
5272
+	if org_id > 0 {
5273
+		db = db.Where("user_org_id = ?", org_id)
5274
+	}
5275
+
5276
+	if start_time > 0 {
5277
+		db = db.Where("ctime >= ?", start_time)
5278
+	}
5279
+
5280
+	if end_time > 0 {
5281
+		db = db.Where("ctime<=?", end_time)
5282
+	}
5283
+
5284
+	err = db.Find(&flow).Error
5285
+
5286
+	return flow, err
5287
+
5288
+}

+ 205 - 0
service/stock_service.go Parādīt failu

@@ -401,6 +401,11 @@ func FindAllGoodInfoTwo(org_id int64) (goodInfo []*models.GoodInfo, err error) {
401 401
 	return goodInfo, err
402 402
 }
403 403
 
404
+func FindAllGoodInfoThree(org_id int64) (goodInfo []*models.XtGoodInformationFourty, err error) {
405
+	err = XTReadDB().Model(&models.XtGoodInformationFourty{}).Where("org_id = ? AND status = 1 and find_in_set('停用',good_status) = 0", org_id).Find(&goodInfo).Error
406
+	return goodInfo, err
407
+}
408
+
404 409
 func FindAllWarehouseTotal(org_id int64) (total int64, err error) {
405 410
 	err = readDb.Model(&models.Warehousing{}).Where("org_id = ?", org_id).Count(&total).Error
406 411
 	return total, err
@@ -9490,3 +9495,203 @@ func UpdateStockFlowByList(good_id int64, packing_price float64) error {
9490 9495
 
9491 9496
 	return err
9492 9497
 }
9498
+
9499
+func GetGoodStockInventoryByRecordate(good_id int64, record_date int64, user_org_id int64) (models.XtGoodStockInventoryList, error) {
9500
+
9501
+	goodStockInventoryList := models.XtGoodStockInventoryList{}
9502
+	err := XTReadDB().Where("good_id = ? and record_date = ? and user_org_id = ? and status=1", good_id, record_date, user_org_id).Find(&goodStockInventoryList).Error
9503
+	return goodStockInventoryList, err
9504
+}
9505
+
9506
+func CreateGoodStockInventoryList(list models.XtGoodStockInventoryList) error {
9507
+
9508
+	err := XTWriteDB().Create(&list).Error
9509
+
9510
+	return err
9511
+}
9512
+
9513
+func SaveGoodStockInventoryList(list models.XtGoodStockInventoryList) error {
9514
+
9515
+	err := XTWriteDB().Save(&list).Error
9516
+
9517
+	return err
9518
+}
9519
+
9520
+func GetGoodStockInventoryList(keyword string, limit int64, page int64, storehouse_id int64, startTime int64, endTime int64, orgId int64) (list []*models.XtGoodStockInventoryList, total int64, err error) {
9521
+
9522
+	likeKey := "%" + keyword + "%"
9523
+	offset := (page - 1) * limit
9524
+
9525
+	db := XTReadDB().Model(&models.XtGoodStockInventoryList{}).Where("status=1")
9526
+
9527
+	if storehouse_id > 0 {
9528
+
9529
+		db = db.Where("storehouse_id = ?", storehouse_id)
9530
+	}
9531
+
9532
+	if startTime > 0 {
9533
+		db = db.Where("record_date >=?", startTime)
9534
+	}
9535
+
9536
+	if endTime > 0 {
9537
+		db = db.Where("record_date<=?", endTime)
9538
+	}
9539
+
9540
+	if len(keyword) > 0 {
9541
+		db = db.Where("good_name like ? or specification_name like ?", likeKey, likeKey)
9542
+	}
9543
+	if orgId > 0 {
9544
+		db = db.Where("user_org_id = ?", orgId)
9545
+	}
9546
+
9547
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
9548
+
9549
+	return list, total, err
9550
+}
9551
+
9552
+func GetDrugStockInventoryList(drug_id int64, record_date int64, user_org_id int64) (models.XtDrugStockInventoryList, error) {
9553
+
9554
+	drugStockInventoryList := models.XtDrugStockInventoryList{}
9555
+
9556
+	err := XTReadDB().Where("drug_id = ? and record_date = ? and user_org_id = ? and status=1", drug_id, record_date, user_org_id).Find(&drugStockInventoryList).Error
9557
+
9558
+	return drugStockInventoryList, err
9559
+}
9560
+
9561
+func CreatedDrugStockInventory(list models.XtDrugStockInventoryList) error {
9562
+
9563
+	err := XTWriteDB().Create(&list).Error
9564
+
9565
+	return err
9566
+}
9567
+
9568
+func SaveDrugStockInventory(list models.XtDrugStockInventoryList) error {
9569
+
9570
+	err := XTWriteDB().Save(&list).Error
9571
+
9572
+	return err
9573
+}
9574
+
9575
+func GetStockInventoryPrintList(storehouse_id int64, keyword string, limit int64, page int64, ids []string, orgId int64) (list []*models.XtGoodStockInventoryList, total int64, err error) {
9576
+
9577
+	db := XTReadDB().Model(&list).Where("status=1")
9578
+	likeKey := "%" + keyword + "%"
9579
+	offset := (page - 1) * limit
9580
+	if storehouse_id > 0 {
9581
+		db = db.Where("storehouse_id = ?", storehouse_id)
9582
+	}
9583
+	if len(keyword) > 0 {
9584
+		db = db.Where("good_name like ?", likeKey)
9585
+	}
9586
+	if orgId > 0 {
9587
+		db = db.Where("user_org_id = ?", orgId)
9588
+	}
9589
+
9590
+	if len(ids) > 0 {
9591
+		db = db.Where("id in(?)", ids)
9592
+	}
9593
+
9594
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
9595
+
9596
+	return list, total, err
9597
+}
9598
+
9599
+func GetGoodWarehouseInfoList(startTime int64, endTime int64, orgId int64) (info []*models.WarehousingInfo, err error) {
9600
+
9601
+	db := XTReadDB().Model(&info).Where("status=1 and is_check=1")
9602
+
9603
+	if startTime > 0 {
9604
+		db = db.Where("ctime>=?", startTime)
9605
+	}
9606
+
9607
+	if endTime > 0 {
9608
+		db = db.Where("ctime<=?", endTime)
9609
+	}
9610
+
9611
+	if orgId > 0 {
9612
+		db = db.Where("org_id = ?", orgId)
9613
+	}
9614
+
9615
+	err = db.Find(&info).Error
9616
+
9617
+	return info, err
9618
+}
9619
+
9620
+func GetGoodWarhouseOutList(startTime int64, endTime int64, orgId int64) (outinfo []*models.WarehouseOutInfo, err error) {
9621
+
9622
+	db := XTReadDB().Model(&outinfo).Where("status=1 and is_check =1")
9623
+
9624
+	if startTime > 0 {
9625
+		db = db.Where("ctime>=?", startTime)
9626
+	}
9627
+	if endTime > 0 {
9628
+		db = db.Where("ctime<=?", endTime)
9629
+	}
9630
+
9631
+	if orgId > 0 {
9632
+		db = db.Where("org_id = ?", orgId)
9633
+	}
9634
+
9635
+	err = db.Find(&outinfo).Error
9636
+
9637
+	return outinfo, err
9638
+}
9639
+
9640
+func GetGoodStockFlowProList(startTime int64, endTime int64, orgId int64) (flow []*models.VmStockFlow, err error) {
9641
+
9642
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 10")
9643
+
9644
+	if startTime > 0 {
9645
+		db = db.Where("ctime>=?", startTime)
9646
+	}
9647
+	if endTime > 0 {
9648
+		db = db.Where("ctime<=?", endTime)
9649
+	}
9650
+	if orgId > 0 {
9651
+		db = db.Where("user_org_id = ?", orgId)
9652
+	}
9653
+	err = db.Find(&flow).Error
9654
+
9655
+	return flow, err
9656
+}
9657
+
9658
+func GetGoodStockFlowNoProList(startTime int64, endTime int64, orgId int64) (flow []*models.VmStockFlow, err error) {
9659
+
9660
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 11")
9661
+
9662
+	if startTime > 0 {
9663
+		db = db.Where("ctime>=?", startTime)
9664
+	}
9665
+	if endTime > 0 {
9666
+		db = db.Where("ctime<=?", endTime)
9667
+	}
9668
+	if orgId > 0 {
9669
+		db = db.Where("user_org_id = ?", orgId)
9670
+	}
9671
+	err = db.Find(&flow).Error
9672
+
9673
+	return flow, err
9674
+}
9675
+
9676
+func GetDrugCodeOpen(user_org_id int64) (models.XtDrugCodeOpen, error) {
9677
+
9678
+	drugCodeOpen := models.XtDrugCodeOpen{}
9679
+
9680
+	err := XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&drugCodeOpen).Error
9681
+
9682
+	return drugCodeOpen, err
9683
+}
9684
+
9685
+func CreateDrugOpen(open models.XtDrugCodeOpen) error {
9686
+
9687
+	err := XTWriteDB().Create(&open).Error
9688
+
9689
+	return err
9690
+}
9691
+
9692
+func SaveDrugOpen(open models.XtDrugCodeOpen) error {
9693
+
9694
+	err := XTWriteDB().Save(&open).Error
9695
+
9696
+	return err
9697
+}

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

@@ -365,6 +365,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
365 365
 			OverCount:               sum_count,
366 366
 			AdviceId:                advice.ID,
367 367
 			OperateTime:             time.Now().Unix(),
368
+			DrugCode:                advice.DrugCode,
368 369
 		}
369 370
 
370 371
 		CreateDrugFlowOne(drugflow)
@@ -543,6 +544,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
543 544
 			OverCount:               sum_count,
544 545
 			AdviceId:                advice.ID,
545 546
 			OperateTime:             time.Now().Unix(),
547
+			DrugCode:                advice.DrugCode,
546 548
 		}
547 549
 
548 550
 		CreateDrugFlowOne(drugflow)
@@ -9327,6 +9329,7 @@ func HisFaDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvi
9327 9329
 				}
9328 9330
 			}
9329 9331
 
9332
+			fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhwode", advice.DrugCode)
9330 9333
 			newadviceInfo := &models.HisDoctorAdviceInfo{
9331 9334
 				ID:                    advice.ID,
9332 9335
 				UserOrgId:             advice.UserOrgId,
@@ -9392,6 +9395,7 @@ func HisFaDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvi
9392 9395
 				IsMobile:              advice.IsMobile,
9393 9396
 				IsSelfDrug:            advice.IsSelfDrug,
9394 9397
 				DrugWayCount:          advice.DrugWayCount,
9398
+				DrugCode:              advice.DrugCode,
9395 9399
 			}
9396 9400
 
9397 9401
 			db := XTWriteDB()