Ver código fonte

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

XMLWAN 4 anos atrás
pai
commit
8671967eb1

+ 2 - 2
conf/app.conf Ver arquivo

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

+ 24 - 1
controllers/dialysis_record_api_controller.go Ver arquivo

@@ -11,7 +11,8 @@ import (
11 11
 	"XT_New/enums"
12 12
 	"XT_New/service"
13 13
 	"XT_New/utils"
14
-
14
+	"net/http"
15
+	"net/url"
15 16
 	"fmt"
16 17
 	"github.com/astaxie/beego"
17 18
 )
@@ -777,6 +778,18 @@ func (this *DialysisRecordAPIController) StartDialysis() {
777 778
 				return
778 779
 			}
779 780
 		}
781
+
782
+		go func (){
783
+			ssoDomain := beego.AppConfig.String("call_domain")
784
+			api := ssoDomain + "/index/uppatient"
785
+			values := make(url.Values)
786
+			values.Set("org_id",  strconv.FormatInt(adminUserInfo.CurrentOrgId,10))
787
+			values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
788
+			values.Set("patient_id",  strconv.FormatInt(patientID,10))
789
+			values.Set("up_time",  strconv.FormatInt(startDate.Unix(),10))
790
+			http.PostForm(api, values)
791
+		} ()
792
+
780 793
 		this.ServeSuccessJSON(map[string]interface{}{
781 794
 			"dialysis_order": dialysisRecord,
782 795
 			"monitor":        record,
@@ -997,6 +1010,16 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
997 1010
 		return
998 1011
 	}
999 1012
 
1013
+	go func (){
1014
+		ssoDomain := beego.AppConfig.String("call_domain")
1015
+		api := ssoDomain + "/index/downpatient"
1016
+		values := make(url.Values)
1017
+		values.Set("org_id",  strconv.FormatInt(adminUserInfo.CurrentOrgId,10))
1018
+		values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
1019
+		values.Set("patient_id",  strconv.FormatInt(patientID,10))
1020
+		http.PostForm(api, values)
1021
+	} ()
1022
+
1000 1023
 	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1001 1024
 	if updateErr != nil {
1002 1025
 		this.ErrorLog("下机失败:%v", updateErr)

+ 1 - 0
controllers/doctors_api_controller.go Ver arquivo

@@ -35,6 +35,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
35 35
 	patientType, _ := c.GetInt("patient_type")
36 36
 	delivery_way := c.GetString("delivery_way")
37 37
 
38
+	delivery_way := c.GetString("delivery_way")
38 39
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
39 40
 		adviceType = 0
40 41
 	}

+ 192 - 5
controllers/his_api_controller.go Ver arquivo

@@ -68,6 +68,52 @@ func HisManagerApiRegistRouters() {
68 68
 
69 69
 	beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
70 70
 
71
+func (c *HisApiController) Sscard() {
72
+	//r := CardInit()
73
+	//if r == 0 {
74
+	//	GetBaseInfo()
75
+	//}
76
+	//c.ServeSuccessJSON(map[string]interface{}{
77
+	//	"list": "11",
78
+	//})
79
+
80
+}
81
+
82
+func GetBaseInfo() error {
83
+	//handle := syscall.MustLoadDLL("SSCard.dll")
84
+	//ReadCardBas := handle.MustFindProc("ReadCardBas")
85
+	//
86
+	//str := make([]byte, 256)
87
+	//str1 := make([]byte, 256)
88
+	//r, _, ferr := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
89
+	//if ferr != nil {
90
+	//	fmt.Println("ReadCardBas 报错", ferr.Error())
91
+	//	return ferr
92
+	//}
93
+	//
94
+	//fmt.Println(string(str))
95
+	//
96
+	//fmt.Println(r)
97
+	return nil
98
+}
99
+
100
+func CardInit() int {
101
+	//DllTestDef := syscall.MustLoadDLL("SSCard.dll")
102
+	//add := DllTestDef.MustFindProc("Init")
103
+	//ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
104
+	//if err != nil {
105
+	//	fmt.Println("SSCard的运算结果为:", ret)
106
+	//}
107
+	//result := int(ret)
108
+	return 0
109
+}
110
+
111
+func IntPtr(n int) uintptr {
112
+	return uintptr(n)
113
+}
114
+
115
+func StrPtr(s string) uintptr {
116
+	return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
71 117
 }
72 118
 
73 119
 func (c *HisApiController) GetHisPatientList() {
@@ -320,6 +366,19 @@ func (c *HisApiController) CreateHisPrescription() {
320 366
 				}
321 367
 				types := int64(items["type"].(float64))
322 368
 
369
+				if items["pre_time"] == nil || reflect.TypeOf(items["pre_time"]).String() != "string" {
370
+					utils.ErrorLog("pre_time")
371
+				}
372
+				preTime, _ := items["pre_time"].(string)
373
+				timeLayout := "2006-01-02"
374
+				loc, _ := time.LoadLocation("Local")
375
+				theTime2, err := time.ParseInLocation(timeLayout+" 15:04", preTime, loc)
376
+				if err != nil {
377
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
378
+					return
379
+				}
380
+				pTime := theTime2.Unix()
381
+
323 382
 				ctime := time.Now().Unix()
324 383
 				prescription := &models.HisPrescription{
325 384
 					ID:                 id,
@@ -337,12 +396,13 @@ func (c *HisApiController) CreateHisPrescription() {
337 396
 					OrderStatus:        1,
338 397
 					BatchNumber:        "",
339 398
 					PrescriptionNumber: hpInfo.PrescriptionNumber,
399
+					PreTime:            pTime,
340 400
 				}
341 401
 				service.SaveHisPrescription(prescription)
342 402
 
343 403
 				//更改患者挂号状态
344
-				_, err := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
345
-				fmt.Println("更改失败", err)
404
+				_, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
405
+				fmt.Println("更改失败", err2)
346 406
 				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
347 407
 					advices := items["advices"].([]interface{})
348 408
 					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
@@ -361,7 +421,7 @@ func (c *HisApiController) CreateHisPrescription() {
361 421
 							s.Status = 1
362 422
 							s.UserOrgId = adminInfo.CurrentOrgId
363 423
 							s.RecordDate = recordDateTime
364
-							s.StartTime = time.Now().Unix()
424
+							s.StartTime = prescription.PreTime
365 425
 							s.Groupno = groupNo
366 426
 							s.CreatedTime = ctime
367 427
 							s.UpdatedTime = mtime
@@ -430,7 +490,7 @@ func (c *HisApiController) CreateHisPrescription() {
430 490
 							s.UpdatedTime = mtime
431 491
 							s.PatientId = patient_id
432 492
 							s.HisPatientId = his_patient_id
433
-							errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}))
493
+							errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
434 494
 							if errcode > 0 {
435 495
 								c.ServeFailJSONWithSGJErrorCode(errcode)
436 496
 								return
@@ -840,6 +900,21 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
840 900
 	if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
841 901
 		advice_id := int64(json["advice_id"].(float64))
842 902
 		advice.ID = advice_id
903
+		if advice.ID > 0 {
904
+			hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
905
+			if err == nil {
906
+				if hisAdvice.ID > 0 {
907
+					advice.ExecutionTime = hisAdvice.ExecutionTime
908
+					advice.ExecutionStaff = hisAdvice.ExecutionStaff
909
+					advice.ExecutionState = hisAdvice.ExecutionState
910
+					advice.CheckTime = hisAdvice.CheckTime
911
+					advice.Checker = hisAdvice.Checker
912
+					advice.CheckState = hisAdvice.CheckState
913
+					advice.StartTime = hisAdvice.StartTime
914
+
915
+				}
916
+			}
917
+		}
843 918
 	}
844 919
 
845 920
 	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
@@ -947,7 +1022,7 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
947 1022
 	return 0
948 1023
 }
949 1024
 
950
-func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}) int {
1025
+func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}, org_id int64) int {
951 1026
 	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
952 1027
 		id := int64(json["id"].(float64))
953 1028
 		additionalCharge.ID = id
@@ -955,6 +1030,12 @@ func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditi
955 1030
 	if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
956 1031
 		item_id := int64(json["item_id"].(float64))
957 1032
 		additionalCharge.ItemId = item_id
1033
+		config, _ := service.GetAdditionChargeByID(org_id, item_id)
1034
+		if config.ID > 0 {
1035
+			if len(config.Code) > 0 {
1036
+				additionalCharge.MedListCodg = config.Code
1037
+			}
1038
+		}
958 1039
 	}
959 1040
 	// if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
960 1041
 	// 	price := int64(json["price"].(float64))
@@ -963,6 +1044,13 @@ func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditi
963 1044
 	// 	additionalCharge.Price = float_price
964 1045
 	// }
965 1046
 
1047
+	//if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
1048
+	//	price := int64(json["price"].(float64))
1049
+	//	formatInt_price := strconv.FormatInt(price, 10)
1050
+	//	float_price, _ := strconv.ParseFloat(formatInt_price, 64)
1051
+	//	additionalCharge.Price = float_price
1052
+	//}
1053
+
966 1054
 	if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
967 1055
 		price, _ := strconv.ParseFloat(json["price"].(string), 64)
968 1056
 		additionalCharge.Price = price
@@ -1255,6 +1343,105 @@ type ResultSeven struct {
1255 1343
 	Signtype    interface{} `json:"signtype"`
1256 1344
 	WarnMsg     interface{} `json:"warn_msg"`
1257 1345
 }
1346
+
1347
+type ResultEight struct {
1348
+	Cainfo      string `json:"cainfo"`
1349
+	ErrMsg      string `json:"err_msg"`
1350
+	InfRefmsgid string `json:"inf_refmsgid"`
1351
+	Infcode     int64  `json:"infcode"`
1352
+	Output      struct {
1353
+		Stmtinfo struct {
1354
+			SetlOptins   string `json:"setl_optins"`
1355
+			StmtRslt     string `json:"stmt_rslt"`
1356
+			StmtRsltDscr string `json:"stmt_rslt_dscr"`
1357
+		} `json:"stmtinfo"`
1358
+	} `json:"output"`
1359
+	RefmsgTime  string      `json:"refmsg_time"`
1360
+	RespondTime string      `json:"respond_time"`
1361
+	Signtype    interface{} `json:"signtype"`
1362
+	WarnMsg     interface{} `json:"warn_msg"`
1363
+}
1364
+
1365
+type ResultNine struct {
1366
+	Cainfo      string `json:"cainfo"`
1367
+	ErrMsg      string `json:"err_msg"`
1368
+	InfRefmsgid string `json:"inf_refmsgid"`
1369
+	Infcode     int64  `json:"infcode"`
1370
+	Output      struct {
1371
+		FileQuryNo string `json:"file_qury_no"`
1372
+	} `json:"output"`
1373
+	RefmsgTime  string      `json:"refmsg_time"`
1374
+	RespondTime string      `json:"respond_time"`
1375
+	Signtype    interface{} `json:"signtype"`
1376
+	WarnMsg     interface{} `json:"warn_msg"`
1377
+}
1378
+
1379
+type ResultTen struct {
1380
+	Cainfo      string `json:"cainfo"`
1381
+	ErrMsg      string `json:"err_msg"`
1382
+	InfRefmsgid string `json:"inf_refmsgid"`
1383
+	Infcode     int64  `json:"infcode"`
1384
+	Output      struct {
1385
+		DldEndtime string `json:"dld_endtime"`
1386
+		FileQuryNo string `json:"file_qury_no"`
1387
+		Filename   string `json:"filename"`
1388
+	} `json:"output"`
1389
+	RefmsgTime  string      `json:"refmsg_time"`
1390
+	RespondTime string      `json:"respond_time"`
1391
+	Signtype    interface{} `json:"signtype"`
1392
+	WarnMsg     interface{} `json:"warn_msg"`
1393
+}
1394
+
1395
+type ResultEleven struct {
1396
+	Cainfo      string `json:"cainfo"`
1397
+	ErrMsg      string `json:"err_msg"`
1398
+	InfRefmsgid string `json:"inf_refmsgid"`
1399
+	Infcode     int64  `json:"infcode"`
1400
+	Output      struct {
1401
+		Setlinfo struct {
1402
+			FixmedinsName   string  `json:"fixmedins_name"`
1403
+			FixmedinsCode   string  `json:"fixmedins_code"`
1404
+			PsnNo           string  `json:"psn_no"`
1405
+			PsnName         string  `json:"psn_name"`
1406
+			HifobPay        float64 `json:"hifob_pay"`
1407
+			Gend            string  `json:"gend"`
1408
+			Brdy            string  `json:"brdy"`
1409
+			PsnCertType     string  `json:"psn_cert_type"`
1410
+			PsnType         string  `json:"psn_type"`
1411
+			EmpName         string  `json:"emp_name"`
1412
+			Certno          string  `json:"certno"`
1413
+			Insutype        string  `json:"insutype"`
1414
+			MedfeeSumamt    float64 `json:"medfee_sumamt"`
1415
+			FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
1416
+			OverlmtSelfpay  float64 `json:"overlmt_selfpay"`
1417
+			PreselfpayAmt   float64 `json:"preselfpay_amt"`
1418
+			InscpScpAmt     float64 `json:"inscp_scp_amt"`
1419
+			ActPayDedc      float64 `json:"act_pay_dedc"`
1420
+			HifpPay         float64 `json:"hifp_pay"`
1421
+			PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
1422
+			CvlservPay      float64 `json:"cvlserv_pay"`
1423
+			HifesPay        float64 `json:"hifes_pay"`
1424
+			HifmiPay        float64 `json:"hifmi_pay"`
1425
+			MafPay          float64 `json:"maf_pay"`
1426
+			OthPay          float64 `json:"oth_pay"`
1427
+			FundPaySumamt   float64 `json:"fund_pay_sumamt"`
1428
+			PsnPay          float64 `json:"psn_pay"`
1429
+			AcctPay         float64 `json:"acct_pay"`
1430
+			CashPayamt      float64 `json:"cash_payamt"`
1431
+			Balc            float64 `json:"balc"`
1432
+			AcctMulaidPay   float64 `json:"acct_mulaid_pay"`
1433
+			MedinsSetlId    string  `json:"medins_setl_id"`
1434
+			RefdSetlFlag    string  `json:"refd_setl_flag"`
1435
+			SetlTime        string  `json:"setl_time"`
1436
+			MedType         string  `json:"med_type"`
1437
+		} `json:"setlinfo"`
1438
+	} `json:"output"`
1439
+	RefmsgTime  string      `json:"refmsg_time"`
1440
+	RespondTime string      `json:"respond_time"`
1441
+	Signtype    interface{} `json:"signtype"`
1442
+	WarnMsg     interface{} `json:"warn_msg"`
1443
+}
1444
+
1258 1445
 type Custom struct {
1259 1446
 	DetItemFeeSumamt string
1260 1447
 	Cut              string

+ 3 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Ver arquivo

@@ -734,9 +734,11 @@ func (c *CheckWeightApiController) GetPatientList() {
734 734
 	}
735 735
 
736 736
 	adminUserInfo := c.GetMobileAdminUserInfo()
737
-	need_update := 0
737
+
738 738
 	patientList, total, error := service.GetPatientListByUpdateTime(adminUserInfo.Org.Id, int64(syncTime))
739 739
 	if len(patientList) > 0 {
740
+	need_update := 0
741
+	if syncTime ==  0 {
740 742
 		need_update = 1
741 743
 	}
742 744
 	if error != nil {

+ 24 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Ver arquivo

@@ -14,6 +14,9 @@ import (
14 14
 	"XT_New/service"
15 15
 	"XT_New/utils"
16 16
 	"math"
17
+	"net/http"
18
+	"net/url"
19
+	"github.com/astaxie/beego"
17 20
 )
18 21
 
19 22
 // type DialysisTestAPIController struct {
@@ -1445,6 +1448,16 @@ func (c *DialysisAPIController) Finish() {
1445 1448
 		dialysisOrder.FinishModifier = adminUserInfo.AdminUser.Id
1446 1449
 		dialysisOrder.EndTime = endDate.Unix()
1447 1450
 
1451
+		go func (){
1452
+			ssoDomain := beego.AppConfig.String("call_domain")
1453
+			api := ssoDomain + "/index/downpatient"
1454
+			values := make(url.Values)
1455
+			values.Set("org_id",  strconv.FormatInt(adminUserInfo.AdminUser.Id,10))
1456
+			values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
1457
+			values.Set("patient_id",  strconv.FormatInt(id,10))
1458
+			http.PostForm(api, values)
1459
+		} ()
1460
+
1448 1461
 		if err == nil {
1449 1462
 			c.ServeSuccessJSON(map[string]interface{}{
1450 1463
 				"dialysisOrder":           dialysisOrder,
@@ -1742,6 +1755,17 @@ func (this *DialysisAPIController) StartDialysis() {
1742 1755
 		}
1743 1756
 	}
1744 1757
 
1758
+	go func (){
1759
+		ssoDomain := beego.AppConfig.String("call_domain")
1760
+		api := ssoDomain + "/index/uppatient"
1761
+		values := make(url.Values)
1762
+		values.Set("org_id",  strconv.FormatInt(adminUserInfo.Org.Id,10))
1763
+		values.Set("admin_user_id", strconv.FormatInt(nurseID,10))
1764
+		values.Set("patient_id",  strconv.FormatInt(patientID,10))
1765
+		values.Set("up_time",  strconv.FormatInt(startDate.Unix(),10))
1766
+		http.PostForm(api, values)
1767
+	} ()
1768
+
1745 1769
 	if createErr != nil {
1746 1770
 		this.ErrorLog("上机失败:%v", createErr)
1747 1771
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 15 - 17
models/good_models.go Ver arquivo

@@ -1,7 +1,5 @@
1 1
 package models
2 2
 
3
-import "XT/models"
4
-
5 3
 type GoodsType struct {
6 4
 	ID             int64  `gorm:"column:id" json:"id"`
7 5
 	TypeCode       string `gorm:"column:type_code" json:"type_code"`
@@ -76,21 +74,21 @@ func (GoodInfo) TableName() string {
76 74
 }
77 75
 
78 76
 type GoodsTypeOne struct {
79
-	ID             int64              `gorm:"column:id" json:"id"`
80
-	TypeCode       string             `gorm:"column:type_code" json:"type_code"`
81
-	TypeName       string             `gorm:"column:type_name" json:"type_name"`
82
-	Remark         string             `gorm:"column:remark" json:"remark"`
83
-	Ctime          int64              `gorm:"column:ctime" json:"ctime"`
84
-	Mtime          int64              `gorm:"column:mtime" json:"mtime"`
85
-	Creater        int64              `gorm:"column:creater" json:"creater"`
86
-	Modifier       int64              `gorm:"column:modifier" json:"modifier"`
87
-	OrgId          int64              `gorm:"column:org_id" json:"org_id"`
88
-	Status         int64              `gorm:"column:status" json:"status"`
89
-	Type           int64              `gorm:"column:type" json:"type"`
90
-	Number         int64              `gorm:"column:number" json:"number"`
91
-	OutStock       int64              `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
92
-	StockAttribute int64              `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
93
-	GoodInfo       []*models.GoodInfo `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"GoodInfo"`
77
+	ID             int64       `gorm:"column:id" json:"id"`
78
+	TypeCode       string      `gorm:"column:type_code" json:"type_code"`
79
+	TypeName       string      `gorm:"column:type_name" json:"type_name"`
80
+	Remark         string      `gorm:"column:remark" json:"remark"`
81
+	Ctime          int64       `gorm:"column:ctime" json:"ctime"`
82
+	Mtime          int64       `gorm:"column:mtime" json:"mtime"`
83
+	Creater        int64       `gorm:"column:creater" json:"creater"`
84
+	Modifier       int64       `gorm:"column:modifier" json:"modifier"`
85
+	OrgId          int64       `gorm:"column:org_id" json:"org_id"`
86
+	Status         int64       `gorm:"column:status" json:"status"`
87
+	Type           int64       `gorm:"column:type" json:"type"`
88
+	Number         int64       `gorm:"column:number" json:"number"`
89
+	OutStock       int64       `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
90
+	StockAttribute int64       `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
91
+	GoodInfo       []*GoodInfo `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"GoodInfo"`
94 92
 }
95 93
 
96 94
 func (GoodsTypeOne) TableName() string {

+ 2 - 0
models/his_models.go Ver arquivo

@@ -311,6 +311,7 @@ type HisPrescription struct {
311 311
 	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
312 312
 	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
313 313
 	OrderStatus            int64                     `gorm:"column:order_status" json:"order_status" form:"order_status"`
314
+	PreTime                int64                     `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
314 315
 	BatchNumber            string                    `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
315 316
 	PrescriptionNumber     string                    `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
316 317
 	Patients               Patients                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
@@ -402,6 +403,7 @@ type HisAdditionalCharge struct {
402 403
 	FeedetlSn          string             `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
403 404
 	PrescriptionId     int64              `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
404 405
 	Count              int64              `gorm:"column:count" json:"count" form:"count"`
406
+	MedListCodg        string             `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
405 407
 }
406 408
 
407 409
 func (HisAdditionalCharge) TableName() string {

+ 164 - 37
models/service/mobile_dialysis_service.go Ver arquivo

@@ -30,13 +30,13 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
30 30
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
31 31
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
32 32
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
33
-		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2", orgID).
33
+		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 AND advice_date = ? ", orgID, scheduleDate).
34 34
 		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
35 35
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
36
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
36
+		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
37 37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38
-		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
39
-		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ?", orgID).
38
+		Preload("TreatmentSummary", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
39
+		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
40 40
 
41 41
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
42 42
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
@@ -115,13 +115,13 @@ type MDialysisScheduleVM struct {
115 115
 
116 116
 	SchedualPatient          *MSchedualPatientVMList           `gorm:"ForeignKey:PatientId" json:"patient"`
117 117
 	DeviceNumber             *MDeviceNumberVM                  `gorm:"ForeignKey:BedId" json:"device_number"`
118
-	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
119
-	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
120
-	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
121
-	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
118
+	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
119
+	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
120
+	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
121
+	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
122 122
 
123
-	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
124
-	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
123
+	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
124
+	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
125 125
 }
126 126
 
127 127
 func (MDialysisScheduleVM) TableName() string {
@@ -290,6 +290,8 @@ type VMDoctorAdvice struct {
290 290
 	Status         int64 `gorm:"column:status" json:"status" form:"status"`
291 291
 	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
292 292
 	RecordDate     int64 `gorm:"column:record_date" json:"record_date"`
293
+	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
294
+	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
293 295
 }
294 296
 
295 297
 func (VMDoctorAdvice) TableName() string {
@@ -489,7 +491,7 @@ func MobileGetDoctorAdvices(orgID int64, patientID int64, recordDate int64) ([]*
489 491
 	err := readDb.
490 492
 		Model(&models.DoctorAdvice{}).
491 493
 		Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 or advice_type = 3)", patientID, orgID, recordDate).
492
-		Select("id,user_org_id,patient_id,advice_type,advice_date,record_date,start_time,advice_name,advice_desc,reminder_date, drug_spec, drug_spec_unit,single_dose,single_dose_unit,prescribing_number,prescribing_number_unit,delivery_way,execution_frequency,advice_doctor,status,created_time,updated_time,advice_affirm,remark,stop_time,stop_reason,stop_doctor,stop_state,parent_id,execution_time,execution_staff,execution_state,checker, check_state, check_time,IF(parent_id>0, parent_id, id) as advice_order,groupno").
494
+		Select("id,user_org_id,patient_id,advice_type,advice_date,record_date,start_time,advice_name,advice_desc,reminder_date, drug_spec, drug_spec_unit,single_dose,single_dose_unit,prescribing_number,prescribing_number_unit,delivery_way,execution_frequency,advice_doctor,status,created_time,updated_time,advice_affirm,remark,stop_time,stop_reason,stop_doctor,stop_state,parent_id,execution_time,execution_staff,execution_state,checker, check_state, check_time,way,drug_id,drug_name_id,IF(parent_id>0, parent_id, id) as advice_order,groupno").
493 495
 		Order("start_time asc, groupno desc, advice_order desc, id").
494 496
 		Scan(&records).Error
495 497
 
@@ -506,7 +508,7 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
506 508
 	err := readDb.
507 509
 		Model(&models.DoctorAdvice{}).
508 510
 		Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and advice_type = 2", patientID, orgID, recordDate).
509
-		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno, IF(parent_id > 0, parent_id, id) as advice_order").
511
+		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
510 512
 		Order("start_time asc, groupno desc, advice_order desc, id asc").
511 513
 		Scan(&records).Error
512 514
 
@@ -637,6 +639,19 @@ func MobileGetDialysisPrescribe(orgID int64, patientID int64, recordDate int64)
637 639
 	return &record, nil
638 640
 }
639 641
 
642
+func MobileGetDialysisSchedual(orgID int64, patientID int64, scheduleDate int64) (*models.XtSchedule, error) {
643
+	var schedule models.XtSchedule
644
+	err := readDb.Model(&models.XtSchedule{}).Where("patient_id = ? and user_org_id = ? and status = 1 and schedule_date = ?", patientID, orgID, scheduleDate).First(&schedule).Error
645
+	if err != nil {
646
+		if err == gorm.ErrRecordNotFound {
647
+			return nil, nil
648
+		} else {
649
+			return nil, err
650
+		}
651
+	}
652
+	return &schedule, nil
653
+}
654
+
640 655
 // 透析方案
641 656
 func MobileGetDialysisSolution(orgID int64, patientID int64) (*models.DialysisSolution, error) {
642 657
 	var record models.DialysisSolution
@@ -692,19 +707,20 @@ func GetMonitor(orgID int64, patientID int64, id int64) (*models.MonitoringRecor
692 707
 }
693 708
 
694 709
 type MScheduleDoctorAdviceVM struct {
695
-	ID              int64               `gorm:"column:id" json:"id"`
696
-	UserOrgId       int64               `gorm:"column:user_org_id" json:"user_org_id"`
697
-	PartitionId     int64               `gorm:"column:partition_id" json:"partition_id"`
698
-	BedId           int64               `gorm:"column:bed_id" json:"bed_id"`
699
-	PatientId       int64               `gorm:"column:patient_id" json:"patient_id"`
700
-	ScheduleDate    int64               `gorm:"column:schedule_date" json:"schedule_date"`
701
-	ScheduleType    int64               `gorm:"column:schedule_type" json:"schedule_type"`
702
-	ModeId          int64               `gorm:"column:mode_id" json:"mode_id"`
703
-	Status          int64               `gorm:"column:status" json:"status"`
704
-	DialysisOrder   *MDialysisOrderVM   `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
705
-	SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
706
-	DeviceNumber    *MDeviceNumberVM    `gorm:"ForeignKey:BedId" json:"device_number"`
707
-	DoctorAdvices   []*MDoctorAdviceVM  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
710
+	ID              int64                            `gorm:"column:id" json:"id"`
711
+	UserOrgId       int64                            `gorm:"column:user_org_id" json:"user_org_id"`
712
+	PartitionId     int64                            `gorm:"column:partition_id" json:"partition_id"`
713
+	BedId           int64                            `gorm:"column:bed_id" json:"bed_id"`
714
+	PatientId       int64                            `gorm:"column:patient_id" json:"patient_id"`
715
+	ScheduleDate    int64                            `gorm:"column:schedule_date" json:"schedule_date"`
716
+	ScheduleType    int64                            `gorm:"column:schedule_type" json:"schedule_type"`
717
+	ModeId          int64                            `gorm:"column:mode_id" json:"mode_id"`
718
+	Status          int64                            `gorm:"column:status" json:"status"`
719
+	DialysisOrder   *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
720
+	SchedualPatient *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
721
+	DeviceNumber    *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
722
+	DoctorAdvices   []*MDoctorAdviceVM               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
723
+	Prescription    *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
708 724
 }
709 725
 
710 726
 func (MScheduleDoctorAdviceVM) TableName() string {
@@ -761,7 +777,7 @@ func (MDoctorAdviceVM) TableName() string {
761 777
 	return "xt_doctor_advice"
762 778
 }
763 779
 
764
-func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64) ([]*MScheduleDoctorAdviceVM, error) {
780
+func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string) ([]*MScheduleDoctorAdviceVM, error) {
765 781
 	var vms []*MScheduleDoctorAdviceVM
766 782
 	adviceWhere := ""
767 783
 	fmt.Println("advicetype", adviceType)
@@ -810,13 +826,26 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
810 826
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
811 827
 		}
812 828
 
813
-	} else if adviceType == 2 {
829
+	} else if adviceType == 2 && len(deliverWay) > 0 {
830
+		if patientType == 0 {
831
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
832
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
833
+
834
+		} else if patientType == 1 {
835
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
836
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
837
+		} else if patientType == 2 {
838
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
839
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
840
+		}
841
+
842
+	} else if adviceType == 2 && len(deliverWay) <= 0 {
814 843
 		if patientType == 0 {
815
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?  "
844
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
816 845
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
817 846
 
818 847
 		} else if patientType == 1 {
819
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? "
848
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
820 849
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
821 850
 		} else if patientType == 2 {
822 851
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
@@ -833,6 +862,7 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
833 862
 		}).
834 863
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
835 864
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
865
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
836 866
 		Preload("DoctorAdvices", adviceCondition...).
837 867
 		Where("status = 1 AND user_org_id = ?", orgID)
838 868
 	if scheduleDate != 0 {
@@ -1056,7 +1086,7 @@ func BatchUpdateMonitors(monitors []*models.MonitoringRecord) error {
1056 1086
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
1057 1087
 	tx := writeDb.Begin()
1058 1088
 	updateTime := time.Now().Unix()
1059
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType}).Error
1089
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse}).Error
1060 1090
 	if err != nil {
1061 1091
 		tx.Rollback()
1062 1092
 		return err
@@ -1173,6 +1203,19 @@ func GetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDate int6
1173 1203
 	return &record, nil
1174 1204
 }
1175 1205
 
1206
+func GetLastTimeOrder(orgID int64, patientID int64, maxDate int64) (*models.DialysisOrder, error) {
1207
+	var record models.DialysisOrder
1208
+	err := readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? and user_org_id = ? and status = 1 and dialysis_date < ?", patientID, orgID, maxDate).Order("dialysis_date desc").First(&record).Error
1209
+	if err != nil {
1210
+		if err == gorm.ErrRecordNotFound {
1211
+			return nil, nil
1212
+		} else {
1213
+			return nil, err
1214
+		}
1215
+	}
1216
+	return &record, nil
1217
+}
1218
+
1176 1219
 func GetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
1177 1220
 	var record models.MonitoringRecord
1178 1221
 	err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, beforeDate).Order("operate_time desc").First(&record).Error
@@ -1301,7 +1344,7 @@ func GetDialysisCountByPatientId(startime int64, endtime int64, patientid int64,
1301 1344
 }
1302 1345
 
1303 1346
 func FindConsumablesByDate(orgID int64, patient_id int64, recordDate int64) (consumables []*models.DialysisBeforePrepare, err error) {
1304
-	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 	AND count > 0", orgID, patient_id, recordDate).Find(&consumables).Error
1347
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 AND count<>0", orgID, patient_id, recordDate).Find(&consumables).Error
1305 1348
 	return
1306 1349
 }
1307 1350
 
@@ -1392,7 +1435,7 @@ type MDialysisGoodsVM struct {
1392 1435
 
1393 1436
 	DeviceNumber              *MDeviceNumberVM         `gorm:"ForeignKey:BedId" json:"device_number"`
1394 1437
 	SchedualPatient           *MSchedualPatientVMList  `gorm:"ForeignKey:PatientId" json:"patient"`
1395
-	AutomaticReduceDetail     []*AutomaticReduceDetail `gorm:"ForeignKey:PatientId,ScheduleDate;AssociationForeignKey:PatientId,RecordTime" json:"good_user"`
1438
+	AutomaticReduceDetail     []*AutomaticReduceDetail `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"good_user"`
1396 1439
 	LastAutomaticReduceDetail []*AutomaticReduceDetail `gorm:"-" json:"last_good_user"`
1397 1440
 	DialysisBeforePrepare     []*DialysisBeforePrepare `gorm:"ForeignKey:PatientId,ScheduleDate;AssociationForeignKey:PatientId,RecordDate" json:"good_user_detail"`
1398 1441
 	LastDialysisBeforePrepare []*DialysisBeforePrepare `gorm:"-" json:"last_good_user_detail"`
@@ -1433,7 +1476,7 @@ type DialysisGoodsDetailDate struct {
1433 1476
 	RecordTime int64
1434 1477
 }
1435 1478
 
1436
-func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, partition_id int64, page int, limit int, patient_id int64, keywords string) ([]*MDialysisGoodsVM, error, int64) {
1479
+func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, partition_id int64, page int, limit int, patient_id int64, keywords string, end_time int64) ([]*MDialysisGoodsVM, error, int64) {
1437 1480
 	var vms []*MDialysisGoodsVM
1438 1481
 	var total int64
1439 1482
 
@@ -1446,7 +1489,7 @@ func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64
1446 1489
 			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ?", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Where("status = 1 AND user_org_id = ? AND record_date = ?  AND count > 0 ", orgID, scheduleDate)
1447 1490
 		}).
1448 1491
 		Preload("AutomaticReduceDetail", func(db *gorm.DB) *gorm.DB {
1449
-			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND record_time = ? AND count > 0 ", orgID, scheduleDate)
1492
+			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND count > 0 AND record_time >= ? AND record_time <= ?  ", orgID, scheduleDate, end_time)
1450 1493
 		}).Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
1451 1494
 	if scheduleDate != 0 {
1452 1495
 		db = db.Where("schedule_date = ?", scheduleDate)
@@ -1470,9 +1513,12 @@ func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64
1470 1513
 }
1471 1514
 
1472 1515
 func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goodUser []*AutomaticReduceDetail, err error) {
1516
+
1473 1517
 	var Id []*DialysisGoodsDetailDate
1518
+
1474 1519
 	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
1475 1520
 	if len(Id) > 0 {
1521
+
1476 1522
 		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
1477 1523
 	}
1478 1524
 	return
@@ -1492,14 +1538,14 @@ func MobileGetGoodsStatistics(orgID int64, start_time int64, end_time int64) (li
1492 1538
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgID)
1493 1539
 	db = db.Joins("JOIN xt_warehouse_out_info AS info ON info.good_id=xt_good_information.id AND info.status = 1 AND info.org_id = ?", orgID).Group("xt_good_information.id")
1494 1540
 	db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1495
-		return db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1", orgID).Joins("JOIN xt_warehouse_out ON xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.status = 1 AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.org_id = ? ", start_time, end_time, orgID)
1541
+		return db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.sys_record_time >=  ? AND  xt_warehouse_out_info.sys_record_time <= ?", orgID, start_time, end_time)
1496 1542
 	})
1497 1543
 	db = db.Preload("GoodsType", "org_id = ? AND status = 1", orgID)
1498 1544
 	err = db.Order("ctime desc").Find(&list).Error
1499 1545
 	return
1500 1546
 }
1501 1547
 
1502
-func PCGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, partition_id int64, page int, limit int, patient_id int64, keywords string) ([]*MDialysisGoodsVM, error, int64) {
1548
+func PCGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, partition_id int64, page int, limit int, patient_id int64, keywords string, end_time int64) ([]*MDialysisGoodsVM, error, int64) {
1503 1549
 	var vms []*MDialysisGoodsVM
1504 1550
 	var total int64
1505 1551
 
@@ -1512,7 +1558,7 @@ func PCGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, pa
1512 1558
 			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ?   ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Where("status = 1 AND user_org_id = ? AND record_date = ? AND count > 0 ", orgID, scheduleDate)
1513 1559
 		}).
1514 1560
 		Preload("AutomaticReduceDetail", func(db *gorm.DB) *gorm.DB {
1515
-			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND record_time = ?  AND count > 0", orgID, scheduleDate)
1561
+			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND record_time >= ? AND record_time <=?  AND count > 0", orgID, scheduleDate, end_time)
1516 1562
 		}).Where("xt_schedule.status = 1 AND xt_schedule.user_org_id = ?", orgID)
1517 1563
 
1518 1564
 	if scheduleDate != 0 {
@@ -1543,3 +1589,84 @@ func PCGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64, pa
1543 1589
 
1544 1590
 	return vms, err, total
1545 1591
 }
1592
+
1593
+func GetLastDialysisGoodsTwo(patient_id int64, orgID int64, record_time int64) (goodUser []*AutomaticReduceDetail, err error) {
1594
+
1595
+	var Id []*DialysisGoodsDetailDate
1596
+
1597
+	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
1598
+	if len(Id) > 0 {
1599
+
1600
+		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
1601
+	}
1602
+	return
1603
+}
1604
+
1605
+func GetLastDialysisBeforePrepareTwo(patient_id int64, orgID int64, record_time int64) (goodUser []*DialysisBeforePrepare, err error) {
1606
+	var Id []*DialysisGoodsDate
1607
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ? AND count > 0", patient_id, orgID, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
1608
+	if len(Id) > 0 {
1609
+		err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordDate).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Find(&goodUser).Error
1610
+	}
1611
+	return
1612
+}
1613
+
1614
+func GetAssessmentBefor(orgid int64, patientid int64, recorddate int64) (*models.PredialysisEvaluation, error) {
1615
+
1616
+	evaluation := models.PredialysisEvaluation{}
1617
+
1618
+	err := XTReadDB().Model(&evaluation).Where("user_org_id = ? and patient_id = ? and assessment_date = ? and status = 1", orgid, patientid, recorddate).Find(&evaluation).Error
1619
+	if err == gorm.ErrRecordNotFound {
1620
+		return nil, err
1621
+	}
1622
+	if err != nil {
1623
+		return nil, err
1624
+	}
1625
+	return &evaluation, nil
1626
+}
1627
+
1628
+func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
1629
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patientid, orgid, recorddate).Find(&his).Error
1630
+	return
1631
+
1632
+}
1633
+
1634
+func GetLastDialysisPrescriptionByPatientId(orgid int64, patientid int64, recorddate int64) (*models.DialysisPrescription, error) {
1635
+
1636
+	prescription := models.DialysisPrescription{}
1637
+	err := readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patientid, recorddate).Find(&prescription).Error
1638
+	if err == gorm.ErrRecordNotFound {
1639
+		return nil, err
1640
+	}
1641
+	if err != nil {
1642
+		return nil, err
1643
+	}
1644
+	return &prescription, nil
1645
+}
1646
+
1647
+type HisMScheduleDoctorAdviceVM struct {
1648
+	ID                  int64                            `gorm:"column:id" json:"id"`
1649
+	UserOrgId           int64                            `gorm:"column:user_org_id" json:"user_org_id"`
1650
+	PartitionId         int64                            `gorm:"column:partition_id" json:"partition_id"`
1651
+	BedId               int64                            `gorm:"column:bed_id" json:"bed_id"`
1652
+	PatientId           int64                            `gorm:"column:patient_id" json:"patient_id"`
1653
+	ScheduleDate        int64                            `gorm:"column:schedule_date" json:"schedule_date"`
1654
+	ScheduleType        int64                            `gorm:"column:schedule_type" json:"schedule_type"`
1655
+	ModeId              int64                            `gorm:"column:mode_id" json:"mode_id"`
1656
+	Status              int64                            `gorm:"column:status" json:"status"`
1657
+	DialysisOrder       *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
1658
+	SchedualPatient     *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1659
+	DeviceNumber        *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
1660
+	Prescription        *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1661
+	HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
1662
+}
1663
+
1664
+func (HisMScheduleDoctorAdviceVM) TableName() string {
1665
+	return "xt_schedule"
1666
+}
1667
+
1668
+func GetHisDoctorConfig(orgid int64) (models.XtHisConfig, error) {
1669
+	config := models.XtHisConfig{}
1670
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status =1", orgid).Find(&config).Error
1671
+	return config, err
1672
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 856 - 21
models/service/stock_service.go


+ 1 - 0
service/gdyb_service.go Ver arquivo

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	//"/models"
5 6
 	"bytes"
6 7
 	"crypto/sha256"
7 8
 	"encoding/hex"

+ 1 - 1
service/his_project_service.go Ver arquivo

@@ -56,7 +56,7 @@ func GetProjectDetail(id int64) (models.XtHisProject, error) {
56 56
 
57 57
 func UpdatedProject(id int64, pro *models.XtHisProject) error {
58 58
 
59
-	err := XTWriteDB().Model(&pro).Where("id=?", id).Updates(map[string]interface{}{"project_name": pro.ProjectName, "pinyin": pro.Pinyin, "wubi": pro.Pinyin, "price": pro.Price, "unit": pro.Unit, "cost_classify": pro.CostClassify, "executive_section": pro.ExecutiveSection, "medical_coverage": pro.MedicalCoverage, "statistical_classification": pro.MedicalCoverage, "disease_directory": pro.DiseaseDirectory, "is_record": pro.DiseaseDirectory, "medical_code": pro.MedicalCode, "tube_color": pro.TubeColor, "medical_status": pro.MedicalStatus, "remark": pro.Remark, "sign": pro.Sign, "default_number": pro.DefaultNumber, "is_default": pro.IsDefault, "is_charge": pro.IsCharge, "is_estimate": pro.IsEstimate, "is_workload": pro.IsWorkload, "sort": pro.Sort, "doctor_advice": pro.DoctorAdvice, "single_dose": pro.SingleDose, "execution_frequency": pro.ExecutionFrequency, "delivery_way": pro.ExecutionFrequency, "number_days": pro.ExecutionFrequency, "total": pro.Total, "updated_time": pro.UpdatedTime}).Error
59
+	err := XTWriteDB().Model(&pro).Where("id=?", id).Updates(map[string]interface{}{"project_name": pro.ProjectName, "pinyin": pro.Pinyin, "wubi": pro.Pinyin, "price": pro.Price, "unit": pro.Unit, "cost_classify": pro.CostClassify, "executive_section": pro.ExecutiveSection, "medical_coverage": pro.MedicalCoverage, "statistical_classification": pro.StatisticalClassification, "disease_directory": pro.DiseaseDirectory, "is_record": pro.IsRecord, "medical_code": pro.MedicalCode, "tube_color": pro.TubeColor, "medical_status": pro.MedicalStatus, "remark": pro.Remark, "sign": pro.Sign, "default_number": pro.DefaultNumber, "is_default": pro.IsDefault, "is_charge": pro.IsCharge, "is_estimate": pro.IsEstimate, "is_workload": pro.IsWorkload, "sort": pro.Sort, "doctor_advice": pro.DoctorAdvice, "single_dose": pro.SingleDose, "execution_frequency": pro.ExecutionFrequency, "delivery_way": pro.DeliveryWay, "number_days": pro.NumberDays, "total": pro.Total, "updated_time": pro.UpdatedTime}).Error
60 60
 	return err
61 61
 }
62 62
 

+ 15 - 4
service/his_service.go Ver arquivo

@@ -581,10 +581,9 @@ func GetMedicalInsuranceConfig(org_id int64) (medicalInsuranceConfig models.Medi
581 581
 }
582 582
 
583 583
 func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
584
-	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
585
-	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": 3, "mtime": time.Now().Unix()}).Error
586
-	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": 4, "mtime": time.Now().Unix()}).Error
587
-	err = writeDb.Model(&models.HisAdditionalCharge{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix()}).Error
584
+	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
585
+	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
586
+	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
588 587
 
589 588
 	return
590 589
 
@@ -817,3 +816,15 @@ func GetOrderByTimeTwo(start_time int64, end_time int64, org_id int64) (orders [
817 816
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND is_medicine_insurance = 1 AND settle_accounts_date <= ? AND settle_accounts_date >= ? ", org_id, end_time, start_time).Find(&orders).Error
818 817
 	return
819 818
 }
819
+
820
+func GetHisDoctorAdvicesById(id int64) (advice models.HisDoctorAdviceInfo, err error) {
821
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND id = ?", id).First(&advice).Error
822
+	return
823
+
824
+}
825
+
826
+func GetAdditionChargeByID(org_id int64, id int64) (addition models.XtHisAddtionConfig, err error) {
827
+	err = readDb.Model(&models.XtHisAddtionConfig{}).Where("status = 1 AND user_org_id = ? AND id = ?", org_id, id).First(&addition).Error
828
+	return
829
+
830
+}