Procházet zdrojové kódy

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

XMLWAN před 3 roky
rodič
revize
7db440afa1
43 změnil soubory, kde provedl 4956 přidání a 654 odebrání
  1. 2 2
      conf/app.conf
  2. 52 50
      controllers/base_api_controller.go
  3. 28 1
      controllers/dialysis_api_controller.go
  4. 1 1
      controllers/doctors_api_controller.go
  5. 67 3
      controllers/gobal_config_api_controller.go
  6. 1115 214
      controllers/his_api_controller.go
  7. 403 0
      controllers/his_config_api_controller.go
  8. 317 0
      controllers/his_hospital_api_controller.go
  9. 223 84
      controllers/his_project_api_controller.go
  10. 8 2
      controllers/manager_center_api_controller.go
  11. 10 1
      controllers/mobile_api_controllers/dialysis_api_controller.go
  12. 5 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  13. 109 2
      controllers/mobile_api_controllers/patient_api_controller.go
  14. 292 40
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  15. 197 0
      controllers/patient_api_controller.go
  16. 32 0
      controllers/public_api_controller.go
  17. 17 0
      controllers/role_controller.go
  18. 1 1
      controllers/stock_in_api_controller.go
  19. 8 0
      enums/error_code.go
  20. 5 0
      models/dialysis.go
  21. 28 0
      models/drug.go
  22. 80 0
      models/his_hospital_models.go
  23. 340 37
      models/his_models.go
  24. 1 1
      models/inspection_models.go
  25. 3 0
      models/self_drug_models.go
  26. 16 13
      models/service/stock_service.go
  27. 1 0
      models/stock_models.go
  28. 4 1
      routers/router.go
  29. 15 0
      service/app_version.go
  30. 16 1
      service/dialysis_service.go
  31. 18 11
      service/drug_stock_service.go
  32. 18 2
      service/gobal_config_service.go
  33. 48 0
      service/his_config_service.go
  34. 174 0
      service/his_hospital_service.go
  35. 28 14
      service/his_project_service.go
  36. 661 156
      service/his_service.go
  37. 14 0
      service/mobile_dialysis_service.go
  38. 16 15
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  39. 3 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  40. 2 0
      service/self_drug_service.go
  41. 23 2
      service/stock_service.go
  42. 8 0
      service/user_service.go
  43. 547 0
      service/warhouse_service.go

+ 2 - 2
conf/app.conf Zobrazit soubor

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

+ 52 - 50
controllers/base_api_controller.go Zobrazit soubor

@@ -2,6 +2,8 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
6
+
5 7
 	//"XT_New/models"
6 8
 
7 9
 	//"XT_New/models"
@@ -67,33 +69,33 @@ type BaseAuthAPIController struct {
67 69
 func (this *BaseAuthAPIController) Prepare() {
68 70
 	this.BaseAPIController.Prepare()
69 71
 	if this.GetAdminUserInfo() == nil {
70
-		//var userAdmin models.AdminUser
71
-		//userAdmin.Id = 1448
72
-		//userAdmin.Mobile = "13318599895"
72
+		var userAdmin models.AdminUser
73
+		userAdmin.Id = 1448
74
+		userAdmin.Mobile = "13318599895"
73 75
 
74 76
 		//userAdmin.Id = 597
75 77
 		//userAdmin.Mobile = "19874122664"
76
-		//userAdmin.IsSuperAdmin = false
77
-		//userAdmin.Status = 1
78
-		//userAdmin.CreateTime = 1530786071
79
-		//userAdmin.ModifyTime = 1530786071
80
-		//var subscibe models.ServeSubscibe
81
-		//subscibe.ID = 1
82
-		//subscibe.OrgId = 4
83
-		//subscibe.PeriodStart = 1538035409
84
-		//subscibe.PeriodEnd = 1569571409
85
-		//subscibe.State = 1
86
-		//subscibe.Status = 1
87
-		//subscibe.CreatedTime = 1538035409
88
-		//subscibe.UpdatedTime = 1538035409
89
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
90
-		//subscibes[4] = &subscibe
91
-		//var adminUserInfo service.AdminUserInfo
92
-		//adminUserInfo.CurrentOrgId = 4
93
-		//adminUserInfo.CurrentAppId = 4
94
-		//adminUserInfo.AdminUser = &userAdmin
95
-		//adminUserInfo.Subscibes = subscibes
96
-		//this.SetSession("admin_user_info", &adminUserInfo)
78
+		userAdmin.IsSuperAdmin = false
79
+		userAdmin.Status = 1
80
+		userAdmin.CreateTime = 1530786071
81
+		userAdmin.ModifyTime = 1530786071
82
+		var subscibe models.ServeSubscibe
83
+		subscibe.ID = 1
84
+		subscibe.OrgId = 4
85
+		subscibe.PeriodStart = 1538035409
86
+		subscibe.PeriodEnd = 1569571409
87
+		subscibe.State = 1
88
+		subscibe.Status = 1
89
+		subscibe.CreatedTime = 1538035409
90
+		subscibe.UpdatedTime = 1538035409
91
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
+		subscibes[4] = &subscibe
93
+		var adminUserInfo service.AdminUserInfo
94
+		adminUserInfo.CurrentOrgId = 4
95
+		adminUserInfo.CurrentAppId = 4
96
+		adminUserInfo.AdminUser = &userAdmin
97
+		adminUserInfo.Subscibes = subscibes
98
+		this.SetSession("admin_user_info", &adminUserInfo)
97 99
 
98 100
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
99 101
 		this.StopRun()
@@ -313,35 +315,35 @@ type BaseServeAPIController struct {
313 315
 func (this *BaseServeAPIController) Prepare() {
314 316
 	this.BaseAPIController.Prepare()
315 317
 	if this.GetAdminUserInfo() == nil {
316
-		//var userAdmin models.AdminUser
317
-		//userAdmin.Id = 1448
318
-		//userAdmin.Mobile = "13318599895"
318
+		var userAdmin models.AdminUser
319
+		userAdmin.Id = 1448
320
+		userAdmin.Mobile = "13318599895"
319 321
 
320 322
 		//userAdmin.Id = 597
321 323
 		//userAdmin.Mobile = "19874122664"
322
-		//userAdmin.IsSuperAdmin = false
323
-		//userAdmin.Status = 1
324
-		//userAdmin.CreateTime = 1530786071
325
-		//userAdmin.ModifyTime = 1530786071
326
-		//var subscibe models.ServeSubscibe
327
-		//subscibe.ID = 1
328
-		//subscibe.OrgId = 4
329
-		//subscibe.PeriodStart = 1538035409
330
-		//subscibe.PeriodEnd = 1569571409
331
-		//subscibe.State = 1
332
-		//subscibe.Status = 1
333
-		//subscibe.CreatedTime = 1538035409
334
-		//subscibe.UpdatedTime = 1538035409
335
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
336
-		//subscibes[4] = &subscibe
337
-		//var adminUserInfo service.AdminUserInfo
338
-		//adminUserInfo.CurrentOrgId = 4
339
-		//adminUserInfo.CurrentAppId = 4
340
-		//adminUserInfo.AdminUser = &userAdmin
341
-		//adminUserInfo.Subscibes = subscibes
342
-		//this.SetSession("admin_user_info", &adminUserInfo)
343
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
344
-		this.StopRun()
324
+		userAdmin.IsSuperAdmin = false
325
+		userAdmin.Status = 1
326
+		userAdmin.CreateTime = 1530786071
327
+		userAdmin.ModifyTime = 1530786071
328
+		var subscibe models.ServeSubscibe
329
+		subscibe.ID = 1
330
+		subscibe.OrgId = 4
331
+		subscibe.PeriodStart = 1538035409
332
+		subscibe.PeriodEnd = 1569571409
333
+		subscibe.State = 1
334
+		subscibe.Status = 1
335
+		subscibe.CreatedTime = 1538035409
336
+		subscibe.UpdatedTime = 1538035409
337
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
+		subscibes[4] = &subscibe
339
+		var adminUserInfo service.AdminUserInfo
340
+		adminUserInfo.CurrentOrgId = 4
341
+		adminUserInfo.CurrentAppId = 4
342
+		adminUserInfo.AdminUser = &userAdmin
343
+		adminUserInfo.Subscibes = subscibes
344
+		this.SetSession("admin_user_info", &adminUserInfo)
345
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
+		//this.StopRun()
345 347
 	}
346 348
 
347 349
 	//if adminUserInfo.AppRole != nil {

+ 28 - 1
controllers/dialysis_api_controller.go Zobrazit soubor

@@ -2520,7 +2520,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
2520 2520
 	dialysisway, err := service.FindDialysisWay(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2521 2521
 	//获取临时医嘱
2522 2522
 	doctorAdvice, _ := service.FindDoctorOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2523
-	config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2523
+	//config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2524 2524
 
2525 2525
 	//获取医嘱内容
2526 2526
 	doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
@@ -2576,6 +2576,33 @@ func (c *DialysisApiController) GetDialysisOrder() {
2576 2576
 
2577 2577
 	//获取his数据
2578 2578
 	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2579
+
2580
+	//hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2581
+	config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2582
+
2583
+	project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
2584
+	projects, _ := service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2585
+	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
2586
+		for _, item := range projects {
2587
+			var advice *models.HisDoctorAdviceInfo
2588
+			advice.ID = item.ID
2589
+			advice.Checker = item.Checker
2590
+			advice.CheckTime = item.CheckTime
2591
+			advice.CheckState = item.CheckState
2592
+			advice.ExecutionState = item.ExecutionState
2593
+			advice.ExecutionStaff = item.ExecutionStaff
2594
+			advice.PrescribingNumber = float64(item.Count)
2595
+			advice.PrescribingNumberUnit = item.Unit
2596
+			advice.AdviceDoctor = item.Doctor
2597
+			if item.Type == 3 {
2598
+				advice.AdviceName = item.GoodInfo.GoodName
2599
+			} else if item.Type == 2 {
2600
+				advice.AdviceName = item.HisProject.ProjectName
2601
+			}
2602
+			advice.StartTime = item.StartTime
2603
+			hisAdvice = append(hisAdvice, advice)
2604
+		}
2605
+	}
2579 2606
 	if config.IsOpen == 1 {
2580 2607
 		c.ServeSuccessJSON(map[string]interface{}{
2581 2608
 			"xtdate":                    xtdate,

+ 1 - 1
controllers/doctors_api_controller.go Zobrazit soubor

@@ -103,7 +103,7 @@ func (c *DoctorsApiController) GetAllDoctorAndNurse() {
103 103
 func (c *DoctorsApiController) GetAllAdminUsers() {
104 104
 
105 105
 	adminUserInfo := c.GetAdminUserInfo()
106
-	users, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
106
+	users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
107 107
 	c.ServeSuccessJSON(map[string]interface{}{
108 108
 		"users": users,
109 109
 	})

+ 67 - 3
controllers/gobal_config_api_controller.go Zobrazit soubor

@@ -67,6 +67,8 @@ func GobalConfigRegistRouters() {
67 67
 	beego.Router("/api/xtconfig/get", &GobalConfigApiController{}, "get:GetXTHisConfig")
68 68
 	beego.Router("/api/xtconfig/isopen", &GobalConfigApiController{}, "post:PostXTHisConfig")
69 69
 
70
+	beego.Router("/api/xtconfigproject/isopen", &GobalConfigApiController{}, "post:PostXTHisProjectConfig")
71
+
70 72
 	beego.Router("/api/isopen/init", &GobalConfigApiController{}, "get:GetAllIsOpenConfig")
71 73
 
72 74
 	beego.Router("/api/passdetail/export", &GobalConfigApiController{}, "get:GetPassExportData")
@@ -1384,20 +1386,80 @@ func (c *GobalConfigApiController) PostXTHisConfig() {
1384 1386
 
1385 1387
 	return
1386 1388
 }
1389
+
1390
+func (c *GobalConfigApiController) PostXTHisProjectConfig() {
1391
+	is_open, _ := c.GetBool("is_open", false)
1392
+	adminUserInfo := c.GetAdminUserInfo()
1393
+	org_id := adminUserInfo.CurrentOrgId
1394
+	isOpen := 0
1395
+
1396
+	if is_open {
1397
+		isOpen = 1
1398
+	} else {
1399
+		isOpen = 2
1400
+	}
1401
+
1402
+	config := models.XtHisProjectConfig{
1403
+		UserOrgId: org_id,
1404
+		IsOpen:    int64(isOpen),
1405
+		Status:    1,
1406
+		Ctime:     time.Now().Unix(),
1407
+		Mtime:     time.Now().Unix(),
1408
+	}
1409
+
1410
+	errs, configs := service.FindXTHisProjectByOrgId(org_id)
1411
+
1412
+	if errs == gorm.ErrRecordNotFound {
1413
+		err := service.CreateXTHisProjectRecord(&config)
1414
+		if err != nil {
1415
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1416
+			return
1417
+		}
1418
+
1419
+	} else if errs == nil {
1420
+		modifyConfig := models.XtHisProjectConfig{
1421
+			ID:        configs.ID,
1422
+			UserOrgId: org_id,
1423
+			Status:    1,
1424
+			Ctime:     time.Now().Unix(),
1425
+			Mtime:     time.Now().Unix(),
1426
+			IsOpen:    int64(isOpen),
1427
+		}
1428
+
1429
+		err := service.UpdateXTHisProjectRecord(&modifyConfig)
1430
+		if err != nil {
1431
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1432
+			return
1433
+		}
1434
+
1435
+	}
1436
+
1437
+	c.ServeSuccessJSON(map[string]interface{}{
1438
+		"is_open": is_open,
1439
+	})
1440
+
1441
+	return
1442
+}
1443
+
1387 1444
 func (c *GobalConfigApiController) GetXTHisConfig() {
1388 1445
 	adminUserInfo := c.GetAdminUserInfo()
1389 1446
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1447
+	_, project_config := service.FindXTHisProjectByOrgId(adminUserInfo.CurrentOrgId)
1448
+
1390 1449
 	c.ServeSuccessJSON(map[string]interface{}{
1391
-		"config": config,
1450
+		"config":         config,
1451
+		"project_config": project_config,
1392 1452
 	})
1393 1453
 }
1394 1454
 
1395 1455
 func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1396 1456
 	adminUserInfo := c.GetAdminUserInfo()
1397 1457
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1458
+	_, project_config := service.FindXTHisProjectByOrgId(adminUserInfo.CurrentOrgId)
1398 1459
 
1399 1460
 	c.ServeSuccessJSON(map[string]interface{}{
1400
-		"is_open_xt_his": config.IsOpen,
1461
+		"is_open_xt_his":         config.IsOpen,
1462
+		"is_open_xt_his_project": project_config.IsOpen,
1401 1463
 	})
1402 1464
 
1403 1465
 }
@@ -1409,6 +1471,8 @@ func (c *GobalConfigApiController) GetPassExportData() {
1409 1471
 func (c *GobalConfigApiController) GetExportData() {
1410 1472
 	start_time := c.GetString("start_time")
1411 1473
 	end_time := c.GetString("end_time")
1474
+	p_type, _ := c.GetInt64("p_type")
1475
+
1412 1476
 	timeLayout := "2006-01-02"
1413 1477
 	loc, _ := time.LoadLocation("Local")
1414 1478
 	var startTime int64
@@ -1432,7 +1496,7 @@ func (c *GobalConfigApiController) GetExportData() {
1432 1496
 		endTime = theTime.Unix()
1433 1497
 	}
1434 1498
 	adminInfo := c.GetAdminUserInfo()
1435
-	order, _ := service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime)
1499
+	order, _ := service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime, p_type)
1436 1500
 	c.ServeSuccessJSON(map[string]interface{}{
1437 1501
 		"order": order,
1438 1502
 	})

Diff nebyl zobrazen, protože je příliš veliký
+ 1115 - 214
controllers/his_api_controller.go


+ 403 - 0
controllers/his_config_api_controller.go Zobrazit soubor

@@ -0,0 +1,403 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"github.com/astaxie/beego"
10
+	"reflect"
11
+	"strconv"
12
+	"time"
13
+)
14
+
15
+type HisConfigApiController struct {
16
+	BaseAuthAPIController
17
+}
18
+
19
+func HisConfigApiRegistRouters() {
20
+	beego.Router("/api/his/patient/list", &HisConfigApiController{}, "get:GetAllHisPatientsList")
21
+	beego.Router("/api/his/prescriptiontemplate/list", &HisConfigApiController{}, "get:GetPrescriptionTemplateList")
22
+	beego.Router("/api/his/prescriptiontemplate/info", &HisConfigApiController{}, "get:GetPrescriptionTemplateInfo")
23
+	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate")
24
+	beego.Router("/api/his/prescriptiontemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionTemplate")
25
+	beego.Router("/api/his/prescriptioninfotemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoTemplate")
26
+	beego.Router("/api/his/advicetemplate/delete", &HisConfigApiController{}, "post:DeleteAdviceTemplate")
27
+	beego.Router("/api/his/projecttemplate/delete", &HisConfigApiController{}, "post:DeleteProjectTemplate")
28
+
29
+}
30
+
31
+func (c *HisConfigApiController) GetAllHisPatientsList() {
32
+	patients, _, _ := service.GetAllPatientList(c.GetAdminUserInfo().CurrentOrgId)
33
+	c.ServeSuccessJSON(map[string]interface{}{
34
+		"list": patients,
35
+	})
36
+}
37
+
38
+func (c *HisConfigApiController) GetPrescriptionTemplateList() {
39
+	patient_id, _ := c.GetInt64("patient_id", 0)
40
+	page, _ := c.GetInt64("page", 0)
41
+	limit, _ := c.GetInt64("limit", 0)
42
+
43
+	if page <= 0 {
44
+		page = 1
45
+	}
46
+	if limit <= 0 {
47
+		limit = 10
48
+	}
49
+	if patient_id <= 0 {
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+
54
+	templates, total, _ := service.GetHisPrescriptionTemplatesList(patient_id, c.GetAdminUserInfo().CurrentOrgId, page, limit)
55
+
56
+	c.ServeSuccessJSON(map[string]interface{}{
57
+		"list":  templates,
58
+		"total": total,
59
+	})
60
+
61
+}
62
+
63
+func (c *HisConfigApiController) GetPrescriptionTemplateInfo() {
64
+	id, _ := c.GetInt64("id", 0)
65
+	template, _ := service.GetHisPrescriptionTemplateByID(id)
66
+	prescriptions, _ := service.GetHisPrescriptionTemplate(template.ID, c.GetAdminUserInfo().CurrentOrgId)
67
+
68
+	c.ServeSuccessJSON(map[string]interface{}{
69
+		"template":      template,
70
+		"prescriptions": prescriptions,
71
+	})
72
+}
73
+
74
+func (c *HisConfigApiController) CreatePrescriptionTemplate() {
75
+	id, _ := c.GetInt64("id")
76
+	name := c.GetString("name")
77
+	mode_id, _ := c.GetInt64("mode_id", 0)
78
+	types, _ := c.GetInt64("type", 0)
79
+	patient_id, _ := c.GetInt64("patient_id", 0)
80
+	types = 1
81
+	adminInfo := c.GetAdminUserInfo()
82
+
83
+	src_template, _ := service.GetHisPrescriptionTemplateByID(id)
84
+
85
+	if src_template.ID == 0 {
86
+		template := models.HisPrescriptionTemplate{
87
+			UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
88
+			PatientId: patient_id,
89
+			Type:      types,
90
+			Status:    1,
91
+			Ctime:     time.Now().Unix(),
92
+			Mtime:     time.Now().Unix(),
93
+			Name:      name,
94
+			Mode:      mode_id,
95
+		}
96
+		src_template = template
97
+		service.CreateHisPrescriptionTemplate(&src_template)
98
+	} else {
99
+		src_template.Name = name
100
+		src_template.Mode = mode_id
101
+		service.SaveHisPrescriptionTemplate(&src_template)
102
+	}
103
+
104
+	dataBody := make(map[string]interface{}, 0)
105
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
106
+	if err != nil {
107
+		utils.ErrorLog(err.Error())
108
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
109
+		return
110
+	}
111
+
112
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
113
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
114
+		if len(prescriptions) > 0 {
115
+			for _, item := range prescriptions {
116
+				items := item.(map[string]interface{})
117
+
118
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
119
+					utils.ErrorLog("id")
120
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121
+					return
122
+				}
123
+
124
+				id := int64(items["id"].(float64))
125
+
126
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
127
+					utils.ErrorLog("type")
128
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
129
+					return
130
+				}
131
+				types := int64(items["type"].(float64))
132
+
133
+				ctime := time.Now().Unix()
134
+				prescription := &models.HisPrescriptionInfoTemplate{
135
+					ID:          id,
136
+					PatientId:   patient_id,
137
+					UserOrgId:   adminInfo.CurrentOrgId,
138
+					Ctime:       ctime,
139
+					Mtime:       ctime,
140
+					Type:        types,
141
+					Modifier:    adminInfo.AdminUser.Id,
142
+					Creator:     adminInfo.AdminUser.Id,
143
+					Status:      1,
144
+					PTemplateId: src_template.ID,
145
+				}
146
+				service.CreateHisPrescriptionInfoTemplate(prescription)
147
+
148
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
149
+					advices := items["advices"].([]interface{})
150
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
151
+					groupNo := int64(0)
152
+					ctime := time.Now().Unix()
153
+					mtime := ctime
154
+					if len(advices) > 0 {
155
+						for _, advice := range advices {
156
+							var s models.HisPrescriptionAdviceTemplate
157
+							s.PrescriptionId = prescription.ID
158
+							s.AdviceType = 2
159
+							s.StopState = 2
160
+							s.ExecutionState = 2
161
+							s.Status = 1
162
+							s.UserOrgId = adminInfo.CurrentOrgId
163
+							s.Groupno = groupNo
164
+							s.CreatedTime = ctime
165
+							s.UpdatedTime = mtime
166
+							s.PatientId = patient_id
167
+							errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
168
+							if errcode > 0 {
169
+								c.ServeFailJSONWithSGJErrorCode(errcode)
170
+								return
171
+							}
172
+							service.CreateHisPrescriptionAdviceTemplate(&s)
173
+						}
174
+					}
175
+				}
176
+				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
177
+					projects := items["project"].([]interface{})
178
+					if len(projects) > 0 {
179
+						for _, project := range projects {
180
+							var p models.HisPrescriptionProjectTemplate
181
+							p.PrescriptionId = prescription.ID
182
+							p.Ctime = time.Now().Unix()
183
+							p.Mtime = time.Now().Unix()
184
+							p.PatientId = patient_id
185
+							p.UserOrgId = adminInfo.CurrentOrgId
186
+							p.Status = 1
187
+							errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
188
+							if errcode > 0 {
189
+								c.ServeFailJSONWithSGJErrorCode(errcode)
190
+								return
191
+							}
192
+							service.CreateHisPrescriptionProjectTemplate(&p)
193
+
194
+						}
195
+					}
196
+				}
197
+			}
198
+			c.ServeSuccessJSON(map[string]interface{}{
199
+				"msg": "创建成功",
200
+			})
201
+		}
202
+	}
203
+
204
+}
205
+
206
+func (c *HisConfigApiController) DeletePrescriptionTemplate() {
207
+	id, _ := c.GetInt64("id")
208
+	err := service.DelelteHisPrescriptionTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
209
+	if err == nil {
210
+		c.ServeSuccessJSON(map[string]interface{}{
211
+			"msg": "删除成功",
212
+		})
213
+		return
214
+	} else {
215
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
216
+		return
217
+	}
218
+
219
+}
220
+
221
+func (c *HisConfigApiController) DeletePrescriptionInfoTemplate() {
222
+
223
+	prescription_id, _ := c.GetInt64("id")
224
+	err := service.DelelteHisPrescriptionInfoTemplate(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
225
+	if err == nil {
226
+		c.ServeSuccessJSON(map[string]interface{}{
227
+			"msg": "删除成功",
228
+		})
229
+		return
230
+	} else {
231
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
232
+		return
233
+	}
234
+}
235
+
236
+func (c *HisConfigApiController) DeleteAdviceTemplate() {
237
+	id, _ := c.GetInt64("id")
238
+	err := service.DelelteHisPrescriptionAdviceTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
239
+	if err == nil {
240
+		c.ServeSuccessJSON(map[string]interface{}{
241
+			"msg": "删除成功",
242
+		})
243
+		return
244
+	} else {
245
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
246
+		return
247
+	}
248
+
249
+}
250
+
251
+func (c *HisConfigApiController) DeleteProjectTemplate() {
252
+	id, _ := c.GetInt64("id")
253
+	err := service.DelelteHisPrescriptionProjectTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
254
+	if err == nil {
255
+		c.ServeSuccessJSON(map[string]interface{}{
256
+			"msg": "删除成功",
257
+		})
258
+		return
259
+	} else {
260
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
261
+		return
262
+	}
263
+}
264
+
265
+func (c *HisConfigApiController) setAdviceTemplateWithJSON(advice *models.HisPrescriptionAdviceTemplate, json map[string]interface{}) int {
266
+
267
+	if json["advice_id"] != nil || reflect.TypeOf(json["advice_id"]).String() == "float64" {
268
+		advice_id := int64(json["advice_id"].(float64))
269
+		advice.ID = advice_id
270
+	}
271
+
272
+	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
273
+		utils.ErrorLog("drug_name")
274
+		return enums.ErrorCodeParamWrong
275
+	}
276
+	adviceName, _ := json["drug_name"].(string)
277
+	if len(adviceName) == 0 {
278
+		utils.ErrorLog("len(advice_name) == 0")
279
+		return enums.ErrorCodeParamWrong
280
+	}
281
+	advice.AdviceName = adviceName
282
+	adviceDesc, _ := json["advice_desc"].(string)
283
+	advice.AdviceDesc = adviceDesc
284
+	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
285
+		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
286
+		advice.DrugSpec = drugSpec
287
+	}
288
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
289
+		remark, _ := json["remark"].(string)
290
+		advice.Remark = remark
291
+	}
292
+	if json["id"] == nil {
293
+		advice.DrugId = 0
294
+	} else {
295
+		if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
296
+			drug_id := int64(json["id"].(float64))
297
+			advice.DrugId = drug_id
298
+		}
299
+	}
300
+
301
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
302
+		drugSpecUnit, _ := json["min_unit"].(string)
303
+		advice.DrugSpecUnit = drugSpecUnit
304
+	}
305
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
306
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
307
+		advice.SingleDose = singleDose
308
+	}
309
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
310
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
311
+		advice.SingleDoseUnit = singleDoseUnit
312
+	}
313
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
314
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
315
+		advice.PrescribingNumber = prescribingNumber
316
+	}
317
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
318
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
319
+		advice.PrescribingNumberUnit = prescribingNumberUnit
320
+	}
321
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
322
+		deliveryWay, _ := json["delivery_way"].(string)
323
+		advice.DeliveryWay = deliveryWay
324
+	}
325
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
326
+		executionFrequency, _ := json["execution_frequency"].(string)
327
+		advice.ExecutionFrequency = executionFrequency
328
+	}
329
+
330
+	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
331
+		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
332
+		advice.Price = price
333
+	}
334
+	if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
335
+		med_list_codg, _ := json["medical_insurance_number"].(string)
336
+		advice.MedListCodg = med_list_codg
337
+	}
338
+	if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
339
+		day := int64(json["day"].(float64))
340
+		advice.Day = day
341
+	}
342
+	return 0
343
+}
344
+
345
+func (c *HisConfigApiController) setProjectTemplateWithJSON(project *models.HisPrescriptionProjectTemplate, json map[string]interface{}) int {
346
+
347
+	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
348
+		id := int64(json["id"].(float64))
349
+		project.ID = id
350
+	}
351
+
352
+	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
353
+		types := int64(json["type"].(float64))
354
+		project.Type = types
355
+	}
356
+	if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
357
+		project_id := int64(json["project_id"].(float64))
358
+		project.ProjectId = project_id
359
+	}
360
+
361
+	if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
362
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
363
+		project.Price = price
364
+	}
365
+
366
+	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
367
+		total, _ := json["total"].(string)
368
+		totals, _ := strconv.ParseInt(total, 10, 64)
369
+		project.Count = totals
370
+	}
371
+
372
+	if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
373
+		medical_code, _ := json["medical_code"].(string)
374
+		project.MedListCodg = medical_code
375
+	}
376
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
377
+		single_dose, _ := json["single_dose"].(string)
378
+		project.SingleDose = single_dose
379
+	}
380
+
381
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
382
+		delivery_way, _ := json["delivery_way"].(string)
383
+		project.DeliveryWay = delivery_way
384
+	}
385
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
386
+		execution_frequency, _ := json["execution_frequency"].(string)
387
+		project.ExecutionFrequency = execution_frequency
388
+	}
389
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
390
+		remark, _ := json["remark"].(string)
391
+		project.Remark = remark
392
+	}
393
+	if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
394
+		day, _ := json["number_days"].(string)
395
+		project.Day = day
396
+	}
397
+
398
+	if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
399
+		unit, _ := json["unit"].(string)
400
+		project.Unit = unit
401
+	}
402
+	return 0
403
+}

+ 317 - 0
controllers/his_hospital_api_controller.go Zobrazit soubor

@@ -0,0 +1,317 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"time"
10
+)
11
+
12
+type HisHospitalApiController struct {
13
+	BaseAuthAPIController
14
+}
15
+
16
+func HisHospitalManagerApiRegistRouters() {
17
+
18
+	beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
19
+
20
+	//beego.Router("/api/hishospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
21
+
22
+	beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
23
+	beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
24
+
25
+	beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
26
+	//beego.Router("/api/hishospitalprescription/info", &HisApiController{}, "get:GetHisHospitalPrescriptionInfo")
27
+
28
+	//beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
29
+	//beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
30
+
31
+	//beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
32
+	//beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
33
+	//beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
34
+
35
+	//beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
36
+	//beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
37
+
38
+	//beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
39
+	//beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
40
+
41
+	//beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
42
+	//
43
+	//beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
44
+	//
45
+	//beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
46
+	//
47
+	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
48
+	//
49
+	//beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
50
+
51
+	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
52
+	//新增附加费用
53
+	//beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
54
+	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
55
+	//beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
56
+	//beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
57
+	//beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
58
+	//beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
59
+	//beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
60
+	//beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
61
+	//beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
62
+	//beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
63
+	//beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
64
+	//beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
65
+	//
66
+	//beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
67
+	//beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
68
+	//
69
+	//beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
70
+	//
71
+	//beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
72
+
73
+}
74
+
75
+func (c *HisHospitalApiController) GetHisHospitalPatientList() {
76
+	record_date := c.GetString("record_date")
77
+	types, _ := c.GetInt64("type", 0)
78
+
79
+	timeLayout := "2006-01-02"
80
+	loc, _ := time.LoadLocation("Local")
81
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
82
+	if err != nil {
83
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
84
+		return
85
+	}
86
+	recordDateTime := theTime.Unix()
87
+	adminInfo := c.GetAdminUserInfo()
88
+	var patients []*service.HospitalPatient
89
+	tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
90
+
91
+	for _, item := range tempPatients {
92
+		if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 && item.HisHospitalCheckRecord.OutHospitalStatus == 0 {
93
+			patients = append(patients, item)
94
+
95
+		}
96
+
97
+	}
98
+
99
+	var total_one int64
100
+	var total_two int64
101
+
102
+	for _, item := range patients {
103
+
104
+		if item.VMHisPrescriptionInfo.ID == 0 {
105
+			total_one = total_one + 1
106
+		}
107
+		if item.VMHisPrescriptionInfo.ID > 0 {
108
+			total_two = total_two + 1
109
+		}
110
+	}
111
+
112
+	adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
113
+	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
114
+	department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
115
+
116
+	if types == 0 {
117
+		c.ServeSuccessJSON(map[string]interface{}{
118
+			"list":       patients,
119
+			"total_one":  total_one,
120
+			"total_two":  total_two,
121
+			"info":       adminUserInfo,
122
+			"doctors":    doctors,
123
+			"department": department,
124
+		})
125
+
126
+	} else if types == 1 { //未就诊
127
+		var patientsOne []*service.HospitalPatient
128
+		for _, item := range tempPatients {
129
+			if item.VMHisPrescriptionInfo.ID == 0 {
130
+				patientsOne = append(patientsOne, item)
131
+			}
132
+		}
133
+		c.ServeSuccessJSON(map[string]interface{}{
134
+			"list":       patientsOne,
135
+			"total_one":  total_one,
136
+			"total_two":  total_two,
137
+			"info":       adminUserInfo,
138
+			"doctors":    doctors,
139
+			"department": department,
140
+		})
141
+
142
+	} else if types == 2 { //已就诊
143
+		var patientsTwo []*service.HospitalPatient
144
+		for _, item := range tempPatients {
145
+
146
+			if item.VMHisPrescriptionInfo.ID > 0 {
147
+				patientsTwo = append(patientsTwo, item)
148
+			}
149
+		}
150
+		c.ServeSuccessJSON(map[string]interface{}{
151
+			"list":       patientsTwo,
152
+			"total_one":  total_one,
153
+			"total_two":  total_two,
154
+			"info":       adminUserInfo,
155
+			"doctors":    doctors,
156
+			"department": department,
157
+		})
158
+	}
159
+}
160
+
161
+func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
162
+	record_date := c.GetString("record_date")
163
+	timeLayout := "2006-01-02"
164
+	loc, _ := time.LoadLocation("Local")
165
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
166
+	if err != nil {
167
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
168
+		return
169
+	}
170
+	recordDateTime := theTime.Unix()
171
+	adminInfo := c.GetAdminUserInfo()
172
+	//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
173
+	tempPatients, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
174
+
175
+	var patients []*service.HospitalPatient
176
+	for _, item := range tempPatients {
177
+		fmt.Println(item.ID)
178
+		if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 &&
179
+			item.HisHospitalCheckRecord.HisHospitalOrder.ID == 0 {
180
+			patients = append(patients, item)
181
+		}
182
+	}
183
+
184
+	c.ServeSuccessJSON(map[string]interface{}{
185
+		"list":     patients,
186
+		"list_two": patients,
187
+	})
188
+}
189
+
190
+func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
191
+	patient_id, _ := c.GetInt64("patient_id")
192
+	his_patient_id, _ := c.GetInt64("his_patient_id")
193
+	record_date := c.GetString("record_date")
194
+	start_time := c.GetString("start_time")
195
+	end_time := c.GetString("end_time")
196
+	order_status, _ := c.GetInt64("type", 0)
197
+	p_type, _ := c.GetInt64("p_type", 0)
198
+
199
+	timeLayout := "2006-01-02"
200
+	loc, _ := time.LoadLocation("Local")
201
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
202
+	if err != nil {
203
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
204
+		return
205
+	}
206
+	recordDateTime := theTime.Unix()
207
+
208
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
209
+	if err != nil {
210
+
211
+	}
212
+	startRecordDateTime := startTime.Unix()
213
+
214
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
215
+	if err != nil {
216
+
217
+	}
218
+	endRecordDateTime := endTime.Unix()
219
+
220
+	admin := c.GetAdminUserInfo()
221
+	his_patient_info, _ := service.GetNewHisHospitalPatientInfo(his_patient_id)
222
+	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
223
+
224
+	var prescriptions []*models.HisPrescription
225
+
226
+	if order_status == 1 || order_status == 0 {
227
+		prescriptions, _ = service.GetUnChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
228
+	} else if order_status == 2 {
229
+		prescriptions, _ = service.GetChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
230
+	}
231
+
232
+	var monthPrescriptions []*models.HisPrescription
233
+	if order_status == 1 || order_status == 0 {
234
+		monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
235
+	} else if order_status == 2 {
236
+		monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
237
+	}
238
+	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
239
+	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
240
+	order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
241
+	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
242
+	//获取所有科室信息
243
+	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
244
+
245
+	c.ServeSuccessJSON(map[string]interface{}{
246
+		"his_info":            his_patient_info,
247
+		"xt_info":             xt_patient_info,
248
+		"prescription":        prescriptions,
249
+		"case_history":        case_history,
250
+		"info":                patientPrescriptionInfo,
251
+		"month_prescriptions": monthPrescriptions,
252
+		"order":               order,
253
+		"doctors":             doctors,
254
+		"department":          department,
255
+	})
256
+	return
257
+
258
+}
259
+
260
+func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
261
+	record_date := c.GetString("record_date")
262
+	keywords := c.GetString("keywords")
263
+	page, _ := c.GetInt64("page")
264
+	limit, _ := c.GetInt64("limit")
265
+
266
+	timeLayout := "2006-01-02"
267
+	loc, _ := time.LoadLocation("Local")
268
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
269
+	if err != nil {
270
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
271
+		return
272
+	}
273
+	recordDateTime := theTime.Unix()
274
+	adminInfo := c.GetAdminUserInfo()
275
+	prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
276
+
277
+	//adminInfo := c.GetAdminUserInfo()
278
+	//prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
279
+	//fmt.Println(prescriptionOrder)
280
+	if err == nil {
281
+		c.ServeSuccessJSON(map[string]interface{}{
282
+			"order": prescriptionOrder,
283
+			"total": total,
284
+		})
285
+	} else {
286
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
287
+		return
288
+	}
289
+}
290
+
291
+func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
292
+	record_date := c.GetString("record_date")
293
+	keywords := c.GetString("keywords")
294
+	page, _ := c.GetInt64("page")
295
+	limit, _ := c.GetInt64("limit")
296
+
297
+	timeLayout := "2006-01-02"
298
+	loc, _ := time.LoadLocation("Local")
299
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
300
+	if err != nil {
301
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
302
+		return
303
+	}
304
+	recordDateTime := theTime.Unix()
305
+	adminInfo := c.GetAdminUserInfo()
306
+	prescriptionOrder, err, total := service.GetHisHospitalPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
307
+	if err == nil {
308
+		c.ServeSuccessJSON(map[string]interface{}{
309
+			"order": prescriptionOrder,
310
+			"total": total,
311
+		})
312
+	} else {
313
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
314
+		return
315
+	}
316
+
317
+}

+ 223 - 84
controllers/his_project_api_controller.go Zobrazit soubor

@@ -5,9 +5,11 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"encoding/json"
8 9
 	"fmt"
9 10
 	"github.com/astaxie/beego"
10 11
 	"github.com/jinzhu/gorm"
12
+	"reflect"
11 13
 	"strconv"
12 14
 	"strings"
13 15
 	"time"
@@ -24,10 +26,10 @@ func HisProjectRouters() {
24 26
 	beego.Router("/api/his/getprojectdetail", &HisProjectApiController{}, "Get:GetProjectDetail")
25 27
 	beego.Router("/api/his/updatedproject", &HisProjectApiController{}, "Get:UpdatedProject")
26 28
 	beego.Router("/api/his/deletehisproject", &HisProjectApiController{}, "Get:DeleteHisProject")
27
-	beego.Router("/api/his/saveprojectteam", &HisProjectApiController{}, "Get:SaveProjectTeam")
29
+	beego.Router("/api/his/saveprojectteam", &HisProjectApiController{}, "post:SaveProjectTeam")
28 30
 	beego.Router("/api/his/getprojectteamlist", &HisProjectApiController{}, "Get:GetProjectTeamList")
29 31
 	beego.Router("/api/his/getprojectteamdetail", &HisProjectApiController{}, "Get:GetProjectTeamDetail")
30
-	beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "Get:UpdatedProjectTeam")
32
+	beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "post:UpdatedProjectTeam")
31 33
 	beego.Router("/api/his/deleteprojectteam", &HisProjectApiController{}, "Get:DeleteProjectTeam")
32 34
 	beego.Router("/api/his/savedepartment", &HisProjectApiController{}, "Get:SaveDePartment")
33 35
 	beego.Router("/api/his/getdepartmentlist", &HisProjectApiController{}, "Get:GetDepartMentList")
@@ -167,6 +169,7 @@ func (this *HisProjectApiController) SaveProject() {
167 169
 	_, errcode := service.GetHisProjectIsExist(project_name, orgId)
168 170
 	if errcode == gorm.ErrRecordNotFound {
169 171
 		err = service.CreateHisProject(&hisProject)
172
+
170 173
 		if err != nil {
171 174
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
172 175
 			return
@@ -328,8 +331,17 @@ func (this *HisProjectApiController) SaveProjectTeam() {
328 331
 	tube_color, _ := this.GetInt64("tube_color")
329 332
 	team_type, _ := this.GetInt64("team_type")
330 333
 	remark := this.GetString("remark")
331
-	ids := this.GetString("ids")
332
-	item_id := this.GetString("item_id")
334
+	//ids := this.GetString("ids")
335
+	//item_id := this.GetString("item_id")
336
+
337
+	dataBody := make(map[string]interface{}, 0)
338
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
339
+	if err != nil {
340
+		utils.ErrorLog(err.Error())
341
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
342
+		return
343
+	}
344
+
333 345
 	adminUserInfo := this.GetAdminUserInfo()
334 346
 	orgId := adminUserInfo.CurrentOrgId
335 347
 	projectTeam := models.XtHisProjectTeam{
@@ -343,23 +355,71 @@ func (this *HisProjectApiController) SaveProjectTeam() {
343 355
 		UserOrgId:   orgId,
344 356
 		Status:      1,
345 357
 		CreatedTime: time.Now().Unix(),
346
-		ProjectId:   ids,
347
-		ItemId:      item_id,
358
+		//ProjectId:   ids,
359
+		//ItemId:      item_id,
348 360
 	}
349 361
 	//fmt.Println(projectTeam)
350 362
 
351 363
 	_, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
352 364
 
353 365
 	if errcodes == gorm.ErrRecordNotFound {
354
-
355 366
 		err := service.CreatedProjectTeam(&projectTeam)
356 367
 		if err != nil {
357
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
368
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
358 369
 			return
359 370
 		}
360
-		this.ServeSuccessJSON(map[string]interface{}{
361
-			"projectTeam": projectTeam,
362
-		})
371
+
372
+		if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
373
+			infos, _ := dataBody["info"].([]interface{})
374
+			if len(infos) > 0 {
375
+				var ids []string
376
+
377
+				for _, item := range infos {
378
+					items := item.(map[string]interface{})
379
+					if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
380
+						utils.ErrorLog("id")
381
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
382
+						return
383
+					}
384
+					id := int64(items["id"].(float64))
385
+
386
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
387
+						utils.ErrorLog("type")
388
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
389
+						return
390
+					}
391
+					types := int64(items["type"].(float64))
392
+
393
+					if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
394
+						utils.ErrorLog("number")
395
+					}
396
+
397
+					number, _ := strconv.ParseInt(items["number"].(string), 10, 64)
398
+
399
+					list := models.XtHisProjectList{
400
+						Number:      number,
401
+						UserOrgId:   adminUserInfo.CurrentOrgId,
402
+						ProjectId:   id,
403
+						Status:      1,
404
+						CreatedTime: time.Now().Unix(),
405
+						UpdatedTime: time.Now().Unix(),
406
+						TeamId:      projectTeam.ID,
407
+						Type:        types,
408
+					}
409
+
410
+					service.CreateProjectList(&list)
411
+
412
+					ids = append(ids, strconv.FormatInt(list.ID, 10))
413
+
414
+				}
415
+				ids_str := strings.Join(ids, ",")
416
+				projectTeam.ItemId = ids_str
417
+				service.SaveProjectTeam(&projectTeam)
418
+				this.ServeSuccessJSON(map[string]interface{}{
419
+					"projectTeam": projectTeam,
420
+				})
421
+			}
422
+		}
363 423
 		return
364 424
 	} else if errcodes == nil {
365 425
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
@@ -387,21 +447,23 @@ func (this *HisProjectApiController) GetProjectTeamList() {
387 447
 }
388 448
 
389 449
 func (this *HisProjectApiController) GetProjectTeamDetail() {
390
-
391 450
 	id, _ := this.GetInt64("id")
392
-	adminUserInfo := this.GetAdminUserInfo()
393
-	orgId := adminUserInfo.CurrentOrgId
451
+	//adminUserInfo := this.GetAdminUserInfo()
452
+	//orgId := adminUserInfo.CurrentOrgId
394 453
 	projectTeamDetail, err := service.GetProjectTeamDetail(id)
395
-	hisList, err := service.GetProjectHisList(orgId)
396
-	list, err := service.GetAllProjectList(orgId)
454
+
455
+	ids := strings.Split(projectTeamDetail.ProjectId, ",")
456
+	hisList, err := service.GetProjectHisListByIds(ids)
457
+
458
+	//list, err := service.GetAllProjectList(orgId)
397 459
 	if err != nil {
398 460
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
399 461
 		return
400 462
 	}
401 463
 	this.ServeSuccessJSON(map[string]interface{}{
402 464
 		"projectTeamDetail": projectTeamDetail,
403
-		"list":              list,
404
-		"hisList":           hisList,
465
+		//"list":              list,
466
+		"hisList": hisList,
405 467
 	})
406 468
 	return
407 469
 }
@@ -417,25 +479,84 @@ func (this *HisProjectApiController) UpdatedProjectTeam() {
417 479
 	tube_color, _ := this.GetInt64("tube_color")
418 480
 	team_type, _ := this.GetInt64("team_type")
419 481
 	remark := this.GetString("remark")
420
-	ids := this.GetString("ids")
421
-	item_id := this.GetString("item_id")
422
-	projectTeam := models.XtHisProjectTeam{
423
-		ProjectTeam: project_team,
424
-		Price:       price_float,
425
-		Pinyin:      pinyin,
426
-		Wubi:        wubi,
427
-		TubeColor:   tube_color,
428
-		TeamType:    team_type,
429
-		Remark:      remark,
430
-		ProjectId:   ids,
431
-		ItemId:      item_id,
482
+
483
+	projectTeam, _ := service.GetProjectTeamDetail(id)
484
+
485
+	projectTeam.ProjectTeam = project_team
486
+	projectTeam.Price = price_float
487
+	projectTeam.Pinyin = pinyin
488
+	projectTeam.Wubi = wubi
489
+	projectTeam.TubeColor = tube_color
490
+	projectTeam.TeamType = team_type
491
+	projectTeam.Remark = remark
492
+
493
+	dataBody := make(map[string]interface{}, 0)
494
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
495
+	if err != nil {
496
+		utils.ErrorLog(err.Error())
497
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
498
+		return
432 499
 	}
433 500
 
434
-	err := service.UpdatedProjectTeam(id, &projectTeam)
501
+	err = service.UpdatedProjectTeam(id, &projectTeam)
502
+
435 503
 	if err != nil {
436 504
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
437 505
 		return
438 506
 	}
507
+
508
+	if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
509
+		infos, _ := dataBody["info"].([]interface{})
510
+		if len(infos) > 0 {
511
+			var ids []string
512
+
513
+			for _, item := range infos {
514
+				items := item.(map[string]interface{})
515
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
516
+					utils.ErrorLog("id")
517
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
+					return
519
+				}
520
+				id := int64(items["id"].(float64))
521
+
522
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
523
+					utils.ErrorLog("type")
524
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
525
+					return
526
+				}
527
+				types := int64(items["type"].(float64))
528
+
529
+				if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
530
+					utils.ErrorLog("number")
531
+				}
532
+
533
+				number, _ := strconv.ParseInt(items["number"].(string), 10, 64)
534
+
535
+				list := models.XtHisProjectList{
536
+					Number:      number,
537
+					UserOrgId:   this.GetAdminUserInfo().CurrentOrgId,
538
+					ProjectId:   id,
539
+					Status:      1,
540
+					CreatedTime: time.Now().Unix(),
541
+					UpdatedTime: time.Now().Unix(),
542
+					TeamId:      projectTeam.ID,
543
+					Type:        types,
544
+				}
545
+
546
+				service.CreateProjectList(&list)
547
+
548
+				ids = append(ids, strconv.FormatInt(list.ID, 10))
549
+
550
+			}
551
+			ids_str := strings.Join(ids, ",")
552
+			projectTeam.ItemId = projectTeam.ItemId + "," + ids_str
553
+			service.SaveProjectTeam(&projectTeam)
554
+			this.ServeSuccessJSON(map[string]interface{}{
555
+				"projectTeam": projectTeam,
556
+			})
557
+		}
558
+	}
559
+
439 560
 	this.ServeSuccessJSON(map[string]interface{}{
440 561
 		"projectTeam": projectTeam,
441 562
 	})
@@ -610,10 +731,12 @@ func (this *HisProjectApiController) GetTreatmentList() {
610 731
 }
611 732
 
612 733
 func (this *HisProjectApiController) GetAllProjectList() {
613
-
734
+	keyword := this.GetString("keyword")
614 735
 	adminUserInfo := this.GetAdminUserInfo()
615 736
 	orgId := adminUserInfo.CurrentOrgId
616
-	projectList, err := service.GetAllProjectList(orgId)
737
+	projectList, err := service.GetAllProjectList(orgId, keyword)
738
+	goodInfos, err := service.GetGoodInfomationList(orgId, keyword)
739
+
617 740
 	//获取列表数据
618 741
 	hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
619 742
 
@@ -624,6 +747,7 @@ func (this *HisProjectApiController) GetAllProjectList() {
624 747
 	this.ServeSuccessJSON(map[string]interface{}{
625 748
 		"projectList":    projectList,
626 749
 		"hisprojectlist": hisprojectlist,
750
+		"good_info":      goodInfos,
627 751
 	})
628 752
 	return
629 753
 }
@@ -689,12 +813,15 @@ func (this *HisProjectApiController) GetHisProject() {
689 813
 	adminUserInfo := this.GetAdminUserInfo()
690 814
 	orgId := adminUserInfo.CurrentOrgId
691 815
 	project, err := service.GetHisProject(orgId)
816
+	good_info, err := service.GetGoodInfoMation(orgId)
817
+
692 818
 	if err != nil {
693 819
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
694 820
 		return
695 821
 	}
696 822
 	this.ServeSuccessJSON(map[string]interface{}{
697
-		"project": project,
823
+		"project":   project,
824
+		"good_info": good_info,
698 825
 	})
699 826
 }
700 827
 
@@ -805,55 +932,65 @@ func (this *HisProjectApiController) SaveHisPatient() {
805 932
 		return
806 933
 	}
807 934
 
808
-	timeStr := time.Now().Format("2006-01-02")
809
-	timeArr := strings.Split(timeStr, "-")
810
-	var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(patient.ID, 10)
811
-
812
-	his, err := service.GetHisPatientInfo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
813
-
935
+	timeStr := time.Now().Format("2006-01-02 15:04:05")
936
+	fmt.Println(timeStr)
937
+	timeArr := strings.Split(timeStr, " ")
938
+	timeArrTwo := strings.Split(timeArr[0], "-")
939
+	timeArrThree := strings.Split(timeArr[1], ":")
940
+	var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
941
+
942
+	//his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
943
+	//if len(his) >= 1 {
944
+	//	order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
945
+	//	if len(his) >= 1 && order.ID == 0 {
946
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
947
+	//		return
948
+	//	}
949
+	//}
814 950
 	var hisPatient models.XtHisPatient
815
-	if err == gorm.ErrRecordNotFound || his.ID == 0 {
816
-		hisPatient = models.XtHisPatient{
817
-			PatientId:              patient_id,
818
-			Birthday:               birthUnix,
819
-			IdType:                 certificates,
820
-			CostOfProduction:       cost_float,
821
-			Departments:            department,
822
-			Doctor:                 doctor,
823
-			AdminUserId:            adminUserInfo.AdminUser.Id,
824
-			MedicalTreatmentType:   medicalcare,
825
-			IdCardNo:               idcard,
826
-			IsNeedCostOfProduction: cost_checked,
827
-			TreatmentCost:          medicalExpense_float,
828
-			MedicalInsuranceNumber: medicalinsurancecard,
829
-			Name:                name,
830
-			Age:                 age,
831
-			Number:              str,
832
-			RegisterType:        register,
833
-			RegisterCost:        registrationfees_float,
834
-			BalanceAccountsType: settlementValue,
835
-			Gender:              sex,
836
-			Total:               totals_float,
837
-			UserOrgId:           orgId,
838
-			Status:              1,
839
-			RecordDate:          nowtime,
840
-			IsReturn:            1,
841
-			Ctime:               time.Now().Unix(),
842
-			Phone:               phone,
843
-			SocialType:          social_type,
844
-			IdCardType:          id_card_type,
845
-			Diagnosis:           diagnosis_id,
846
-			PType:               reg_type,
847
-			SickType:            sick_type,
848
-		}
849
-		service.CreateHisPatient(&hisPatient)
850
-		this.ServeSuccessJSON(map[string]interface{}{
851
-			"his_info": hisPatient,
852
-		})
853
-	} else {
854
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
855
-		return
856
-	}
951
+	//if err == gorm.ErrRecordNotFound || his.ID == 0 {
952
+	hisPatient = models.XtHisPatient{
953
+		PatientId:              patient_id,
954
+		Birthday:               birthUnix,
955
+		IdType:                 certificates,
956
+		CostOfProduction:       cost_float,
957
+		Departments:            department,
958
+		Doctor:                 doctor,
959
+		AdminUserId:            adminUserInfo.AdminUser.Id,
960
+		MedicalTreatmentType:   medicalcare,
961
+		IdCardNo:               idcard,
962
+		IsNeedCostOfProduction: cost_checked,
963
+		TreatmentCost:          medicalExpense_float,
964
+		MedicalInsuranceNumber: medicalinsurancecard,
965
+		Name:                   name,
966
+		Age:                    age,
967
+		Number:                 str,
968
+		RegisterType:           register,
969
+		RegisterCost:           registrationfees_float,
970
+		BalanceAccountsType:    settlementValue,
971
+		Gender:                 sex,
972
+		Total:                  totals_float,
973
+		UserOrgId:              orgId,
974
+		Status:                 1,
975
+		RecordDate:             nowtime,
976
+		IsReturn:               1,
977
+		Ctime:                  time.Now().Unix(),
978
+		Phone:                  phone,
979
+		SocialType:             social_type,
980
+		IdCardType:             id_card_type,
981
+		Diagnosis:              diagnosis_id,
982
+		PType:                  reg_type,
983
+		SickType:               sick_type,
984
+	}
985
+	service.CreateHisPatient(&hisPatient)
986
+	this.ServeSuccessJSON(map[string]interface{}{
987
+		"his_info": hisPatient,
988
+	})
989
+	//}
990
+	//else {
991
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
992
+	//	return
993
+	//}
857 994
 
858 995
 }
859 996
 
@@ -1051,7 +1188,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1051 1188
 	//prescription_id, _ := this.GetInt64("prescription_id")
1052 1189
 	adminUserInfo := this.GetAdminUserInfo()
1053 1190
 	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId)
1054
-	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId)
1191
+	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
1055 1192
 	//prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1056 1193
 	hisPatient, _ := service.GetHisPatientById(patient_id)
1057 1194
 	if err != nil {
@@ -1394,13 +1531,15 @@ func (this *HisProjectApiController) GetAllDepartmentList() {
1394 1531
 func (this *HisProjectApiController) GetPrescription() {
1395 1532
 
1396 1533
 	patient_id, _ := this.GetInt64("patient_id")
1534
+	p_type, _ := this.GetInt64("p_type")
1535
+
1397 1536
 	fmt.Println("patient_id", patient_id)
1398 1537
 	timeStr := time.Now().Format("2006-01-02")
1399 1538
 	timeLayout := "2006-01-02 15:04:05"
1400 1539
 	fmt.Println("timeStr:", timeStr)
1401 1540
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
1402 1541
 	timenow := timeStringToTime.Unix()
1403
-	list, err := service.GetPrescriptionByPatientId(patient_id, timenow)
1542
+	list, err := service.GetPrescriptionByPatientId(patient_id, timenow, p_type)
1404 1543
 	if err != nil {
1405 1544
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1406 1545
 		return

+ 8 - 2
controllers/manager_center_api_controller.go Zobrazit soubor

@@ -141,8 +141,9 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
141 141
 	min_price, _ := c.GetFloat("min_price")
142 142
 	min_number, _ := c.GetInt64("min_number")
143 143
 	drug_day := c.GetString("drug_day")
144
+	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
145
+	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
144 146
 	adminInfo := c.GetAdminUserInfo()
145
-
146 147
 	drugLib := &models.BaseDrugLib{
147 148
 		DrugName:                    drug_name,
148 149
 		Pinyin:                      pinyin,
@@ -202,6 +203,8 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
202 203
 		Dose:                        dose,
203 204
 		MinPrice:                    min_price,
204 205
 		DoseUnit:                    dose_unit,
206
+		HospApprFlag:                hosp_appr_flag,
207
+		LmtUsedFlag:                 lmt_used_flag,
205 208
 	}
206 209
 
207 210
 	total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
@@ -292,9 +295,10 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
292 295
 	dose_unit := c.GetString("dose_unit")
293 296
 	fmt.Println("单位999999999999999999999999999999", dose_unit)
294 297
 	min_price, _ := c.GetFloat("min_price")
298
+	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
299
+	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
295 300
 	adminInfo := c.GetAdminUserInfo()
296 301
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
297
-
298 302
 	drugLib := &models.BaseDrugLib{
299 303
 		ID:                          id,
300 304
 		DrugName:                    drug_name,
@@ -352,6 +356,8 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
352 356
 		RecordDate:                  theTime.Unix(),
353 357
 		DrugRemark:                  drug_remark,
354 358
 		DrugDay:                     drug_day,
359
+		HospApprFlag:                hosp_appr_flag,
360
+		LmtUsedFlag:                 lmt_used_flag,
355 361
 		MinNumber:                   min_number,
356 362
 		Dose:                        dose,
357 363
 		MinPrice:                    min_price,

+ 10 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Zobrazit soubor

@@ -375,6 +375,10 @@ func (this *DialysisAPIController) DialysisRecord() {
375 375
 
376 376
 	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
377 377
 
378
+	_, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
379
+
380
+	projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
381
+
378 382
 	stockType, _ := service.GetStockType(adminInfo.Org.Id)
379 383
 
380 384
 	prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
@@ -439,6 +443,8 @@ func (this *DialysisAPIController) DialysisRecord() {
439 443
 		"prepare":                        prepare,
440 444
 		"lastAssessment":                 lastAssessment,
441 445
 		"prescribeOne":                   prescribeOne,
446
+		"is_project_open_config":         is_project_open_config,
447
+		"project":                        projects,
442 448
 	}
443 449
 	this.ServeSuccessJSON(returnData)
444 450
 }
@@ -4288,14 +4294,16 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
4288 4294
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4289 4295
 		return
4290 4296
 	}
4297
+
4291 4298
 	goodTypes, _ := service.FindAllGoodTypeOne(adminUser.Org.Id)
4292 4299
 	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
4293 4300
 
4294 4301
 	goodUser, _ := service.GetAllStockOutUserDetail(patient_id, adminUser.Org.Id, date.Unix())
4295 4302
 	lastGoodUserDetial, _ := service.GetLastDialysisGoods(patient_id, adminUser.Org.Id, date.Unix())
4296 4303
 
4297
-	//获取今日患者的透析处方参数
4304
+	project, _ := service.GetHisPrescriptionProject(adminUser.Org.Id, patient_id, date.Unix())
4298 4305
 
4306
+	//获取今日患者的透析处方参数
4299 4307
 	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
4300 4308
 
4301 4309
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -4303,6 +4311,7 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
4303 4311
 		"good_user":      goodUser,
4304 4312
 		"good_info":      good_info,
4305 4313
 		"last_good_user": lastGoodUserDetial,
4314
+		"project":        project,
4306 4315
 		"prescription":   prescribe,
4307 4316
 	})
4308 4317
 	return

+ 5 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go Zobrazit soubor

@@ -48,6 +48,11 @@ func MobileAPIControllersRegisterRouters() {
48 48
 	beego.Router("/m/api/advice/exec", &PatientApiController{}, "Post:ExecDoctorAdvice")
49 49
 	beego.Router("/m/api/advice/exec/modify", &PatientApiController{}, "Post:ModifyExecDoctorAdvice")
50 50
 
51
+	beego.Router("/m/api/project/exec", &PatientApiController{}, "Post:ExecProject")
52
+	beego.Router("/m/api/project/check", &PatientApiController{}, "Post:CheckProject")
53
+
54
+	//beego.Router("/m/api/advice/ex/**/ec/modify", &PatientApiController{}, "Post:ModifyExecDoctorAdvice")
55
+
51 56
 	beego.Router("/m/api/advice/check", &PatientApiController{}, "Post:CheckDoctorAdvice")
52 57
 	beego.Router("/m/api/patient/info", &PatientApiController{}, "Get:GetPatientInfoWithDiseases")
53 58
 

+ 109 - 2
controllers/mobile_api_controllers/patient_api_controller.go Zobrazit soubor

@@ -2947,6 +2947,34 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2947 2947
 	//临时医嘱
2948 2948
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2949 2949
 
2950
+	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2951
+	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
2952
+
2953
+	project_config, _ := service.GetHisProjectConfig(adminUserInfo.Org.Id)
2954
+	projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2955
+	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
2956
+		for _, item := range projects {
2957
+			var advice *models.HisDoctorAdviceInfo
2958
+			advice.ID = item.ID
2959
+			advice.Checker = item.Checker
2960
+			advice.CheckTime = item.CheckTime
2961
+			advice.CheckState = item.CheckState
2962
+			advice.ExecutionState = item.ExecutionState
2963
+			advice.ExecutionStaff = item.ExecutionStaff
2964
+			advice.PrescribingNumber = float64(item.Count)
2965
+			advice.PrescribingNumberUnit = item.Unit
2966
+			advice.AdviceDoctor = item.Doctor
2967
+			if item.Type == 3 {
2968
+				advice.AdviceName = item.GoodInfo.GoodName
2969
+			} else if item.Type == 2 {
2970
+				advice.AdviceName = item.HisProject.ProjectName
2971
+			}
2972
+			advice.StartTime = item.StartTime
2973
+			hisAdvice = append(hisAdvice, advice)
2974
+		}
2975
+
2976
+	}
2977
+
2950 2978
 	if len(DoctorAdvice) > 0 {
2951 2979
 		for _, item := range DoctorAdvice {
2952 2980
 			if item.AdviceDoctor > 0 {
@@ -2961,6 +2989,8 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2961 2989
 		}
2962 2990
 	}
2963 2991
 
2992
+	//DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2993
+
2964 2994
 	//透析监测
2965 2995
 	Record, _ := service.FindAllMonitorRecord(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2966 2996
 	//透析小结
@@ -2977,8 +3007,6 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2977 3007
 
2978 3008
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.Org.Id)
2979 3009
 
2980
-	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
2981
-	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2982 3010
 	if config.IsOpen == 1 {
2983 3011
 		c.ServeSuccessJSON(map[string]interface{}{
2984 3012
 			"users":                   adminUser,
@@ -3565,3 +3593,82 @@ func (this *PatientApiController) GetSearchPatient() {
3565 3593
 		"patient": patient,
3566 3594
 	})
3567 3595
 }
3596
+
3597
+func (c *PatientApiController) ExecProject() {
3598
+	execution_time := c.GetString("execution_time")
3599
+	project_id, _ := c.GetInt64("project_id")
3600
+
3601
+	if len(execution_time) <= 0 {
3602
+		utils.ErrorLog("execution_time")
3603
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3604
+		return
3605
+	}
3606
+	timeLayout2 := "2006-01-02 15:04:05"
3607
+	loc, _ := time.LoadLocation("Local")
3608
+	theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
3609
+	if errs != nil {
3610
+		utils.ErrorLog(errs.Error())
3611
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3612
+		return
3613
+	}
3614
+	adminInfo := c.GetMobileAdminUserInfo()
3615
+	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3616
+	if project.ExecutionState == 1 {
3617
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
3618
+		return
3619
+	}
3620
+	if project.Checker >= 0 && project.Checker == adminInfo.AdminUser.Id {
3621
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
3622
+		return
3623
+	}
3624
+
3625
+	project.ExecutionState = 1
3626
+	project.ExecutionStaff = adminInfo.AdminUser.Id
3627
+	project.ExecutionTime = theTime.Unix()
3628
+	err := service.SaveHisProject(&project)
3629
+	if err == nil {
3630
+		c.ServeSuccessJSON(map[string]interface{}{
3631
+			"project": project,
3632
+		})
3633
+	} else {
3634
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3635
+		return
3636
+
3637
+	}
3638
+
3639
+}
3640
+
3641
+func (c *PatientApiController) CheckProject() {
3642
+
3643
+	adminInfo := c.GetMobileAdminUserInfo()
3644
+	project_id, _ := c.GetInt64("project_id")
3645
+	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3646
+
3647
+	if project.CheckState == 1 {
3648
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
3649
+		return
3650
+	}
3651
+	if project.ExecutionStaff >= 0 && project.ExecutionStaff == adminInfo.AdminUser.Id {
3652
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
3653
+		return
3654
+	}
3655
+
3656
+	project.Checker = adminInfo.AdminUser.Id
3657
+	project.CheckTime = time.Now().Unix()
3658
+	project.CheckState = 1
3659
+
3660
+	err := service.SaveHisProject(&project)
3661
+
3662
+	if err == nil {
3663
+		c.ServeSuccessJSON(map[string]interface{}{
3664
+			"msg":     "ok",
3665
+			"project": project,
3666
+		})
3667
+
3668
+	} else {
3669
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3670
+		return
3671
+
3672
+	}
3673
+
3674
+}

+ 292 - 40
controllers/new_mobile_api_controllers/mobile_his_api_controller.go Zobrazit soubor

@@ -19,6 +19,7 @@ type MobileHisApiController struct {
19 19
 
20 20
 func (c *MobileHisApiController) GetHisPrescriptionConfig() {
21 21
 	adminInfo := c.GetMobileAdminUserInfo()
22
+
22 23
 	//获取医嘱模版
23 24
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.Org.Id)
24 25
 	//获取所有基础药
@@ -28,6 +29,7 @@ func (c *MobileHisApiController) GetHisPrescriptionConfig() {
28 29
 	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.Org.Id)
29 30
 	team, _ := service.GetAllProjectTeamList(adminInfo.Org.Id)
30 31
 	projects, _ := service.GetHisProject(adminInfo.Org.Id)
32
+	good_info, _ := service.GetGoodInfoMation(adminInfo.Org.Id)
31 33
 	//获取所有科室信息
32 34
 	department, _ := service.GetAllDepartMent(adminInfo.Org.Id)
33 35
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -39,6 +41,7 @@ func (c *MobileHisApiController) GetHisPrescriptionConfig() {
39 41
 		"department":       department,
40 42
 		"projects":         projects,
41 43
 		"team":             team,
44
+		"good_info":        good_info,
42 45
 	})
43 46
 }
44 47
 func (c *MobileHisApiController) GetHisPatientInfo() {
@@ -68,22 +71,30 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
68 71
 	}
69 72
 	endRecordDateTime := endTime.Unix()
70 73
 
74
+	var last_prescriptions []*models.HisPrescription
75
+	var sch_prescriptions []*models.HisPrescriptionInfoTemplate
76
+
71 77
 	admin := c.GetMobileAdminUserInfo()
72 78
 	his_patient_info, _ := service.GetHisPatientInfo(admin.Org.Id, patient_id, recordDateTime)
73 79
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.Org.Id, patient_id)
74
-	prescriptions, _ := service.GetHisPrescription(admin.Org.Id, patient_id, recordDateTime)
75
-	monthPrescriptions, _ := service.GetMonthHisPrescriptionTwo(admin.Org.Id, patient_id, startRecordDateTime, endRecordDateTime)
80
+	prescriptions, _ := service.GetHisPrescription(admin.Org.Id, patient_id, recordDateTime, 2)
81
+	monthPrescriptions, _ := service.GetMonthHisPrescriptionTwo(admin.Org.Id, patient_id, startRecordDateTime, endRecordDateTime, 2)
76 82
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.Org.Id, patient_id, recordDateTime)
77
-	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.Org.Id, patient_id, recordDateTime)
83
+	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.Org.Id, patient_id, recordDateTime, 2)
78 84
 	order, _ := service.GetHisOrder(admin.Org.Id, number, patient_id)
79
-	all_prescriptions, _ := service.GetCallHisPrescriptions(startRecordDateTime, endRecordDateTime, admin.Org.Id, patient_id)
80
-
85
+	all_prescriptions, _ := service.GetCallHisPrescriptions(startRecordDateTime, endRecordDateTime, admin.Org.Id, patient_id, 2)
81 86
 	adminUserInfo, _ := service.GetAdminUserInfoByID(admin.Org.Id, admin.AdminUser.Id)
82
-
83 87
 	doctors, _ := service.GetHisAdminUserDoctors(admin.Org.Id)
84 88
 	//获取所有科室信息
85 89
 	department, _ := service.GetAllDepartMent(admin.Org.Id)
86
-
90
+	last_p_info, _ := service.FindLastPatientPrescriptionInfo(admin.Org.Id, patient_id, recordDateTime)
91
+	last_prescriptions, _ = service.GetHisPrescription(admin.Org.Id, patient_id, last_p_info.RecordDate, 2)
92
+	sch, _ := service.GetPatientSch(patient_id, recordDateTime, admin.Org.Id)
93
+	if sch.ID > 0 {
94
+		mode_template, _ := service.GetHisPrescriptionBySchMode(sch.ModeId, patient_id, admin.Org.Id)
95
+		sch_prescriptions, _ = service.GetHisPrescriptionTemplate(mode_template.ID, admin.Org.Id)
96
+	}
97
+	count, _ := service.GetHisPatientCount(admin.Org.Id, patient_id, recordDateTime)
87 98
 	c.ServeSuccessJSON(map[string]interface{}{
88 99
 		"his_info":            his_patient_info,
89 100
 		"xt_info":             xt_patient_info,
@@ -96,6 +107,10 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
96 107
 		"department":          department,
97 108
 		"admin_user_info":     adminUserInfo,
98 109
 		"all_prescriptions":   all_prescriptions,
110
+		"sch_prescriptions":   sch_prescriptions,
111
+		"last_prescriptions":  last_prescriptions,
112
+		"schedule":            sch,
113
+		"count":               count,
99 114
 	})
100 115
 	return
101 116
 
@@ -109,7 +124,7 @@ func (this *MobileHisApiController) GetCallHisPrescription() {
109 124
 	end_time := this.GetString("end_time")
110 125
 	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
111 126
 	adminUserInfo := this.GetMobileAdminUserInfo()
112
-	prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.Org.Id, patient_id)
127
+	prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.Org.Id, patient_id, 2)
113 128
 	if err == nil {
114 129
 		this.ServeSuccessJSON(map[string]interface{}{
115 130
 			"prescriptions": prescriptions,
@@ -122,8 +137,38 @@ func (this *MobileHisApiController) GetCallHisPrescription() {
122 137
 }
123 138
 func (c *MobileHisApiController) DeletePrescription() {
124 139
 	prescription_id, _ := c.GetInt64("id")
140
+	projects, _ := service.GetHisPrescriptionProjectsByID(prescription_id)
141
+	advices, _ := service.GetHisPrescriptionAdviceByID(prescription_id)
142
+
125 143
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
126 144
 	if err == nil {
145
+		if len(projects) > 0 {
146
+			for _, item := range projects {
147
+				if item.Type == 3 { //处理透前准备耗材数量数据
148
+					consumables, _ := service.FindHisConsumablesByID(item.UserOrgId, item.PatientId, item.RecordDate, item.ProjectId)
149
+					if consumables.ID > 0 {
150
+						consumables.Count = 0
151
+						service.UpdateConsumables(&consumables)
152
+					}
153
+				}
154
+			}
155
+		}
156
+		if len(advices) > 0 {
157
+			for _, item := range advices {
158
+				drug, _ := service.FindBaseDrugLibRecord(c.GetMobileAdminUserInfo().Org.Id, item.DrugId)
159
+				if item.PrescribingNumberUnit == drug.MinUnit {
160
+					drug.Total = drug.Total + item.PrescribingNumber
161
+					service.UpdateBaseDrugLib(&drug)
162
+				} else {
163
+					if item.PrescribingNumberUnit == drug.MaxUnit {
164
+						item.PrescribingNumber = item.PrescribingNumber * float64(drug.MinNumber)
165
+						drug.Total = drug.Total + item.PrescribingNumber
166
+						service.UpdateBaseDrugLib(&drug)
167
+					}
168
+				}
169
+			}
170
+		}
171
+
127 172
 		c.ServeSuccessJSON(map[string]interface{}{
128 173
 			"msg": "删除成功",
129 174
 		})
@@ -135,9 +180,20 @@ func (c *MobileHisApiController) DeletePrescription() {
135 180
 }
136 181
 func (c *MobileHisApiController) DeleteDoctorAdvice() {
137 182
 	id, _ := c.GetInt64("id")
138
-	//TODO 需要判断是否已经结算
183
+	advice, _ := service.GetHisDoctorAdvicesById(id)
139 184
 	err := service.DelelteDoctorAdvice(id, c.GetMobileAdminUserInfo().Org.Id)
140 185
 	if err == nil {
186
+		drug, _ := service.FindBaseDrugLibRecord(c.GetMobileAdminUserInfo().Org.Id, advice.DrugId)
187
+		if advice.PrescribingNumberUnit == drug.MinUnit {
188
+			drug.Total = drug.Total + advice.PrescribingNumber
189
+			service.UpdateBaseDrugLib(&drug)
190
+		} else {
191
+			if advice.PrescribingNumberUnit == drug.MaxUnit {
192
+				advice.PrescribingNumber = advice.PrescribingNumber * float64(drug.MinNumber)
193
+				drug.Total = drug.Total + advice.PrescribingNumber
194
+				service.UpdateBaseDrugLib(&drug)
195
+			}
196
+		}
141 197
 		c.ServeSuccessJSON(map[string]interface{}{
142 198
 			"msg": "删除成功",
143 199
 		})
@@ -149,9 +205,18 @@ func (c *MobileHisApiController) DeleteDoctorAdvice() {
149 205
 }
150 206
 func (c *MobileHisApiController) DeleteProject() {
151 207
 	id, _ := c.GetInt64("id")
152
-	//TODO 需要判断是否已经结算
208
+	project, _ := service.GetHisProjectByID(id)
209
+	adminInfo := c.GetMobileAdminUserInfo()
210
+	var consumable models.DialysisBeforePrepare
211
+	if project.ID > 0 && project.Type == 3 {
212
+		consumable, _ = service.FindHisConsumablesByID(adminInfo.Org.Id, project.PatientId, project.RecordDate, project.ProjectId)
213
+	}
153 214
 	err := service.DelelteProject(id, c.GetMobileAdminUserInfo().Org.Id)
154 215
 	if err == nil {
216
+		if consumable.ID > 0 {
217
+			consumable.Count = 0
218
+			service.UpdateConsumables(&consumable)
219
+		}
155 220
 		c.ServeSuccessJSON(map[string]interface{}{
156 221
 			"msg": "删除成功",
157 222
 		})
@@ -191,7 +256,63 @@ func (c *MobileHisApiController) CreateHisPrescription() {
191 256
 
192 257
 	role, _ := service.GetAdminUserInfoByID(adminInfo.Org.Id, doctor_id)
193 258
 
194
-	info, _ := service.FindPatientPrescriptionInfo(adminInfo.Org.Id, patient_id, recordDateTime)
259
+	//校验库存总量
260
+
261
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
262
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
263
+		if len(prescriptions) > 0 {
264
+			for _, item := range prescriptions {
265
+				items := item.(map[string]interface{})
266
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
267
+					advices := items["advices"].([]interface{})
268
+					if len(advices) > 0 {
269
+						for _, advice := range advices {
270
+							var drug_id int64
271
+							var prescribing_number float64
272
+							var prescribingNumberUnit string
273
+
274
+							if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
275
+								drug_id = int64(advice.(map[string]interface{})["id"].(float64))
276
+							}
277
+							if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "float64" {
278
+								//presc ribing_number = advice.(map[string]interface{})["prescribing_number"].(float64)
279
+								prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
280
+								prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
281
+
282
+							}
283
+
284
+							if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
285
+								prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
286
+							}
287
+
288
+							drug, _ := service.FindBaseDrugLibRecord(adminInfo.Org.Id, drug_id)
289
+							if drug.ID == 0 {
290
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
291
+								return
292
+							}
293
+
294
+							if prescribingNumberUnit == drug.MinUnit {
295
+								if prescribing_number > drug.Total {
296
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
297
+									return
298
+								}
299
+							} else {
300
+								if prescribingNumberUnit == drug.MaxUnit {
301
+									num := prescribing_number * float64(drug.MinNumber)
302
+									if num > drug.Total {
303
+										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
304
+										return
305
+									}
306
+								}
307
+							}
308
+						}
309
+					}
310
+				}
311
+			}
312
+		}
313
+	}
314
+
315
+	info, _ := service.FindPatientPrescriptionInfo(adminInfo.Org.Id, patient_id, recordDateTime, 2)
195 316
 	var hpInfo models.HisPrescriptionInfo
196 317
 	if info.ID == 0 {
197 318
 		var randNum int
@@ -219,6 +340,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
219 340
 			Doctor:             role.UserName,
220 341
 			DoctorId:           doctor_id,
221 342
 			SickType:           sick_type,
343
+			PType:              2,
222 344
 		}
223 345
 		service.SavePatientPrescriptionInfo(hpInfo)
224 346
 
@@ -242,12 +364,14 @@ func (c *MobileHisApiController) CreateHisPrescription() {
242 364
 			PrescriptionStatus: info.PrescriptionStatus,
243 365
 			DoctorId:           doctor_id,
244 366
 			SickType:           sick_type,
367
+			PType:              info.PType,
245 368
 		}
246 369
 		service.SavePatientPrescriptionInfo(hpInfo)
247 370
 	}
248 371
 
249 372
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
250 373
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
374
+		var tempPrescription *models.HisPrescription
251 375
 
252 376
 		if len(prescriptions) > 0 {
253 377
 			for _, item := range prescriptions {
@@ -259,6 +383,9 @@ func (c *MobileHisApiController) CreateHisPrescription() {
259 383
 				}
260 384
 				id := int64(items["id"].(float64))
261 385
 
386
+				new_prescription, _ := service.GetPrescriptionById(id, adminInfo.Org.Id)
387
+				tempPrescription = &new_prescription
388
+
262 389
 				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
263 390
 					utils.ErrorLog("type")
264 391
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -266,6 +393,15 @@ func (c *MobileHisApiController) CreateHisPrescription() {
266 393
 				}
267 394
 				types := int64(items["type"].(float64))
268 395
 
396
+				if items["order_status"] == nil || reflect.TypeOf(items["order_status"]).String() != "float64" {
397
+					utils.ErrorLog("order_status")
398
+				}
399
+				order_status := int64(items["order_status"].(float64))
400
+
401
+				if order_status == 0 {
402
+					order_status = 1
403
+				}
404
+
269 405
 				if items["pre_time"] == nil || reflect.TypeOf(items["pre_time"]).String() != "string" {
270 406
 					utils.ErrorLog("pre_time")
271 407
 				}
@@ -283,25 +419,38 @@ func (c *MobileHisApiController) CreateHisPrescription() {
283 419
 				fmt.Println(pTime)
284 420
 
285 421
 				ctime := time.Now().Unix()
286
-				prescription := &models.HisPrescription{
287
-					ID:                 id,
288
-					PatientId:          patient_id,
289
-					UserOrgId:          adminInfo.Org.Id,
290
-					RecordDate:         recordDateTime,
291
-					Ctime:              ctime,
292
-					Mtime:              ctime,
293
-					Type:               types,
294
-					Modifier:           adminInfo.AdminUser.Id,
295
-					Creator:            adminInfo.AdminUser.Id,
296
-					Status:             1,
297
-					Doctor:             role.UserName,
298
-					HisPatientId:       his_patient_id,
299
-					OrderStatus:        1,
300
-					BatchNumber:        "",
301
-					PrescriptionNumber: hpInfo.PrescriptionNumber,
302
-					PreTime:            pTime,
422
+				if tempPrescription.ID == 0 {
423
+					prescription := &models.HisPrescription{
424
+						ID:                 id,
425
+						PatientId:          patient_id,
426
+						UserOrgId:          adminInfo.Org.Id,
427
+						RecordDate:         recordDateTime,
428
+						Ctime:              ctime,
429
+						Mtime:              ctime,
430
+						Type:               types,
431
+						Modifier:           adminInfo.AdminUser.Id,
432
+						Creator:            adminInfo.AdminUser.Id,
433
+						Status:             1,
434
+						Doctor:             role.UserName,
435
+						HisPatientId:       his_patient_id,
436
+						OrderStatus:        order_status,
437
+						BatchNumber:        "",
438
+						PrescriptionNumber: hpInfo.PrescriptionNumber,
439
+						PreTime:            pTime,
440
+						PType:              2,
441
+					}
442
+					tempPrescription = prescription
443
+				} else {
444
+					tempPrescription.Type = types
445
+					tempPrescription.Modifier = adminInfo.AdminUser.Id
446
+					tempPrescription.Mtime = time.Now().Unix()
447
+					tempPrescription.Doctor = role.UserName
448
+					tempPrescription.OrderStatus = order_status
449
+					tempPrescription.PreTime = pTime
450
+					tempPrescription.PType = 2
451
+
303 452
 				}
304
-				service.SaveHisPrescription(prescription)
453
+				service.SaveHisPrescription(tempPrescription)
305 454
 
306 455
 				//更改患者挂号状态
307 456
 				_, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.Org.Id)
@@ -315,7 +464,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
315 464
 					if len(advices) > 0 {
316 465
 						for _, advice := range advices {
317 466
 							var s models.HisDoctorAdviceInfo
318
-							s.PrescriptionId = prescription.ID
467
+							s.PrescriptionId = tempPrescription.ID
319 468
 							s.AdviceType = 2
320 469
 							s.AdviceDoctor = doctor_id
321 470
 							s.StopState = 2
@@ -352,7 +501,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
352 501
 					if len(projects) > 0 {
353 502
 						for _, project := range projects {
354 503
 							var p models.HisPrescriptionProject
355
-							p.PrescriptionId = prescription.ID
504
+							p.PrescriptionId = tempPrescription.ID
356 505
 							p.Ctime = time.Now().Unix()
357 506
 							p.Mtime = time.Now().Unix()
358 507
 							p.PatientId = patient_id
@@ -360,6 +509,8 @@ func (c *MobileHisApiController) CreateHisPrescription() {
360 509
 							p.UserOrgId = adminInfo.Org.Id
361 510
 							p.HisPatientId = his_patient_id
362 511
 							p.Status = 1
512
+							p.Doctor = doctor_id
513
+							p.StartTime = pTime
363 514
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
364 515
 							if errcode > 0 {
365 516
 								c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -374,6 +525,14 @@ func (c *MobileHisApiController) CreateHisPrescription() {
374 525
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
375 526
 							service.SaveHisProjectTwo(&p)
376 527
 
528
+							if p.Type == 3 { //处理透前准备耗材数量数据
529
+								consumables, _ := service.FindHisConsumablesByID(adminInfo.Org.Id, patient_id, recordDateTime, p.ProjectId)
530
+								if consumables.ID > 0 {
531
+									consumables.Count = p.Count
532
+									service.UpdateConsumables(&consumables)
533
+								}
534
+							}
535
+
377 536
 						}
378 537
 					}
379 538
 				}
@@ -402,7 +561,7 @@ func (this *MobileHisApiController) GetLastOrNextHisPrescription() {
402 561
 	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
403 562
 	record_time := theAdviceRecordTime.Unix()
404 563
 	adminUserInfo := this.GetMobileAdminUserInfo()
405
-	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.Org.Id, patient_id)
564
+	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.Org.Id, patient_id, 2)
406 565
 	if err == nil {
407 566
 		if len(prescriptions) == 0 {
408 567
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
@@ -468,6 +627,88 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
468 627
 		}
469 628
 	}
470 629
 
630
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
631
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
632
+		advice.PrescribingNumber = prescribingNumber
633
+	}
634
+
635
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
636
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
637
+		advice.PrescribingNumberUnit = prescribingNumberUnit
638
+	}
639
+
640
+	drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
641
+	if advice.ID == 0 { //医嘱不存在
642
+		if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据单位与基础库一致为最小单位,直接计算
643
+			drug.Total = drug.Total - advice.PrescribingNumber
644
+			service.UpdateBaseDrugLib(&drug)
645
+
646
+		} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据单位为最大单位,需要将最大单位转为最小单位
647
+			num := advice.PrescribingNumber * float64(drug.MinNumber)
648
+			drug.Total = drug.Total - num
649
+			service.UpdateBaseDrugLib(&drug)
650
+		}
651
+
652
+	} else if advice.ID > 0 { //医嘱存在
653
+		hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
654
+		var num float64
655
+
656
+		if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据为最小单位
657
+			if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最小单位,三个单位一致为最小单位直接计算
658
+				if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
659
+					num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
660
+					drug.Total = drug.Total + num
661
+					service.UpdateBaseDrugLib(&drug)
662
+				} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
663
+					num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
664
+					drug.Total = drug.Total - num
665
+					service.UpdateBaseDrugLib(&drug)
666
+				}
667
+			} else { //原数据为最大单位,需要将最大单位数量转为最小单位数量
668
+				num2 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
669
+				if num2 > advice.PrescribingNumber {
670
+					num = num2 - advice.PrescribingNumber
671
+					drug.Total = drug.Total + num
672
+					service.UpdateBaseDrugLib(&drug)
673
+				} else if num2 < advice.PrescribingNumber {
674
+					num = advice.PrescribingNumber - num2
675
+					drug.Total = drug.Total - num
676
+					service.UpdateBaseDrugLib(&drug)
677
+				}
678
+
679
+			}
680
+
681
+		} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据为最大单位
682
+			if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最大单位, 当前数据单位和原数据单位都为最大单位,需要将两个数据转成最小单位
683
+				num1 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
684
+				num2 := advice.PrescribingNumber * float64(drug.MinNumber)
685
+				if num1 > num2 {
686
+					num = num1 - num2
687
+					drug.Total = drug.Total + num
688
+					service.UpdateBaseDrugLib(&drug)
689
+				} else if num1 < num2 {
690
+					num = num2 - num1
691
+					drug.Total = drug.Total - num
692
+					service.UpdateBaseDrugLib(&drug)
693
+				}
694
+
695
+			} else { //原数据为最小单位,当前数据为最大单位,需要将当前数据数量转为最小单位数量
696
+				num2 := advice.PrescribingNumber * float64(drug.MinNumber)
697
+				//num2 := hisAdvice.PrescribingNumber * (drug.Dose / float64(drug.MinNumber))
698
+				if hisAdvice.PrescribingNumber > num2 {
699
+					num = hisAdvice.PrescribingNumber - num2
700
+					drug.Total = drug.Total + num
701
+					service.UpdateBaseDrugLib(&drug)
702
+				} else if num2 < advice.PrescribingNumber {
703
+					num = num2 - hisAdvice.PrescribingNumber
704
+					drug.Total = drug.Total - num
705
+					service.UpdateBaseDrugLib(&drug)
706
+				}
707
+
708
+			}
709
+		}
710
+	}
711
+
471 712
 	//
472 713
 	//if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
473 714
 	//	execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
@@ -523,14 +764,7 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
523 764
 		singleDoseUnit, _ := json["single_dose_unit"].(string)
524 765
 		advice.SingleDoseUnit = singleDoseUnit
525 766
 	}
526
-	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
527
-		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
528
-		advice.PrescribingNumber = prescribingNumber
529
-	}
530
-	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
531
-		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
532
-		advice.PrescribingNumberUnit = prescribingNumberUnit
533
-	}
767
+
534 768
 	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
535 769
 		deliveryWay, _ := json["delivery_way"].(string)
536 770
 		advice.DeliveryWay = deliveryWay
@@ -555,10 +789,28 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
555 789
 	return 0
556 790
 }
557 791
 func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
792
+	project.ExecutionStaff = 0
793
+	project.ExecutionState = 2
794
+	project.ExecutionTime = 0
795
+	project.Checker = 0
796
+	project.CheckState = 2
797
+	project.CheckTime = 0
558 798
 	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
559 799
 		id := int64(json["id"].(float64))
560 800
 		project.ID = id
801
+		temp_project, _ := service.GetHisPrescriptionProjectByID(id)
802
+		project.ExecutionStaff = temp_project.ExecutionStaff
803
+		project.ExecutionState = temp_project.ExecutionState
804
+		project.ExecutionTime = temp_project.ExecutionTime
805
+		project.Checker = temp_project.Checker
806
+		project.CheckState = temp_project.CheckState
807
+		project.CheckTime = temp_project.CheckTime
561 808
 	}
809
+	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
810
+		types := int64(json["type"].(float64))
811
+		project.Type = types
812
+	}
813
+
562 814
 	if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
563 815
 		project_id := int64(json["project_id"].(float64))
564 816
 		project.ProjectId = project_id

+ 197 - 0
controllers/patient_api_controller.go Zobrazit soubor

@@ -1654,6 +1654,203 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1654 1654
 		fmt.Println("9999999999999999999999999", drugStockConfig.IsOpen)
1655 1655
 		if drugStockConfig.IsOpen == 1 {
1656 1656
 			//查询已经执行的医嘱
1657
+			//advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1658
+			//for _, item := range advices {
1659
+			//
1660
+			//	//调用药品出库接口
1661
+			//	//service.DrugsDelivery(item.UserOrgId, item)
1662
+			//
1663
+			//	//if item.Way == 1 {
1664
+			//	//	out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
1665
+			//	//	if err == gorm.ErrRecordNotFound {
1666
+			//	//		//没有记录,则创建出库单
1667
+			//	//		timeStr := time.Now().Format("2006-01-02")
1668
+			//	//		timeArr := strings.Split(timeStr, "-")
1669
+			//	//		total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1670
+			//	//		total = total + 1
1671
+			//	//		warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1672
+			//	//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1673
+			//	//		number = number + total
1674
+			//	//		warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1675
+			//	//		creater := adminUserInfo.AdminUser.Id
1676
+			//	//		warehouseOut := models.DrugWarehouseOut{
1677
+			//	//			WarehouseOutOrderNumber: warehousing_out_order,
1678
+			//	//			OperationTime:           time.Now().Unix(),
1679
+			//	//			OrgId:                   adminUserInfo.CurrentOrgId,
1680
+			//	//			Creater:                 creater,
1681
+			//	//			Ctime:                   time.Now().Unix(),
1682
+			//	//			Status:                  1,
1683
+			//	//			WarehouseOutTime:        item.RecordDate,
1684
+			//	//			Dealer:                  0,
1685
+			//	//			Manufacturer:            0,
1686
+			//	//			Type:                    1,
1687
+			//	//			IsSys:                   1,
1688
+			//	//		}
1689
+			//	//
1690
+			//	//		err := service.AddSigleDrugWarehouseOut(&warehouseOut)
1691
+			//	//		if err != nil {
1692
+			//	//			utils.TraceLog("创建出库单失败 err = %v", err)
1693
+			//	//		} else {
1694
+			//	//			if item.Way == 1 {
1695
+			//	//				if item.PrescribingNumber > 0 {
1696
+			//	//					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1697
+			//	//						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1698
+			//	//						WarehouseOutId:          warehouseOut.ID,
1699
+			//	//						Status:                  1,
1700
+			//	//						Ctime:                   time.Now().Unix(),
1701
+			//	//						Remark:                  "",
1702
+			//	//						OrgId:                   adminUserInfo.CurrentOrgId,
1703
+			//	//						Type:                    1,
1704
+			//	//						Manufacturer:            0,
1705
+			//	//						Dealer:                  0,
1706
+			//	//						IsSys:                   1,
1707
+			//	//						SysRecordTime:           item.RecordDate,
1708
+			//	//						DrugId:                  item.DrugId,
1709
+			//	//					}
1710
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1711
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1712
+			//	//					warehouseOutInfo.Count = count
1713
+			//	//					stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1714
+			//	//					warehouseOutInfo.Price = stockInInfo.Price
1715
+			//	//					err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1716
+			//	//					if err == nil {
1717
+			//	//						details := &models.DrugAutomaticReduceDetail{
1718
+			//	//							WarehouseOutId:          warehouseOutInfo.ID,
1719
+			//	//							WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1720
+			//	//							PatientId:               item.PatientId,
1721
+			//	//							Ctime:                   time.Now().Unix(),
1722
+			//	//							Mtime:                   time.Now().Unix(),
1723
+			//	//							Status:                  1,
1724
+			//	//							RecordTime:              item.RecordDate,
1725
+			//	//							OrgId:                   adminUserInfo.CurrentOrgId,
1726
+			//	//							DrugId:                  item.DrugId,
1727
+			//	//							Count:                   count,
1728
+			//	//						}
1729
+			//	//						service.AddSigleDrugAutoReduceRecordInfo(details)
1730
+			//	//						if err != nil {
1731
+			//	//							utils.TraceLog("创建出库单失败 err = %v", err)
1732
+			//	//						} else {
1733
+			//	//							if item.Way == 1 {
1734
+			//	//								if item.PrescribingNumber > 0 {
1735
+			//	//									warehouseOutInfo := &models.DrugWarehouseOutInfo{
1736
+			//	//										WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1737
+			//	//										WarehouseOutId:          warehouseOut.ID,
1738
+			//	//										Status:                  1,
1739
+			//	//										Ctime:                   time.Now().Unix(),
1740
+			//	//										Remark:                  "",
1741
+			//	//										OrgId:                   adminUserInfo.CurrentOrgId,
1742
+			//	//										Type:                    1,
1743
+			//	//										Manufacturer:            0,
1744
+			//	//										Dealer:                  0,
1745
+			//	//										IsSys:                   1,
1746
+			//	//										SysRecordTime:           item.RecordDate,
1747
+			//	//										DrugId:                  item.DrugId,
1748
+			//	//									}
1749
+			//	//									prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1750
+			//	//									count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1751
+			//	//									warehouseOutInfo.Count = count
1752
+			//	//									stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1753
+			//	//									warehouseOutInfo.Price = stockInInfo.Price
1754
+			//	//									err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1755
+			//	//									if err == nil {
1756
+			//	//										details := &models.DrugAutomaticReduceDetail{
1757
+			//	//											WarehouseOutId:          warehouseOutInfo.ID,
1758
+			//	//											WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1759
+			//	//											PatientId:               item.PatientId,
1760
+			//	//											Ctime:                   time.Now().Unix(),
1761
+			//	//											Mtime:                   time.Now().Unix(),
1762
+			//	//											Status:                  1,
1763
+			//	//											RecordTime:              item.RecordDate,
1764
+			//	//											OrgId:                   adminUserInfo.CurrentOrgId,
1765
+			//	//											DrugId:                  item.DrugId,
1766
+			//	//											Count:                   count,
1767
+			//	//										}
1768
+			//	//										service.AddSigleDrugAutoReduceRecordInfo(details)
1769
+			//	//									}
1770
+			//	//								}
1771
+			//	//							}
1772
+			//	//						}
1773
+			//	//
1774
+			//	//					}
1775
+			//	//				}
1776
+			//	//			}
1777
+			//	//		}
1778
+			//	//	} else if err == nil {
1779
+			//	//		if item.Way == 1 {
1780
+			//	//			outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
1781
+			//	//			if err == gorm.ErrRecordNotFound {
1782
+			//	//				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1783
+			//	//					WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
1784
+			//	//					WarehouseOutId:          out.ID,
1785
+			//	//					Status:                  1,
1786
+			//	//					Ctime:                   time.Now().Unix(),
1787
+			//	//					Remark:                  "",
1788
+			//	//					OrgId:                   adminUserInfo.CurrentOrgId,
1789
+			//	//					Type:                    1,
1790
+			//	//					Manufacturer:            0,
1791
+			//	//					Dealer:                  0,
1792
+			//	//					IsSys:                   1,
1793
+			//	//					SysRecordTime:           item.RecordDate,
1794
+			//	//				}
1795
+			//	//
1796
+			//	//				stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1797
+			//	//				warehouseOutInfo.Price = stockInInfo.Price
1798
+			//	//				warehouseOutInfo.DrugId = item.DrugId
1799
+			//	//				prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1800
+			//	//				count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1801
+			//	//				warehouseOutInfo.Count = count
1802
+			//	//				err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1803
+			//	//				if err == nil {
1804
+			//	//					details := &models.DrugAutomaticReduceDetail{
1805
+			//	//						WarehouseOutId:          warehouseOutInfo.ID,
1806
+			//	//						WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1807
+			//	//						PatientId:               item.PatientId,
1808
+			//	//						Ctime:                   time.Now().Unix(),
1809
+			//	//						Mtime:                   time.Now().Unix(),
1810
+			//	//						Status:                  1,
1811
+			//	//						RecordTime:              item.RecordDate,
1812
+			//	//						OrgId:                   adminUserInfo.CurrentOrgId,
1813
+			//	//						DrugId:                  item.DrugId,
1814
+			//	//						Count:                   count,
1815
+			//	//					}
1816
+			//	//					service.AddSigleDrugAutoReduceRecordInfo(details)
1817
+			//	//				}
1818
+			//	//
1819
+			//	//			} else if err == nil { //记录存在,则将增加数量
1820
+			//	//				if outInfo.ID > 0 {
1821
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1822
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1823
+			//	//					service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
1824
+			//	//				}
1825
+			//	//
1826
+			//	//				count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
1827
+			//	//				if count == 0 {
1828
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1829
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1830
+			//	//					details := &models.DrugAutomaticReduceDetail{
1831
+			//	//						WarehouseOutId:          outInfo.ID,
1832
+			//	//						WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
1833
+			//	//						PatientId:               item.PatientId,
1834
+			//	//						Ctime:                   time.Now().Unix(),
1835
+			//	//						Mtime:                   time.Now().Unix(),
1836
+			//	//						Status:                  1,
1837
+			//	//						RecordTime:              item.RecordDate,
1838
+			//	//						OrgId:                   adminUserInfo.CurrentOrgId,
1839
+			//	//						DrugId:                  item.DrugId,
1840
+			//	//						Count:                   count,
1841
+			//	//					}
1842
+			//	//					service.AddSigleDrugAutoReduceRecordInfo(details)
1843
+			//	//				} else if count == 1 {
1844
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1845
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1846
+			//	//					service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
1847
+			//	//				}
1848
+			//	//
1849
+			//	//			}
1850
+			//	//		}
1851
+			//	//	}
1852
+			//	//}
1853
+			//}
1657 1854
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1658 1855
 			for _, item := range advices {
1659 1856
 				fmt.Println("imte00000000000000", item.PrescribingNumber)

+ 32 - 0
controllers/public_api_controller.go Zobrazit soubor

@@ -32,6 +32,8 @@ func PublicApiRegistRouters() {
32 32
 
33 33
 	beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
34 34
 
35
+	//beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
36
+
35 37
 }
36 38
 
37 39
 func (c *PublicApiController) GetDoctorAdviceConfig() {
@@ -1647,3 +1649,33 @@ func (c *PublicApiController) HandleHIS() {
1647 1649
 	}
1648 1650
 
1649 1651
 }
1652
+
1653
+//func (c *PublicApiController)HandleOrder(){
1654
+//	//orders, _ := service.GetAllHisOrder()
1655
+//
1656
+//
1657
+//	order, _ := service.GetLastHisOrder()
1658
+//
1659
+//	fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
1660
+//
1661
+//
1662
+//	//fmt.Println(fpNumber)
1663
+//
1664
+//	//for index, item := range orders {
1665
+//	//	item.FaPiaoCode ="144072080589"
1666
+//	//	var zero string
1667
+//	//	if 1520 + int64(index) >= 1000{
1668
+//	//		zero = "0000" + strconv.FormatInt(1520 + int64(index),10)
1669
+//	//	}else if 1520 + int64(index) >= 10000{
1670
+//	//		zero = "000" + strconv.FormatInt(1520 + int64(index),10)
1671
+//	//	} else if 1520 + int64(index) >= 100000{
1672
+//	//		zero = "00" +strconv.FormatInt(1520 + int64(index),10)
1673
+//	//	} else if 1520 + int64(index) >= 1000000{
1674
+//	//		zero = "0" +strconv.FormatInt(1520 + int64(index),10)
1675
+//	//	}else {
1676
+//	//		zero = strconv.FormatInt(1520 + int64(index),10)
1677
+//	//	}
1678
+//	//	item.FaPiaoNumber = zero
1679
+//	//	service.SaveOrder(item)
1680
+//	//}
1681
+//}

+ 17 - 0
controllers/role_controller.go Zobrazit soubor

@@ -238,6 +238,8 @@ func (this *RoleAPIController) EditPurviewInitData() {
238 238
 
239 239
 	_, _, outpatientRegistrationPurviewThree := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientCharges")
240 240
 
241
+	_, _, outpatientRegistrationPurviewFour := service.GetOtherAllGeneralPurviewVMsProcessed("/hospitalStation")
242
+
241 243
 	//透析管理
242 244
 	_, _, originDialysisWatchPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/dialysis/watch")
243 245
 	_, _, originWorkforcePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/workforce/patient")
@@ -263,6 +265,7 @@ func (this *RoleAPIController) EditPurviewInitData() {
263 265
 
264 266
 	subPurviewTreeViewModelTwo := []*service.PurviewTreeViewModel{}
265 267
 	subPurviewTreeViewModelThree := []*service.PurviewTreeViewModel{}
268
+	subPurviewTreeViewModelFour := []*service.PurviewTreeViewModel{}
266 269
 
267 270
 	for _, item := range outpatientRegistrationPurview {
268 271
 		temp := &service.PurviewTreeViewModel{
@@ -294,6 +297,16 @@ func (this *RoleAPIController) EditPurviewInitData() {
294 297
 		subPurviewTreeViewModelThree = append(subPurviewTreeViewModelThree, temp)
295 298
 	}
296 299
 
300
+	for _, item := range outpatientRegistrationPurviewFour {
301
+		temp := &service.PurviewTreeViewModel{
302
+			ID:     item.Id,
303
+			PID:    item.Parentid,
304
+			Name:   item.Name,
305
+			Number: 1,
306
+		}
307
+		subPurviewTreeViewModelFour = append(subPurviewTreeViewModelFour, temp)
308
+	}
309
+
297 310
 	for _, item := range outpatientRegistration {
298 311
 		if item.Name == "门诊挂号" {
299 312
 			item.Childs = append(item.Childs, subPurviewTreeViewModel...)
@@ -306,6 +319,10 @@ func (this *RoleAPIController) EditPurviewInitData() {
306 319
 		if item.Name == "门诊收费" {
307 320
 			item.Childs = append(item.Childs, subPurviewTreeViewModelThree...)
308 321
 		}
322
+
323
+		if item.Name == "住院工作站" {
324
+			item.Childs = append(item.Childs, subPurviewTreeViewModelFour...)
325
+		}
309 326
 	}
310 327
 
311 328
 	//电子病历

+ 1 - 1
controllers/stock_in_api_controller.go Zobrazit soubor

@@ -1821,7 +1821,7 @@ func (c *StockManagerApiController) GetQueryInfo() {
1821 1821
 	list, total, err := service.FindAllStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword, startTime, endTime, type_name)
1822 1822
 	info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
1823 1823
 
1824
-	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
1824
+	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId, "")
1825 1825
 	if err == nil {
1826 1826
 		c.ServeSuccessJSON(map[string]interface{}{
1827 1827
 			"list":           list,

+ 8 - 0
enums/error_code.go Zobrazit soubor

@@ -228,6 +228,10 @@ const ( // ErrorCode
228 228
 	ErrorCodeNoBloodPatientException = 300002
229 229
 
230 230
 	ErrorCodeOrderParamWrong = 300003
231
+
232
+	ErrorCodeHisPatientParamWrong = 300004
233
+
234
+	ErrorCodeOutOfStockParamWrong = 300300
231 235
 )
232 236
 
233 237
 var ErrCodeMsgs = map[int]string{
@@ -446,6 +450,10 @@ var ErrCodeMsgs = map[int]string{
446 450
 	ErrorCodeNoBloodPatientException: "找不到该患者,请先在系统录入患者信息或检查患者身份证信息",
447 451
 
448 452
 	ErrorCodeOrderParamWrong: "结算记录不存在",
453
+
454
+	ErrorCodeHisPatientParamWrong: "订单正在结算、请先结算完成",
455
+
456
+	ErrorCodeOutOfStockParamWrong: "库存不足",
449 457
 }
450 458
 
451 459
 type SGJError struct {

+ 5 - 0
models/dialysis.go Zobrazit soubor

@@ -1041,6 +1041,11 @@ type NewDialysisBeforePrepareGoods struct {
1041 1041
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1042 1042
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1043 1043
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1044
+	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1045
+	Count             int64  `gorm:"column:count" json:"count" form:"count"`
1046
+	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1047
+	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1048
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1044 1049
 }
1045 1050
 
1046 1051
 type QueueCallConfig struct {

+ 28 - 0
models/drug.go Zobrazit soubor

@@ -21,6 +21,27 @@ type BaseDrugLib struct {
21 21
 	Dose                        float64 `gorm:"column:dose" json:"dose" form:"dose"`
22 22
 	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
23 23
 	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
24
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
25
+	DrugName              string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
26
+	Pinyin                string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
27
+	Wubi                  string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
28
+	DrugAlias             string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
29
+	DrugAliasPinyin       string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
30
+	DrugAliasWubi         string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
31
+	DrugCategory          int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
32
+	DrugSpec              string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
33
+	DrugType              int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
34
+	DrugStockLimit        string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
35
+	DrugOriginPlace       string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
36
+	DrugDosageForm        int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
37
+	MedicalInsuranceLevel int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
38
+	MaxUnit               string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
39
+	MinNumber             int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
40
+	MinUnit               string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
41
+	Dose                  float64 `gorm:"column:dose" json:"dose" form:"dose"`
42
+	DoseUnit              string  `gorm:"column:Dose_unit" json:"Dose_unit" form:"Dose_unit"`
43
+	MinPrice              string  `gorm:"column:min_price" json:"min_price" form:"min_price"`
44
+
24 45
 	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
25 46
 	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
26 47
 	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
@@ -60,12 +81,19 @@ type BaseDrugLib struct {
60 81
 	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
61 82
 	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
62 83
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
84
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
63 85
 	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
64 86
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
65 87
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
66 88
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
67 89
 	DrugDay string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
68 90
 	Total   float64 `gorm:"column:total" json:"total" form:"total"`
91
+	Dosage       string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
92
+	Unval        string  `gorm:"column:unval" json:"unval" form:"unval"`
93
+	PackingUnit  string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
94
+	PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
95
+	DrugDay      string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
96
+	Total        float64 `gorm:"column:total" json:"total" form:"total"`
69 97
 }
70 98
 
71 99
 func (BaseDrugLib) TableName() string {

+ 80 - 0
models/his_hospital_models.go Zobrazit soubor

@@ -0,0 +1,80 @@
1
+package models
2
+
3
+type HisHospitalOrder struct {
4
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
7
+	SettleAccountsDate    int64   `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
8
+	Ctime                 int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
9
+	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
10
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
11
+	Number                string  `gorm:"column:number" json:"number" form:"number"`
12
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
13
+	MedfeeSumamt          float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
14
+	OrderStatus           float64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
15
+	PayWay                int64   `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
16
+	PayPrice              float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
17
+	PayCardNo             string  `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
18
+	DiscountPrice         float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
19
+	PreferentialPrice     float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
20
+	RealityPrice          float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
21
+	FoundPrice            float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
22
+	MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
23
+	PrivatePrice          float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
24
+	Creator               int64   `gorm:"column:creator" json:"creator" form:"creator"`
25
+	MdtrtId               string  `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
26
+	MzNumber              string  `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
27
+
28
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
29
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
30
+}
31
+
32
+func (HisHospitalOrder) TableName() string {
33
+	return "his_order"
34
+}
35
+
36
+type HisHospitalCheckRecord struct {
37
+	ID                   int64            `gorm:"column:id" json:"id" form:"id"`
38
+	Name                 string           `gorm:"column:name" json:"name" form:"name"`
39
+	MedicalTreatmentType int64            `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
40
+	RecordDate           int64            `gorm:"column:record_date" json:"record_date" form:"record_date"`
41
+	IdCardNo             string           `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
42
+	AdminUserId          int64            `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
43
+	Departments          int64            `gorm:"column:departments" json:"departments" form:"departments"`
44
+	UserOrgId            int64            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
45
+	Status               int64            `gorm:"column:status" json:"status" form:"status"`
46
+	Ctime                int64            `gorm:"column:ctime" json:"ctime" form:"ctime"`
47
+	Mtime                int64            `gorm:"column:mtime" json:"mtime" form:"mtime"`
48
+	PatientId            int64            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
49
+	Number               string           `gorm:"column:number" json:"number" form:"number"`
50
+	Doctor               int64            `gorm:"column:doctor" json:"doctor" form:"doctor"`
51
+	PsnNo                string           `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
52
+	PsnCertType          string           `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
53
+	Certno               string           `gorm:"column:certno" json:"certno" form:"certno"`
54
+	PsnName              string           `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
55
+	Gend                 string           `gorm:"column:gend" json:"gend" form:"gend"`
56
+	Naty                 string           `gorm:"column:naty" json:"naty" form:"naty"`
57
+	MedType              int64            `gorm:"column:med_type" json:"med_type" form:"med_type"`
58
+	Brdy                 string           `gorm:"column:brdy" json:"brdy" form:"brdy"`
59
+	Iinfo                string           `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
60
+	Idetinfo             string           `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
61
+	IptOtpNo             string           `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
62
+	AdmBed               int64            `gorm:"column:adm_bed" json:"adm_bed" form:"adm_bed"`
63
+	IdCardType           int64            `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
64
+	Diagnosis            string           `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
65
+	SickType             int64            `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
66
+	MdtrtCertType        string           `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
67
+	InHosptialTime       string           `gorm:"column:in_hosptial_time" json:"in_hosptial_time" form:"in_hosptial_time"`
68
+	OutHosptialTime      string           `gorm:"column:out_hosptial_time" json:"out_hosptial_time" form:"out_hosptial_time"`
69
+	InHospitalStatus     int64            `gorm:"column:in_hospital_status" json:"in_hospital_status" form:"in_hospital_status"`
70
+	Certificates         int64            `gorm:"column:certificates" json:"certificates" form:"certificates"`
71
+	InsutypeType         string           `gorm:"column:insutype_type" json:"insutype_type" form:"insutype_type"`
72
+	OutHospitalStatus    int64            `gorm:"column:out_hospital_status" json:"out_hospital_status" form:"out_hospital_status"`
73
+	OutWay               int64            `gorm:"column:out_way" json:"out_way" form:"out_way"`
74
+	Phone                string           `gorm:"column:phone" json:"phone" form:"phone"`
75
+	HisHospitalOrder     HisHospitalOrder `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"order"`
76
+}
77
+
78
+func (HisHospitalCheckRecord) TableName() string {
79
+	return "his_hospital_check_record"
80
+}

+ 340 - 37
models/his_models.go Zobrazit soubor

@@ -234,6 +234,8 @@ type HisDoctorAdviceInfo struct {
234 234
 	Drug                  Drug                   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
235 235
 	Diagnosis             int64                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
236 236
 	Way                   int64                  `gorm:"column:way" json:"way" form:"way"`
237
+	HospApprFlag          int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
238
+	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
237 239
 }
238 240
 
239 241
 func (HisDoctorAdviceInfo) TableName() string {
@@ -241,20 +243,75 @@ func (HisDoctorAdviceInfo) TableName() string {
241 243
 }
242 244
 
243 245
 type Drug struct {
244
-	ID                     int64  `gorm:"column:id" json:"id" form:"id"`
245
-	DrugName               string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
246
-	DrugSpec               string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
247
-	DrugType               int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
248
-	DrugStockLimit         string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
249
-	DrugOriginPlace        string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
250
-	DrugDosageForm         int64  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
251
-	Manufacturer           int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
252
-	Status                 int64  `gorm:"column:status" json:"status" form:"status"`
253
-	Ctime                  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
254
-	Mtime                  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
255
-	OrgId                  int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
256
-	DrugCode               string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
257
-	MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
246
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
247
+	DrugName                    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
248
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
249
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
250
+	DrugAlias                   string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
251
+	DrugAliasPinyin             string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
252
+	DrugAliasWubi               string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
253
+	DrugCategory                int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
254
+	DrugSpec                    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
255
+	DrugType                    int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
256
+	DrugStockLimit              string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
257
+	DrugOriginPlace             string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
258
+	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
259
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
260
+	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
261
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
262
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
263
+	Dose                        float64 `gorm:"column:dose" json:"dose" form:"dose"`
264
+	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
265
+	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
266
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
267
+	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
268
+	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
269
+	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
270
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
271
+	DrugClassify                string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
272
+	DrugDose                    float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
273
+	DrugDoseUnit                int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
274
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
275
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
276
+	PharmacologyCategory        int64   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
277
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
278
+	Code                        string  `gorm:"column:code" json:"code" form:"code"`
279
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
280
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
281
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
282
+	DrugStatus                  string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
283
+	LimitRemark                 string  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
284
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
285
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
286
+	SingleDose                  float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
287
+	PrescribingNumber           float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
288
+	Label                       int64   `gorm:"column:label" json:"label" form:"label"`
289
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
290
+	IsUseDoctorAdvice           int64   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
291
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
292
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
293
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
294
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
295
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
296
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
297
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
298
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
299
+	DrugCode                    string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
300
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
301
+	PrescriptionMark            int64   `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
302
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
303
+	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
304
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
305
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
306
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
307
+	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
308
+	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
309
+	Dosage                      string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
310
+	Unval                       string  `gorm:"column:unval" json:"unval" form:"unval"`
311
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
312
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
313
+	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
314
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
258 315
 }
259 316
 
260 317
 func (Drug) TableName() string {
@@ -328,6 +385,7 @@ type HisPrescriptionInfo struct {
328 385
 	DoctorId           int64           `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
329 386
 	XtHisDepartment    XtHisDepartment `gorm:"ForeignKey:ID;AssociationForeignKey:Departments" json:"department"`
330 387
 	SickType           int64           `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
388
+	PType              int64           `gorm:"column:p_type" json:"p_type" form:"p_type"`
331 389
 }
332 390
 
333 391
 func (HisPrescriptionInfo) TableName() string {
@@ -356,9 +414,11 @@ type HisPrescription struct {
356 414
 	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
357 415
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
358 416
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
359
-	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
360
-	VMHisPrescriptionInfo  HisPrescriptionInfo       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
361
-	Total                  string                    `gorm:"-" json:"total" form:"total"`
417
+
418
+	HisAdditionalCharge   []*HisAdditionalCharge `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
419
+	VMHisPrescriptionInfo HisPrescriptionInfo    `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
420
+	Total                 string                 `gorm:"-" json:"total" form:"total"`
421
+	PType                 int64                  `gorm:"column:p_type" json:"p_type" form:"p_type"`
362 422
 }
363 423
 
364 424
 func (HisPrescription) TableName() string {
@@ -475,14 +535,75 @@ func (HisDoctorAdviceParentTemplate) TableName() string {
475 535
 }
476 536
 
477 537
 type VMDrug struct {
478
-	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
479
-	MaxUnit                string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
480
-	MinUnit                string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
481
-	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
482
-	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
483
-	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
484
-	DrugCode               string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
485
-	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number"`
538
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
539
+	DrugName                    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
540
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
541
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
542
+	DrugAlias                   string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
543
+	DrugAliasPinyin             string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
544
+	DrugAliasWubi               string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
545
+	DrugCategory                int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
546
+	DrugSpec                    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
547
+	DrugType                    int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
548
+	DrugStockLimit              string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
549
+	DrugOriginPlace             string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
550
+	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
551
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
552
+	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
553
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
554
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
555
+	Dose                        float64 `gorm:"column:dose" json:"dose" form:"dose"`
556
+	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
557
+	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
558
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
559
+	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
560
+	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
561
+	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
562
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
563
+	DrugClassify                string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
564
+	DrugDose                    float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
565
+	DrugDoseUnit                int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
566
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
567
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
568
+	PharmacologyCategory        int64   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
569
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
570
+	Code                        string  `gorm:"column:code" json:"code" form:"code"`
571
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
572
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
573
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
574
+	DrugStatus                  string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
575
+	LimitRemark                 string  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
576
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
577
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
578
+	SingleDose                  float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
579
+	PrescribingNumber           float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
580
+	Label                       int64   `gorm:"column:label" json:"label" form:"label"`
581
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
582
+	IsUseDoctorAdvice           int64   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
583
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
584
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
585
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
586
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
587
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
588
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
589
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
590
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
591
+	DrugCode                    string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
592
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
593
+	PrescriptionMark            int64   `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
594
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
595
+	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
596
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
597
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
598
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
599
+	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
600
+	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
601
+	Dosage                      string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
602
+	Unval                       string  `gorm:"column:unval" json:"unval" form:"unval"`
603
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
604
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
605
+	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
606
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
486 607
 }
487 608
 
488 609
 func (VMDrug) TableName() string {
@@ -542,8 +663,20 @@ type HisPrescriptionProject struct {
542 663
 	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
543 664
 	Day                string     `gorm:"column:day" json:"day" form:"day"`
544 665
 	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
545
-	Remark             string     `gorm:"column:remark" json:"remark" form:"remark"`
546
-	Unit               string     `gorm:"column:unit" json:"unit" form:"unit"`
666
+	GoodInfo           GoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
667
+
668
+	Remark string `gorm:"column:remark" json:"remark" form:"remark"`
669
+	Unit   string `gorm:"column:unit" json:"unit" form:"unit"`
670
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
671
+
672
+	Doctor         int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
673
+	ExecutionTime  int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
674
+	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
675
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
676
+	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
677
+	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
678
+	Checker        int64 `gorm:"column:checker" json:"checker" form:"checker"`
679
+	StartTime      int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
547 680
 }
548 681
 
549 682
 func (HisPrescriptionProject) TableName() string {
@@ -580,13 +713,17 @@ type HisProjectListVm struct {
580 713
 }
581 714
 
582 715
 type XtHisProjectList struct {
583
-	ID          int64 `gorm:"column:id" json:"id" form:"id"`
584
-	Number      int64 `gorm:"column:number" json:"number" form:"number"`
585
-	UserOrgId   int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
586
-	ProjectId   int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
587
-	Status      int64 `gorm:"column:status" json:"status" form:"status"`
588
-	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
589
-	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
716
+	ID           int64        `gorm:"column:id" json:"id" form:"id"`
717
+	Number       int64        `gorm:"column:number" json:"number" form:"number"`
718
+	UserOrgId    int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
719
+	ProjectId    int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
720
+	Status       int64        `gorm:"column:status" json:"status" form:"status"`
721
+	CreatedTime  int64        `gorm:"column:created_time" json:"created_time" form:"created_time"`
722
+	UpdatedTime  int64        `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
723
+	TeamId       int64        `gorm:"column:team_id" json:"team_id" form:"team_id"`
724
+	Type         int64        `gorm:"column:type" json:"type" form:"type"`
725
+	XtHisProject XtHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
726
+	GoodInfo     GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
590 727
 }
591 728
 
592 729
 func (XtHisProjectList) TableName() string {
@@ -707,15 +844,25 @@ type HisOrder struct {
707 844
 	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
708 845
 	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
709 846
 	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
847
+	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
848
+
849
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
850
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
851
+
852
+	AdminUser AdminUser `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
710 853
 
711 854
 	SettleType      int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
712 855
 	SettleStartTime int64 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
713 856
 	SettleEndTime   int64 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
714 857
 
715
-	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
716
-	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
717
-	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
858
+	HisOrderInfo           HisOrderInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
859
+	Patients               Patients               `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
860
+	HisPatient             HisPatient             `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"his_patient"`
861
+	HisHospitalCheckRecord HisHospitalCheckRecord `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"his_hospital_patient"`
862
+
718 863
 	HisPrescriptionInfo HisPrescriptionInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"p_info"`
864
+
865
+	HisFundSettleListResult HisFundSettleListResult `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"result"`
719 866
 }
720 867
 
721 868
 func (HisOrder) TableName() string {
@@ -874,6 +1021,19 @@ func (XtHisConfig) TableName() string {
874 1021
 	return "xt_his_config"
875 1022
 }
876 1023
 
1024
+type XtHisProjectConfig struct {
1025
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1026
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1027
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1028
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1029
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1030
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1031
+}
1032
+
1033
+func (XtHisProjectConfig) TableName() string {
1034
+	return "xt_his_project_config"
1035
+}
1036
+
877 1037
 type XtHisTemplate struct {
878 1038
 	ID         int64 `gorm:"column:id" json:"id" form:"id"`
879 1039
 	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -1014,3 +1174,146 @@ type BusinessParams struct {
1014 1174
 	MdtrtId          string
1015 1175
 	SetlId           string
1016 1176
 }
1177
+
1178
+type HisFundSettleListResult struct {
1179
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
1180
+	Number    string `gorm:"column:number" json:"number" form:"number"`
1181
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
1182
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1183
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1184
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1185
+	IsUpload  int64  `gorm:"column:is_upload" json:"is_upload" form:"is_upload"`
1186
+	OrderId   int64  `gorm:"column:order_id" json:"order_id" form:"order_id"`
1187
+}
1188
+
1189
+func (HisFundSettleListResult) TableName() string {
1190
+	return "his_fund_settle_list_result"
1191
+}
1192
+
1193
+type HisPrescriptionTemplate struct {
1194
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
1195
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1196
+	PatientId int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1197
+	Type      int64  `gorm:"column:type" json:"type" form:"type"`
1198
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
1199
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1200
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1201
+	Name      string `gorm:"column:name" json:"name" form:"name"`
1202
+	Mode      int64  `gorm:"column:mode" json:"mode" form:"mode"`
1203
+}
1204
+
1205
+func (HisPrescriptionTemplate) TableName() string {
1206
+	return "his_prescription_template"
1207
+}
1208
+
1209
+type HisPrescriptionAdviceTemplate struct {
1210
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
1211
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1212
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1213
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1214
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1215
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1216
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
1217
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1218
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
1219
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
1220
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1221
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
1222
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1223
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1224
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1225
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1226
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
1227
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
1228
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
1229
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1230
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
1231
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
1232
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
1233
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
1234
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
1235
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
1236
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1237
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1238
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1239
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1240
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
1241
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1242
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1243
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
1244
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
1245
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
1246
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
1247
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
1248
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
1249
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1250
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
1251
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
1252
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
1253
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
1254
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1255
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
1256
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1257
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1258
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1259
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
1260
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
1261
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
1262
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1263
+	Drug                  Drug    `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
1264
+}
1265
+
1266
+func (HisPrescriptionAdviceTemplate) TableName() string {
1267
+	return "his_prescription_advice_template"
1268
+}
1269
+
1270
+type HisPrescriptionProjectTemplate struct {
1271
+	ID                 int64        `gorm:"column:id" json:"id" form:"id"`
1272
+	ProjectId          int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
1273
+	Price              float64      `gorm:"column:price" json:"price" form:"price"`
1274
+	UserOrgId          int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1275
+	Status             int64        `gorm:"column:status" json:"status" form:"status"`
1276
+	Ctime              int64        `gorm:"column:ctime" json:"ctime" form:"ctime"`
1277
+	Mtime              int64        `gorm:"column:mtime" json:"mtime" form:"mtime"`
1278
+	PatientId          int64        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1279
+	HisPatientId       int64        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1280
+	RecordDate         int64        `gorm:"column:record_date" json:"record_date" form:"record_date"`
1281
+	Count              int64        `gorm:"column:count" json:"count" form:"count"`
1282
+	FeedetlSn          string       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1283
+	MedListCodg        string       `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1284
+	SingleDose         string       `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1285
+	DeliveryWay        string       `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1286
+	ExecutionFrequency string       `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1287
+	Day                string       `gorm:"column:day" json:"day" form:"day"`
1288
+	Remark             string       `gorm:"column:remark" json:"remark" form:"remark"`
1289
+	Unit               string       `gorm:"column:unit" json:"unit" form:"unit"`
1290
+	Type               int64        `gorm:"column:type" json:"type" form:"type"`
1291
+	PrescriptionId     int64        `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1292
+	XtHisProject       XtHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1293
+	GoodInfo           GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
1294
+}
1295
+
1296
+func (HisPrescriptionProjectTemplate) TableName() string {
1297
+	return "his_prescription_project_template"
1298
+}
1299
+
1300
+type HisPrescriptionInfoTemplate struct {
1301
+	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
1302
+	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1303
+	RecordDate                     int64                             `gorm:"column:record_date" json:"record_date" form:"record_date"`
1304
+	PatientId                      int64                             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1305
+	Status                         int64                             `gorm:"column:status" json:"status" form:"status"`
1306
+	Ctime                          int64                             `gorm:"column:ctime" json:"ctime" form:"ctime"`
1307
+	Mtime                          int64                             `gorm:"column:mtime" json:"mtime" form:"mtime"`
1308
+	Type                           int64                             `gorm:"column:type" json:"type" form:"type"`
1309
+	Creator                        int64                             `gorm:"column:creator" json:"creator" form:"creator"`
1310
+	Modifier                       int64                             `gorm:"column:modifier" json:"modifier" form:"modifier"`
1311
+	PType                          int64                             `gorm:"column:p_type" json:"p_type" form:"p_type"`
1312
+	PTemplateId                    int64                             `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
1313
+	HisPrescriptionAdviceTemplate  []*HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
1314
+	HisPrescriptionProjectTemplate []*HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
1315
+}
1316
+
1317
+func (HisPrescriptionInfoTemplate) TableName() string {
1318
+	return "his_prescription_info_template"
1319
+}

+ 1 - 1
models/inspection_models.go Zobrazit soubor

@@ -10,7 +10,7 @@ type Inspection struct {
10 10
 	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
11 11
 	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
12 12
 	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
13
-	InspectTips	 string `gorm:"column:inspect_tips" json:"inspect_tips" form:"inspect_tips"`
13
+	InspectTips  string `gorm:"column:inspect_tips" json:"inspect_tips" form:"inspect_tips"`
14 14
 	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
15 15
 	Status       int64  `gorm:"column:status" json:"status" form:"status"`
16 16
 	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`

+ 3 - 0
models/self_drug_models.go Zobrazit soubor

@@ -63,6 +63,9 @@ type XtBaseDrug struct {
63 63
 	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
64 64
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
65 65
 	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
66
+	HospApprFlag           int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
67
+	LmtUsedFlag            int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
68
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
66 69
 }
67 70
 
68 71
 func (XtBaseDrug) TableName() string {

+ 16 - 13
models/service/stock_service.go Zobrazit soubor

@@ -507,19 +507,22 @@ func (VMDrugWarehouseInfo) TableName() string {
507 507
 }
508 508
 
509 509
 type Drug struct {
510
-	ID              int64  `gorm:"column:id" json:"id" form:"id"`
511
-	DrugName        string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
512
-	DrugSpec        string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
513
-	DrugType        int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
514
-	DrugStockLimit  string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
515
-	DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
516
-	DrugDosageForm  int64  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
517
-	Manufacturer    int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
518
-	Status          int64  `gorm:"column:status" json:"status" form:"status"`
519
-	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
520
-	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
521
-	OrgId           int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
522
-	DrugCode        string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
510
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
511
+	DrugName        string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
512
+	DrugSpec        string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
513
+	DrugType        int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
514
+	DrugStockLimit  string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
515
+	DrugOriginPlace string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
516
+	DrugDosageForm  int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
517
+	Manufacturer    int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
518
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
519
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
520
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
521
+	OrgId           int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
522
+	DrugCode        string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
523
+	HospApprFlag    int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
524
+	LmtUsedFlag     int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
525
+	Total           float64 `gorm:"column:total" json:"total" form:"total"`
523 526
 }
524 527
 
525 528
 func (Drug) TableName() string {

+ 1 - 0
models/stock_models.go Zobrazit soubor

@@ -80,6 +80,7 @@ type WarehousingInfo struct {
80 80
 	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date"`
81 81
 	WarehousingCount int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
82 82
 	WarehousingUnit  string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
83
+	StockNumber      int64       `gorm:"column:stock_number" json:"stock_number"`
83 84
 	Price            float64     `gorm:"column:price" json:"price"`
84 85
 	TotalPrice       float64     `gorm:"column:total_price" json:"total_price"`
85 86
 	Dealer           int64       `gorm:"column:dealer" json:"dealer"`

+ 4 - 1
routers/router.go Zobrazit soubor

@@ -54,6 +54,9 @@ func init() {
54 54
 	controllers.ManagerCenterRegistRouters()
55 55
 	controllers.DrugStockManagerApiRegistRouters()
56 56
 	controllers.HisManagerApiRegistRouters()
57
+	controllers.HisConfigApiRegistRouters()
58
+
59
+	controllers.HisHospitalManagerApiRegistRouters()
57 60
 
58 61
 	m_api.MobileAPIControllersRegisterRouters()
59 62
 	new_m_api.NewMobileAPIControllersRegisterRouters()
@@ -70,7 +73,7 @@ func init() {
70 73
 	controllers.DialysisPrameteRoutes()
71 74
 	new_m_api.DialysisParameterApiControllersRegisterRouters()
72 75
 	controllers.SelfDrugRouters()
73
-	new_m_api.NewDrugApiControllersRegisterRouters()
76
+	//new_m_api.NewDrugApiControllersRegisterRouters()
74 77
 	controllers.HisProjectRouters()
75 78
 	controllers.GdybRegistRouters()
76 79
 

+ 15 - 0
service/app_version.go Zobrazit soubor

@@ -256,3 +256,18 @@ func UpDateHis(his *models.HisDoctorAdviceInfo) {
256 256
 func UpDateHis2(his *models.HisPrescriptionProject) {
257 257
 	writeDb.Save(&his)
258 258
 }
259
+
260
+func GetAllHisOrder() (his []*models.HisOrder, err error) {
261
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2 AND settle_accounts_date < 1623168000").Find(&his).Error
262
+	return
263
+}
264
+
265
+func GetLastHisOrder() (his models.HisOrder, err error) {
266
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 4 AND status = 1 AND order_status = 2").Last(&his).Error
267
+	return
268
+}
269
+
270
+func SaveOrder(his *models.HisOrder) {
271
+	writeDb.Save(&his)
272
+
273
+}

+ 16 - 1
service/dialysis_service.go Zobrazit soubor

@@ -1027,7 +1027,7 @@ func GetMaxLongAdviceGroupID(orgId int64, patient_id int64) (group int64) {
1027 1027
 }
1028 1028
 
1029 1029
 func GetLastLongAdviceByGroupNo(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1030
-	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1030
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1031 1031
 	return
1032 1032
 }
1033 1033
 
@@ -1196,3 +1196,18 @@ func ModifyExceDoctorAdviceById(m *models.HisDoctorAdviceInfo, ids []string) (er
1196 1196
 	ut.Commit()
1197 1197
 	return err
1198 1198
 }
1199
+
1200
+func FindHisProjectById(orgID int64, id int64) (advice models.HisPrescriptionProject, err error) {
1201
+	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1202
+	return
1203
+}
1204
+
1205
+func SaveHisProject(advice *models.HisPrescriptionProject) (err error) {
1206
+	err = writeDb.Save(&advice).Error
1207
+	return
1208
+}
1209
+
1210
+func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (advice []*models.HisPrescriptionProject, err error) {
1211
+	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1212
+	return
1213
+}

+ 18 - 11
service/drug_stock_service.go Zobrazit soubor

@@ -19,6 +19,9 @@ type DrugConfig struct {
19 19
 	RetailPrice  float64      `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
20 20
 	LastPrice    float64      `gorm:"column:last_price" json:"last_price" form:"last_price"`
21 21
 	MinUnit      string       `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
22
+	HospApprFlag int64        `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
23
+	LmtUsedFlag  int64        `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
24
+	Total        float64      `gorm:"column:total" json:"total" form:"total"`
22 25
 }
23 26
 
24 27
 func (DrugConfig) TableName() string {
@@ -69,22 +72,26 @@ func FindStockInNumber(orgId int64) (stockIns []*DrugWarehouseInfo, err error) {
69 72
 }
70 73
 
71 74
 type DrugStockInfo struct {
72
-	ID          int64   `gorm:"column:id" json:"id" form:"id"`
73
-	DrugName    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
74
-	DrugSpec    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
75
-	RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
76
-	LastPrice   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
77
-	DrugStatus  string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
78
-	Status      int64   `gorm:"column:status" json:"status" form:"status"`
79
-	Ctime       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
80
-	Mtime       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
81
-	OrgId       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
82
-	DrugCode    string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
75
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
76
+	DrugName     string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
77
+	DrugSpec     string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
78
+	RetailPrice  float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
79
+	LastPrice    float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
80
+	DrugStatus   string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
81
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
82
+	Ctime        int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
83
+	Mtime        int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
84
+	OrgId        int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
85
+	DrugCode     string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
86
+	HospApprFlag int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
87
+	LmtUsedFlag  int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
83 88
 
84 89
 	QueryWarehousingInfo  []models.DrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_warehousing_info"`
85 90
 	QuerySalesReturnInfo  []models.DrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_sales_return_info"`
86 91
 	QueryWarehouseOutInfo []models.DrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_warehouseout_info"`
87 92
 	QueryCancelStockInfo  []models.DrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_cancel_stock_info"`
93
+
94
+	Total float64 `gorm:"column:total" json:"total" form:"total"`
88 95
 }
89 96
 
90 97
 func (DrugStockInfo) TableName() string {

+ 18 - 2
service/gobal_config_service.go Zobrazit soubor

@@ -195,7 +195,23 @@ func CreateXTHisRecord(config *models.XtHisConfig) (err error) {
195 195
 	return
196 196
 }
197 197
 
198
-func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64) (order []*models.HisOrder, err error) {
198
+//TODO:项目开关
199
+func FindXTHisProjectByOrgId(org_id int64) (err error, config models.XtHisProjectConfig) {
200
+	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
201
+	return
202
+}
203
+
204
+func UpdateXTHisProjectRecord(config *models.XtHisProjectConfig) (err error) {
205
+	err = writeDb.Save(config).Error
206
+	return
207
+}
208
+
209
+func CreateXTHisProjectRecord(config *models.XtHisProjectConfig) (err error) {
210
+	err = writeDb.Model(&models.XtHisProjectConfig{}).Create(config).Error
211
+	return
212
+}
213
+
214
+func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64, p_type int64) (order []*models.HisOrder, err error) {
199 215
 	db := readDb.Model(&models.HisOrder{})
200 216
 	if start_time != 0 {
201 217
 		db = db.Where("his_order.settle_accounts_date>=?", start_time)
@@ -204,7 +220,7 @@ func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64)
204 220
 		db = db.Where("his_order.settle_accounts_date<=?", end_time)
205 221
 	}
206 222
 
207
-	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ?", user_org_id)
223
+	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status > 1 AND p_type = ? ", user_org_id, p_type)
208 224
 
209 225
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
210 226
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).

+ 48 - 0
service/his_config_service.go Zobrazit soubor

@@ -0,0 +1,48 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"time"
6
+)
7
+
8
+func GetHisPrescriptionTemplatesList(patient_id int64, org_id int64, page int64, limit int64) (templates []*models.HisPrescriptionTemplate, total int64, err error) {
9
+	offset := (page - 1) * limit
10
+	db := readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND patient_id= ? AND status = 1", org_id, patient_id)
11
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&templates).Error
12
+	return
13
+}
14
+
15
+func GetHisPrescriptionTemplateByID(template_id int64) (prescription models.HisPrescriptionTemplate, err error) {
16
+	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("id = ? AND status = 1 ", template_id).First(&prescription).Error
17
+	return
18
+}
19
+
20
+func SaveHisPrescriptionTemplate(template *models.HisPrescriptionTemplate) (err error) {
21
+	err = writeDb.Save(&template).Error
22
+	return
23
+
24
+}
25
+
26
+func DelelteHisPrescriptionInfoTemplate(id int64, user_org_id int64) (err error) {
27
+	err = writeDb.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
28
+	err = writeDb.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
29
+	err = writeDb.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
30
+	return
31
+}
32
+
33
+func DelelteHisPrescriptionTemplate(id int64, user_org_id int64) (err error) {
34
+	err = writeDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
35
+	err = writeDb.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
36
+	return
37
+}
38
+
39
+func DelelteHisPrescriptionAdviceTemplate(id int64, user_org_id int64) (err error) {
40
+	err = writeDb.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
41
+	return
42
+}
43
+
44
+func DelelteHisPrescriptionProjectTemplate(id int64, user_org_id int64) (err error) {
45
+	err = writeDb.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
46
+
47
+	return
48
+}

+ 174 - 0
service/his_hospital_service.go Zobrazit soubor

@@ -0,0 +1,174 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+type HospitalPatient struct {
9
+	ID                     int64                         `gorm:"column:id" json:"id" form:"id"`
10
+	UserOrgId              int64                         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
11
+	Name                   string                        `gorm:"column:name" json:"name" form:"name"`
12
+	Status                 int64                         `gorm:"column:status" json:"status" form:"status"`
13
+	IdCardNo               string                        `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
14
+	ScheduleType           int64                         `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
15
+	Schedule               Schedule                      `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
16
+	HisHospitalCheckRecord models.HisHospitalCheckRecord `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
17
+	VMHisPrescriptionInfo  VMHisPrescriptionInfo         `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"info"`
18
+	//HisHospitalOrder       models.HisHospitalOrder       `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"order"`
19
+}
20
+
21
+func (HospitalPatient) TableName() string {
22
+	return "xt_patients"
23
+}
24
+
25
+func GetHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
26
+	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
27
+	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1 AND record.out_hospital_status = 0", org_id)
28
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
29
+		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id)
30
+	})
31
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
32
+	return
33
+}
34
+
35
+func GetNewAllChargeHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
36
+	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
37
+	db = db.Joins("join his_hospital_check_record as hp ON hp.patient_id = xt_patients.id  AND hp.status = 1 AND hp.user_org_id = ? ", org_id)
38
+
39
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
40
+		return db.Where("status = 1 AND user_org_id = ? AND in_hospital_status = 1", org_id).Preload("HisHospitalOrder", "user_org_id = ? AND status = 1", org_id)
41
+	})
42
+	//db = db.Preload("HisHospitalOrder", "user_org_id = ? AND status = 1 ", org_id)
43
+	err = db.Group("id").Find(&patients).Error
44
+	return
45
+}
46
+
47
+func GetNewHisHospitalPatientInfo(his_patient_id int64) (info models.HisHospitalCheckRecord, err error) {
48
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 ", his_patient_id).First(&info).Error
49
+	return
50
+}
51
+
52
+func GetUnChargeHisHospitalPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
53
+	err = readDb.Model(&models.HisPrescription{}).
54
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
55
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
56
+		}).
57
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
58
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
59
+		}).
60
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
61
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
62
+		}).
63
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3", org_id, record_date, patient_id).
64
+		Find(&prescription).Error
65
+	return
66
+}
67
+
68
+func GetChargeHisHospitalPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
69
+	err = readDb.Model(&models.HisPrescription{}).
70
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
71
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
72
+		}).
73
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
74
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
75
+		}).
76
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
77
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
78
+		}).
79
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 2 ", org_id, record_date, patient_id).
80
+		Find(&prescription).Error
81
+	return
82
+}
83
+
84
+//
85
+type VMHospitalPatient struct {
86
+	ID                     int64                         `gorm:"column:id" json:"id" form:"id"`
87
+	UserOrgId              int64                         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
88
+	Name                   string                        `gorm:"column:name" json:"name" form:"name"`
89
+	Status                 int64                         `gorm:"column:status" json:"status" form:"status"`
90
+	IdCardNo               string                        `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
91
+	ScheduleType           int64                         `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
92
+	Schedule               Schedule                      `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
93
+	HisHospitalCheckRecord models.HisHospitalCheckRecord `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
94
+	VMHisPrescriptionInfo  VMHisPrescriptionInfo         `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"info"`
95
+}
96
+
97
+func (VMHospitalPatient) TableName() string {
98
+	return "xt_patients"
99
+}
100
+
101
+//
102
+//
103
+//func GetHisHospitalPatientPrescriptionList(org_id int64, record_date int64,page int64, limit int64) (patients []*HospitalPatient, err error) {
104
+//	offset := (page - 1) * limit
105
+//	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
106
+//	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ?", org_id)
107
+//	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
108
+//		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id)
109
+//	})
110
+//	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
111
+//	return
112
+//}
113
+
114
+//
115
+//func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMSchedule, err error, total int64) {
116
+//	offset := (page - 1) * limit
117
+//	db := readDb.Model(&VMHospitalPatient{}).Where("user_org_id = ? AND status = 1", org_id)
118
+//	if len(keywords) > 0 {
119
+//		keywords = "%" + keywords + "%"
120
+//		db = db.Joins("JOIN xt_patients as p On xt_schedule.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
121
+//		db = db.Joins("JOIN his_prescription_info as info On xt_schedule.patient_id = info.patient_id  AND info.user_org_id = ? AND  info.record_date = ? AND info.prescription_number like ? AND info.p_type == 1", org_id, record_date, keywords)
122
+//	}
123
+//	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
124
+//	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
125
+//	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND p_type == 1", org_id).
126
+//		Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND p_type == 1", org_id)
127
+//	db = db.Count(&total)
128
+//	err = db.Limit(limit).Offset(offset).Find(&patients).Error
129
+//	return
130
+//}
131
+
132
+type VMHisHospitalPrescriptionInfo struct {
133
+	ID                 int64              `gorm:"column:id" json:"id" form:"id"`
134
+	UserOrgId          int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
135
+	RecordDate         int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
136
+	PatientId          int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
137
+	HisPatientId       int64              `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
138
+	Status             int64              `gorm:"column:status" json:"status" form:"status"`
139
+	Ctime              int64              `gorm:"column:ctime" json:"ctime" form:"ctime"`
140
+	Mtime              int64              `gorm:"column:mtime" json:"mtime" form:"mtime"`
141
+	Creator            int64              `gorm:"column:creator" json:"creator" form:"creator"`
142
+	Modifier           int64              `gorm:"column:modifier" json:"modifier" form:"modifier"`
143
+	Diagnosis          int64              `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
144
+	RegisterType       int64              `gorm:"column:register_type" json:"register_type" form:"register_type"`
145
+	Doctor             string             `gorm:"column:doctor" json:"doctor" form:"doctor"`
146
+	Departments        string             `gorm:"column:departments" json:"departments" form:"departments"`
147
+	SickHistory        string             `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
148
+	PrescriptionNumber string             `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
149
+	BatchNumber        string             `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
150
+	PrescriptionStatus int64              `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
151
+	DoctorId           int64              `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
152
+	DepartmentId       int64              `gorm:"column:department_id" json:"department_id" form:"department_id"`
153
+	SickType           int64              `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
154
+	Patients           Patients           `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patients"`
155
+	HisPrescription    []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"prescription"`
156
+}
157
+
158
+func (VMHisHospitalPrescriptionInfo) TableName() string {
159
+	return "his_prescription_info"
160
+}
161
+
162
+func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
163
+	offset := (page - 1) * limit
164
+	db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1 ", org_id, record_date)
165
+	if len(keywords) > 0 {
166
+		keywords = "%" + keywords + "%"
167
+		db = db.Joins("JOIN xt_patients as p On his_prescription_info.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
168
+	}
169
+	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
170
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND p_type = 1", org_id)
171
+	db = db.Count(&total)
172
+	err = db.Limit(limit).Offset(offset).Find(&patients).Error
173
+	return
174
+}

+ 28 - 14
service/his_project_service.go Zobrazit soubor

@@ -72,7 +72,7 @@ func DeleteHisProject(id int64) error {
72 72
 func GetHisProjectByNameOne(projectName string, orgid int64) (*models.XtHisProjectTeam, error) {
73 73
 
74 74
 	projectTeam := models.XtHisProjectTeam{}
75
-	err := XTReadDB().Model(&projectTeam).Where("project_team = ? and user_org_id = ? and status = 1", projectName, orgid).Find(&projectTeam).Error
75
+	err := XTReadDB().Model(&projectTeam).Where("project_team = ? and user_org_id = ? and status = 1", projectName, orgid).First(&projectTeam).Error
76 76
 	if err != nil {
77 77
 		if err == gorm.ErrRecordNotFound {
78 78
 			return nil, err
@@ -262,6 +262,13 @@ func CreateHisPatient(patient *models.XtHisPatient) error {
262 262
 	return err
263 263
 }
264 264
 
265
+func UpdateHisPrescriptionHisID(his_patient_id int64, patient_id int64, record_time int64, org_id int64) {
266
+	XTWriteDB().Model(&models.HisPrescription{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ?", record_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
267
+	XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ?", record_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
268
+
269
+	return
270
+}
271
+
265 272
 func GetBloodPatientByIdCard(idcard string, orgid int64) (*models.XtPatients, error) {
266 273
 	var patients models.XtPatients
267 274
 	var err error
@@ -282,16 +289,15 @@ func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err err
282 289
 	return project, err
283 290
 }
284 291
 
285
-func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProject, err error) {
286
-	err = XTReadDB().Model(&project).Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
292
+func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProjectList, err error) {
293
+	err = XTReadDB().Model(&project).Preload("XtHisProject", "status = 1").Preload("GoodInfo", "status=1").Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
287 294
 	return project, err
288 295
 }
289 296
 
290 297
 func GetHisPatientHistory(keyword string, startime int64, endtime int64, registtype int64, limit int64, page int64, orgid int64) (hisPatient []*models.XtHisPatient, total int64, err error) {
291 298
 	offset := (page - 1) * limit
292 299
 	likeKey := "%" + keyword + "%"
293
-	db := XTReadDB().Table("his_patient as x").Where("x.status = 1")
294
-
300
+	db := XTReadDB().Table("his_patient as x")
295 301
 	if len(keyword) > 0 {
296 302
 		db = db.Where("x.name like ?", likeKey)
297 303
 	}
@@ -307,7 +313,6 @@ func GetHisPatientHistory(keyword string, startime int64, endtime int64, registt
307 313
 	if orgid > 0 {
308 314
 		db = db.Where("x.user_org_id = ?", orgid)
309 315
 	}
310
-	db = db.Preload("HisOrder", "status = 1 AND user_org_id = ?", orgid)
311 316
 	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number,x.is_return,x.doctor,x.ctime,x.social_type,x.phone,x.status").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Find(&hisPatient).Error
312 317
 	return hisPatient, total, err
313 318
 }
@@ -393,11 +398,9 @@ func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatien
393 398
 
394 399
 func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string, orgid int64) (prescription []*models.HisPrescription, err error) {
395 400
 
396
-	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1 and user_org_id = ?", orgid).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
397
-		return XTReadDB().Where("user_org_id=? and status=1", orgid).Preload("Drug", func(db *gorm.DB) *gorm.DB {
398
-			return XTReadDB().Where("status = 1")
399
-		})
400
-	}).Preload("HisPrescriptionProject", "status = 1 and user_org_id = ?", orgid).Preload("VMHisPrescriptionInfo", "status =1 and user_org_id = ?", orgid).Preload("XtHisAdditionalCharge", "status = 1 and user_org_id = ?", orgid).Find(&prescription).Error
401
+	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1 and user_org_id = ?", orgid).Preload("HisDoctorAdviceInfo", "status = 1 and user_org_id = ?", orgid).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
402
+		return db.Where("status = 1 AND user_org_id = ?", orgid).Preload("HisProject").Preload("GoodInfo", "status=1")
403
+	}).Preload("VMHisPrescriptionInfo", "status =1 and user_org_id = ?", orgid).Preload("XtHisAdditionalCharge", "status = 1 and user_org_id = ?", orgid).Find(&prescription).Error
401 404
 
402 405
 	return prescription, err
403 406
 }
@@ -541,7 +544,7 @@ func GetChargePrintTemplate(orgid int64) (models.XtHisChargeTemplate, error) {
541 544
 func GetDoctorProjectItem(patientid int64, record_date int64) (models.HisPrescriptionProject, error) {
542 545
 
543 546
 	project := models.HisPrescriptionProject{}
544
-	err := XTReadDB().Model(&project).Where("patient_id = ? and record_date = ? and status = 1", patientid, record_date).Preload("HisProject", "status = 1").Find(&project).Error
547
+	err := XTReadDB().Model(&project).Where("patient_id = ? and record_date = ? and status = 1", patientid, record_date).Preload("HisProject").Find(&project).Error
545 548
 	return project, err
546 549
 }
547 550
 
@@ -591,9 +594,9 @@ func GetPrscriptionInfo(patientid int64, recorddata int64) (info []*models.HisPr
591 594
 
592 595
 }
593 596
 
594
-func GetPrescriptionByPatientId(patient_id int64, startime int64) (prescritpion []*models.HisPrescription, err error) {
597
+func GetPrescriptionByPatientId(patient_id int64, startime int64, p_type int64) (prescritpion []*models.HisPrescription, err error) {
595 598
 
596
-	err = XTReadDB().Model(&prescritpion).Where("patient_id = ? and record_date =?", patient_id, startime).Find(&prescritpion).Error
599
+	err = XTReadDB().Model(&prescritpion).Where("patient_id = ? and record_date =? AND p_type = ?", patient_id, startime, p_type).Find(&prescritpion).Error
597 600
 	return prescritpion, err
598 601
 }
599 602
 
@@ -698,3 +701,14 @@ func GetLastItem(orgid int64) (models.XtHisProjectList, error) {
698 701
 	err := XTReadDB().Model(&list).Where("user_org_id = ? and status = 1", orgid).Last(&list).Error
699 702
 	return list, err
700 703
 }
704
+
705
+func SaveProjectTeam(team *models.XtHisProjectTeam) error {
706
+
707
+	err := XTWriteDB().Model(&team).Save(&team).Error
708
+	return err
709
+}
710
+
711
+func GetProjectHisListByIds(ids []string) (hisProjectList []*models.XtHisProjectList, error error) {
712
+	error = XTReadDB().Model(&hisProjectList).Preload("XtHisProject").Preload("GoodInfo", "status = 1").Where(" status = 1 and id in (?)", ids).Find(&hisProjectList).Error
713
+	return hisProjectList, error
714
+}

Diff nebyl zobrazen, protože je příliš veliký
+ 661 - 156
service/his_service.go


+ 14 - 0
service/mobile_dialysis_service.go Zobrazit soubor

@@ -1504,6 +1504,8 @@ type VMGoodInfo struct {
1504 1504
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
1505 1505
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id"`
1506 1506
 	OrgId             int64  `gorm:"column:org_id" json:"org_id"`
1507
+	GoodName          string `gorm:"column:good_name" json:"good_name" form:"good_name"`
1508
+	GoodUnit          int64  `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
1507 1509
 }
1508 1510
 
1509 1511
 func (VMGoodInfo) TableName() string {
@@ -2103,3 +2105,15 @@ func GetHisAdviceExecutionById(ids []string) (doctor []*models.HisDoctorAdviceIn
2103 2105
 	err = XTReadDB().Model(&doctor).Where("id IN(?) AND status = 1", ids).Find(&doctor).Error
2104 2106
 	return doctor, err
2105 2107
 }
2108
+
2109
+func GetHisProjectConfig(orgid int64) (models.XtHisProjectConfig, error) {
2110
+	config := models.XtHisProjectConfig{}
2111
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status =1", orgid).Find(&config).Error
2112
+	return config, err
2113
+}
2114
+
2115
+func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64) (project []*models.HisPrescriptionProject, err error) {
2116
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status=1").Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND type = 3", org_id, record_date, patient_id).Find(&project).Error
2117
+
2118
+	return
2119
+}

+ 16 - 15
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go Zobrazit soubor

@@ -531,21 +531,22 @@ type ScheduleVM struct {
531 531
 	BedID        int64 `gorm:"column:bed_id" json:"bed_id"`
532 532
 	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
533 533
 
534
-	Patient                  *PatientVM                    `gorm:"ForeignKey:PatientID" json:"patient"`
535
-	DialysisOrder            DialysisOrderVM               `gorm:"ForeignKey:DialysisDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"dialysis_order"`
536
-	Prescription             PrescriptionVM                `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"prescription"`
537
-	ReceiveAssessment        ReceiveAssessmentVM           `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"receive_assessment"`
538
-	XtReceiveTreatmentAsses  *XtReceiveTreatmentAsses      `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"xt_receive_assessment"`
539
-	AssessmentBeforeDislysis AssessmentBeforeDislysisVM    `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"assessment_before_dislysis"`
540
-	AssessmentAfterDislysis  AssessmentAfterDislysisVM     `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"assessment_after_dislysis"`
541
-	MonitoringRecords        []*MonitoringRecordVM         `gorm:"ForeignKey:MonitoringDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"monitor_records"`
542
-	DeviceNumber             *DeviceNumberVM               `gorm:"ForeignKey:BedID" json:"device_number"`
543
-	DeviceZone               *DeviceZoneVM                 `gorm:"ForeignKey:PartitionId" json:"device_zone"`
544
-	Advices                  []*DoctorAdviceVM             `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientId" json:"advices"`
545
-	DoubleCheck              *DoubleCheckVM                `gorm:"ForeignKey:CheckDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"check"`
546
-	Summer                   *SummerVM                     `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"summer"`
547
-	LastAfterWeight          XtAssessmentAfterDislysisVM   `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
548
-	HisAdvices               []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
534
+	Patient                  *PatientVM                       `gorm:"ForeignKey:PatientID" json:"patient"`
535
+	DialysisOrder            DialysisOrderVM                  `gorm:"ForeignKey:DialysisDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"dialysis_order"`
536
+	Prescription             PrescriptionVM                   `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"prescription"`
537
+	ReceiveAssessment        ReceiveAssessmentVM              `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"receive_assessment"`
538
+	XtReceiveTreatmentAsses  *XtReceiveTreatmentAsses         `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"xt_receive_assessment"`
539
+	AssessmentBeforeDislysis AssessmentBeforeDislysisVM       `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"assessment_before_dislysis"`
540
+	AssessmentAfterDislysis  AssessmentAfterDislysisVM        `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"assessment_after_dislysis"`
541
+	MonitoringRecords        []*MonitoringRecordVM            `gorm:"ForeignKey:MonitoringDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"monitor_records"`
542
+	DeviceNumber             *DeviceNumberVM                  `gorm:"ForeignKey:BedID" json:"device_number"`
543
+	DeviceZone               *DeviceZoneVM                    `gorm:"ForeignKey:PartitionId" json:"device_zone"`
544
+	Advices                  []*DoctorAdviceVM                `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientId" json:"advices"`
545
+	DoubleCheck              *DoubleCheckVM                   `gorm:"ForeignKey:CheckDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"check"`
546
+	Summer                   *SummerVM                        `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"summer"`
547
+	LastAfterWeight          XtAssessmentAfterDislysisVM      `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
548
+	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
549
+	HisProject               []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
549 550
 }
550 551
 
551 552
 func (ScheduleVM) TableName() string {

+ 3 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Zobrazit soubor

@@ -47,6 +47,9 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
47 47
 				Where("user_org_id = ? AND status = 1", orgID).
48 48
 				Order("start_time asc, groupno desc, advice_order desc, id asc")
49 49
 		}).
50
+		Preload("HisProject", func(db *gorm.DB) *gorm.DB {
51
+			return db.Where("user_org_id = ? AND status = 1", orgID).Preload("XtHisProject").Preload("GoodInfo", "status=1")
52
+		}).
50 53
 		Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).Order("schedule_date desc").
51 54
 		Find(&schedules).
52 55
 		Error

+ 2 - 0
service/self_drug_service.go Zobrazit soubor

@@ -532,6 +532,8 @@ type Drugs struct {
532 532
 	OrgId              int64    `gorm:"column:org_id" json:"org_id" form:"org_id"`
533 533
 	MinUnit            string   `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
534 534
 	Drugs              []*Drugs `gorm:"ForeignKey:DrugName;AssociationForeignKey:DrugName" json:"drug_specs"`
535
+	HospApprFlag       int64    `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
536
+	LmtUsedFlag        int64    `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
535 537
 }
536 538
 
537 539
 func (Drugs) TableName() string {

+ 23 - 2
service/stock_service.go Zobrazit soubor

@@ -463,6 +463,10 @@ func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err err
463 463
 
464 464
 }
465 465
 
466
+//func FindFirstWarehousingInfoByStock(good_id int64,good_type_id int64) (info models.WarehousingInfo, err error) {
467
+//	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND good_type_id = ? AND status = 1 and stock_count > 0", order).Order("ctime").First(&info).Error
468
+//	return info, err
469
+//}
466 470
 func FindFirstWarehousingInfoByStock(good_id int64, good_type_id int64) (info models.WarehousingInfo, err error) {
467 471
 	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND good_type_id = ? AND status = 1 and stock_count > 0", good_id, good_type_id).Order("ctime").First(&info).Error
468 472
 	return info, err
@@ -480,6 +484,12 @@ func FindLastWarehousingInfoByID(drug_id int64) (info models.WarehousingInfo, er
480 484
 	err = readDb.Model(&models.WarehousingInfo{}).Where("drup_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) ", drug_id).Order("ctime").First(&info).Error
481 485
 	return info, err
482 486
 }
487
+//
488
+//// 出库时先进先出,找出最先入库的批次
489
+//func  (drug_id int64) (info models.WarehousingInfo, err error) {
490
+//	err = readDb.Model(&models.WarehousingInfo{}).Where("drup_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) ", drug_id).Order("ctime").First(&info).Error
491
+//	return info, err
492
+//}
483 493
 
484 494
 func FindLastDrugWarehousingInfo(order string) (info models.DrugWarehouseInfo, err error) {
485 495
 	err = readDb.Model(&models.DrugWarehouseInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
@@ -1634,6 +1644,11 @@ func UpDateWarehouseInfoByStock(info *models.WarehousingInfo) (err error) {
1634 1644
 	return err
1635 1645
 }
1636 1646
 
1647
+//func UpDateWarehouseInfoByStockDelete(id int64,count int64) (err error) {
1648
+//	err = DB.Model(&models.WarehousingInfo{}).Where("id = ?",info.ID).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
1649
+//	return err
1650
+//}
1651
+
1637 1652
 func UpDateDrugWarehouseOutStatus(id int64) (err error) {
1638 1653
 	err = readDb.Model(&models.DrugWarehouseOutInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1639 1654
 	return
@@ -2362,9 +2377,15 @@ func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutI
2362 2377
 	return houseOutInfo, err
2363 2378
 }
2364 2379
 
2365
-func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error) {
2380
+func GetGoodInfomationList(orgid int64, keyword string) (goodInfo []*models.GoodInfo, err error) {
2381
+	key := "%" + keyword + "%"
2382
+	if len(keyword) == 0 {
2383
+		err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2384
+
2385
+	} else {
2386
+		err = XTReadDB().Where("org_id = ? and status = 1 AND good_name like ?", orgid, key).Find(&goodInfo).Error
2366 2387
 
2367
-	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2388
+	}
2368 2389
 	return goodInfo, err
2369 2390
 }
2370 2391
 

+ 8 - 0
service/user_service.go Zobrazit soubor

@@ -55,6 +55,14 @@ func GetAllAdminUsers(orgId, appid int64) (list []*AdminUserList, err error) {
55 55
 	return
56 56
 }
57 57
 
58
+func GetAllAdminUsersTwo(orgId int64) (list []*AdminUserList, err error) {
59
+	//fmt.Println("orgid", orgId)
60
+	//fmt.Println("appid", appid)
61
+	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type").Scan(&list).Error
62
+	//err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1  and ua.status=1").Select("ua.id, uar.user_name as name, uar.user_type").Scan(&list).Error
63
+	return
64
+}
65
+
58 66
 func GetAdminUser(orgId, appid, id int64) (*AdminUserList, error) {
59 67
 	var err error
60 68
 	var user AdminUserList

+ 547 - 0
service/warhouse_service.go Zobrazit soubor

@@ -871,6 +871,553 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
871 871
 				CreateAutoReduceRecord(&details)
872 872
 			}
873 873
 		}
874
+//
875
+//import (
876
+//	"XT_New/models"
877
+//	"XT_New/utils"
878
+//	"errors"
879
+//	"fmt"
880
+//	_ "fmt"
881
+//	"github.com/jinzhu/gorm"
882
+//	"math"
883
+//	"strconv"
884
+//	"strings"
885
+//	"time"
886
+//)
887
+//
888
+//// 药品出库
889
+//
890
+//func DrugsDelivery(orgID int64, advice *models.DoctorAdvice) (err error) {
891
+//	// 1.判断药品是否来自专用字典的药品库
892
+//	// 2.判断当天当前机构有没有创建出库单,没有则创建
893
+//	// 3.创建出库流程
894
+//	// 3.1 实现先进先出逻辑 由于药品执行后,不可以修改和删除,所以不考虑出库后的退库和修改出库数量等
895
+//	isHasWay := false
896
+//	record_time := int64(0)
897
+//	if advice.Way == 1 {
898
+//		isHasWay = true
899
+//		record_time = advice.RecordDate
900
+//	}
901
+//	if isHasWay {
902
+//		//判断当天当前机构有没有创建出库单,没有则创建
903
+//		out, err := FindDrugStockOutByIsSys(orgID, 1, record_time)
904
+//		if err == gorm.ErrRecordNotFound {
905
+//			timeStr := time.Now().Format("2006-01-02")
906
+//			timeArr := strings.Split(timeStr, "-")
907
+//			total, _ := FindAllDrugWarehouseOut(orgID)
908
+//			total = total + 1
909
+//			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
910
+//			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
911
+//			number = number + total
912
+//			warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
913
+//			// creater := adminUserInfo.AdminUser.Id
914
+//			warehouseOut := models.DrugWarehouseOut{
915
+//				WarehouseOutOrderNumber: warehousing_out_order,
916
+//				OperationTime:           time.Now().Unix(),
917
+//				OrgId:                   orgID,
918
+//				Creater:                 0,
919
+//				Ctime:                   time.Now().Unix(),
920
+//				Status:                  1,
921
+//				WarehouseOutTime:        record_time,
922
+//				Dealer:                  0,
923
+//				Manufacturer:            0,
924
+//				Type:                    1,
925
+//				IsSys:                   1,
926
+//			}
927
+//			err := AddSigleDrugWarehouseOut(&warehouseOut)
928
+//			if err != nil {
929
+//				utils.TraceLog("创建出库单失败 err = %v", err)
930
+//				return err
931
+//			} else {
932
+//				out = warehouseOut
933
+//			}
934
+//		}
935
+//
936
+//		// 出库流程
937
+//		// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
938
+//		drup, _ := FindBaseDrugLibRecord(orgID, advice.DrugId)
939
+//		if drup.ID > 0 {
940
+//			prescribingNumber := advice.PrescribingNumber
941
+//			DrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice)
942
+//		} else {
943
+//			return errors.New("药品信息不存在")
944
+//		}
945
+//
946
+//	}
947
+//
948
+//	return
949
+//}
950
+//
951
+//// 药品出库 递归方式
952
+//func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DoctorAdvice) (err error) {
953
+//	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
954
+//	var deliver_number int64 = 0
955
+//	var stock_number int64 = 0
956
+//
957
+//	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
958
+//	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
959
+//	if advice.PrescribingNumberUnit == drup.MaxUnit {
960
+//		deliver_number = count * drup.MinNumber
961
+//	} else {
962
+//		deliver_number = count
963
+//	}
964
+//
965
+//	// 根据先进先出原则,查询最先入库的批次,进行出库
966
+//	// 如果没有对应的库存,则报错
967
+//	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId)
968
+//	fmt.Println("查询222222222222222222222222222222222222222222222222", err)
969
+//	if err != nil {
970
+//		return err
971
+//	}
972
+//
973
+//	// 将该批次的剩余库存数量转换为拆零数量
974
+//	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
975
+//	// 当库存数量大于或等于出库数量的话,则正常出库该批次
976
+//	if stock_number >= deliver_number {
977
+//		warehouseOutInfo := &models.DrugWarehouseOutInfo{
978
+//			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
979
+//			WarehouseOutId:          warehouseout.ID,
980
+//			Status:                  1,
981
+//			Ctime:                   time.Now().Unix(),
982
+//			Remark:                  "",
983
+//			OrgId:                   orgID,
984
+//			Type:                    1,
985
+//			Manufacturer:            0,
986
+//			Dealer:                  0,
987
+//			IsSys:                   1,
988
+//			SysRecordTime:           advice.RecordDate,
989
+//			DrugId:                  advice.DrugId,
990
+//		}
991
+//		warehouseOutInfo.Count = deliver_number
992
+//		warehouseOutInfo.CountUnit = drup.MinUnit
993
+//		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
994
+//		if errOne != nil {
995
+//			return errOne
996
+//		} else {
997
+//			// prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
998
+//			// count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
999
+//			details := &models.DrugAutomaticReduceDetail{
1000
+//				WarehouseOutId:          warehouseOutInfo.ID,
1001
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1002
+//				PatientId:               advice.PatientId,
1003
+//				Ctime:                   time.Now().Unix(),
1004
+//				Mtime:                   time.Now().Unix(),
1005
+//				Status:                  1,
1006
+//				RecordTime:              advice.RecordDate,
1007
+//				OrgId:                   orgID,
1008
+//				DrugId:                  advice.DrugId,
1009
+//				Count:                   deliver_number,
1010
+//				CountUnit:               drup.MinUnit,
1011
+//			}
1012
+//			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
1013
+//			if errTwo != nil {
1014
+//				return errTwo
1015
+//			}
1016
+//		}
1017
+//		// 出库完成后,要减去对应批次的库存数量
1018
+//		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
1019
+//		var maxNumber int64 = 0
1020
+//		var minNumber int64 = 0
1021
+//		if advice.PrescribingNumberUnit == drup.MinUnit {
1022
+//			maxNumber = count / drup.MinNumber
1023
+//			minNumber = count % drup.MinNumber
1024
+//		} else {
1025
+//			maxNumber = count
1026
+//		}
1027
+//
1028
+//		if warehouse.StockMaxNumber < maxNumber {
1029
+//			return errors.New("库存数量不足")
1030
+//		}
1031
+//
1032
+//		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
1033
+//		warehouse.Mtime = time.Now().Unix()
1034
+//		if warehouse.StockMinNumber < minNumber {
1035
+//			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
1036
+//			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
1037
+//		} else {
1038
+//			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
1039
+//		}
1040
+//
1041
+//		if warehouse.StockMaxNumber < 0 {
1042
+//			return errors.New("库存数量不足")
1043
+//		}
1044
+//		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
1045
+//		if errThree != nil {
1046
+//			return errThree
1047
+//		}
1048
+//
1049
+//		return nil
1050
+//	} else {
1051
+//		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1052
+//		warehouseOutInfo := &models.DrugWarehouseOutInfo{
1053
+//			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
1054
+//			WarehouseOutId:          warehouseout.ID,
1055
+//			Status:                  1,
1056
+//			Ctime:                   time.Now().Unix(),
1057
+//			Remark:                  "",
1058
+//			OrgId:                   orgID,
1059
+//			Type:                    1,
1060
+//			Manufacturer:            0,
1061
+//			Dealer:                  0,
1062
+//			IsSys:                   1,
1063
+//			SysRecordTime:           advice.RecordDate,
1064
+//			DrugId:                  advice.DrugId,
1065
+//		}
1066
+//		// prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1067
+//		// count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1068
+//		warehouseOutInfo.Count = stock_number
1069
+//		warehouseOutInfo.CountUnit = drup.MinUnit
1070
+//
1071
+//		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1072
+//		if errOne != nil {
1073
+//			return errOne
1074
+//		} else {
1075
+//			details := &models.DrugAutomaticReduceDetail{
1076
+//				WarehouseOutId:          warehouseOutInfo.ID,
1077
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1078
+//				PatientId:               advice.PatientId,
1079
+//				Ctime:                   time.Now().Unix(),
1080
+//				Mtime:                   time.Now().Unix(),
1081
+//				Status:                  1,
1082
+//				RecordTime:              advice.RecordDate,
1083
+//				OrgId:                   orgID,
1084
+//				DrugId:                  advice.DrugId,
1085
+//				Count:                   stock_number,
1086
+//				CountUnit:               drup.MinUnit,
1087
+//			}
1088
+//			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
1089
+//			if errTwo != nil {
1090
+//				return errTwo
1091
+//			}
1092
+//		}
1093
+//		// 出库完成后,要将该批次库存清零
1094
+//		warehouse.StockMaxNumber = 0
1095
+//		warehouse.StockMinNumber = 0
1096
+//		warehouse.Mtime = time.Now().Unix()
1097
+//		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
1098
+//		if errThree != nil {
1099
+//			return errThree
1100
+//		}
1101
+//		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1102
+//		prescribingNumber_two_temp := deliver_number - stock_number
1103
+//		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
1104
+//		advice.PrescribingNumberUnit = drup.MinUnit
1105
+//		DrugDeliverInfo(orgID, prescribingNumber, warehouseout, drup, advice)
1106
+//	}
1107
+//	return
1108
+//}
1109
+//
1110
+//// 耗材出库
1111
+//func ConsumablesDeliveryTotal(orgID int64,patient_id int64,record_time int64,goods []models.DialysisBeforePrepareGoods) (err error) {
1112
+//	//查询该患者当天已经出库的耗材信息
1113
+//	goods_yc,_ := FindConsumablesByDateTwo(orgID, patient_id, record_time)
1114
+//	// 和新请求的出库数据进行对比,分出那些是继续出库的,那些是需要删除出库的
1115
+//	for i := len(goods_yc) - 1; i >= 0; i--{
1116
+//		goods_yc_temp := goods_yc[i]
1117
+//		for j := len(goods) - 1; j >= 0; j-- {
1118
+//			goods_temp := goods[j]
1119
+//			// 已经出库和新请求出库都存在该耗材,则判断出库数量,分成是继续出库,还是删除出库
1120
+//			if goods_yc_temp.GoodTypeId == goods_temp.GoodTypeId && goods_yc_temp.GoodId == goods_temp.GoodId{
1121
+//				// 已经出库和新请求出库的出库数量一致,则清除两个结构体里的数据(既不出库,也不删除出库)
1122
+//				if goods_yc_temp.Count == goods_temp.Count {
1123
+//					goods_yc = append(goods_yc[:i],goods_yc[i+1:]...)
1124
+//					goods = append(goods[:j],goods[j+1:]...)
1125
+//				}
1126
+//
1127
+//				// 如果已经出库的数量 大于 新请求出库的数量,则代表需要删除出库
1128
+//				if goods_yc_temp.Count > goods_temp.Count {
1129
+//					temp_count := goods_yc_temp.Count - goods_temp.Count
1130
+//					goods_yc[i].Count = temp_count
1131
+//					goods = append(goods[:j],goods[j+1:]...)
1132
+//				}
1133
+//
1134
+//				// 如果已经出库的数量 小于 新请求出库的梳理,则代表需要增加出库
1135
+//				if goods_yc_temp.Count < goods_temp.Count {
1136
+//					temp_count := goods_temp.Count - goods_yc_temp.Count
1137
+//					goods[j].Count = temp_count
1138
+//					goods_yc = append(goods_yc[:i],goods_yc[i+1:]...)
1139
+//				}
1140
+//			}
1141
+//		}
1142
+//	}
1143
+//
1144
+//	// goods_yc 这个数据就是需要已经出库了,但是现在需要删除出库的耗材数据
1145
+//	// goods 这个数据就是需要出库的耗材的数据
1146
+//	if len(goods) > 0 {
1147
+//		out, err := FindStockOutByIsSys(orgID, 1, record_time)
1148
+//		if err == gorm.ErrRecordNotFound {
1149
+//			//没有记录,则创建出库单
1150
+//			timeStr := time.Now().Format("2006-01-02")
1151
+//			timeArr := strings.Split(timeStr, "-")
1152
+//			total, _ :=  FindAllWarehouseOut(orgID)
1153
+//			total = total + 1
1154
+//			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1155
+//			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1156
+//			number = number + total
1157
+//			warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1158
+//			warehouseOut := models.WarehouseOut{
1159
+//				WarehouseOutOrderNumber: warehousing_out_order,
1160
+//				OperationTime:           time.Now().Unix(),
1161
+//				OrgId:                   orgID,
1162
+//				Creater:                 0,
1163
+//				Ctime:                   time.Now().Unix(),
1164
+//				Status:                  1,
1165
+//				WarehouseOutTime:        record_time,
1166
+//				Dealer:                  0,
1167
+//				Manufacturer:            0,
1168
+//				Type:                    1,
1169
+//				IsSys:                   1,
1170
+//			}
1171
+//			err := AddSigleWarehouseOut(&warehouseOut)
1172
+//			if err != nil {
1173
+//				utils.TraceLog("创建出库单失败 err = %v", err)
1174
+//				return err
1175
+//			} else {
1176
+//				out = warehouseOut
1177
+//			}
1178
+//		}
1179
+//		for _,good := range goods {
1180
+//			ConsumablesDelivery(orgID ,patient_id ,record_time ,good,out )
1181
+//		}
1182
+//	}
1183
+//
1184
+//	if len(goods_yc) > 0 {
1185
+//		for _,good_yc := range goods_yc{
1186
+//			ConsumablesDeliveryDelete(orgID ,patient_id ,record_time ,good_yc ,out )
1187
+//		}
1188
+//	}
1189
+//
1190
+//	return nil
1191
+//}
1192
+//
1193
+//// 耗材出库
1194
+//func ConsumablesDelivery(orgID int64,patient_id int64,record_time int64,goods models.DialysisBeforePrepareGoods,warehouseOut models.WarehouseOut) (err error) {
1195
+//	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
1196
+//	var deliver_number int64 = 0
1197
+//	var stock_number int64 = 0
1198
+//
1199
+//	deliver_number = good.Count
1200
+//
1201
+//
1202
+//	// 根据先进先出原则,查询最先入库的批次,进行出库
1203
+//	// 如果没有对应的库存,则报错
1204
+//	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId,goods.GoodTypeId)
1205
+//	if err != nil {
1206
+//		return err
1207
+//	}
1208
+//
1209
+//	// 将该批次的剩余库存数量转换为拆零数量
1210
+//	stock_number = warehouse.StockCount
1211
+//	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1212
+//	if stock_number >= deliver_number {
1213
+//		warehouseOutInfo := &models.WarehouseOutInfo{
1214
+//			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1215
+//			WarehouseOutId:          warehouseOut.ID,
1216
+//			WarehouseInfoId:		 warehouse.ID,
1217
+//			Status:                  1,
1218
+//			Ctime:                   time.Now().Unix(),
1219
+//			Remark:                  "",
1220
+//			OrgId:                   orgID,
1221
+//			Type:                    1,
1222
+//			Manufacturer:            0,
1223
+//			Dealer:                  0,
1224
+//			IsSys:                   1,
1225
+//			SysRecordTime:           record_time,
1226
+//			GoodTypeId:              goods.GoodTypeId,
1227
+//			GoodId:                  goods.GoodId,
1228
+//			PatientId:				 patient_id,
1229
+//		}
1230
+//		warehouseOutInfo.Count = goods.Count
1231
+//		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1232
+//		warehouseOutInfo.Price = stockInInfo.Price
1233
+//		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1234
+//		if errOne != nil {
1235
+//			return errOne
1236
+//		} else {
1237
+//			details := &models.AutomaticReduceDetail{
1238
+//				WarehouseOutId:          warehouseOutInfo.ID,
1239
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1240
+//				PatientId:               patient_id,
1241
+//				Ctime:                   time.Now().Unix(),
1242
+//				Mtime:                   time.Now().Unix(),
1243
+//				Status:                  1,
1244
+//				RecordTime:              record_time,
1245
+//				OrgId:                   orgID,
1246
+//				GoodId:                  goods.GoodId,
1247
+//				GoodTypeId:              goods.GoodTypeId,
1248
+//				Count:                   goods.Count,
1249
+//			}
1250
+//			errTwo := service.AddSigleAutoReduceRecordInfo(details)
1251
+//			if errTwo != nil {
1252
+//				return errTwo
1253
+//			}
1254
+//		}
1255
+//
1256
+//		// 出库完成后,要减去对应批次的库存数量
1257
+//
1258
+//		maxNumber = goods.Count
1259
+//
1260
+//
1261
+//		if warehouse.StockMaxNumber < maxNumber {
1262
+//			return errors.New("库存数量不足")
1263
+//		}
1264
+//
1265
+//		warehouse.StockNumber = warehouse.StockMaxNumber - maxNumber
1266
+//		warehouse.Mtime = time.Now().Unix()
1267
+//
1268
+//
1269
+//		if warehouse.StockNumber < 0 {
1270
+//			return errors.New("库存数量不足")
1271
+//		}
1272
+//		errThree := UpDateWarehouseInfoByStock(&warehouse)
1273
+//		if errThree != nil {
1274
+//			return errThree
1275
+//		}
1276
+//
1277
+//		return nil
1278
+//	}  else {
1279
+//		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1280
+//		warehouseOutInfo := &models.WarehouseOutInfo{
1281
+//			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1282
+//			WarehouseOutId:          warehouseOut.ID,
1283
+//			WarehouseInfoId:		 warehouse.ID,
1284
+//			Status:                  1,
1285
+//			Ctime:                   time.Now().Unix(),
1286
+//			Remark:                  "",
1287
+//			OrgId:                   orgID,
1288
+//			Type:                    1,
1289
+//			Manufacturer:            0,
1290
+//			Dealer:                  0,
1291
+//			IsSys:                   1,
1292
+//			SysRecordTime:           record_time,
1293
+//			GoodTypeId:              goods..GoodTypeId,
1294
+//			GoodId:                  goods.GoodId,
1295
+//			PatientId:				 patient_id,
1296
+//		}
1297
+//		warehouseOutInfo.Count = stock_number
1298
+//		stockInInfo, _ := service.FindLastStockInInfoRecord(goods.GoodId, orgID)
1299
+//		warehouseOutInfo.Price = stockInInfo.Price
1300
+//		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1301
+//		if errOne != nil {
1302
+//			return errOne
1303
+//		} else {
1304
+//			details := &models.AutomaticReduceDetail{
1305
+//				WarehouseOutId:          warehouseOutInfo.ID,
1306
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1307
+//				PatientId:               patient_id,
1308
+//				Ctime:                   time.Now().Unix(),
1309
+//				Mtime:                   time.Now().Unix(),
1310
+//				Status:                  1,
1311
+//				RecordTime:              record_time,
1312
+//				OrgId:                   orgID,
1313
+//				GoodId:                  goods.GoodId,
1314
+//				GoodTypeId:              goods.GoodTypeId,
1315
+//				Count:                   goods.Count,
1316
+//			}
1317
+//			errTwo := service.AddSigleAutoReduceRecordInfo(details)
1318
+//			if errTwo != nil {
1319
+//				return errTwo
1320
+//			}
1321
+//		}
1322
+//		// 出库完成后,要将该批次库存清零
1323
+//		warehouse.StockNumber = 0
1324
+//		warehouse.Mtime = time.Now().Unix()
1325
+//		errThree := UpDateWarehouseInfoByStock(&warehouse)
1326
+//		if errThree != nil {
1327
+//			return errThree
1328
+//		}
1329
+//		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1330
+//		goods.Count := deliver_number - stock_number
1331
+//
1332
+//		ConsumablesDelivery(orgID ,patient_id ,record_time ,good,out )
1333
+//	}
1334
+//	return nil
1335
+//}
1336
+//
1337
+//// 耗材出库删除
1338
+//func ConsumablesDeliveryDelete(orgID int64,patient_id int64,record_time int64,good_yc models.DialysisBeforePrepare,warehouseOut models.WarehouseOut) (err error) {
1339
+//	// 先根据相关信息查询当天该耗材的出库信息
1340
+//	warehouseOutInfos,err :=FindStockOutInfoByStock(orgID,good_yc.GoodTypeId,good_yc.GoodId,record_time,patient_id)
1341
+//	if err != nil {
1342
+//		return err
1343
+//	}
1344
+//
1345
+//	var delete_count int64 = 0
1346
+//
1347
+//	for _ , ware := range warehouseOutInfos{
1348
+//		// 判断当前出库的数据和删除出库数量
1349
+//		if good_yc.Count <= ware.Count {
1350
+//			delete_count = good_yc.Count
1351
+//		} else {
1352
+//			delete_count = ware.Count
1353
+//		}
1354
+//		// 在出库记录表里记录退库详情
1355
+//		warehouseOutInfo := &models.WarehouseOutInfo{
1356
+//			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1357
+//			WarehouseOutId:          warehouseOut.ID,
1358
+//			WarehouseInfoId:		 warehouse.ID,
1359
+//			Status:                  1,
1360
+//			Ctime:                   time.Now().Unix(),
1361
+//			Remark:                  "",
1362
+//			OrgId:                   orgID,
1363
+//			Type:                    1,
1364
+//			Manufacturer:            0,
1365
+//			Dealer:                  0,
1366
+//			IsSys:                   2,
1367
+//			SysRecordTime:           record_time,
1368
+//			GoodTypeId:              goods..GoodTypeId,
1369
+//			GoodId:                  goods.GoodId,
1370
+//			PatientId:				 patient_id,
1371
+//		}
1372
+//		warehouseOutInfo.Count = delete_count
1373
+//		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
1374
+//		warehouseOutInfo.Price = stockInInfo.Price
1375
+//		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1376
+//		if errOne != nil {
1377
+//			return errOne
1378
+//		} else {
1379
+//			details := &models.AutomaticReduceDetail{
1380
+//				WarehouseOutId:          warehouseOutInfo.ID,
1381
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1382
+//				PatientId:               patient_id,
1383
+//				Ctime:                   time.Now().Unix(),
1384
+//				Mtime:                   time.Now().Unix(),
1385
+//				Status:                  1,
1386
+//				RecordTime:              record_time,
1387
+//				OrgId:                   orgID,
1388
+//				GoodId:                  goods.GoodId,
1389
+//				GoodTypeId:              goods.GoodTypeId,
1390
+//				Count:                   delete_count,
1391
+//				Type:					 2,
1392
+//			}
1393
+//			errTwo := AddSigleAutoReduceRecordInfo(details)
1394
+//			if errTwo != nil {
1395
+//				return errTwo
1396
+//			}
1397
+//		}
1398
+//
1399
+//		// 删除出库完成后,要增加对应批次的库存数量
1400
+//
1401
+//
1402
+//
1403
+//		errThree := UpDateWarehouseInfoByStockDelete(ware.WarehouseInfoId,delete_count)
1404
+//		if errThree != nil {
1405
+//			return errThree
1406
+//		}
1407
+//
1408
+//		// 增加了对应的库存后,看看还有多少需要退库的
1409
+//		good_yc.Count = goods_yc.Count - delete_count
1410
+//		if good_yc.Count == 0 {
1411
+//			return nil
1412
+//		}
1413
+//	}
1414
+//
1415
+//	if good_yd.Count == 0 {
1416
+//		return nil
1417
+//	}  else {
1418
+//		return errors.New("退库和出库数据不匹配")
1419
+//	}
1420
+//}
874 1421
 
875 1422
 		// 出库完成后,要减去对应批次的库存数量
876 1423