Browse Source

医保对接

csx 3 years ago
parent
commit
246699b123
36 changed files with 3257 additions and 475 deletions
  1. 6 6
      controllers/base_api_controller.go
  2. 47 18
      controllers/dialysis_api_controller.go
  3. 1 0
      controllers/dialysis_record_api_controller.go
  4. 89 4
      controllers/gobal_config_api_controller.go
  5. 530 63
      controllers/his_api_controller.go
  6. 403 0
      controllers/his_config_api_controller.go
  7. 317 0
      controllers/his_hospital_api_controller.go
  8. 190 60
      controllers/his_project_api_controller.go
  9. 53 19
      controllers/mobile_api_controllers/dialysis_api_controller.go
  10. 5 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  11. 121 2
      controllers/mobile_api_controllers/patient_api_controller.go
  12. 81 11
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  13. 32 0
      controllers/public_api_controller.go
  14. 17 0
      controllers/role_controller.go
  15. 22 5
      controllers/schedule_api_controller.go
  16. 134 54
      controllers/stock_in_api_controller.go
  17. 1 0
      models/dialysis.go
  18. 10 1
      models/drug.go
  19. 10 0
      models/drug_stock.go
  20. 80 0
      models/his_hospital_models.go
  21. 334 41
      models/his_models.go
  22. 4 1
      routers/router.go
  23. 15 0
      service/app_version.go
  24. 42 4
      service/dialysis_service.go
  25. 32 2
      service/gobal_config_service.go
  26. 48 0
      service/his_config_service.go
  27. 174 0
      service/his_hospital_service.go
  28. 23 8
      service/his_project_service.go
  29. 344 153
      service/his_service.go
  30. 14 0
      service/mobile_dialysis_service.go
  31. 16 1
      service/patient_service.go
  32. 16 15
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  33. 3 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  34. 18 0
      service/schedule_service.go
  35. 1 1
      service/self_drug_service.go
  36. 24 6
      service/stock_service.go

+ 6 - 6
controllers/base_api_controller.go View File

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 1
84
-		subscibe.OrgId = 3877
84
+		subscibe.OrgId = 4
85 85
 		subscibe.PeriodStart = 1538035409
86 86
 		subscibe.PeriodEnd = 1569571409
87 87
 		subscibe.State = 1
@@ -91,14 +91,14 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 3877
94
+		adminUserInfo.CurrentOrgId = 4
95 95
 		adminUserInfo.CurrentAppId = 4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
98 98
 		this.SetSession("admin_user_info", &adminUserInfo)
99 99
 
100
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
-		//this.StopRun()
100
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
+		this.StopRun()
102 102
 
103 103
 	}
104 104
 
@@ -327,7 +327,7 @@ func (this *BaseServeAPIController) Prepare() {
327 327
 		userAdmin.ModifyTime = 1530786071
328 328
 		var subscibe models.ServeSubscibe
329 329
 		subscibe.ID = 1
330
-		subscibe.OrgId = 3877
330
+		subscibe.OrgId = 4
331 331
 		subscibe.PeriodStart = 1538035409
332 332
 		subscibe.PeriodEnd = 1569571409
333 333
 		subscibe.State = 1
@@ -337,7 +337,7 @@ func (this *BaseServeAPIController) Prepare() {
337 337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338 338
 		subscibes[4] = &subscibe
339 339
 		var adminUserInfo service.AdminUserInfo
340
-		adminUserInfo.CurrentOrgId = 3877
340
+		adminUserInfo.CurrentOrgId = 4
341 341
 		adminUserInfo.CurrentAppId = 4
342 342
 		adminUserInfo.AdminUser = &userAdmin
343 343
 		adminUserInfo.Subscibes = subscibes

+ 47 - 18
controllers/dialysis_api_controller.go View File

@@ -327,11 +327,11 @@ func (c *DialysisApiController) PostPrescription() {
327 327
 		PreImpulse:                 preImpules,
328 328
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
329 329
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
330
-		Blood:                    blood,
331
-		DialysisDialyszers:       dialysis_dialyszers,
332
-		DialysisIrrigation:       dialysis_irrigation,
333
-		AntioxidantCommodityName: antioxidant_commodity_name,
334
-		DisplaceSpeed:            displace_speed,
330
+		Blood:                      blood,
331
+		DialysisDialyszers:         dialysis_dialyszers,
332
+		DialysisIrrigation:         dialysis_irrigation,
333
+		AntioxidantCommodityName:   antioxidant_commodity_name,
334
+		DisplaceSpeed:              displace_speed,
335 335
 	}
336 336
 
337 337
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -656,11 +656,11 @@ func (c *DialysisApiController) PostSoulution() {
656 656
 
657 657
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
658 658
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
659
-		Blood:                    blood,
660
-		DialysisIrrigation:       dialysis_irrigation,
661
-		DialysisDialyszers:       dialysis_dialyszers,
662
-		AntioxidantCommodityName: antioxidant_commodity_name,
663
-		DisplaceSpeed:            displace_speed,
659
+		Blood:                     blood,
660
+		DialysisIrrigation:        dialysis_irrigation,
661
+		DialysisDialyszers:        dialysis_dialyszers,
662
+		AntioxidantCommodityName:  antioxidant_commodity_name,
663
+		DisplaceSpeed:             displace_speed,
664 664
 	}
665 665
 
666 666
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1100,7 +1100,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1100 1100
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1101 1101
 		return
1102 1102
 	}
1103
-	fmt.Println("丰管业配置", data.SealingFluidDispose)
1103
+
1104 1104
 	assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1105 1105
 	assessment.DialysisOrderId = data.DialysisOrderId
1106 1106
 	assessment.Evaluator = adminUserInfo.AdminUser.Id
@@ -1163,6 +1163,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1163 1163
 	assessment.DiastolicPressure = data.DiastolicPressure
1164 1164
 	assessment.AdditionalWeight = data.AdditionalWeight
1165 1165
 	assessment.OtherComplication = data.OtherComplication
1166
+	assessment.Ktv = data.Ktv
1166 1167
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1167 1168
 
1168 1169
 	if assessment.ID > 0 {
@@ -2459,7 +2460,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
2459 2460
 	dialysisway, err := service.FindDialysisWay(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2460 2461
 	//获取临时医嘱
2461 2462
 	doctorAdvice, _ := service.FindDoctorOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2462
-	config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2463
+	//config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2463 2464
 
2464 2465
 	//获取医嘱内容
2465 2466
 	doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
@@ -2515,6 +2516,33 @@ func (c *DialysisApiController) GetDialysisOrder() {
2515 2516
 
2516 2517
 	//获取his数据
2517 2518
 	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2519
+
2520
+	//hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2521
+	config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
2522
+
2523
+	project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
2524
+	projects, _ := service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2525
+	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
2526
+		for _, item := range projects {
2527
+			var advice *models.HisDoctorAdviceInfo
2528
+			advice.ID = item.ID
2529
+			advice.Checker = item.Checker
2530
+			advice.CheckTime = item.CheckTime
2531
+			advice.CheckState = item.CheckState
2532
+			advice.ExecutionState = item.ExecutionState
2533
+			advice.ExecutionStaff = item.ExecutionStaff
2534
+			advice.PrescribingNumber = float64(item.Count)
2535
+			advice.PrescribingNumberUnit = item.Unit
2536
+			advice.AdviceDoctor = item.Doctor
2537
+			if item.Type == 3 {
2538
+				advice.AdviceName = item.GoodInfo.GoodName
2539
+			} else if item.Type == 2 {
2540
+				advice.AdviceName = item.HisProject.ProjectName
2541
+			}
2542
+			advice.StartTime = item.StartTime
2543
+			hisAdvice = append(hisAdvice, advice)
2544
+		}
2545
+	}
2518 2546
 	if config.IsOpen == 1 {
2519 2547
 		c.ServeSuccessJSON(map[string]interface{}{
2520 2548
 			"xtdate":                    xtdate,
@@ -3010,12 +3038,13 @@ func (c *DialysisApiController) GetSchedule() {
3010 3038
 	schedual_type, _ := c.GetInt64("schedual_type")
3011 3039
 	adminUserInfo := c.GetAdminUserInfo()
3012 3040
 
3013
-	timeLayout := "2006-01-02 15:04:05"
3014
-
3015
-	date := time.Now().Format("2006-01-02") + " 00:00:00"
3016
-	loc, _ := time.LoadLocation("Local")
3017
-	theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3018
-	scheduleTime := theStartTime.Unix()
3041
+	//timeLayout := "2006-01-02 15:04:05"
3042
+	//
3043
+	//date := time.Now().Format("2006-01-02") + " 00:00:00"
3044
+	//loc, _ := time.LoadLocation("Local")
3045
+	//theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3046
+	//scheduleTime := theStartTime.Unix()
3047
+	scheduleTime, _ := c.GetInt64("record_date")
3019 3048
 
3020 3049
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
3021 3050
 

+ 1 - 0
controllers/dialysis_record_api_controller.go View File

@@ -553,6 +553,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
553 553
 func (this *DialysisRecordAPIController) StartDialysis() {
554 554
 	patientID, _ := this.GetInt64("patient_id")
555 555
 	recordDateStr := this.GetString("date")
556
+	fmt.Println("上机日期222222222222222222222222", recordDateStr)
556 557
 	nurseID, _ := this.GetInt64("nurse")
557 558
 	punctureNurseId, _ := this.GetInt64("puncture_nurse")
558 559
 	startDateStr := this.GetString("start_time")

+ 89 - 4
controllers/gobal_config_api_controller.go View File

@@ -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")
@@ -84,7 +86,7 @@ func GobalConfigRegistRouters() {
84 86
 	beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
85 87
 	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
86 88
 	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
87
-
89
+	beego.Router("/api/drugstock/getdrugautomaticlist", &GobalConfigApiController{}, "Get:GetDrugAutoMaticList")
88 90
 }
89 91
 
90 92
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1379,20 +1381,80 @@ func (c *GobalConfigApiController) PostXTHisConfig() {
1379 1381
 
1380 1382
 	return
1381 1383
 }
1384
+
1385
+func (c *GobalConfigApiController) PostXTHisProjectConfig() {
1386
+	is_open, _ := c.GetBool("is_open", false)
1387
+	adminUserInfo := c.GetAdminUserInfo()
1388
+	org_id := adminUserInfo.CurrentOrgId
1389
+	isOpen := 0
1390
+
1391
+	if is_open {
1392
+		isOpen = 1
1393
+	} else {
1394
+		isOpen = 2
1395
+	}
1396
+
1397
+	config := models.XtHisProjectConfig{
1398
+		UserOrgId: org_id,
1399
+		IsOpen:    int64(isOpen),
1400
+		Status:    1,
1401
+		Ctime:     time.Now().Unix(),
1402
+		Mtime:     time.Now().Unix(),
1403
+	}
1404
+
1405
+	errs, configs := service.FindXTHisProjectByOrgId(org_id)
1406
+
1407
+	if errs == gorm.ErrRecordNotFound {
1408
+		err := service.CreateXTHisProjectRecord(&config)
1409
+		if err != nil {
1410
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1411
+			return
1412
+		}
1413
+
1414
+	} else if errs == nil {
1415
+		modifyConfig := models.XtHisProjectConfig{
1416
+			ID:        configs.ID,
1417
+			UserOrgId: org_id,
1418
+			Status:    1,
1419
+			Ctime:     time.Now().Unix(),
1420
+			Mtime:     time.Now().Unix(),
1421
+			IsOpen:    int64(isOpen),
1422
+		}
1423
+
1424
+		err := service.UpdateXTHisProjectRecord(&modifyConfig)
1425
+		if err != nil {
1426
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1427
+			return
1428
+		}
1429
+
1430
+	}
1431
+
1432
+	c.ServeSuccessJSON(map[string]interface{}{
1433
+		"is_open": is_open,
1434
+	})
1435
+
1436
+	return
1437
+}
1438
+
1382 1439
 func (c *GobalConfigApiController) GetXTHisConfig() {
1383 1440
 	adminUserInfo := c.GetAdminUserInfo()
1384 1441
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1442
+	_, project_config := service.FindXTHisProjectByOrgId(adminUserInfo.CurrentOrgId)
1443
+
1385 1444
 	c.ServeSuccessJSON(map[string]interface{}{
1386
-		"config": config,
1445
+		"config":         config,
1446
+		"project_config": project_config,
1387 1447
 	})
1388 1448
 }
1389 1449
 
1390 1450
 func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1391 1451
 	adminUserInfo := c.GetAdminUserInfo()
1392 1452
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1453
+	_, project_config := service.FindXTHisProjectByOrgId(adminUserInfo.CurrentOrgId)
1393 1454
 
1394 1455
 	c.ServeSuccessJSON(map[string]interface{}{
1395
-		"is_open_xt_his": config.IsOpen,
1456
+		"is_open_xt_his":         config.IsOpen,
1457
+		"is_open_xt_his_project": project_config.IsOpen,
1396 1458
 	})
1397 1459
 
1398 1460
 }
@@ -1404,6 +1466,8 @@ func (c *GobalConfigApiController) GetPassExportData() {
1404 1466
 func (c *GobalConfigApiController) GetExportData() {
1405 1467
 	start_time := c.GetString("start_time")
1406 1468
 	end_time := c.GetString("end_time")
1469
+	p_type, _ := c.GetInt64("p_type")
1470
+
1407 1471
 	timeLayout := "2006-01-02"
1408 1472
 	loc, _ := time.LoadLocation("Local")
1409 1473
 	var startTime int64
@@ -1427,7 +1491,7 @@ func (c *GobalConfigApiController) GetExportData() {
1427 1491
 		endTime = theTime.Unix()
1428 1492
 	}
1429 1493
 	adminInfo := c.GetAdminUserInfo()
1430
-	order, _ := service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime)
1494
+	order, _ := service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime, p_type)
1431 1495
 	c.ServeSuccessJSON(map[string]interface{}{
1432 1496
 		"order": order,
1433 1497
 	})
@@ -1700,3 +1764,24 @@ func (c *GobalConfigApiController) GetOrderConfig() {
1700 1764
 		"config": config,
1701 1765
 	})
1702 1766
 }
1767
+
1768
+func (c *GobalConfigApiController) GetDrugAutoMaticList() {
1769
+
1770
+	adminUserInfo := c.GetAdminUserInfo()
1771
+	orgId := adminUserInfo.CurrentOrgId
1772
+	warehous_out_id, _ := c.GetInt64("warehous_out_id")
1773
+	record_time, _ := c.GetInt64("record_time")
1774
+	warehouse_out_order_number := c.GetString("warehouse_out_order_number")
1775
+	drugConfig, _ := service.GetDrugStockConfig(orgId)
1776
+	list, err := service.GetDrugAutoMaticList(orgId, warehous_out_id, record_time, warehouse_out_order_number)
1777
+	drugList, err := service.GetAllBaseDrugList(orgId)
1778
+	if err != nil {
1779
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1780
+		return
1781
+	}
1782
+	c.ServeSuccessJSON(map[string]interface{}{
1783
+		"list":       list,
1784
+		"drugConfig": drugConfig,
1785
+		"drugList":   drugList,
1786
+	})
1787
+}

File diff suppressed because it is too large
+ 530 - 63
controllers/his_api_controller.go


+ 403 - 0
controllers/his_config_api_controller.go View File

@@ -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 View File

@@ -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
+}

+ 190 - 60
controllers/his_project_api_controller.go View File

@@ -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
 	})
@@ -614,6 +735,9 @@ func (this *HisProjectApiController) GetAllProjectList() {
614 735
 	adminUserInfo := this.GetAdminUserInfo()
615 736
 	orgId := adminUserInfo.CurrentOrgId
616 737
 	projectList, err := service.GetAllProjectList(orgId)
738
+
739
+	goodInfos, err := service.GetGoodInfomationList(orgId)
740
+
617 741
 	//获取列表数据
618 742
 	hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
619 743
 
@@ -624,6 +748,7 @@ func (this *HisProjectApiController) GetAllProjectList() {
624 748
 	this.ServeSuccessJSON(map[string]interface{}{
625 749
 		"projectList":    projectList,
626 750
 		"hisprojectlist": hisprojectlist,
751
+		"good_info":      goodInfos,
627 752
 	})
628 753
 	return
629 754
 }
@@ -689,12 +814,15 @@ func (this *HisProjectApiController) GetHisProject() {
689 814
 	adminUserInfo := this.GetAdminUserInfo()
690 815
 	orgId := adminUserInfo.CurrentOrgId
691 816
 	project, err := service.GetHisProject(orgId)
817
+	good_info, err := service.GetGoodInfoMation(orgId)
818
+
692 819
 	if err != nil {
693 820
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
694 821
 		return
695 822
 	}
696 823
 	this.ServeSuccessJSON(map[string]interface{}{
697
-		"project": project,
824
+		"project":   project,
825
+		"good_info": good_info,
698 826
 	})
699 827
 }
700 828
 
@@ -812,14 +940,14 @@ func (this *HisProjectApiController) SaveHisPatient() {
812 940
 	timeArrThree := strings.Split(timeArr[1], ":")
813 941
 	var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
814 942
 
815
-	his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
816
-	if len(his) >= 1 {
817
-		order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
818
-		if len(his) >= 1 && order.ID == 0 {
819
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
820
-			return
821
-		}
822
-	}
943
+	//his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
944
+	//if len(his) >= 1 {
945
+	//	order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
946
+	//	if len(his) >= 1 && order.ID == 0 {
947
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
948
+	//		return
949
+	//	}
950
+	//}
823 951
 	var hisPatient models.XtHisPatient
824 952
 	//if err == gorm.ErrRecordNotFound || his.ID == 0 {
825 953
 	hisPatient = models.XtHisPatient{
@@ -835,25 +963,25 @@ func (this *HisProjectApiController) SaveHisPatient() {
835 963
 		IsNeedCostOfProduction: cost_checked,
836 964
 		TreatmentCost:          medicalExpense_float,
837 965
 		MedicalInsuranceNumber: medicalinsurancecard,
838
-		Name:                name,
839
-		Age:                 age,
840
-		Number:              str,
841
-		RegisterType:        register,
842
-		RegisterCost:        registrationfees_float,
843
-		BalanceAccountsType: settlementValue,
844
-		Gender:              sex,
845
-		Total:               totals_float,
846
-		UserOrgId:           orgId,
847
-		Status:              1,
848
-		RecordDate:          nowtime,
849
-		IsReturn:            1,
850
-		Ctime:               time.Now().Unix(),
851
-		Phone:               phone,
852
-		SocialType:          social_type,
853
-		IdCardType:          id_card_type,
854
-		Diagnosis:           diagnosis_id,
855
-		PType:               reg_type,
856
-		SickType:            sick_type,
966
+		Name:                   name,
967
+		Age:                    age,
968
+		Number:                 str,
969
+		RegisterType:           register,
970
+		RegisterCost:           registrationfees_float,
971
+		BalanceAccountsType:    settlementValue,
972
+		Gender:                 sex,
973
+		Total:                  totals_float,
974
+		UserOrgId:              orgId,
975
+		Status:                 1,
976
+		RecordDate:             nowtime,
977
+		IsReturn:               1,
978
+		Ctime:                  time.Now().Unix(),
979
+		Phone:                  phone,
980
+		SocialType:             social_type,
981
+		IdCardType:             id_card_type,
982
+		Diagnosis:              diagnosis_id,
983
+		PType:                  reg_type,
984
+		SickType:               sick_type,
857 985
 	}
858 986
 	service.CreateHisPatient(&hisPatient)
859 987
 	this.ServeSuccessJSON(map[string]interface{}{
@@ -1404,13 +1532,15 @@ func (this *HisProjectApiController) GetAllDepartmentList() {
1404 1532
 func (this *HisProjectApiController) GetPrescription() {
1405 1533
 
1406 1534
 	patient_id, _ := this.GetInt64("patient_id")
1535
+	p_type, _ := this.GetInt64("p_type")
1536
+
1407 1537
 	fmt.Println("patient_id", patient_id)
1408 1538
 	timeStr := time.Now().Format("2006-01-02")
1409 1539
 	timeLayout := "2006-01-02 15:04:05"
1410 1540
 	fmt.Println("timeStr:", timeStr)
1411 1541
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
1412 1542
 	timenow := timeStringToTime.Unix()
1413
-	list, err := service.GetPrescriptionByPatientId(patient_id, timenow)
1543
+	list, err := service.GetPrescriptionByPatientId(patient_id, timenow, p_type)
1414 1544
 	if err != nil {
1415 1545
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1416 1546
 		return

+ 53 - 19
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -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
 }
@@ -846,6 +852,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
846 852
 	supine_diastolic_blood_pressure := c.GetString("supine_diastolic_blood_pressure")
847 853
 	diastolic_pressure := c.GetString("diastolic_pressure")
848 854
 	other_complication := c.GetString("other_complication")
855
+	ktv := c.GetString("ktv")
849 856
 	if id <= 0 {
850 857
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
851 858
 		return
@@ -938,6 +945,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
938 945
 		SettingPressure:              setting_pressure,
939 946
 		DiastolicPressure:            diastolic_pressure,
940 947
 		OtherComplication:            other_complication,
948
+		Ktv:                          ktv,
941 949
 	}
942 950
 
943 951
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -1158,11 +1166,11 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1158 1166
 		PreImpulse:                 pre_impulse,
1159 1167
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1160 1168
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1161
-		Blood:                    blood,
1162
-		DialysisDialyszers:       dialysis_dialyszers,
1163
-		DialysisIrrigation:       dialysis_irrigation,
1164
-		AntioxidantCommodityName: antioxidant_commodity_name,
1165
-		DisplaceSpeed:            displace_speed,
1169
+		Blood:                      blood,
1170
+		DialysisDialyszers:         dialysis_dialyszers,
1171
+		DialysisIrrigation:         dialysis_irrigation,
1172
+		AntioxidantCommodityName:   antioxidant_commodity_name,
1173
+		DisplaceSpeed:              displace_speed,
1166 1174
 	}
1167 1175
 
1168 1176
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -2039,11 +2047,11 @@ func (c *DialysisAPIController) PostSolution() {
2039 2047
 		ALiquid:                   a_liquid,
2040 2048
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
2041 2049
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
2042
-		Blood:                    blood,
2043
-		DialysisDialyszers:       dialysis_dialyszers,
2044
-		DialysisIrrigation:       dialysis_irrigation,
2045
-		AntioxidantCommodityName: antioxidant_commodity_name,
2046
-		DisplaceSpeed:            displace_speed,
2050
+		Blood:                     blood,
2051
+		DialysisDialyszers:        dialysis_dialyszers,
2052
+		DialysisIrrigation:        dialysis_irrigation,
2053
+		AntioxidantCommodityName:  antioxidant_commodity_name,
2054
+		DisplaceSpeed:             displace_speed,
2047 2055
 	}
2048 2056
 
2049 2057
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -3075,13 +3083,13 @@ func (c *DialysisAPIController) GetSchedule() {
3075 3083
 	schedual_type, _ := c.GetInt64("schedual_type")
3076 3084
 	adminUserInfo := c.GetMobileAdminUserInfo()
3077 3085
 
3078
-	timeLayout := "2006-01-02 15:04:05"
3079
-
3080
-	date := time.Now().Format("2006-01-02") + " 00:00:00"
3081
-	loc, _ := time.LoadLocation("Local")
3082
-	theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3083
-	scheduleTime := theStartTime.Unix()
3084
-
3086
+	//timeLayout := "2006-01-02 15:04:05"
3087
+	//
3088
+	//date := time.Now().Format("2006-01-02") + " 00:00:00"
3089
+	//loc, _ := time.LoadLocation("Local")
3090
+	//theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3091
+	//scheduleTime := theStartTime.Unix()
3092
+	scheduleTime, _ := c.GetInt64("record_date")
3085 3093
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.Org.Id, scheduleTime, schedual_type)
3086 3094
 
3087 3095
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -3553,6 +3561,7 @@ func (c *DialysisAPIController) EditConsumables() {
3553 3561
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
3554 3562
 
3555 3563
 			goods, _ := dataBody["goods"].([]interface{})
3564
+			fmt.Println("goods2222222222222", goods)
3556 3565
 			if len(goods) > 0 {
3557 3566
 				for _, item := range goods {
3558 3567
 					items := item.(map[string]interface{})
@@ -3636,7 +3645,7 @@ func (c *DialysisAPIController) EditConsumables() {
3636 3645
 				}
3637 3646
 			}
3638 3647
 		}
3639
-
3648
+		fmt.Println("hhhhhhhhhhhhhhhhhhhh", beforePrepares)
3640 3649
 		//查询今日患者出库列表
3641 3650
 		consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
3642 3651
 
@@ -3696,6 +3705,7 @@ func (c *DialysisAPIController) EditConsumables() {
3696 3705
 
3697 3706
 		//查询是否有出库单
3698 3707
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
3708
+		fmt.Println("是否有出库单22222222222222222222222", err)
3699 3709
 		if err == gorm.ErrRecordNotFound {
3700 3710
 			//没有记录,则创建出库单
3701 3711
 			timeStr := time.Now().Format("2006-01-02")
@@ -3800,6 +3810,7 @@ func (c *DialysisAPIController) EditConsumables() {
3800 3810
 						if err == nil {
3801 3811
 
3802 3812
 							count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3813
+
3803 3814
 							if count == 0 {
3804 3815
 								details := &models.AutomaticReduceDetail{
3805 3816
 									WarehouseOutId:          warehouseOutInfo.ID,
@@ -3826,6 +3837,7 @@ func (c *DialysisAPIController) EditConsumables() {
3826 3837
 						}
3827 3838
 
3828 3839
 						count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3840
+
3829 3841
 						if count == 0 {
3830 3842
 							details := &models.AutomaticReduceDetail{
3831 3843
 								WarehouseOutId:          outInfo.ID,
@@ -3842,6 +3854,7 @@ func (c *DialysisAPIController) EditConsumables() {
3842 3854
 							}
3843 3855
 							service.AddSigleAutoReduceRecordInfo(details)
3844 3856
 						} else if count == 1 {
3857
+							fmt.Println("llllllllllllllllllllll")
3845 3858
 							service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
3846 3859
 						}
3847 3860
 						//details := &models.AutomaticReduceDetail{
@@ -3864,7 +3877,9 @@ func (c *DialysisAPIController) EditConsumables() {
3864 3877
 			}
3865 3878
 
3866 3879
 			if len(beforePrepares) > 0 { //修改
3880
+
3867 3881
 				for _, consumable := range consumables_source {
3882
+
3868 3883
 					for _, before := range beforePrepares {
3869 3884
 
3870 3885
 						if consumable.GoodId == before.GoodId {
@@ -3874,6 +3889,7 @@ func (c *DialysisAPIController) EditConsumables() {
3874 3889
 								//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
3875 3890
 								//判断前端更改后的商品id的出库记录在数据库中是否存在
3876 3891
 								err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
3892
+								fmt.Println("err222222222222222222", err)
3877 3893
 								if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
3878 3894
 
3879 3895
 									warehouseOutInfo := &models.WarehouseOutInfo{
@@ -3895,6 +3911,7 @@ func (c *DialysisAPIController) EditConsumables() {
3895 3911
 									warehouseOutInfo.GoodId = before.GoodId
3896 3912
 									warehouseOutInfo.GoodTypeId = before.GoodTypeId
3897 3913
 									err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3914
+									fmt.Println("err2223444444444444444444", err)
3898 3915
 									if err == nil {
3899 3916
 										//可能存在商品使用人不存在的情况,需要先判断商品使用人是否存在
3900 3917
 										user, err := service.FindGoodUserById(before.GoodTypeId, before.GoodId, patient_id, adminInfo.Org.Id, record_time)
@@ -3953,6 +3970,7 @@ func (c *DialysisAPIController) EditConsumables() {
3953 3970
 												GoodTypeId:              consumable.GoodTypeId,
3954 3971
 												Count:                   before.Count,
3955 3972
 											}
3973
+
3956 3974
 											service.AddSigleAutoReduceRecordInfo(details)
3957 3975
 										} else if err == nil {
3958 3976
 											if user.ID > 0 {
@@ -3969,10 +3987,23 @@ func (c *DialysisAPIController) EditConsumables() {
3969 3987
 			}
3970 3988
 		}
3971 3989
 
3990
+		//更新自动出库的地方
3972 3991
 		var errs error
3973 3992
 		if len(beforePrepares) > 0 {
3993
+
3974 3994
 			for _, item := range beforePrepares {
3975 3995
 				errs = service.UpdateDialysisBeforePrepareTwo(item)
3996
+
3997
+				detail := models.AutomaticReduceDetail{
3998
+					PatientId:  item.PatientId,
3999
+					Status:     1,
4000
+					RecordTime: item.RecordDate,
4001
+					OrgId:      item.UserOrgId,
4002
+					GoodId:     item.GoodId,
4003
+					GoodTypeId: item.GoodTypeId,
4004
+					Count:      item.Count,
4005
+				}
4006
+				service.UpdateAutoReduceDetailSix(&detail)
3976 4007
 			}
3977 4008
 		}
3978 4009
 		if errs == nil {
@@ -4273,14 +4304,16 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
4273 4304
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4274 4305
 		return
4275 4306
 	}
4307
+
4276 4308
 	goodTypes, _ := service.FindAllGoodTypeOne(adminUser.Org.Id)
4277 4309
 	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
4278 4310
 
4279 4311
 	goodUser, _ := service.GetAllStockOutUserDetail(patient_id, adminUser.Org.Id, date.Unix())
4280 4312
 	lastGoodUserDetial, _ := service.GetLastDialysisGoods(patient_id, adminUser.Org.Id, date.Unix())
4281 4313
 
4282
-	//获取今日患者的透析处方参数
4314
+	project, _ := service.GetHisPrescriptionProject(adminUser.Org.Id, patient_id, date.Unix())
4283 4315
 
4316
+	//获取今日患者的透析处方参数
4284 4317
 	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
4285 4318
 
4286 4319
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -4288,6 +4321,7 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
4288 4321
 		"good_user":      goodUser,
4289 4322
 		"good_info":      good_info,
4290 4323
 		"last_good_user": lastGoodUserDetial,
4324
+		"project":        project,
4291 4325
 		"prescription":   prescribe,
4292 4326
 	})
4293 4327
 	return

+ 5 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -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
 

+ 121 - 2
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -1242,6 +1242,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1242 1242
 func (c *PatientApiController) ModifyExecDoctorAdvice() {
1243 1243
 	execution_time := c.GetString("execution_time")
1244 1244
 	groupno, _ := c.GetInt64("groupno", -1)
1245
+
1245 1246
 	var ids []string
1246 1247
 	if groupno == 0 {
1247 1248
 		advice_ids := c.GetString("advice_id")
@@ -1312,10 +1313,21 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1312 1313
 	var err error
1313 1314
 	if groupno > 0 {
1314 1315
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1316
+
1315 1317
 	} else {
1316 1318
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1317 1319
 	}
1318 1320
 
1321
+	//判断是否开启his
1322
+	errs, config := service.FindXTHisRecordByOrgId(adminUserInfo.Org.Id)
1323
+	//如果开启去修改执行时间
1324
+	if config.IsOpen == 1 {
1325
+		advicesinfo := models.HisDoctorAdviceInfo{
1326
+			ExecutionTime: theTime.Unix(),
1327
+			UpdatedTime:   time.Now().Unix(),
1328
+		}
1329
+		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1330
+	}
1319 1331
 	if err != nil {
1320 1332
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1321 1333
 		return
@@ -2909,6 +2921,34 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2909 2921
 	//临时医嘱
2910 2922
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2911 2923
 
2924
+	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2925
+	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
2926
+
2927
+	project_config, _ := service.GetHisProjectConfig(adminUserInfo.Org.Id)
2928
+	projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2929
+	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
2930
+		for _, item := range projects {
2931
+			var advice *models.HisDoctorAdviceInfo
2932
+			advice.ID = item.ID
2933
+			advice.Checker = item.Checker
2934
+			advice.CheckTime = item.CheckTime
2935
+			advice.CheckState = item.CheckState
2936
+			advice.ExecutionState = item.ExecutionState
2937
+			advice.ExecutionStaff = item.ExecutionStaff
2938
+			advice.PrescribingNumber = float64(item.Count)
2939
+			advice.PrescribingNumberUnit = item.Unit
2940
+			advice.AdviceDoctor = item.Doctor
2941
+			if item.Type == 3 {
2942
+				advice.AdviceName = item.GoodInfo.GoodName
2943
+			} else if item.Type == 2 {
2944
+				advice.AdviceName = item.HisProject.ProjectName
2945
+			}
2946
+			advice.StartTime = item.StartTime
2947
+			hisAdvice = append(hisAdvice, advice)
2948
+		}
2949
+
2950
+	}
2951
+
2912 2952
 	if len(DoctorAdvice) > 0 {
2913 2953
 		for _, item := range DoctorAdvice {
2914 2954
 			if item.AdviceDoctor > 0 {
@@ -2923,6 +2963,8 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2923 2963
 		}
2924 2964
 	}
2925 2965
 
2966
+	//DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2967
+
2926 2968
 	//透析监测
2927 2969
 	Record, _ := service.FindAllMonitorRecord(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2928 2970
 	//透析小结
@@ -2939,8 +2981,6 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2939 2981
 
2940 2982
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.Org.Id)
2941 2983
 
2942
-	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
2943
-	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2944 2984
 	if config.IsOpen == 1 {
2945 2985
 		c.ServeSuccessJSON(map[string]interface{}{
2946 2986
 			"users":                   adminUser,
@@ -3527,3 +3567,82 @@ func (this *PatientApiController) GetSearchPatient() {
3527 3567
 		"patient": patient,
3528 3568
 	})
3529 3569
 }
3570
+
3571
+func (c *PatientApiController) ExecProject() {
3572
+	execution_time := c.GetString("execution_time")
3573
+	project_id, _ := c.GetInt64("project_id")
3574
+
3575
+	if len(execution_time) <= 0 {
3576
+		utils.ErrorLog("execution_time")
3577
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3578
+		return
3579
+	}
3580
+	timeLayout2 := "2006-01-02 15:04:05"
3581
+	loc, _ := time.LoadLocation("Local")
3582
+	theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
3583
+	if errs != nil {
3584
+		utils.ErrorLog(errs.Error())
3585
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3586
+		return
3587
+	}
3588
+	adminInfo := c.GetMobileAdminUserInfo()
3589
+	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3590
+	if project.ExecutionState == 1 {
3591
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
3592
+		return
3593
+	}
3594
+	if project.Checker >= 0 && project.Checker == adminInfo.AdminUser.Id {
3595
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
3596
+		return
3597
+	}
3598
+
3599
+	project.ExecutionState = 1
3600
+	project.ExecutionStaff = adminInfo.AdminUser.Id
3601
+	project.ExecutionTime = theTime.Unix()
3602
+	err := service.SaveHisProject(&project)
3603
+	if err == nil {
3604
+		c.ServeSuccessJSON(map[string]interface{}{
3605
+			"project": project,
3606
+		})
3607
+	} else {
3608
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3609
+		return
3610
+
3611
+	}
3612
+
3613
+}
3614
+
3615
+func (c *PatientApiController) CheckProject() {
3616
+
3617
+	adminInfo := c.GetMobileAdminUserInfo()
3618
+	project_id, _ := c.GetInt64("project_id")
3619
+	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3620
+
3621
+	if project.CheckState == 1 {
3622
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
3623
+		return
3624
+	}
3625
+	if project.ExecutionStaff >= 0 && project.ExecutionStaff == adminInfo.AdminUser.Id {
3626
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
3627
+		return
3628
+	}
3629
+
3630
+	project.Checker = adminInfo.AdminUser.Id
3631
+	project.CheckTime = time.Now().Unix()
3632
+	project.CheckState = 1
3633
+
3634
+	err := service.SaveHisProject(&project)
3635
+
3636
+	if err == nil {
3637
+		c.ServeSuccessJSON(map[string]interface{}{
3638
+			"msg":     "ok",
3639
+			"project": project,
3640
+		})
3641
+
3642
+	} else {
3643
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3644
+		return
3645
+
3646
+	}
3647
+
3648
+}

+ 81 - 11
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -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,21 @@ 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
+
125 142
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
126 143
 	if err == nil {
144
+		if len(projects) > 0 {
145
+			for _, item := range projects {
146
+				if item.Type == 3 { //处理透前准备耗材数量数据
147
+					consumables, _ := service.FindHisConsumablesByID(item.UserOrgId, item.PatientId, item.RecordDate, item.ProjectId)
148
+					if consumables.ID > 0 {
149
+						consumables.Count = 0
150
+						service.UpdateConsumables(&consumables)
151
+					}
152
+				}
153
+			}
154
+		}
127 155
 		c.ServeSuccessJSON(map[string]interface{}{
128 156
 			"msg": "删除成功",
129 157
 		})
@@ -149,9 +177,18 @@ func (c *MobileHisApiController) DeleteDoctorAdvice() {
149 177
 }
150 178
 func (c *MobileHisApiController) DeleteProject() {
151 179
 	id, _ := c.GetInt64("id")
152
-	//TODO 需要判断是否已经结算
180
+	project, _ := service.GetHisProjectByID(id)
181
+	adminInfo := c.GetMobileAdminUserInfo()
182
+	var consumable models.DialysisBeforePrepare
183
+	if project.ID > 0 && project.Type == 3 {
184
+		consumable, _ = service.FindHisConsumablesByID(adminInfo.Org.Id, project.PatientId, project.RecordDate, project.ProjectId)
185
+	}
153 186
 	err := service.DelelteProject(id, c.GetMobileAdminUserInfo().Org.Id)
154 187
 	if err == nil {
188
+		if consumable.ID > 0 {
189
+			consumable.Count = 0
190
+			service.UpdateConsumables(&consumable)
191
+		}
155 192
 		c.ServeSuccessJSON(map[string]interface{}{
156 193
 			"msg": "删除成功",
157 194
 		})
@@ -191,7 +228,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
191 228
 
192 229
 	role, _ := service.GetAdminUserInfoByID(adminInfo.Org.Id, doctor_id)
193 230
 
194
-	info, _ := service.FindPatientPrescriptionInfo(adminInfo.Org.Id, patient_id, recordDateTime)
231
+	info, _ := service.FindPatientPrescriptionInfo(adminInfo.Org.Id, patient_id, recordDateTime, 2)
195 232
 	var hpInfo models.HisPrescriptionInfo
196 233
 	if info.ID == 0 {
197 234
 		var randNum int
@@ -219,6 +256,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
219 256
 			Doctor:             role.UserName,
220 257
 			DoctorId:           doctor_id,
221 258
 			SickType:           sick_type,
259
+			PType:              2,
222 260
 		}
223 261
 		service.SavePatientPrescriptionInfo(hpInfo)
224 262
 
@@ -242,6 +280,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
242 280
 			PrescriptionStatus: info.PrescriptionStatus,
243 281
 			DoctorId:           doctor_id,
244 282
 			SickType:           sick_type,
283
+			PType:              info.PType,
245 284
 		}
246 285
 		service.SavePatientPrescriptionInfo(hpInfo)
247 286
 	}
@@ -314,6 +353,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
314 353
 						BatchNumber:        "",
315 354
 						PrescriptionNumber: hpInfo.PrescriptionNumber,
316 355
 						PreTime:            pTime,
356
+						PType:              2,
317 357
 					}
318 358
 					tempPrescription = prescription
319 359
 				} else {
@@ -323,6 +363,8 @@ func (c *MobileHisApiController) CreateHisPrescription() {
323 363
 					tempPrescription.Doctor = role.UserName
324 364
 					tempPrescription.OrderStatus = order_status
325 365
 					tempPrescription.PreTime = pTime
366
+					tempPrescription.PType = 2
367
+
326 368
 				}
327 369
 				service.SaveHisPrescription(tempPrescription)
328 370
 
@@ -383,6 +425,8 @@ func (c *MobileHisApiController) CreateHisPrescription() {
383 425
 							p.UserOrgId = adminInfo.Org.Id
384 426
 							p.HisPatientId = his_patient_id
385 427
 							p.Status = 1
428
+							p.Doctor = doctor_id
429
+							p.StartTime = pTime
386 430
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
387 431
 							if errcode > 0 {
388 432
 								c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -397,6 +441,14 @@ func (c *MobileHisApiController) CreateHisPrescription() {
397 441
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
398 442
 							service.SaveHisProjectTwo(&p)
399 443
 
444
+							if p.Type == 3 { //处理透前准备耗材数量数据
445
+								consumables, _ := service.FindHisConsumablesByID(adminInfo.Org.Id, patient_id, recordDateTime, p.ProjectId)
446
+								if consumables.ID > 0 {
447
+									consumables.Count = p.Count
448
+									service.UpdateConsumables(&consumables)
449
+								}
450
+							}
451
+
400 452
 						}
401 453
 					}
402 454
 				}
@@ -425,7 +477,7 @@ func (this *MobileHisApiController) GetLastOrNextHisPrescription() {
425 477
 	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
426 478
 	record_time := theAdviceRecordTime.Unix()
427 479
 	adminUserInfo := this.GetMobileAdminUserInfo()
428
-	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.Org.Id, patient_id)
480
+	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.Org.Id, patient_id, 2)
429 481
 	if err == nil {
430 482
 		if len(prescriptions) == 0 {
431 483
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
@@ -578,10 +630,28 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
578 630
 	return 0
579 631
 }
580 632
 func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
633
+	project.ExecutionStaff = 0
634
+	project.ExecutionState = 2
635
+	project.ExecutionTime = 0
636
+	project.Checker = 0
637
+	project.CheckState = 2
638
+	project.CheckTime = 0
581 639
 	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
582 640
 		id := int64(json["id"].(float64))
583 641
 		project.ID = id
642
+		temp_project, _ := service.GetHisPrescriptionProjectByID(id)
643
+		project.ExecutionStaff = temp_project.ExecutionStaff
644
+		project.ExecutionState = temp_project.ExecutionState
645
+		project.ExecutionTime = temp_project.ExecutionTime
646
+		project.Checker = temp_project.Checker
647
+		project.CheckState = temp_project.CheckState
648
+		project.CheckTime = temp_project.CheckTime
584 649
 	}
650
+	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
651
+		types := int64(json["type"].(float64))
652
+		project.Type = types
653
+	}
654
+
585 655
 	if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
586 656
 		project_id := int64(json["project_id"].(float64))
587 657
 		project.ProjectId = project_id

+ 32 - 0
controllers/public_api_controller.go View File

@@ -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 View File

@@ -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
 	//电子病历

+ 22 - 5
controllers/schedule_api_controller.go View File

@@ -1317,13 +1317,30 @@ func (this *ScheduleApiController) ExportSchedule() {
1317 1317
 		errLogs, _ := service.FindSchedualExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
1318 1318
 
1319 1319
 		if len(schedules) > 0 {
1320
-			schedule_date := time.Now().Format("2006-01-02")
1321
-			date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1322
-			clear_schedule_date := date.Unix() //根据日期去清除,该日期未来的排班数据
1323
-			err := service.UpdateScheduleStatus(clear_schedule_date, this.GetAdminUserInfo().CurrentOrgId)
1320
+			//schedule_date := time.Now().Format("2006-01-02")
1321
+			//date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1322
+			//clear_schedule_date := date.Unix() //根据日期去清除,该日期未来的排班数据
1323
+			//err := service.UpdateScheduleStatus(clear_schedule_date, this.GetAdminUserInfo().CurrentOrgId)
1324 1324
 			if err == nil {
1325 1325
 				for _, item := range schedules {
1326
-					service.CreateSchedule(item)
1326
+					//查找当天日期是否存在
1327
+					_, errcode := service.GetTodayScheduleIsExist(item.PatientId, item.ScheduleDate, item.UserOrgId)
1328
+					if errcode == gorm.ErrRecordNotFound {
1329
+						service.CreateSchedule(item)
1330
+					} else if errcode == nil {
1331
+						schedule := models.XtSchedule{
1332
+							PartitionId:  item.PartitionId,
1333
+							BedId:        item.BedId,
1334
+							PatientId:    item.PatientId,
1335
+							ScheduleDate: item.ScheduleDate,
1336
+							ScheduleType: item.ScheduleType,
1337
+							ScheduleWeek: item.ScheduleWeek,
1338
+							ModeId:       item.ModeId,
1339
+							Status:       1,
1340
+						}
1341
+						service.UpdateScheduleByOrgId(item.PatientId, item.ScheduleDate, item.UserOrgId, &schedule)
1342
+					}
1343
+
1327 1344
 				}
1328 1345
 
1329 1346
 				log := models.ExportLog{

+ 134 - 54
controllers/stock_in_api_controller.go View File

@@ -72,6 +72,8 @@ func StockManagerApiRegistRouters() {
72 72
 	beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
73 73
 
74 74
 	beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
75
+
76
+	beego.Router("/api/good/initializtion", &StockManagerApiController{}, "Get:GetInitializtion")
75 77
 }
76 78
 
77 79
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -1388,7 +1390,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1388 1390
 					sys_record_time := int64(items["sys_record_time"].(float64))
1389 1391
 
1390 1392
 					warehouseOutInfo := &models.WarehouseOutInfo{
1391
-						ID: id,
1393
+						ID:                      id,
1392 1394
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1393 1395
 						WarehouseOutId:          warehouseOut.ID,
1394 1396
 						GoodId:                  good_id,
@@ -2076,14 +2078,14 @@ func (this *StockManagerApiController) AddGoodInformation() {
2076 2078
 
2077 2079
 		if len(good_kind) != 0 {
2078 2080
 			_, errcodegoodkind := service.IsExistDicConfig(config.ID, good_kind, orgId)
2079
-
2081
+			lastConfig, _ := service.GetLastDicConfig(config.ID, orgId)
2080 2082
 			dataconfig := models.DictDataconfig{
2081 2083
 				ParentId:       config.ID,
2082 2084
 				Module:         "system",
2083 2085
 				OrgId:          orgId,
2084 2086
 				Name:           good_kind,
2085 2087
 				FieldName:      "",
2086
-				Value:          index + 50,
2088
+				Value:          lastConfig.Value + 1,
2087 2089
 				CreatedTime:    "",
2088 2090
 				UpdatedTime:    "",
2089 2091
 				CreateUserId:   adminUserInfo.AdminUser.Id,
@@ -2175,13 +2177,14 @@ func (this *StockManagerApiController) AddGoodInformation() {
2175 2177
 		if len(medical_insurance_level) != 0 {
2176 2178
 			_, errcodemedicalInsurance := service.IsExistDicConfig(medicalInsuranceDataConfig.ID, medical_insurance_level, orgId)
2177 2179
 			if errcodemedicalInsurance == gorm.ErrRecordNotFound {
2180
+				mediConfigOne, _ := service.GetLastDicConfig(medicalInsuranceDataConfig.ID, orgId)
2178 2181
 				dataconfig := models.DictDataconfig{
2179 2182
 					ParentId:       medicalInsuranceDataConfig.ID,
2180 2183
 					Module:         "system",
2181 2184
 					OrgId:          orgId,
2182 2185
 					Name:           medical_insurance_level,
2183 2186
 					FieldName:      "",
2184
-					Value:          index + 50,
2187
+					Value:          mediConfigOne.Value + 1,
2185 2188
 					CreatedTime:    "",
2186 2189
 					UpdatedTime:    "",
2187 2190
 					CreateUserId:   adminUserInfo.AdminUser.Id,
@@ -2329,7 +2332,8 @@ func (this *StockManagerApiController) AddGoodInformation() {
2329 2332
 
2330 2333
 		var dealer_id int64
2331 2334
 		dealerName := goodNameM["dealer"].(string)
2332
-		fmt.Println("经销商33333333", dealerName)
2335
+
2336
+		fmt.Println("经销商", dealerName)
2333 2337
 		dealer := models.Dealer{
2334 2338
 			OrgId:      orgId,
2335 2339
 			Status:     1,
@@ -2435,13 +2439,14 @@ func (this *StockManagerApiController) AddGoodInformation() {
2435 2439
 			_, errcodecagegory := service.IsExistDicConfig(drugDataConfig.ID, statistics_category, orgId)
2436 2440
 
2437 2441
 			if errcodecagegory == gorm.ErrRecordNotFound {
2442
+				dicConfigThree, _ := service.GetLastDicConfig(drugDataConfig.ID, orgId)
2438 2443
 				dataconfig := models.DictDataconfig{
2439 2444
 					ParentId:       drugDataConfig.ID,
2440 2445
 					Module:         "system",
2441 2446
 					OrgId:          orgId,
2442 2447
 					Name:           statistics_category,
2443 2448
 					FieldName:      "",
2444
-					Value:          index + 50,
2449
+					Value:          dicConfigThree.Value + 1,
2445 2450
 					CreatedTime:    "",
2446 2451
 					UpdatedTime:    "",
2447 2452
 					CreateUserId:   adminUserInfo.AdminUser.Id,
@@ -2474,23 +2479,23 @@ func (this *StockManagerApiController) AddGoodInformation() {
2474 2479
 	}
2475 2480
 
2476 2481
 	export_time := time.Now().Unix()
2477
-	errLogs, _ := service.FindPatientExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
2482
+	errLogs, _ := service.FindPatientExportLogTwo(this.GetAdminUserInfo().CurrentOrgId, export_time)
2478 2483
 	if len(goods) > 0 {
2479 2484
 
2480 2485
 		for _, item := range goods {
2481 2486
 
2482 2487
 			goodInfo := models.GoodInfo{
2483
-				GoodName:          item.GoodName,
2484
-				SpecificationName: item.SpecificationName,
2485
-				GoodKind:          item.GoodKind,
2486
-				GoodTypeId:        item.GoodTypeId,
2487
-				Dealer:            item.Dealer,
2488
-				GoodUnit:          item.GoodUnit,
2489
-				IsRecord:          item.IsRecord,
2490
-				IsSpecialDiseases: item.IsSpecialDiseases,
2491
-				Manufacturer:      item.Manufacturer,
2492
-				Pinyin:            item.Pinyin,
2493
-
2488
+				GoodName:                    item.GoodName,
2489
+				SpecificationName:           item.SpecificationName,
2490
+				GoodKind:                    item.GoodKind,
2491
+				GoodTypeId:                  item.GoodTypeId,
2492
+				Dealer:                      item.Dealer,
2493
+				GoodUnit:                    item.GoodUnit,
2494
+				IsRecord:                    item.IsRecord,
2495
+				IsSpecialDiseases:           item.IsSpecialDiseases,
2496
+				Manufacturer:                item.Manufacturer,
2497
+				Pinyin:                      item.Pinyin,
2498
+				GoodStatus:                  item.GoodStatus,
2494 2499
 				ProductionType:              item.ProductionType,
2495 2500
 				Remark:                      item.Remark,
2496 2501
 				RetailPrice:                 item.RetailPrice,
@@ -2499,13 +2504,13 @@ func (this *StockManagerApiController) AddGoodInformation() {
2499 2504
 				Wubi:                        item.Wubi,
2500 2505
 				StockWarnCount:              item.StockWarnCount,
2501 2506
 				MedicalInsuranceLevel:       item.MedicalInsuranceLevel,
2502
-				OrgId:                  orgId,
2503
-				Status:                 1,
2504
-				Ctime:                  time.Now().Unix(),
2505
-				StatisticsCategory:     item.StatisticsCategory,
2506
-				GoodCode:               item.GoodCode,
2507
-				BuyPrice:               item.BuyPrice,
2508
-				MedicalInsuranceNumber: item.MedicalInsuranceNumber,
2507
+				OrgId:                       orgId,
2508
+				Status:                      1,
2509
+				Ctime:                       time.Now().Unix(),
2510
+				StatisticsCategory:          item.StatisticsCategory,
2511
+				GoodCode:                    item.GoodCode,
2512
+				BuyPrice:                    item.BuyPrice,
2513
+				MedicalInsuranceNumber:      item.MedicalInsuranceNumber,
2509 2514
 			}
2510 2515
 
2511 2516
 			//查询同种耗材名称同种类型同种规格的耗材是否存在
@@ -2575,6 +2580,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2575 2580
 
2576 2581
 	total_goods = tempDrugs
2577 2582
 	for index, drugMap := range tempDrugs {
2583
+
2578 2584
 		goodNameM := drugMap.(map[string]interface{})
2579 2585
 		var drug models.BaseDrugLib
2580 2586
 		if goodNameM["drug_name"] == nil || reflect.TypeOf(goodNameM["drug_name"]).String() != "string" {
@@ -2644,16 +2650,19 @@ func (this *StockManagerApiController) AddDrugInformation() {
2644 2650
 		var drugType = "药品类型"
2645 2651
 
2646 2652
 		drugconfig, _ := service.GetDrugDataConfig(0, drugType)
2647
-		if len(drug_type) == 0 {
2648
-			_, errcodes := service.IsExistDicConfig(drugconfig.ParentId, drug_type, orgId)
2653
+		if len(drug_type) != 0 {
2654
+			_, errcodes := service.IsExistDicConfig(drugconfig.ID, drug_type, orgId)
2649 2655
 			if errcodes == gorm.ErrRecordNotFound {
2656
+				//获取该型号最后一条数据型号
2657
+				config, _ := service.GetLastDicConfig(drugconfig.ID, orgId)
2658
+
2650 2659
 				dataconfig := models.DictDataconfig{
2651 2660
 					ParentId:       drugconfig.ID,
2652 2661
 					Module:         "system",
2653 2662
 					OrgId:          orgId,
2654 2663
 					Name:           drug_type,
2655 2664
 					FieldName:      "",
2656
-					Value:          index + 50,
2665
+					Value:          config.Value + 1,
2657 2666
 					CreatedTime:    "",
2658 2667
 					UpdatedTime:    "",
2659 2668
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2713,7 +2722,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2713 2722
 		drug.DrugOriginPlace = drug_origin_place
2714 2723
 
2715 2724
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2716
-		fmt.Println("药品剂型2222222222", drug_dosage_form)
2725
+
2717 2726
 		if len(drug_dosage_form) == 0 {
2718 2727
 			err_log := models.ExportErrLog{
2719 2728
 				LogType:    4,
@@ -2734,13 +2743,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
2734 2743
 		if len(drug_dosage_form) != 0 {
2735 2744
 			_, errcodess := service.IsExistDicConfig(drugDosageconfig.ID, drug_dosage_form, orgId)
2736 2745
 			if errcodess == gorm.ErrRecordNotFound {
2746
+				configOne, _ := service.GetLastDicConfig(drugDosageconfig.ID, orgId)
2737 2747
 				dataconfig := models.DictDataconfig{
2738 2748
 					ParentId:       drugDosageconfig.ID,
2739 2749
 					Module:         "system",
2740 2750
 					OrgId:          orgId,
2741
-					Name:           drug_dosage,
2751
+					Name:           drug_dosage_form,
2742 2752
 					FieldName:      "",
2743
-					Value:          index + 50,
2753
+					Value:          configOne.Value + 1,
2744 2754
 					CreatedTime:    "",
2745 2755
 					UpdatedTime:    "",
2746 2756
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2762,12 +2772,12 @@ func (this *StockManagerApiController) AddDrugInformation() {
2762 2772
 				drug_dosage_form_id = int64(it.Value)
2763 2773
 			}
2764 2774
 		}
2765
-		fmt.Println("hhhhhhh66666666666666", drug_dosage_form_id)
2775
+
2766 2776
 		drug.DrugDosageForm = drug_dosage_form_id
2767 2777
 
2768 2778
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2769 2779
 		var medical_insurance_level_id int64
2770
-		if len(medical_insurance_level) <= 0 { //名字为空则生成一条导入错误日志
2780
+		if len(medical_insurance_level) == 0 { //名字为空则生成一条导入错误日志
2771 2781
 			err_log := models.ExportErrLog{
2772 2782
 				LogType:    4,
2773 2783
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
@@ -2785,13 +2795,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
2785 2795
 		if len(medical_insurance_level) != 0 {
2786 2796
 			_, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
2787 2797
 			if errcodemedical == gorm.ErrRecordNotFound {
2798
+				medConfig, _ := service.GetLastDicConfig(medicalInsuranceConfig.ID, orgId)
2788 2799
 				dataconfig := models.DictDataconfig{
2789 2800
 					ParentId:       medicalInsuranceConfig.ID,
2790 2801
 					Module:         "system",
2791 2802
 					OrgId:          orgId,
2792 2803
 					Name:           medical_insurance_level,
2793 2804
 					FieldName:      "",
2794
-					Value:          index + 50,
2805
+					Value:          medConfig.Value + 1,
2795 2806
 					CreatedTime:    "",
2796 2807
 					UpdatedTime:    "",
2797 2808
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2921,17 +2932,18 @@ func (this *StockManagerApiController) AddDrugInformation() {
2921 2932
 		var drugClassify = "药物分类"
2922 2933
 		var drug_classify_id int64
2923 2934
 		drugClassifyConfig, _ := service.GetDrugDataConfig(0, drugClassify)
2924
-		fmt.Println("9999999999999999999", drugClassifyConfig)
2935
+
2925 2936
 		if len(drug_classify) != 0 {
2926 2937
 			_, errcodesClass := service.IsExistDicConfig(drugClassifyConfig.ID, drug_classify, orgId)
2927 2938
 			if errcodesClass == gorm.ErrRecordNotFound {
2939
+				drugClassConfig, _ := service.GetLastDicConfig(drugClassifyConfig.ID, orgId)
2928 2940
 				dataconfig := models.DictDataconfig{
2929 2941
 					ParentId:       drugClassifyConfig.ID,
2930 2942
 					Module:         "system",
2931 2943
 					OrgId:          orgId,
2932 2944
 					Name:           drug_classify,
2933 2945
 					FieldName:      "",
2934
-					Value:          index + 50,
2946
+					Value:          drugClassConfig.Value + 1,
2935 2947
 					CreatedTime:    "",
2936 2948
 					UpdatedTime:    "",
2937 2949
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2996,17 +3008,20 @@ func (this *StockManagerApiController) AddDrugInformation() {
2996 3008
 		drug.Manufacturer = manufacturer_id
2997 3009
 
2998 3010
 		dealer := goodNameM["dealer"].(string)
2999
-		_, errcodesdealer := service.GetDealerByName(orgId, dealer)
3000
-		if errcodesdealer == gorm.ErrRecordNotFound {
3001
-			dealerconfig := models.Dealer{
3002
-				DealerName: dealer,
3003
-				Status:     1,
3004
-				OrgId:      orgId,
3005
-				Ctime:      time.Now().Unix(),
3006
-				Creater:    adminUser.AdminUser.Id,
3011
+		if len(dealer) != 0 {
3012
+			_, errcodesdealer := service.GetDealerByName(orgId, dealer)
3013
+			if errcodesdealer == gorm.ErrRecordNotFound {
3014
+				dealerconfig := models.Dealer{
3015
+					DealerName: dealer,
3016
+					Status:     1,
3017
+					OrgId:      orgId,
3018
+					Ctime:      time.Now().Unix(),
3019
+					Creater:    adminUser.AdminUser.Id,
3020
+				}
3021
+				service.CreateDealer(&dealerconfig)
3007 3022
 			}
3008
-			service.CreateDealer(&dealerconfig)
3009 3023
 		}
3024
+
3010 3025
 		var dealer_id int64
3011 3026
 		dealerList, _ := service.GetAllDealerList(orgId)
3012 3027
 		for _, it := range dealerList {
@@ -3034,14 +3049,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3034 3049
 		if len(statistics_category) != 0 {
3035 3050
 			_, errcodestatistc := service.IsExistDicConfig(statistcConfig.ID, statistics_category, orgId)
3036 3051
 			if errcodestatistc == gorm.ErrRecordNotFound {
3037
-
3052
+				staConfig, _ := service.GetLastDicConfig(statistcConfig.ID, orgId)
3038 3053
 				dataconfig := models.DictDataconfig{
3039 3054
 					ParentId:       statistcConfig.ID,
3040 3055
 					Module:         "system",
3041 3056
 					OrgId:          orgId,
3042 3057
 					Name:           statistics_category,
3043 3058
 					FieldName:      "",
3044
-					Value:          index + 50,
3059
+					Value:          staConfig.Value + 1,
3045 3060
 					CreatedTime:    "",
3046 3061
 					UpdatedTime:    "",
3047 3062
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3081,13 +3096,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3081 3096
 		if len(pharmacology_category) != 0 {
3082 3097
 			_, errcodespharmacology := service.IsExistDicConfig(pharmacologyConfig.ID, pharmacology_category, orgId)
3083 3098
 			if errcodespharmacology == gorm.ErrRecordNotFound {
3099
+				dicConfig, _ := service.GetLastDicConfig(pharmacologyConfig.ID, orgId)
3084 3100
 				dataconfig := models.DictDataconfig{
3085 3101
 					ParentId:       pharmacologyConfig.ID,
3086 3102
 					Module:         "system",
3087 3103
 					OrgId:          orgId,
3088 3104
 					Name:           pharmacology_category,
3089 3105
 					FieldName:      "",
3090
-					Value:          index + 50,
3106
+					Value:          dicConfig.Value + 1,
3091 3107
 					CreatedTime:    "",
3092 3108
 					UpdatedTime:    "",
3093 3109
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3147,13 +3163,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3147 3163
 		if len(drug_control) != 0 {
3148 3164
 			_, errcodesdrugcontrol := service.IsExistDicConfig(drugContorlConfig.ID, drug_control, orgId)
3149 3165
 			if errcodesdrugcontrol == gorm.ErrRecordNotFound {
3166
+				drugContorlConfigOne, _ := service.GetLastDicConfig(drugContorlConfig.ID, orgId)
3150 3167
 				dataconfig := models.DictDataconfig{
3151 3168
 					ParentId:       drugContorlConfig.ID,
3152 3169
 					Module:         "system",
3153 3170
 					OrgId:          orgId,
3154 3171
 					Name:           drug_control,
3155 3172
 					FieldName:      "",
3156
-					Value:          index + 50,
3173
+					Value:          drugContorlConfigOne.Value + 1,
3157 3174
 					CreatedTime:    "",
3158 3175
 					UpdatedTime:    "",
3159 3176
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3183,17 +3200,18 @@ func (this *StockManagerApiController) AddDrugInformation() {
3183 3200
 		var drug_category_id int64
3184 3201
 
3185 3202
 		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3186
-		fmt.Println("33333drugCategoryConfig", drugCategoryConfig)
3203
+
3187 3204
 		if len(drug_category) != 0 {
3188 3205
 			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3189 3206
 			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3207
+				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3190 3208
 				dataconfig := models.DictDataconfig{
3191 3209
 					ParentId:       drugCategoryConfig.ID,
3192 3210
 					Module:         "system",
3193 3211
 					OrgId:          orgId,
3194 3212
 					Name:           drug_category,
3195 3213
 					FieldName:      "",
3196
-					Value:          index + 50,
3214
+					Value:          drugCategoryConfigSix.Value + 1,
3197 3215
 					CreatedTime:    "",
3198 3216
 					UpdatedTime:    "",
3199 3217
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3259,13 +3277,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3259 3277
 		if len(drugDoseUnit) != 0 {
3260 3278
 			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3261 3279
 			if errcodedataconfig == gorm.ErrRecordNotFound {
3280
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3262 3281
 				dataconfig := models.Dataconfig{
3263 3282
 					ParentId:       dataConfig.ID,
3264 3283
 					Module:         "hemodialysis",
3265 3284
 					OrgId:          orgId,
3266 3285
 					Name:           drugDoseUnit,
3267 3286
 					FieldName:      "",
3268
-					Value:          index + 50,
3287
+					Value:          childConfig.Value + 1,
3269 3288
 					CreatedTime:    "",
3270 3289
 					UpdatedTime:    "",
3271 3290
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3296,8 +3315,8 @@ func (this *StockManagerApiController) AddDrugInformation() {
3296 3315
 	}
3297 3316
 
3298 3317
 	export_time := time.Now().Unix()
3299
-	errLogs, _ := service.FindPatientExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
3300
-	fmt.Println("数组", drugList)
3318
+	errLogs, _ := service.FindPatientExportLogOne(this.GetAdminUserInfo().CurrentOrgId, export_time)
3319
+
3301 3320
 	if len(drugList) > 0 {
3302 3321
 		for _, item := range drugList {
3303 3322
 
@@ -3395,3 +3414,64 @@ func (this *StockManagerApiController) AddDrugInformation() {
3395 3414
 		})
3396 3415
 	}
3397 3416
 }
3417
+
3418
+func (this *StockManagerApiController) GetInitializtion() {
3419
+
3420
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3421
+	var drugCategory = "药品类别"
3422
+	var drugType = "药品类型"
3423
+	var drugDosageForm = "药品剂型"
3424
+	var medicalInsuranceLevel = "医保等级"
3425
+	var drugControl = "开药控制"
3426
+	var drugClassify = "药物分类"
3427
+	var statisticsCategory = "统计分类"
3428
+	var pharmacologyCategory = "药理分类"
3429
+	var goodKind = "耗材种类"
3430
+	var tubeColor = "试管颜色"
3431
+	var costClassify = "费用类别"
3432
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
3433
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
3434
+
3435
+	drugCategoryParent, _ := service.GetDrugDataConfig(0, drugCategory)
3436
+	drugCategoryList, _ := service.GetParentDataConfig(drugCategoryParent.ID, orgId)
3437
+
3438
+	drugDosageFormParent, _ := service.GetDrugDataConfig(0, drugDosageForm)
3439
+	drugDosageFormList, _ := service.GetParentDataConfig(drugDosageFormParent.ID, orgId)
3440
+
3441
+	medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
3442
+	medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, orgId)
3443
+
3444
+	drugControlParent, _ := service.GetDrugDataConfig(0, drugControl)
3445
+	drugControlList, _ := service.GetParentDataConfig(drugControlParent.ID, orgId)
3446
+
3447
+	drugClassifyParent, _ := service.GetDrugDataConfig(0, drugClassify)
3448
+	drugClassifyList, _ := service.GetParentDataConfig(drugClassifyParent.ID, orgId)
3449
+
3450
+	statisticsCategoryParent, _ := service.GetDrugDataConfig(0, statisticsCategory)
3451
+	statisticsCategoryList, _ := service.GetParentDataConfig(statisticsCategoryParent.ID, orgId)
3452
+
3453
+	pharmacologyCategoryParent, _ := service.GetDrugDataConfig(0, pharmacologyCategory)
3454
+	pharmacologyCategoryList, _ := service.GetParentDataConfig(pharmacologyCategoryParent.ID, orgId)
3455
+
3456
+	goodKindParent, _ := service.GetDrugDataConfig(0, goodKind)
3457
+	goodKindList, _ := service.GetParentDataConfig(goodKindParent.ID, orgId)
3458
+
3459
+	tubeColorParent, _ := service.GetDrugDataConfig(0, tubeColor)
3460
+	tubeColorList, _ := service.GetParentDataConfig(tubeColorParent.ID, orgId)
3461
+
3462
+	costClassifyParent, _ := service.GetDrugDataConfig(0, costClassify)
3463
+	costClassifyList, _ := service.GetParentDataConfig(costClassifyParent.ID, orgId)
3464
+	this.ServeSuccessJSON(map[string]interface{}{
3465
+		"drugCategoryList":          drugCategoryList,
3466
+		"drugTypeList":              drugTypeList,
3467
+		"drugDosageFormList":        drugDosageFormList,
3468
+		"medicalInsuranceLevelList": medicalInsuranceLevelList,
3469
+		"drugControlList":           drugControlList,
3470
+		"drugClassifyList":          drugClassifyList,
3471
+		"statisticsCategoryList":    statisticsCategoryList,
3472
+		"pharmacologyCategoryList":  pharmacologyCategoryList,
3473
+		"goodKindList":              goodKindList,
3474
+		"tubeColorList":             tubeColorList,
3475
+		"costClassifyList":          costClassifyList,
3476
+	})
3477
+}

+ 1 - 0
models/dialysis.go View File

@@ -585,6 +585,7 @@ type AssessmentAfterDislysis struct {
585 585
 	SupineDiastolicBloodPressure    string  `gorm:"column:supine_diastolic_blood_pressure" json:"supine_diastolic_blood_pressure" form:"supine_diastolic_blood_pressure"`
586 586
 	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
587 587
 	OtherComplication               string  `gorm:"column:other_complication" json:"other_complication" form:"other_complication"`
588
+	Ktv                             string  `gorm:"column:ktv" json:"ktv" form:"ktv"`
588 589
 }
589 590
 
590 591
 func (AssessmentAfterDislysis) TableName() string {

+ 10 - 1
models/drug.go View File

@@ -16,9 +16,13 @@ type BaseDrugLib struct {
16 16
 	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
17 17
 	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
18 18
 	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
19
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
19 20
 	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
21
+	Dose                        float64 `gorm:"column:dose" json:"dose" form:"dose"`
22
+	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
20 23
 	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
21 24
 	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
25
+	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
22 26
 	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
23 27
 	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
24 28
 	Number                      string  `gorm:"column:number" json:"number" form:"number"`
@@ -56,10 +60,15 @@ type BaseDrugLib struct {
56 60
 	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
57 61
 	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
58 62
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
63
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
59 64
 	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
60 65
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
61 66
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
62
-	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
67
+	Dosage                      string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
68
+	Unval                       string  `gorm:"column:unval" json:"unval" form:"unval"`
69
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
70
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
71
+	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
63 72
 }
64 73
 
65 74
 func (BaseDrugLib) TableName() string {

+ 10 - 0
models/drug_stock.go View File

@@ -215,3 +215,13 @@ type DrugAutomaticReduceDetail struct {
215 215
 func (DrugAutomaticReduceDetail) TableName() string {
216 216
 	return "xt_drug_automatic_reduce_detail"
217 217
 }
218
+
219
+type VmDrugAutomaticReduceDetail struct {
220
+	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
221
+	WarehouseOutId          int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
222
+	WarehouseOutOrderNumber string `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
223
+	PatientId               int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
224
+	RecordTime              int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
225
+	DrugId                  int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
226
+	Total                   int64
227
+}

+ 80 - 0
models/his_hospital_models.go View File

@@ -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
+}

+ 334 - 41
models/his_models.go View File

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

+ 4 - 1
routers/router.go View File

@@ -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 View File

@@ -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
+}

+ 42 - 4
service/dialysis_service.go View File

@@ -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
 
@@ -1093,12 +1093,18 @@ func UpdateDialysisBeforePrepare(info *models.DialysisBeforePrepare) (err error)
1093 1093
 
1094 1094
 func UpdateDialysisBeforePrepareTwo(info *models.DialysisBeforePrepare) (err error) {
1095 1095
 	err = writeDb.Model(&models.DialysisBeforePrepare{}).
1096
-		Where("status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND user_org_id = ? AND record_date = ?", info.GoodId, info.GoodTypeId, info.PatientId, info.UserOrgId, info.RecordDate).
1097
-		Updates(map[string]interface{}{"count": info.Count, "updated_time": time.Now().Unix(), "modifier": info.Modifier, "commdity_code": info.CommdityCode}).Error
1096
+		Where("status = 1 and good_id = ? AND good_type_id = ? AND patient_id = ? AND user_org_id = ? AND record_date = ?", info.GoodId, info.GoodTypeId, info.PatientId, info.UserOrgId, info.RecordDate).
1097
+		Updates(map[string]interface{}{"count": info.Count, "updated_time": time.Now().Unix(), "modifier": info.Modifier, "commdity_code": info.CommdityCode, "status": 1}).Error
1098 1098
 
1099 1099
 	return err
1100 1100
 }
1101 1101
 
1102
+func UpdateAutoReduceDetailSix(detail *models.AutomaticReduceDetail) (err error) {
1103
+
1104
+	err = writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? and good_type_id = ? And patient_id = ? and org_id =?", detail.GoodId, detail.GoodTypeId, detail.PatientId, detail.OrgId).Updates(map[string]interface{}{"count": detail.Count, "mtime": detail.Mtime, "status": 1}).Error
1105
+	return err
1106
+}
1107
+
1102 1108
 func UpdateOrderCountSub(good_type_id int64, good_id int64, number string, org_id int64, count int64) {
1103 1109
 	writeDb.Model(&models.WarehouseOutInfo{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, number).UpdateColumn("count", gorm.Expr("count - ?", count))
1104 1110
 
@@ -1110,7 +1116,7 @@ func UpdateOrderCountAdd(good_type_id int64, good_id int64, number string, org_i
1110 1116
 }
1111 1117
 
1112 1118
 func UpdateUserInfoDetails(good_type_id int64, good_id int64, time int64, org_id int64, patient_id int64, count int64, out *models.WarehouseOutInfo) {
1113
-	writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND warehouse_out_order_number = ? AND patient_id = ?", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber, patient_id).Updates(map[string]interface{}{"count": count})
1119
+	writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND warehouse_out_order_number = ? AND patient_id = ?", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber, patient_id).Updates(map[string]interface{}{"count": count, "status": 1})
1114 1120
 	//writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber).UpdateColumn("count", count)
1115 1121
 
1116 1122
 }
@@ -1173,3 +1179,35 @@ func CreateDialysisBeforePrepareOne(prepare *models.DialysisBeforePrepare) error
1173 1179
 	err := XTReadDB().Create(&prepare).Error
1174 1180
 	return err
1175 1181
 }
1182
+
1183
+func ModifyExceDoctorAdviceById(m *models.HisDoctorAdviceInfo, ids []string) (err error) {
1184
+
1185
+	ut := writeDb.Begin()
1186
+	err = ut.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1   AND id IN (?) AND execution_state = 1", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
1187
+	if err != nil {
1188
+		ut.Rollback()
1189
+		return
1190
+	}
1191
+	err = ut.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1   AND parent_id IN (?) AND execution_state = 1 ", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
1192
+	if err != nil {
1193
+		ut.Rollback()
1194
+		return
1195
+	}
1196
+	ut.Commit()
1197
+	return err
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
+}

+ 32 - 2
service/gobal_config_service.go View File

@@ -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 = ? AND his_order.order_status > 1 ", 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).
@@ -459,3 +475,17 @@ func GetMonitorConfigById(orgid int64) (*models.XtMonitorConfig, error) {
459 475
 	}
460 476
 	return &config, nil
461 477
 }
478
+
479
+func GetDrugAutoMaticList(orgid int64, warehouse_out_id int64, record_time int64, warehouse_out_order_number string) (auto []*models.VmDrugAutomaticReduceDetail, err error) {
480
+
481
+	db := XTReadDB().Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
482
+	err = db.Select("x.org_id,x.warehouse_out_id,x.record_time,x.drug_id,sum(x.count) as total").Where("x.org_id = ?  and x.record_time = ? and x.status= 1 and x.warehouse_out_order_number = ?", orgid, record_time, warehouse_out_order_number).Group("x.drug_id").Scan(&auto).Error
483
+	return auto, err
484
+
485
+}
486
+
487
+func GetAllBaseDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
488
+
489
+	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
490
+	return drug, err
491
+}

+ 48 - 0
service/his_config_service.go View File

@@ -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 View File

@@ -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
+}

+ 23 - 8
service/his_project_service.go View File

@@ -47,7 +47,7 @@ func GetHisProjectList(orgid int64, limit int64, page int64, charge int64, start
47 47
 	if isMark > 0 {
48 48
 		db = db.Where("x.is_mark = ?", isMark)
49 49
 	}
50
-	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time,x.is_mark").Count(&total).Offset(offset).Limit(limit).Find(&hisproject).Error
50
+	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time,x.is_mark").Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&hisproject).Error
51 51
 	return hisproject, total, err
52 52
 }
53 53
 
@@ -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
@@ -264,6 +264,8 @@ func CreateHisPatient(patient *models.XtHisPatient) error {
264 264
 
265 265
 func UpdateHisPrescriptionHisID(his_patient_id int64, patient_id int64, record_time int64, org_id int64) {
266 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
+
267 269
 	return
268 270
 }
269 271
 
@@ -287,8 +289,8 @@ func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err err
287 289
 	return project, err
288 290
 }
289 291
 
290
-func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProject, err error) {
291
-	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
292 294
 	return project, err
293 295
 }
294 296
 
@@ -396,7 +398,9 @@ func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatien
396 398
 
397 399
 func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string, orgid int64) (prescription []*models.HisPrescription, err error) {
398 400
 
399
-	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", "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
400 404
 
401 405
 	return prescription, err
402 406
 }
@@ -540,7 +544,7 @@ func GetChargePrintTemplate(orgid int64) (models.XtHisChargeTemplate, error) {
540 544
 func GetDoctorProjectItem(patientid int64, record_date int64) (models.HisPrescriptionProject, error) {
541 545
 
542 546
 	project := models.HisPrescriptionProject{}
543
-	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
544 548
 	return project, err
545 549
 }
546 550
 
@@ -590,9 +594,9 @@ func GetPrscriptionInfo(patientid int64, recorddata int64) (info []*models.HisPr
590 594
 
591 595
 }
592 596
 
593
-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) {
594 598
 
595
-	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
596 600
 	return prescritpion, err
597 601
 }
598 602
 
@@ -697,3 +701,14 @@ func GetLastItem(orgid int64) (models.XtHisProjectList, error) {
697 701
 	err := XTReadDB().Model(&list).Where("user_org_id = ? and status = 1", orgid).Last(&list).Error
698 702
 	return list, err
699 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
+}

+ 344 - 153
service/his_service.go View File

@@ -35,6 +35,7 @@ type HisPatient struct {
35 35
 	HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"prescription"`
36 36
 	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
37 37
 	Number          string             `gorm:"column:number" json:"number" form:"number"`
38
+	VMHisOrders     []*VMHisOrder      `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"orders"`
38 39
 	VMHisOrder      VMHisOrder         `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"order"`
39 40
 }
40 41
 
@@ -106,6 +107,9 @@ type VMHisOrder struct {
106 107
 	Creator               int64   `gorm:"column:creator" json:"creator" form:"creator"`
107 108
 	MdtrtId               string  `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
108 109
 	MzNumber              string  `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
110
+
111
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
112
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
109 113
 }
110 114
 
111 115
 func (VMHisOrder) TableName() string {
@@ -154,8 +158,8 @@ func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64,
154 158
 	}
155 159
 
156 160
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
157
-	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
158
-	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
161
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
162
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
159 163
 	return
160 164
 }
161 165
 
@@ -189,8 +193,8 @@ func GetHisPatientList(org_id int64, keywords string, record_date int64) (patien
189 193
 	db := readDb.Model(&Patients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
190 194
 		Joins("join his_patient as hp ON hp.patient_id = xt_patients.id AND hp.record_date = ? AND hp.status = 1 AND hp.user_org_id = ?", record_date, org_id)
191 195
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
192
-	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
193
-	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Find(&patients).Error
196
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
197
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?  AND p_type <> 1", org_id, record_date).Find(&patients).Error
194 198
 	return
195 199
 }
196 200
 
@@ -261,8 +265,8 @@ func GetNewHisPatientList(org_id int64, record_date int64) (patients []*PatientT
261 265
 	return
262 266
 }
263 267
 
264
-func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*Patients, err error) {
265
-	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
268
+func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*PatientTwo, err error) {
269
+	db := readDb.Model(&PatientTwo{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
266 270
 
267 271
 	if sch_type != 0 {
268 272
 		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_type = ?", record_date, org_id, sch_type)
@@ -271,7 +275,6 @@ func GetNewScheduleHisPatientList(org_id int64, keywords string, record_date int
271 275
 	}
272 276
 
273 277
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
274
-	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
275 278
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
276 279
 	return
277 280
 }
@@ -301,6 +304,11 @@ func GetNewHisPatientInfoTwo(org_id int64, id int64, record_date int64) (info mo
301 304
 	return
302 305
 }
303 306
 
307
+func GetHisPatientCount(org_id int64, patient_id int64, record_date int64) (total int64, err error) {
308
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Count(&total).Error
309
+	return
310
+}
311
+
304 312
 func GetXTPatientInfo(org_id int64, patient_id int64) (info models.Patients, err error) {
305 313
 	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1  AND id = ?", org_id, patient_id).First(&info).Error
306 314
 	return
@@ -392,7 +400,7 @@ func DelelteProject(id int64, user_org_id int64) (err error) {
392 400
 	return
393 401
 }
394 402
 
395
-func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
403
+func GetHisPrescription(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
396 404
 	err = readDb.Model(&models.HisPrescription{}).
397 405
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
398 406
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -401,14 +409,14 @@ func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (pres
401 409
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
402 410
 		}).
403 411
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
404
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
412
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
405 413
 		}).
406
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?  ", org_id, record_date, patient_id).
414
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ?", org_id, record_date, patient_id, p_type).
407 415
 		Find(&prescription).Error
408 416
 	return
409 417
 }
410 418
 
411
-func GetNewHisPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
419
+func GetNewHisPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
412 420
 	err = readDb.Model(&models.HisPrescription{}).
413 421
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
414 422
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -417,14 +425,14 @@ func GetNewHisPrescription(org_id int64, patient_id int64, his_patient_id int64,
417 425
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
418 426
 		}).
419 427
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
420
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
428
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
421 429
 		}).
422
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? ", org_id, record_date, patient_id, his_patient_id).
430
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, his_patient_id, p_type).
423 431
 		Find(&prescription).Error
424 432
 	return
425 433
 }
426 434
 
427
-func GetChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
435
+func GetChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
428 436
 	err = readDb.Model(&models.HisPrescription{}).
429 437
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
430 438
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -433,14 +441,14 @@ func GetChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id
433 441
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
434 442
 		}).
435 443
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
436
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
444
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
437 445
 		}).
438
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 2 AND his_patient_id = ?", org_id, record_date, patient_id, his_patient_id).
446
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 2 AND his_patient_id = ? AND p_type = ?", org_id, record_date, patient_id, his_patient_id, p_type).
439 447
 		Find(&prescription).Error
440 448
 	return
441 449
 }
442 450
 
443
-func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
451
+func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
444 452
 	err = readDb.Model(&models.HisPrescription{}).
445 453
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
446 454
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -449,9 +457,9 @@ func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_
449 457
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
450 458
 		}).
451 459
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
452
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
460
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
453 461
 		}).
454
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? AND order_status <> 2 AND order_status <> 3", org_id, record_date, patient_id, his_patient_id).
462
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND his_patient_id = ? AND order_status <> 2 AND order_status <> 3 AND p_type = ?", org_id, record_date, patient_id, his_patient_id, p_type).
455 463
 		Find(&prescription).Error
456 464
 	return
457 465
 }
@@ -465,9 +473,9 @@ func GetSettleHisPrescription(org_id int64, patient_id int64, his_patient_id int
465 473
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
466 474
 		}).
467 475
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
468
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
476
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
469 477
 		}).
470
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND his_patient_id = ?", org_id, record_date, patient_id, his_patient_id).
478
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND his_patient_id = ? AND p_type <> 1", org_id, record_date, patient_id, his_patient_id).
471 479
 		Find(&prescription).Error
472 480
 	return
473 481
 }
@@ -481,14 +489,14 @@ func GetMonthHisPrescription(org_id int64, patient_id int64, start_date int64, e
481 489
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
482 490
 		}).
483 491
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
484
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
492
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
485 493
 		}).
486
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 ", org_id, start_date, end_date, patient_id).
494
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1", org_id, start_date, end_date, patient_id).
487 495
 		Find(&prescription).Error
488 496
 	return
489 497
 }
490 498
 
491
-func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
499
+func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
492 500
 	err = readDb.Model(&models.HisPrescription{}).
493 501
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
494 502
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -497,14 +505,14 @@ func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64
497 505
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
498 506
 		}).
499 507
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
500
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
508
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
501 509
 		}).
502
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?", org_id, start_date, end_date, patient_id).
510
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
503 511
 		Find(&prescription).Error
504 512
 	return
505 513
 }
506 514
 
507
-func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
515
+func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
508 516
 	err = readDb.Model(&models.HisPrescription{}).
509 517
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
510 518
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -513,15 +521,15 @@ func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int
513 521
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
514 522
 		}).
515 523
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
516
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
524
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
517 525
 		}).
518
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  ", org_id, start_date, end_date, patient_id).
526
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND p_type = ? ", org_id, start_date, end_date, patient_id, p_type).
519 527
 		Find(&prescription).Error
520 528
 	return
521 529
 }
522 530
 
523 531
 //未收费
524
-func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
532
+func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
525 533
 	err = readDb.Model(&models.HisPrescription{}).
526 534
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
527 535
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -530,15 +538,15 @@ func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_
530 538
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
531 539
 		}).
532 540
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
533
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
541
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
534 542
 		}).
535
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND  order_status <> 2 AND order_status <> 3 ", org_id, start_date, end_date, patient_id).
543
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND  order_status <> 2 AND order_status <> 3  AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
536 544
 		Find(&prescription).Error
537 545
 	return
538 546
 }
539 547
 
540 548
 //已收费
541
-func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
549
+func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
542 550
 	err = readDb.Model(&models.HisPrescription{}).
543 551
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
544 552
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -547,9 +555,9 @@ func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_dat
547 555
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
548 556
 		}).
549 557
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
550
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
558
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
551 559
 		}).
552
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status = 2", org_id, start_date, end_date, patient_id).
560
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status = 2 AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
553 561
 		Find(&prescription).Error
554 562
 	return
555 563
 }
@@ -603,58 +611,75 @@ func (VMDrugCancelStockInfo) TableName() string {
603 611
 }
604 612
 
605 613
 type BaseDrugLib struct {
606
-	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
607
-	DrugName               string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
608
-	Pinyin                 string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
609
-	Wubi                   string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
610
-	DrugAlias              string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
611
-	DrugAliasPinyin        string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
612
-	DrugAliasWubi          string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
613
-	DrugCategory           int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
614
-	DrugSpec               string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
615
-	DrugType               int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
616
-	DrugStockLimit         string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
617
-	DrugOriginPlace        string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
618
-	DrugDosageForm         int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
619
-	MedicalInsuranceLevel  int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
620
-	MaxUnit                string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
621
-	MinUnit                string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
622
-	UnitMatrixing          string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
623
-	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
624
-	LastPrice              float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
625
-	DrugControl            int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
626
-	Number                 string  `gorm:"column:number" json:"number" form:"number"`
627
-	DrugClassify           string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
628
-	DrugDose               float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
629
-	DrugDoseUnit           int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
630
-	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
631
-	Manufacturer           int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
632
-	PharmacologyCategory   int64   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
633
-	StatisticsCategory     int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
634
-	Code                   string  `gorm:"column:code" json:"code" form:"code"`
635
-	IsSpecialDiseases      int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
636
-	IsRecord               int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
637
-	Agent                  string  `gorm:"column:agent" json:"agent" form:"agent"`
638
-	DrugStatus             string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
639
-	LimitRemark            string  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
640
-	DeliveryWay            string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
641
-	ExecutionFrequency     string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
642
-	SingleDose             float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
643
-	PrescribingNumber      float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
644
-	Label                  int64   `gorm:"column:label" json:"label" form:"label"`
645
-	Sort                   int64   `gorm:"column:sort" json:"sort" form:"sort"`
646
-	IsUseDoctorAdvice      int64   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
647
-	IsDefault              int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
648
-	IsChargePredict        int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
649
-	IsStatisticsWork       int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
650
-	IsChargeUse            int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
651
-	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
652
-	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
653
-	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
654
-	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
655
-	DrugCode               string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
656
-	HospApprFlag           int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
657
-	LmtUsedFlag            int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
614
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
615
+	DrugName                    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
616
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
617
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
618
+	DrugAlias                   string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
619
+	DrugAliasPinyin             string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
620
+	DrugAliasWubi               string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
621
+	DrugCategory                int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
622
+	DrugSpec                    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
623
+	DrugType                    int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
624
+	DrugStockLimit              string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
625
+	DrugOriginPlace             string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
626
+	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
627
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
628
+	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
629
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
630
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
631
+	Dose                        float64 `gorm:"column:dose" json:"dose" form:"dose"`
632
+	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
633
+	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
634
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
635
+	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
636
+	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
637
+	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
638
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
639
+	DrugClassify                string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
640
+	DrugDose                    float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
641
+	DrugDoseUnit                int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
642
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
643
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
644
+	PharmacologyCategory        int64   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
645
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
646
+	Code                        string  `gorm:"column:code" json:"code" form:"code"`
647
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
648
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
649
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
650
+	DrugStatus                  string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
651
+	LimitRemark                 string  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
652
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
653
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
654
+	SingleDose                  float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
655
+	PrescribingNumber           float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
656
+	Label                       int64   `gorm:"column:label" json:"label" form:"label"`
657
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
658
+	IsUseDoctorAdvice           int64   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
659
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
660
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
661
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
662
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
663
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
664
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
665
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
666
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
667
+	DrugCode                    string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
668
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
669
+	PrescriptionMark            int64   `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
670
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
671
+	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
672
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
673
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
674
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
675
+	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
676
+	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
677
+	Dosage                      string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
678
+	Unval                       string  `gorm:"column:unval" json:"unval" form:"unval"`
679
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
680
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
681
+	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
682
+
658 683
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
659 684
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
660 685
 	VMDrugSalesReturnInfo  []*VMDrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
@@ -701,7 +726,7 @@ func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdvicePare
701 726
 func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
702 727
 	err = readUserDb.Model(&models.UserAdminRole{}).Preload("XtHisDepartment", func(db *gorm.DB) *gorm.DB {
703 728
 		return readDb.Model(&models.XtHisDepartment{}).Where("status = 1 AND user_org_id = ?", org_id)
704
-	}).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
729
+	}).Where("org_id = ? AND status = 1 AND user_type = 2", org_id).Find(&doctors).Error
705 730
 	return
706 731
 }
707 732
 
@@ -740,8 +765,14 @@ func CreateOrderInfo(order *models.HisOrderInfo) (err error) {
740 765
 	return
741 766
 }
742 767
 
743
-func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
744
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
768
+func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
769
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
770
+	return
771
+
772
+}
773
+
774
+func FindHisPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64, p_type int64, his_patient_id int64) (info models.HisPrescriptionInfo, err error) {
775
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? AND his_patient_id = ? ", org_id, record_date, patient_id, p_type, his_patient_id).First(&info).Error
745 776
 	return
746 777
 
747 778
 }
@@ -757,7 +788,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
757 788
 
758 789
 }
759 790
 
760
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string) (order []*models.HisOrder, err error, total int64) {
791
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string, p_type int64) (order []*models.HisOrder, err error, total int64) {
761 792
 	offset := (page - 1) * limit
762 793
 	db := readDb.Model(&models.HisOrder{})
763 794
 
@@ -778,12 +809,13 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int6
778 809
 		db = db.Where("his_order.settle_accounts_date<=?", end_time)
779 810
 	}
780 811
 
781
-	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ?", user_org_id)
812
+	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ?", user_org_id, p_type)
782 813
 
783 814
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
784 815
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
785
-		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id)
786
-
816
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
817
+		Preload("HisHospitalCheckRecord", "status = 1 AND user_org_id = ?", user_org_id)
818
+	db = db.Preload("HisFundSettleListResult", "status = 1")
787 819
 	db = db.Count(&total)
788 820
 	err = db.Limit(limit).Offset(offset).Order("setl_time desc,ctime").Find(&order).Error
789 821
 	return
@@ -805,6 +837,12 @@ func UpDatePrescriptionInfoNumber(user_org_id int64, id int64, number string, re
805 837
 	return
806 838
 }
807 839
 
840
+func UpDateHisPrescriptionInfoNumber(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64) (err error) {
841
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
842
+
843
+	return
844
+}
845
+
808 846
 type HisOrder struct {
809 847
 	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
810 848
 	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -832,6 +870,9 @@ type HisOrder struct {
832 870
 	HisPatient          models.HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
833 871
 	HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
834 872
 	HisPrescription     []*models.HisPrescription  `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
873
+
874
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
875
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
835 876
 }
836 877
 
837 878
 func (HisOrder) TableName() string {
@@ -853,7 +894,7 @@ func GetHisPrescriptionThree(org_id int64, patient_id int64, number string) (pre
853 894
 	err = readDb.Model(&models.HisPrescription{}).
854 895
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
855 896
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
856
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
897
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
857 898
 		}).
858 899
 		Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
859 900
 		Where("user_org_id = ? AND status = 1  AND patient_id = ? AND batch_number=?", org_id, patient_id, number).
@@ -903,7 +944,7 @@ func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescrip
903 944
 }
904 945
 
905 946
 func GetHisPrescriptionOrderInfo(id int64, org_id int64) (prescriptionOrder HisPrescriptionInfo, err error) {
906
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ? ", id, org_id).
947
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, org_id).
907 948
 		Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
908 949
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
909 950
 		Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
@@ -915,7 +956,7 @@ func GetHisPrescriptionFour(org_id int64, patient_id int64, record_date int64, n
915 956
 	err = readDb.Model(&models.HisPrescription{}).
916 957
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
917 958
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
918
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
959
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
919 960
 		}).
920 961
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND prescription_number=?", org_id, record_date, patient_id, number).
921 962
 		Find(&prescription).Error
@@ -929,7 +970,7 @@ func GetMedicalInsuranceConfig(org_id int64) (medicalInsuranceConfig models.Medi
929 970
 }
930 971
 
931 972
 func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
932
-	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
973
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix()}).Error
933 974
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
934 975
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
935 976
 
@@ -1019,6 +1060,9 @@ type XtHisOrder struct {
1019 1060
 	HisPatient          models.HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
1020 1061
 	HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
1021 1062
 	HisPrescription     []*models.HisPrescription  `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
1063
+
1064
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1065
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
1022 1066
 }
1023 1067
 
1024 1068
 func (XtHisOrder) TableName() string {
@@ -1029,7 +1073,7 @@ func GetHisPrescriptionNight(org_id int64, patient_id int64, record_date int64,
1029 1073
 	err = readDb.Model(&models.HisPrescription{}).
1030 1074
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? and prescription_id =?", org_id, prescription_id).
1031 1075
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1032
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1076
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
1033 1077
 		}).
1034 1078
 		Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
1035 1079
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
@@ -1048,18 +1092,32 @@ func DelelteAddition(id int64, user_org_id int64) (err error) {
1048 1092
 	return
1049 1093
 }
1050 1094
 
1095
+func GetNewHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
1096
+	offset := (page - 1) * limit
1097
+	db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 ", org_id, record_date)
1098
+	if len(keywords) > 0 {
1099
+		keywords = "%" + keywords + "%"
1100
+		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)
1101
+	}
1102
+	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
1103
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND p_type <> 1", org_id)
1104
+	db = db.Count(&total)
1105
+	err = db.Limit(limit).Offset(offset).Find(&patients).Error
1106
+	return
1107
+}
1108
+
1051 1109
 func GetHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMSchedule, err error, total int64) {
1052 1110
 	offset := (page - 1) * limit
1053 1111
 	db := readDb.Model(&VMSchedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
1054 1112
 	if len(keywords) > 0 {
1055 1113
 		keywords = "%" + keywords + "%"
1056 1114
 		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)
1057
-		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 ?", org_id, record_date, keywords)
1115
+		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)
1058 1116
 	}
1059 1117
 	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
1060 1118
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
1061
-	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).
1062
-		Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1", org_id)
1119
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND p_type <> 1", org_id).
1120
+		Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND p_type <> 1", org_id)
1063 1121
 	db = db.Count(&total)
1064 1122
 	err = db.Limit(limit).Offset(offset).Find(&patients).Error
1065 1123
 	return
@@ -1106,39 +1164,54 @@ func (VMHisPrescription) TableName() string {
1106 1164
 	return "his_prescription"
1107 1165
 }
1108 1166
 
1109
-func GetHisPrescriptionByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
1167
+func GetHisPrescriptionByType(change_type int64, record_time int64, org_id int64, patient_id int64, p_type int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
1110 1168
 	if change_type == 1 { //根据日期取出上一方数据
1111 1169
 		var Id AdviceDate
1112
-		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
1113
-		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).
1170
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ? AND p_type = ?", patient_id, org_id, record_time, p_type).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
1171
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ? AND p_type = ?", patient_id, org_id, Id.RecordDate, p_type).
1114 1172
 			Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
1115 1173
 				return db.Where("status = 1 AND user_org_id = ?", org_id).
1116 1174
 					Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1117 1175
 						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
1118 1176
 					}).
1119 1177
 					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1120
-						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1178
+						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
1121 1179
 					})
1122 1180
 			}).Find(&advice).Error
1123 1181
 
1124 1182
 	} else if change_type == 2 {
1125 1183
 		var Id AdviceDate
1126
-		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
1127
-		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).
1184
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ? AND p_type = ?", patient_id, org_id, record_time, p_type).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
1185
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ? AND p_type = ?", patient_id, org_id, Id.RecordDate, p_type).
1128 1186
 			Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
1129 1187
 				return db.Where("status = 1 AND user_org_id = ?", org_id).
1130 1188
 					Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1131 1189
 						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
1132 1190
 					}).
1133 1191
 					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1134
-						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1192
+						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
1135 1193
 					})
1136 1194
 			}).Find(&advice).Error
1137 1195
 	}
1138 1196
 	return
1139 1197
 }
1140 1198
 
1141
-func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
1199
+func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64, p_type int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
1200
+	err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date >= ? AND record_date <= ? AND p_type = ?", patient_id, org_id, start_time, end_time, p_type).
1201
+		Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
1202
+			return db.Where("status = 1 AND user_org_id = ?", org_id).
1203
+				Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1204
+					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
1205
+				}).
1206
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1207
+					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
1208
+				})
1209
+		}).Find(&advice).Error
1210
+
1211
+	return
1212
+}
1213
+
1214
+func GetMobileCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
1142 1215
 	err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date >= ? AND record_date <= ?", patient_id, org_id, start_time, end_time).
1143 1216
 		Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
1144 1217
 			return db.Where("status = 1 AND user_org_id = ?", org_id).
@@ -1146,7 +1219,7 @@ func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, pat
1146 1219
 					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
1147 1220
 				}).
1148 1221
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1149
-					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1222
+					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
1150 1223
 				})
1151 1224
 		}).Find(&advice).Error
1152 1225
 
@@ -1227,20 +1300,21 @@ func GetHisPrescriptionByPatientID(patientID int64, orgID int64) (info models.Hi
1227 1300
 }
1228 1301
 
1229 1302
 type VMHisProjectTeam struct {
1230
-	ID           int64           `gorm:"column:id" json:"id" form:"id"`
1231
-	ProjectTeam  string          `gorm:"column:project_team" json:"project_team" form:"project_team"`
1232
-	Price        float64         `gorm:"column:price" json:"price" form:"price"`
1233
-	Pinyin       string          `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
1234
-	Wubi         string          `gorm:"column:wubi" json:"wubi" form:"wubi"`
1235
-	TubeColor    int64           `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
1236
-	TeamType     int64           `gorm:"column:team_type" json:"team_type" form:"team_type"`
1237
-	Remark       string          `gorm:"column:remark" json:"remark" form:"remark"`
1238
-	UserOrgId    int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1239
-	Status       int64           `gorm:"column:status" json:"status" form:"status"`
1240
-	CreatedTime  int64           `gorm:"column:created_time" json:"created_time" form:"created_time"`
1241
-	UpdatedTime  int64           `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1242
-	ProjectId    string          `gorm:"column:project_id" json:"project_id" form:"project_id"`
1243
-	VMHisProject []*VMHisProject `gorm:"-" json:"project" form:"project"`
1303
+	ID                int64                `gorm:"column:id" json:"id" form:"id"`
1304
+	ProjectTeam       string               `gorm:"column:project_team" json:"project_team" form:"project_team"`
1305
+	Price             float64              `gorm:"column:price" json:"price" form:"price"`
1306
+	Pinyin            string               `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
1307
+	Wubi              string               `gorm:"column:wubi" json:"wubi" form:"wubi"`
1308
+	TubeColor         int64                `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
1309
+	TeamType          int64                `gorm:"column:team_type" json:"team_type" form:"team_type"`
1310
+	Remark            string               `gorm:"column:remark" json:"remark" form:"remark"`
1311
+	UserOrgId         int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1312
+	Status            int64                `gorm:"column:status" json:"status" form:"status"`
1313
+	CreatedTime       int64                `gorm:"column:created_time" json:"created_time" form:"created_time"`
1314
+	UpdatedTime       int64                `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1315
+	ProjectId         string               `gorm:"column:project_id" json:"project_id" form:"project_id"`
1316
+	VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
1317
+	ItemId            string               `gorm:"column:item_id" json:"item_id" form:"item_id"`
1244 1318
 }
1245 1319
 
1246 1320
 func (VMHisProjectTeam) TableName() string {
@@ -1267,6 +1341,24 @@ func (VMHisProject) TableName() string {
1267 1341
 	return "xt_his_project"
1268 1342
 }
1269 1343
 
1344
+type VMItemProjectList struct {
1345
+	ID           int64        `gorm:"column:id" json:"id" form:"id"`
1346
+	Number       int64        `gorm:"column:number" json:"number" form:"number"`
1347
+	UserOrgId    int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1348
+	ProjectId    int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
1349
+	Status       int64        `gorm:"column:status" json:"status" form:"status"`
1350
+	CreatedTime  int64        `gorm:"column:created_time" json:"created_time" form:"created_time"`
1351
+	UpdatedTime  int64        `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1352
+	TeamId       int64        `gorm:"column:team_id" json:"team_id" form:"team_id"`
1353
+	Type         int64        `gorm:"column:type" json:"type" form:"type"`
1354
+	VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1355
+	GoodInfo     GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
1356
+}
1357
+
1358
+func (VMItemProjectList) TableName() string {
1359
+	return "xt_his_project_list"
1360
+}
1361
+
1270 1362
 type VMHisPrescriptionTwo struct {
1271 1363
 	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1272 1364
 	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -1284,10 +1376,10 @@ func (VMHisPrescriptionTwo) TableName() string {
1284 1376
 func GetAllProjectTeamList(orgid int64) (project []*VMHisProjectTeam, err error) {
1285 1377
 	err = XTReadDB().Model(&VMHisProjectTeam{}).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
1286 1378
 	for _, item := range project {
1287
-		var project_item []*VMHisProject
1288
-		ids := strings.Split(item.ProjectId, ",")
1289
-		XTReadDB().Model(&VMHisProject{}).Where("status = 1 AND id IN (?)", ids).Find(&project_item)
1290
-		item.VMHisProject = append(item.VMHisProject, project_item...)
1379
+		var project_item []*VMItemProjectList
1380
+		ids := strings.Split(item.ItemId, ",")
1381
+		XTReadDB().Model(&VMItemProjectList{}).Where("status = 1 AND id IN (?)", ids).Preload("VMHisProject", "status = 1 AND user_org_id = ?", orgid).Preload("GoodInfo", "status = 1 AND org_id = ?", orgid).Find(&project_item)
1382
+		item.VMItemProjectList = append(item.VMItemProjectList, project_item...)
1291 1383
 	}
1292 1384
 	return
1293 1385
 }
@@ -1323,28 +1415,40 @@ func (HisDoctorAdviceInfo) TableName() string {
1323 1415
 }
1324 1416
 
1325 1417
 type HisPrescriptionProject struct {
1326
-	ID                   int64                `gorm:"column:id" json:"id" form:"id"`
1327
-	ProjectId            int64                `gorm:"column:project_id" json:"project_id" form:"project_id"`
1328
-	Price                float64              `gorm:"column:price" json:"price" form:"price"`
1329
-	UserOrgId            int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1330
-	Status               int64                `gorm:"column:status" json:"status" form:"status"`
1331
-	Ctime                int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
1332
-	Mtime                int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
1333
-	PatientId            int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1334
-	HisPatientId         int64                `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1335
-	RecordDate           int64                `gorm:"column:record_date" json:"record_date" form:"record_date"`
1336
-	PrescriptionId       int64                `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1337
-	Count                int64                `gorm:"column:count" json:"count" form:"count"`
1338
-	FeedetlSn            string               `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1339
-	MedListCodg          string               `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1340
-	SingleDose           string               `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1341
-	DeliveryWay          string               `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1342
-	ExecutionFrequency   string               `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1343
-	Day                  string               `gorm:"column:day" json:"day" form:"day"`
1344
-	VMHisProject         VMHisProject         `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
1418
+	ID                 int64        `gorm:"column:id" json:"id" form:"id"`
1419
+	ProjectId          int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
1420
+	Price              float64      `gorm:"column:price" json:"price" form:"price"`
1421
+	UserOrgId          int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1422
+	Status             int64        `gorm:"column:status" json:"status" form:"status"`
1423
+	Ctime              int64        `gorm:"column:ctime" json:"ctime" form:"ctime"`
1424
+	Mtime              int64        `gorm:"column:mtime" json:"mtime" form:"mtime"`
1425
+	PatientId          int64        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1426
+	HisPatientId       int64        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1427
+	RecordDate         int64        `gorm:"column:record_date" json:"record_date" form:"record_date"`
1428
+	PrescriptionId     int64        `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1429
+	Count              int64        `gorm:"column:count" json:"count" form:"count"`
1430
+	FeedetlSn          string       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1431
+	MedListCodg        string       `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1432
+	SingleDose         string       `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1433
+	DeliveryWay        string       `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1434
+	ExecutionFrequency string       `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1435
+	Day                string       `gorm:"column:day" json:"day" form:"day"`
1436
+	VMHisProject       VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
1437
+	VMGoodInfo         VMGoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
1438
+
1345 1439
 	Remark               string               `gorm:"column:remark" json:"remark" form:"remark"`
1346 1440
 	Unit                 string               `gorm:"column:unit" json:"unit" form:"unit"`
1347 1441
 	VMHisPrescriptionTwo VMHisPrescriptionTwo `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"prescription"`
1442
+	Type                 int64                `gorm:"column:type" json:"type" form:"type"`
1443
+
1444
+	Doctor         int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
1445
+	ExecutionTime  int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1446
+	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1447
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1448
+	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
1449
+	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
1450
+	Checker        int64 `gorm:"column:checker" json:"checker" form:"checker"`
1451
+	StartTime      int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
1348 1452
 }
1349 1453
 
1350 1454
 func (HisPrescriptionProject) TableName() string {
@@ -1378,7 +1482,7 @@ func (HisOrderInfo) TableName() string {
1378 1482
 
1379 1483
 func GetHisOrderDetailByNumber(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
1380 1484
 	err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1381
-		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id)
1485
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
1382 1486
 	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1383 1487
 		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
1384 1488
 	}).Find(&order).Error
@@ -1531,7 +1635,7 @@ func GetNewHisOrder(user_org_id int64, mdtrt_id string, patient_id int64) (order
1531 1635
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
1532 1636
 		Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
1533 1637
 		Order("ctime desc").
1534
-		Find(&order).Error
1638
+		Last(&order).Error
1535 1639
 	return
1536 1640
 }
1537 1641
 
@@ -1601,10 +1705,20 @@ func (NewTempPatients) TableName() string {
1601 1705
 func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
1602 1706
 	db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
1603 1707
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
1604
-		return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrder", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
1708
+		return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
1605 1709
 	})
1606
-	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
1607
-	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Find(&patients).Error
1710
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date)
1711
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Find(&patients).Error
1712
+
1713
+	for _, item := range patients {
1714
+		for _, sumItem := range item.HisPatient {
1715
+			if len(sumItem.VMHisOrders) > 0 {
1716
+				sumItem.VMHisOrder.OrderStatus = sumItem.VMHisOrders[len(sumItem.VMHisOrders)-1].OrderStatus
1717
+			}
1718
+		}
1719
+
1720
+	}
1721
+
1608 1722
 	return
1609 1723
 }
1610 1724
 
@@ -1628,6 +1742,9 @@ type CustomInComeStatistics struct {
1628 1742
 	DiscountPrice      float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
1629 1743
 	PreferentialPrice  float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
1630 1744
 	AcctPay            float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
1745
+
1746
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1747
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
1631 1748
 }
1632 1749
 
1633 1750
 func (CustomInComeStatistics) TableName() string {
@@ -1667,3 +1784,77 @@ func GetDayIncomeDetailStatisticsData(org_id int64, keywords string, start_time
1667 1784
 	}
1668 1785
 	return
1669 1786
 }
1787
+
1788
+//func GetHisPatientInfoList(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
1789
+//	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
1790
+//	return
1791
+//}
1792
+
1793
+func CreateHisPrescriptionTemplate(template *models.HisPrescriptionTemplate) (err error) {
1794
+	err = writeDb.Create(&template).Error
1795
+	return
1796
+
1797
+}
1798
+
1799
+func CreateHisPrescriptionAdviceTemplate(s *models.HisPrescriptionAdviceTemplate) (err error) {
1800
+	err = writeDb.Save(&s).Error
1801
+	return
1802
+}
1803
+
1804
+func CreateHisPrescriptionInfoTemplate(s *models.HisPrescriptionInfoTemplate) (err error) {
1805
+	err = writeDb.Save(&s).Error
1806
+	return
1807
+}
1808
+
1809
+func CreateHisPrescriptionProjectTemplate(project *models.HisPrescriptionProjectTemplate) (err error) {
1810
+	err = writeDb.Save(&project).Error
1811
+	return
1812
+}
1813
+
1814
+func GetPatientSch(patient_id int64, sch_date int64, org_id int64) (sch models.Schedule, err error) {
1815
+	err = readDb.Model(&models.Schedule{}).Where("user_org_id = ? AND patient_id = ? AND schedule_date = ? AND status = 1", org_id, patient_id, sch_date).First(&sch).Error
1816
+	return
1817
+}
1818
+
1819
+func GetHisPrescriptionBySchMode(mode_id int64, patient_id int64, org_id int64) (prescription models.HisPrescriptionTemplate, err error) {
1820
+	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1 AND mode = ? AND patient_id = ?", org_id, mode_id, patient_id).Last(&prescription).Error
1821
+	return
1822
+}
1823
+
1824
+func GetHisPrescriptionTemplate(template_id int64, org_id int64) (prescription []*models.HisPrescriptionInfoTemplate, err error) {
1825
+	err = readDb.Model(&models.HisPrescriptionInfoTemplate{}).
1826
+		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
1827
+			return db.Where("status = 1 AND user_org_id = ?", org_id)
1828
+		}).
1829
+		Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
1830
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisProject").Preload("GoodInfo", "status=1")
1831
+		}).
1832
+		Where("status = 1 AND p_template_id = ? ", template_id).
1833
+		Find(&prescription).Error
1834
+	return
1835
+}
1836
+
1837
+func FindHisConsumablesByID(orgID int64, patient_id int64, recordDate int64, good_id int64) (consumables models.DialysisBeforePrepare, err error) {
1838
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 AND good_id = ?", orgID, patient_id, recordDate, good_id).First(&consumables).Error
1839
+	return
1840
+}
1841
+
1842
+func UpdateConsumables(consumables *models.DialysisBeforePrepare) (err error) {
1843
+	err = writeDb.Save(&consumables).Error
1844
+	return
1845
+}
1846
+
1847
+func GetHisPrescriptionProjectsByID(id int64) (projects []*models.HisPrescriptionProject, err error) {
1848
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("prescription_id = ? AND status = 1", id).Find(&projects).Error
1849
+	return
1850
+}
1851
+
1852
+func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
1853
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1", user_org_id, patient_id, record_time).Find(&projects).Error
1854
+	return
1855
+}
1856
+
1857
+func GetHisPrescriptionProjectByID(id int64) (projects models.HisPrescriptionProject, err error) {
1858
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("id = ? AND status = 1", id).First(&projects).Error
1859
+	return
1860
+}

+ 14 - 0
service/mobile_dialysis_service.go View File

@@ -1457,6 +1457,8 @@ type VMGoodInfo struct {
1457 1457
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
1458 1458
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id"`
1459 1459
 	OrgId             int64  `gorm:"column:org_id" json:"org_id"`
1460
+	GoodName          string `gorm:"column:good_name" json:"good_name" form:"good_name"`
1461
+	GoodUnit          int64  `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
1460 1462
 }
1461 1463
 
1462 1464
 func (VMGoodInfo) TableName() string {
@@ -2056,3 +2058,15 @@ func GetHisAdviceExecutionById(ids []string) (doctor []*models.HisDoctorAdviceIn
2056 2058
 	err = XTReadDB().Model(&doctor).Where("id IN(?) AND status = 1", ids).Find(&doctor).Error
2057 2059
 	return doctor, err
2058 2060
 }
2061
+
2062
+func GetHisProjectConfig(orgid int64) (models.XtHisProjectConfig, error) {
2063
+	config := models.XtHisProjectConfig{}
2064
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status =1", orgid).Find(&config).Error
2065
+	return config, err
2066
+}
2067
+
2068
+func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64) (project []*models.HisPrescriptionProject, err error) {
2069
+	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
2070
+
2071
+	return
2072
+}

+ 16 - 1
service/patient_service.go View File

@@ -1394,6 +1394,21 @@ func FindPatientExportLog(org_id int64, export_time int64) (errLogs []*models.Ex
1394 1394
 	return
1395 1395
 }
1396 1396
 
1397
+func FindPatientExportLogOne(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
1398
+	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 4", org_id, export_time).Find(&errLogs).Error
1399
+	return
1400
+}
1401
+
1402
+func FindPatientExportLogTwo(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
1403
+	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 5", org_id, export_time).Find(&errLogs).Error
1404
+	return
1405
+}
1406
+
1407
+func FindPatientExportLogThree(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
1408
+	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 6", org_id, export_time).Find(&errLogs).Error
1409
+	return
1410
+}
1411
+
1397 1412
 func CreateExportLog(log *models.ExportLog) {
1398 1413
 	writeDb.Create(&log)
1399 1414
 }
@@ -1481,6 +1496,6 @@ func UpdatePatientDialysisSolutionOne(patientid int64, orgid int64, prescription
1481 1496
 }
1482 1497
 
1483 1498
 func FindRemindAdvice(user_org_id int64, advice_name string, advice_desc string, template_id string, fre_type int64, patient_id int64, record_date int64) (advice models.DoctorAdvice, err error) {
1484
-	err = XTWriteDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and advice_name = ? and advice_desc = ? and template_id = ? and frequency_type = ? ", patient_id, user_org_id, record_date, advice_name, advice_desc, template_id, fre_type).First(&advice).Error
1499
+	err = XTWriteDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and advice_name = ? and advice_desc = ? and template_id = ? and frequency_type = ? AND advice_type = 2 ", patient_id, user_org_id, record_date, advice_name, advice_desc, template_id, fre_type).First(&advice).Error
1485 1500
 	return
1486 1501
 }

+ 16 - 15
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

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

+ 3 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -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

+ 18 - 0
service/schedule_service.go View File

@@ -133,6 +133,24 @@ func CreateSchedule(m *models.Schedule) error {
133 133
 	return writeDb.Model(&models.Schedule{}).Create(&m).Error
134 134
 }
135 135
 
136
+func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64) (*models.XtSchedule, error) {
137
+	var scheudle models.XtSchedule
138
+	var err error
139
+	err = XTReadDB().Model(&scheudle).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1", patientid, schedudate, orgid).Find(&scheudle).Error
140
+	if err == gorm.ErrRecordNotFound {
141
+		return nil, err
142
+	}
143
+	if err != nil {
144
+		return nil, err
145
+	}
146
+	return &scheudle, nil
147
+}
148
+
149
+func UpdateScheduleByOrgId(patientid int64, scheduledate int64, orgid int64, sch *models.XtSchedule) error {
150
+	err := XTWriteDB().Model(&sch).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1", patientid, scheduledate, orgid).Updates(map[string]interface{}{"partition_id": sch.PartitionId, "bed_id": sch.BedId, "schedule_type": sch.ScheduleType, "schedule_week": sch.ScheduleWeek, "mode_id": sch.ModeId, "updated_time": time.Now().Unix()}).Error
151
+	return err
152
+}
153
+
136 154
 func GetSchedule(orgID, id int64) (*models.Schedule, error) {
137 155
 	var schedule models.Schedule
138 156
 	var err error

+ 1 - 1
service/self_drug_service.go View File

@@ -500,7 +500,7 @@ func CreateAotoMaticReduceDetail(detail *models.XtDrugAutomaticReduceDetail) err
500 500
 func GetDrugStockConfig(orgid int64) (models.XtDrugStockConfig, error) {
501 501
 
502 502
 	config := models.XtDrugStockConfig{}
503
-	err := XTReadDB().Model(&config).Where("org_id =? and status = 1", orgid).Find(&orgid).Error
503
+	err := XTReadDB().Model(&config).Where("org_id =? and status = 1", orgid).Find(&config).Error
504 504
 	return config, err
505 505
 }
506 506
 

+ 24 - 6
service/stock_service.go View File

@@ -971,6 +971,7 @@ func FindAllDrugWarehouseOutList(orgId int64, page int64, limit int64, startTime
971 971
 		likeKey := "%" + keywords + "%"
972 972
 		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse_out.creater")
973 973
 		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_warehouse_out.manufacturer")
974
+
974 975
 		db = db.Where("xt_manufacturer.manufacturer_name LIKE ? OR sgj_user_admin_role.user_name LIKE ? OR xt_drug_warehouse_out.warehouse_out_order_number LIKE ?", likeKey, likeKey, likeKey).Group("xt_drug_warehouse_out.id")
975 976
 	}
976 977
 
@@ -2112,7 +2113,7 @@ func UpdateDrugStockOutInfoCount2(org_id int64, id int64, count int64) {
2112 2113
 
2113 2114
 func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
2114 2115
 
2115
-	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ? AND count <> 0", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2116
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ?AND status = 1  AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ? AND count <> 0", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2116 2117
 	return
2117 2118
 
2118 2119
 }
@@ -2139,10 +2140,13 @@ func (VMWarehousingInfo) TableName() string {
2139 2140
 }
2140 2141
 
2141 2142
 type GoodInfo struct {
2142
-	ID                int64  `gorm:"column:id" json:"id"`
2143
-	SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
2144
-	Status            int64  `gorm:"column:status" json:"status"`
2145
-	OrgId             int64  `gorm:"column:org_id" json:"org_id"`
2143
+	ID                int64   `gorm:"column:id" json:"id"`
2144
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name"`
2145
+	Status            int64   `gorm:"column:status" json:"status"`
2146
+	OrgId             int64   `gorm:"column:org_id" json:"org_id"`
2147
+	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
2148
+	GoodUnit          int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
2149
+	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
2146 2150
 }
2147 2151
 
2148 2152
 func (GoodInfo) TableName() string {
@@ -2291,7 +2295,7 @@ func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error)
2291 2295
 func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.BaseDrugLib, error) {
2292 2296
 	var drug models.BaseDrugLib
2293 2297
 	var err error
2294
-	err = XTReadDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and status =1", drugname, drugdesc).Find(&drug).Error
2298
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and status =1 and org_id = ?", drugname, drugdesc, orgid).Find(&drug).Error
2295 2299
 	if err == gorm.ErrRecordNotFound {
2296 2300
 		return nil, err
2297 2301
 	}
@@ -2410,6 +2414,13 @@ func IsExistDicConfig(parentid int64, goodKind string, orgid int64) (*models.Dic
2410 2414
 	return &dataconfig, nil
2411 2415
 }
2412 2416
 
2417
+func GetLastDicConfig(parentid int64, orgid int64) (models.DictDataconfig, error) {
2418
+
2419
+	dataconfig := models.DictDataconfig{}
2420
+	err := XTReadDB().Model(&dataconfig).Where("parent_id = ? and (org_id = ? or org_id = 0) and status = 1", parentid, orgid).Last(&dataconfig).Error
2421
+	return dataconfig, err
2422
+}
2423
+
2413 2424
 func CreatedDicConfig(dataconfig *models.DictDataconfig) error {
2414 2425
 
2415 2426
 	err := XTWriteDB().Create(&dataconfig).Error
@@ -2482,6 +2493,13 @@ func GetChildeConfigIsExist(parentid int64, name string, orgid int64) (*models.D
2482 2493
 	return &dataconfig, nil
2483 2494
 }
2484 2495
 
2496
+func GetLastChildeConfig(parentid int64, orgid int64) (models.Dataconfig, error) {
2497
+
2498
+	dataconfig := models.Dataconfig{}
2499
+	err := XTReadDB().Model(&dataconfig).Where("parent_id = ? and (org_id = ? or org_id = 0) and status =1", parentid, orgid).Last(&dataconfig).Error
2500
+	return dataconfig, err
2501
+}
2502
+
2485 2503
 func CreateDataConfig(dataconfig *models.Dataconfig) error {
2486 2504
 
2487 2505
 	err := XTWriteDB().Create(&dataconfig).Error