Bläddra i källkod

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

csx 2 år sedan
förälder
incheckning
c66a61635f

+ 2 - 1
.idea/vcs.xml Visa fil

@@ -7,5 +7,6 @@
7 7
   </component>
8 8
   <component name="VcsDirectoryMappings">
9 9
     <mapping directory="$PROJECT_DIR$" vcs="Git" />
10
+    <mapping directory="$PROJECT_DIR$/src/golang.org/x/sync" vcs="Git" />
10 11
   </component>
11
-</project>
12
+</project>

+ 1 - 1
conf/app.conf Visa fil

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

+ 5 - 3
controllers/data_api_controller.go Visa fil

@@ -1411,16 +1411,18 @@ func (this *DataApiController) ModifyTemplateName() {
1411 1411
 func (this *DataApiController) ModifyFiledIsShow() {
1412 1412
 	id, _ := this.GetInt64("id", 0)
1413 1413
 	is_show, _ := this.GetInt("is_show", 0)
1414
+	is_write, _ := this.GetInt("is_write", 0)
1414 1415
 	adminUserInfo := this.GetAdminUserInfo()
1415
-	err := service.ShowFiledConfig(adminUserInfo.CurrentOrgId, is_show, id)
1416
+	err := service.ShowFiledConfig(adminUserInfo.CurrentOrgId, is_show, is_write, id)
1416 1417
 	if err != nil {
1417 1418
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
1418 1419
 		return
1419 1420
 	} else {
1420 1421
 
1421 1422
 		this.ServeSuccessJSON(map[string]interface{}{
1422
-			"id":      id,
1423
-			"is_show": is_show,
1423
+			"id":       id,
1424
+			"is_show":  is_show,
1425
+			"is_write": is_write,
1424 1426
 		})
1425 1427
 	}
1426 1428
 }

+ 4 - 0
controllers/dialysis_api_controller.go Visa fil

@@ -1289,6 +1289,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1289 1289
 	assessment.MachineRun = data.MachineRun
1290 1290
 	assessment.AfterUrea = data.AfterUrea
1291 1291
 	assessment.PipCoagulation = data.PipCoagulation
1292
+	assessment.AccumulatedBloodVolume = data.AccumulatedBloodVolume
1292 1293
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1293 1294
 
1294 1295
 	if assessment.ID > 0 {
@@ -1447,6 +1448,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1447 1448
 	blood_pressure_during_dialysis := c.GetString("blood_pressure_during_dialysis")
1448 1449
 	urea_befor := c.GetString("urea_befor")
1449 1450
 	suction := c.GetString("suction")
1451
+	weight_befor_remake := c.GetString("weight_befor_remake")
1452
+
1450 1453
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1451 1454
 		DialysisCount:                  dialysis_count,
1452 1455
 		EmergencyTreatment:             emergency_treatment,
@@ -1515,6 +1518,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1515 1518
 		BloodPressureDuringDialysis:    blood_pressure_during_dialysis,
1516 1519
 		UreaBefor:                      urea_befor,
1517 1520
 		Suction:                        suction,
1521
+		WeightBeforRemake:              weight_befor_remake,
1518 1522
 	}
1519 1523
 
1520 1524
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)

+ 73 - 66
controllers/dialysis_record_api_controller.go Visa fil

@@ -1259,6 +1259,13 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1259 1259
 		tempassessmentAfterDislysis.BreathingRate = endmonitorRecords.BreathingRate
1260 1260
 		tempassessmentAfterDislysis.SystolicBloodPressure = endmonitorRecords.SystolicBloodPressure
1261 1261
 		tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
1262
+		//长沙南雅
1263
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
1264
+			//获取最后一条透析处方数据
1265
+			prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1266
+			evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1267
+			tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration
1268
+		}
1262 1269
 		if adminUserInfo.CurrentOrgId == 10101 {
1263 1270
 			tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume / 1000
1264 1271
 		} else {
@@ -1348,72 +1355,72 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1348 1355
 
1349 1356
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1350 1357
 
1351
-	//evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1352
-	//if evaluation.SystolicBloodPressure == 0 {
1353
-	//	evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1354
-	//
1355
-	//	pre := models.PredialysisEvaluation{
1356
-	//		SystolicBloodPressure: evaluation.SystolicBloodPressure,
1357
-	//	}
1358
-	//	fmt.Println("prew", pre)
1359
-	//	getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1360
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1361
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1362
-	//
1363
-	//	redis := service.RedisClient()
1364
-	//	redis.Set(key, "", time.Second)
1365
-	//	redis.Set(keyOne, "", time.Second)
1366
-	//	defer redis.Close()
1367
-	//	fmt.Println(getNurseErr)
1368
-	//}
1369
-	//if evaluation.DiastolicBloodPressure == 0 {
1370
-	//	evaluation.DiastolicBloodPressure = fmonitorRecords.DiastolicBloodPressure
1371
-	//	pres := models.PredialysisEvaluation{
1372
-	//		DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
1373
-	//	}
1374
-	//	getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1375
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1376
-	//
1377
-	//	redis := service.RedisClient()
1378
-	//	redis.Set(key, "", time.Second)
1379
-	//
1380
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1381
-	//	redis.Set(keyOne, "", time.Second)
1382
-	//	defer redis.Close()
1383
-	//	fmt.Println(getNurseErr)
1384
-	//}
1385
-	//if evaluation.PulseFrequency == 0 {
1386
-	//	evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1387
-	//	press := models.PredialysisEvaluation{
1388
-	//		PulseFrequency: evaluation.PulseFrequency,
1389
-	//	}
1390
-	//	getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1391
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1392
-	//
1393
-	//	redis := service.RedisClient()
1394
-	//	redis.Set(key, "", time.Second)
1395
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1396
-	//	redis.Set(keyOne, "", time.Second)
1397
-	//	defer redis.Close()
1398
-	//	fmt.Println(getNurseErr)
1399
-	//}
1400
-	//
1401
-	//if evaluation.Temperature == 0 {
1402
-	//	evaluation.Temperature = fmonitorRecords.Temperature
1403
-	//	press := models.PredialysisEvaluation{
1404
-	//		Temperature: evaluation.Temperature,
1405
-	//	}
1406
-	//	getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1407
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1408
-	//
1409
-	//	redis := service.RedisClient()
1410
-	//	redis.Set(key, "", time.Second)
1411
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1412
-	//	redis.Set(keyOne, "", time.Second)
1413
-	//	defer redis.Close()
1414
-	//	fmt.Println(getNurseErr)
1415
-	//}
1416
-	//
1358
+	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10340 {
1359
+		fmt.Println("进来2332233333333333333333333333333333333我的")
1360
+		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1361
+		if evaluation.SystolicBloodPressure == 0 {
1362
+			pre := models.PredialysisEvaluation{
1363
+				SystolicBloodPressure: fmonitorRecords.SystolicBloodPressure,
1364
+			}
1365
+			fmt.Println("prew", pre)
1366
+			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1367
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1368
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1369
+
1370
+			redis := service.RedisClient()
1371
+			redis.Set(key, "", time.Second)
1372
+			redis.Set(keyOne, "", time.Second)
1373
+			defer redis.Close()
1374
+			fmt.Println(getNurseErr)
1375
+		}
1376
+		if evaluation.DiastolicBloodPressure == 0 {
1377
+			pres := models.PredialysisEvaluation{
1378
+				DiastolicBloodPressure: fmonitorRecords.DiastolicBloodPressure,
1379
+			}
1380
+			getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1381
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1382
+
1383
+			redis := service.RedisClient()
1384
+			redis.Set(key, "", time.Second)
1385
+
1386
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1387
+			redis.Set(keyOne, "", time.Second)
1388
+			defer redis.Close()
1389
+			fmt.Println(getNurseErr)
1390
+		}
1391
+		if evaluation.PulseFrequency == 0 {
1392
+			evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1393
+			press := models.PredialysisEvaluation{
1394
+				PulseFrequency: evaluation.PulseFrequency,
1395
+			}
1396
+			getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1397
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1398
+
1399
+			redis := service.RedisClient()
1400
+			redis.Set(key, "", time.Second)
1401
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1402
+			redis.Set(keyOne, "", time.Second)
1403
+			defer redis.Close()
1404
+			fmt.Println(getNurseErr)
1405
+		}
1406
+
1407
+		if evaluation.Temperature == 0 {
1408
+			evaluation.Temperature = fmonitorRecords.Temperature
1409
+			press := models.PredialysisEvaluation{
1410
+				Temperature: evaluation.Temperature,
1411
+			}
1412
+			getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1413
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1414
+
1415
+			redis := service.RedisClient()
1416
+			redis.Set(key, "", time.Second)
1417
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1418
+			redis.Set(keyOne, "", time.Second)
1419
+			defer redis.Close()
1420
+			fmt.Println(getNurseErr)
1421
+		}
1422
+	}
1423
+
1417 1424
 	if err != nil {
1418 1425
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1419 1426
 		return

+ 3 - 0
controllers/drug_pharmacy_management_controller.go Visa fil

@@ -469,6 +469,9 @@ func (this *PharmacyApiController) GetReturnPharmacyBaseDrug() {
469 469
 func (this *PharmacyApiController) SaveSetting() {
470 470
 	var err error
471 471
 	defer func() {
472
+		if rec := recover(); rec != nil {
473
+			err = fmt.Errorf("程序异常:%v", rec)
474
+		}
472 475
 		if err != nil {
473 476
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
474 477
 		}

+ 936 - 1
controllers/his_config_api_controller.go Visa fil

@@ -6,9 +6,13 @@ import (
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8 8
 	"encoding/json"
9
+	"fmt"
9 10
 	"github.com/astaxie/beego"
11
+	"github.com/astaxie/beego/config"
12
+	"golang.org/x/sync/errgroup"
10 13
 	"reflect"
11 14
 	"strconv"
15
+	"strings"
12 16
 	"time"
13 17
 )
14 18
 
@@ -16,11 +20,16 @@ type HisConfigApiController struct {
16 20
 	BaseAuthAPIController
17 21
 }
18 22
 
23
+const (
24
+	AddTypeDrug    = 1 //药品
25
+	AddTypeProject = 2 //项目
26
+)
27
+
19 28
 func HisConfigApiRegistRouters() {
20 29
 	beego.Router("/api/his/patient/list", &HisConfigApiController{}, "get:GetAllHisPatientsList")
21 30
 	beego.Router("/api/his/prescriptiontemplate/list", &HisConfigApiController{}, "get:GetPrescriptionTemplateList")
22 31
 	beego.Router("/api/his/prescriptiontemplate/info", &HisConfigApiController{}, "get:GetPrescriptionTemplateInfo")
23
-	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate")
32
+	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate") //批量添加
24 33
 	beego.Router("/api/his/prescriptiontemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionTemplate")
25 34
 	beego.Router("/api/his/prescriptioninfotemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoTemplate")
26 35
 	beego.Router("/api/his/advicetemplate/delete", &HisConfigApiController{}, "post:DeleteAdviceTemplate")
@@ -35,6 +44,19 @@ func HisConfigApiRegistRouters() {
35 44
 	beego.Router("/api/his/projectmodetemplate/delete", &HisConfigApiController{}, "post:DeleteModeProjectTemplate")
36 45
 	beego.Router("/api/his/advicempdetemplate/delete", &HisConfigApiController{}, "post:DeleteModeAdviceTemplate")
37 46
 	beego.Router("/api/his/prescriptioninfomodetemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoModeTemplate")
47
+	beego.Router("/api/his/getdialysismodename", &HisConfigApiController{}, "get:GetDialysisModeName") //根据透析模式获取患者姓名
48
+	beego.Router("/api/his/getdrugsname", &HisConfigApiController{}, "get:GetDrugsName")               //根据类型获取药品名称
49
+	beego.Router("/api/his/getmodeconfigs", &HisConfigApiController{}, "get:GetModeConfigs")
50
+	beego.Router("/api/his/getdrugsinformation", &HisConfigApiController{}, "get:GetDrugsInformation") //根据id获取药品耗材项目基本信息
51
+	beego.Router("/api/his/replacepeoplename", &HisConfigApiController{}, "get:ReplacePeopleName")     //替换——获取患者名字
52
+	beego.Router("/api/his/replaceconfig", &HisConfigApiController{}, "get:ReplaceConfig")
53
+	beego.Router("/api/his/replacesavedrug", &HisConfigApiController{}, "post:ReplaceSaveDrug")          //替换——药品保存
54
+	beego.Router("/api/his/replacesaveproject", &HisConfigApiController{}, "post:ReplaceSaveProject")    //替换——项目保存
55
+	beego.Router("/api/his/deletedrugsbatch", &HisConfigApiController{}, "get:DeleteDrugsBatch")         //批量删除——药品
56
+	beego.Router("/api/his/batchdeleteitems", &HisConfigApiController{}, "get:BatchDeleteItems")         //批量删除——项目
57
+	beego.Router("/api/his/addstemplate", &HisConfigApiController{}, "post:AddsTemplate")                //批量添加
58
+	beego.Router("/api/his/ptemplateinformation", &HisConfigApiController{}, "get:PTemplateInformation") //根据患者id、透析模式获取处方模板信息
59
+	beego.Router("/api/his/deleteone", &HisConfigApiController{}, "get:DeleteOne")                       //删除单条处方模板
38 60
 }
39 61
 
40 62
 func (c *HisConfigApiController) GetAllHisPatientsList() {
@@ -898,3 +920,916 @@ func (c *HisConfigApiController) DeletePrescriptionInfoModeTemplate() {
898 920
 		return
899 921
 	}
900 922
 }
923
+
924
+func (c *HisConfigApiController) GetDialysisModeName() {
925
+	var err error
926
+	defer func() {
927
+		if rec := recover(); rec != nil {
928
+			err = fmt.Errorf("程序异常:%v", rec)
929
+		}
930
+		if err != nil {
931
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
932
+		}
933
+	}()
934
+	orgid := c.GetAdminUserInfo().CurrentOrgId
935
+	mode, _ := c.GetInt64("mode")
936
+	var list []*models.DialysisPatient
937
+	list, err = service.GetDialysisModePatient(orgid, mode)
938
+	if err != nil {
939
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
940
+		return
941
+	}
942
+	c.ServeSuccessJSON(map[string]interface{}{
943
+		"list": list,
944
+	})
945
+	return
946
+
947
+}
948
+func (c *HisConfigApiController) GetDrugsName() {
949
+	var err error
950
+	defer func() {
951
+		if rec := recover(); rec != nil {
952
+			err = fmt.Errorf("程序异常:%v", rec)
953
+		}
954
+		if err != nil {
955
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
956
+		}
957
+	}()
958
+	orgid := c.GetAdminUserInfo().CurrentOrgId
959
+	addtype, _ := c.GetInt("addtype")
960
+	//special,_ := c.GetInt("special")
961
+	//tmpBool := false
962
+	//if special == IsSpecialDiseases{
963
+	//	tmpBool = true
964
+	//}
965
+
966
+	tmp := make(map[string]interface{}, 0)
967
+	if addtype == AddTypeDrug {
968
+		var list []*models.ReplacementDrugs
969
+		list, err = service.ReplacementDrugs(orgid, true)
970
+		if err != nil {
971
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
972
+			return
973
+		}
974
+		var list2 []*models.ReplacementDrugs
975
+		list2, err = service.ReplacementDrugs(orgid, false)
976
+		if err != nil {
977
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
978
+			return
979
+		}
980
+		tmp["list"] = list
981
+		tmp["list2"] = list2
982
+	} else if addtype == AddTypeProject {
983
+		var list3 []*models.DropDownList
984
+		list3, err = service.ProjectConsumables2(orgid, true)
985
+		if err != nil {
986
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
987
+			return
988
+		}
989
+		var list4 []*models.DropDownList
990
+		list4, err = service.ProjectConsumables2(orgid, false)
991
+		if err != nil {
992
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
993
+			return
994
+		}
995
+		tmp["list"] = list3
996
+		tmp["list2"] = list4
997
+	} else {
998
+		err = fmt.Errorf("类型解析错误")
999
+		if err != nil {
1000
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1001
+			return
1002
+		}
1003
+	}
1004
+	c.ServeSuccessJSON(tmp)
1005
+	return
1006
+
1007
+}
1008
+
1009
+//配置项
1010
+func (c *HisConfigApiController) GetModeConfigs() {
1011
+	var err error
1012
+	defer func() {
1013
+		if rec := recover(); rec != nil {
1014
+			err = fmt.Errorf("程序异常:%v", rec)
1015
+		}
1016
+		if err != nil {
1017
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1018
+		}
1019
+	}()
1020
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1021
+	var drugways []*models.DrugwayDic
1022
+	var efs []*models.ExecutionFrequencyDic
1023
+	var dataconfig []*models.DictDataconfig
1024
+	drugways, _, err = service.GetDrugWayDics(orgid)
1025
+	if err != nil {
1026
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1027
+		return
1028
+	}
1029
+	efs, _, err = service.GetExecutionFrequencyDics(orgid)
1030
+	if err != nil {
1031
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1032
+		return
1033
+	}
1034
+	dataconfig, err = service.GetDataConfig(orgid)
1035
+	c.ServeSuccessJSON(map[string]interface{}{
1036
+		"drugways":   drugways,
1037
+		"efs":        efs,
1038
+		"dataconfig": dataconfig, //组
1039
+	})
1040
+	return
1041
+}
1042
+func (c *HisConfigApiController) GetDrugsInformation() {
1043
+	var err error
1044
+	defer func() {
1045
+		if rec := recover(); rec != nil {
1046
+			err = fmt.Errorf("程序异常:%v", rec)
1047
+		}
1048
+		if err != nil {
1049
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1050
+		}
1051
+	}()
1052
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1053
+	id := c.GetString("id", "")
1054
+	if len(id) == 0 {
1055
+		err = fmt.Errorf("参数错误")
1056
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1057
+		return
1058
+	}
1059
+	var list interface{}
1060
+	list, err = service.QueryFourTables(id, orgid)
1061
+	if err != nil {
1062
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1063
+		return
1064
+	}
1065
+	c.ServeSuccessJSON(map[string]interface{}{
1066
+		"list": list,
1067
+	})
1068
+	return
1069
+}
1070
+
1071
+func (c *HisConfigApiController) ReplacePeopleName() {
1072
+	var g errgroup.Group
1073
+	var err error
1074
+	defer func() {
1075
+		if rec := recover(); rec != nil {
1076
+			err = fmt.Errorf("程序异常:%v", rec)
1077
+		}
1078
+		if err != nil {
1079
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1080
+		}
1081
+	}()
1082
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1083
+	mode, _ := c.GetInt64("mode") //透析模式
1084
+	id := c.GetString("id", "")   //药品/项目/耗材id
1085
+	if id == "" {
1086
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
1087
+		return
1088
+	}
1089
+	var list []*models.DialysisPatient
1090
+	finlist := make([]*models.DialysisPatient, 0) //筛选后的列表
1091
+	list, err = service.GetDialysisModePatient(orgid, mode)
1092
+	if err != nil {
1093
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1094
+		return
1095
+	}
1096
+	for _, v := range list {
1097
+		v := v
1098
+		g.Go(func() error {
1099
+			//判断该患者是否有使用该药品/项目/耗材
1100
+			tmpid := id[:1]
1101
+			bo := false
1102
+			if tmpid == "p" {
1103
+				pid := id[1:]
1104
+				tmpisid, _ := strconv.ParseInt(pid, 10, 64)
1105
+				tp := service.FindPatientXiang(orgid, v.ID, tmpisid, mode)
1106
+				if tp {
1107
+					bo = true
1108
+				}
1109
+
1110
+			} else if tmpid == "i" {
1111
+				pid := id[1:]
1112
+				tmpisid, _ := strconv.ParseInt(pid, 10, 64)
1113
+				tp := service.FindPatientXiang2(orgid, v.ID, tmpisid, mode)
1114
+				if tp {
1115
+					bo = true
1116
+				}
1117
+			} else {
1118
+				pid := id
1119
+				tmpisid, _ := strconv.ParseInt(pid, 10, 64)
1120
+				tp := service.FindPatientDrug(orgid, v.ID, tmpisid, mode)
1121
+				if tp {
1122
+					bo = true
1123
+				}
1124
+			}
1125
+			if bo {
1126
+				finlist = append(finlist, v)
1127
+			}
1128
+			return nil
1129
+		})
1130
+	}
1131
+	if err = g.Wait(); err != nil {
1132
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1133
+		return
1134
+	}
1135
+
1136
+	c.ServeSuccessJSON(map[string]interface{}{
1137
+		"list": finlist,
1138
+	})
1139
+	return
1140
+}
1141
+func (c *HisConfigApiController) ReplaceConfig() {
1142
+	var err error
1143
+	defer func() {
1144
+		if rec := recover(); rec != nil {
1145
+			err = fmt.Errorf("程序异常:%v", rec)
1146
+		}
1147
+		if err != nil {
1148
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1149
+		}
1150
+	}()
1151
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1152
+	tmp := make(map[string]interface{}, 0)
1153
+	var list []*models.ReplacementDrugs
1154
+	var list2 []*models.DropDownList
1155
+	list, err = service.ReplacementDrugsT(orgid)
1156
+	if err != nil {
1157
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1158
+		return
1159
+	}
1160
+	tmp["list"] = list
1161
+	list2, err = service.ProjectConsumables2T(orgid)
1162
+	if err != nil {
1163
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1164
+		return
1165
+	}
1166
+	tmp["list2"] = list2
1167
+	c.ServeSuccessJSON(tmp)
1168
+	return
1169
+
1170
+}
1171
+
1172
+//批量替换——药品
1173
+func (c *HisConfigApiController) ReplaceSaveDrug() {
1174
+	var g errgroup.Group
1175
+	var err error
1176
+	tx := service.XTWriteDB().Begin()
1177
+	defer func() {
1178
+		if rec := recover(); rec != nil {
1179
+			err = fmt.Errorf("程序异常:%v", rec)
1180
+		}
1181
+		if err != nil {
1182
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1183
+			tx.Rollback()
1184
+		} else {
1185
+			tx.Commit()
1186
+		}
1187
+	}()
1188
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1189
+	types, _ := c.GetInt64("type", 1)       //1.药品 2.项目
1190
+	patient_id := c.GetString("patient_id") //患者
1191
+	replaced := c.GetString("replaced", "") //被替换的药品、项目、耗材id
1192
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1193
+	dataBody := make(map[string]interface{}, 0)
1194
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1195
+	if err != nil {
1196
+		utils.ErrorLog(err.Error())
1197
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1198
+		return
1199
+	}
1200
+	t_ids := ""
1201
+	if patient_id[len(patient_id)-1] == 44 {
1202
+		t_ids = patient_id[:len(patient_id)-1]
1203
+	} else {
1204
+		t_ids = patient_id
1205
+	}
1206
+	tmp_id := strings.Split(t_ids, ",")
1207
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1208
+	drugid, _ := strconv.ParseInt(replaced, 10, 64)
1209
+	for _, v := range tmp_id {
1210
+		v := v
1211
+		g.Go(func() error {
1212
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1213
+			var err error
1214
+			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1215
+				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1216
+				if len(prescriptions) > 0 {
1217
+					for _, item := range prescriptions {
1218
+						items := item.(map[string]interface{})
1219
+						var s models.HisPrescriptionAdviceTemplate
1220
+						var tmpdrugid int64
1221
+						if items["drug_name"] != nil && reflect.TypeOf(items["drug_name"]).String() == "string" {
1222
+							tmpdrugid, _ = strconv.ParseInt(items["drug_name"].(string), 10, 64)
1223
+						}
1224
+						if items["drug_name"] != nil && reflect.TypeOf(items["drug_name"]).String() == "float64" {
1225
+							tmpdrugid = int64(items["drug_name"].(float64))
1226
+						}
1227
+						s.AdviceName = service.FindDrugsName(tmpdrugid) //药品名称
1228
+						if items["id"] == nil {
1229
+							err = fmt.Errorf("缺少参数")
1230
+							return err
1231
+						} else {
1232
+							if items["id"] != nil && reflect.TypeOf(items["id"]).String() == "string" {
1233
+								tmp_drugid := items["id"].(string)
1234
+								drug_id, _ := strconv.ParseInt(tmp_drugid, 10, 64)
1235
+								s.DrugId = drug_id //药品id
1236
+							}
1237
+							if items["id"] != nil && reflect.TypeOf(items["id"]).String() == "float64" {
1238
+								drug_id := int64(items["id"].(float64))
1239
+								s.DrugId = drug_id
1240
+							}
1241
+						}
1242
+						if items["remark"] != nil && reflect.TypeOf(items["remark"]).String() == "string" {
1243
+							remark, _ := items["remark"].(string)
1244
+							s.Remark = remark //备注
1245
+						}
1246
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "string" {
1247
+							singleDose, _ := strconv.ParseFloat(items["single_dose"].(string), 64)
1248
+							s.SingleDose = singleDose
1249
+						}
1250
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "float64" {
1251
+							singleDose := items["single_dose"].(float64)
1252
+							s.SingleDose = singleDose
1253
+						}
1254
+						if items["single_dose_unit"] != nil && reflect.TypeOf(items["single_dose_unit"]).String() == "string" {
1255
+							singleDoseUnit, _ := items["single_dose_unit"].(string)
1256
+							s.SingleDoseUnit = singleDoseUnit
1257
+						}
1258
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "string" {
1259
+							prescribingNumber, _ := strconv.ParseFloat(items["prescribing_number"].(string), 64)
1260
+							s.PrescribingNumber = prescribingNumber
1261
+						}
1262
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "float64" {
1263
+							prescribingNumber := items["prescribing_number"].(float64)
1264
+							s.PrescribingNumber = prescribingNumber
1265
+						}
1266
+						if items["prescribing_number_unit"] != nil && reflect.TypeOf(items["prescribing_number_unit"]).String() == "string" {
1267
+							prescribingNumberUnit, _ := items["prescribing_number_unit"].(string)
1268
+							s.PrescribingNumberUnit = prescribingNumberUnit
1269
+						}
1270
+						if items["delivery_way"] != nil && reflect.TypeOf(items["delivery_way"]).String() == "string" {
1271
+							deliveryWay, _ := items["delivery_way"].(string)
1272
+							s.DeliveryWay = deliveryWay
1273
+						}
1274
+						if items["execution_frequency"] != nil && reflect.TypeOf(items["execution_frequency"]).String() == "string" {
1275
+							executionFrequency, _ := items["execution_frequency"].(string)
1276
+							s.ExecutionFrequency = executionFrequency
1277
+						}
1278
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "string" {
1279
+							price, _ := strconv.ParseFloat(items["price"].(string), 64)
1280
+							s.Price = price
1281
+						}
1282
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "float64" {
1283
+							price := items["price"].(float64)
1284
+							s.Price = price
1285
+						}
1286
+						if items["day"] != nil && reflect.TypeOf(items["day"]).String() == "string" {
1287
+							day, _ := strconv.ParseInt(items["day"].(string), 10, 64)
1288
+							s.Day = day
1289
+						}
1290
+						if items["day"] != nil && reflect.TypeOf(items["day"]).String() == "float64" {
1291
+							day := int64(items["day"].(float64))
1292
+							s.Day = day
1293
+						}
1294
+						s.FrequencyType = 1
1295
+						err = service.ReplaceDrugPrescriptionTemplate(orgid, pp, drugid, ids, s, tx)
1296
+						if err != nil {
1297
+							return err
1298
+						}
1299
+
1300
+					}
1301
+					return nil
1302
+				}
1303
+			}
1304
+			return err
1305
+		})
1306
+	}
1307
+	if errs := g.Wait(); errs != nil {
1308
+		err = errs
1309
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1310
+		return
1311
+	}
1312
+	c.ServeSuccessJSON(map[string]interface{}{
1313
+		"list": "替换成功",
1314
+	})
1315
+	return
1316
+}
1317
+
1318
+//批量替换项目
1319
+func (c *HisConfigApiController) ReplaceSaveProject() {
1320
+	var g errgroup.Group
1321
+	var err error
1322
+	tx := service.XTWriteDB().Begin()
1323
+	defer func() {
1324
+		if rec := recover(); rec != nil {
1325
+			err = fmt.Errorf("程序异常:%v", rec)
1326
+		}
1327
+		if err != nil {
1328
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1329
+			tx.Rollback()
1330
+		} else {
1331
+			tx.Commit()
1332
+		}
1333
+	}()
1334
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1335
+	types, _ := c.GetInt64("type", 2)       //1.药品 2.项目
1336
+	patient_id := c.GetString("patient_id") //患者
1337
+	replaced := c.GetString("replaced", "") //被替换的药品、项目、耗材id
1338
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1339
+	dataBody := make(map[string]interface{}, 0)
1340
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1341
+	if err != nil {
1342
+		utils.ErrorLog(err.Error())
1343
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1344
+		return
1345
+	}
1346
+	t_ids := ""
1347
+	if patient_id[len(patient_id)-1] == 44 {
1348
+		t_ids = patient_id[:len(patient_id)-1]
1349
+	} else {
1350
+		t_ids = patient_id
1351
+	}
1352
+	tmp_id := strings.Split(t_ids, ",")
1353
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1354
+	drugid, _ := strconv.ParseInt(replaced[1:], 10, 64)
1355
+	for _, v := range tmp_id {
1356
+		v := v
1357
+		g.Go(func() error {
1358
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1359
+			var err error
1360
+			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1361
+				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1362
+				if len(prescriptions) > 0 {
1363
+					for _, item := range prescriptions {
1364
+						items := item.(map[string]interface{})
1365
+						var s models.HisPrescriptionProjectTemplate
1366
+						if items["id"] != nil {
1367
+							id := items["id"].(string)
1368
+							if id != "" {
1369
+								tmpPid := id[1:]
1370
+								project_id, _ := strconv.ParseInt(tmpPid, 10, 64)
1371
+								if id[0] == 112 {
1372
+									s.Type = 2
1373
+								}
1374
+								if id[0] == 105 {
1375
+									s.Type = 3
1376
+								}
1377
+								s.ProjectId = project_id
1378
+							} else {
1379
+								s.ProjectId = int64(0)
1380
+							}
1381
+
1382
+						}
1383
+						if items["frequency_type"] != nil && reflect.TypeOf(items["frequency_type"]).String() == "string" {
1384
+							tmp_drugid := items["frequency_type"].(string)
1385
+							frequency_type, _ := strconv.ParseInt(tmp_drugid, 10, 64)
1386
+							s.FrequencyType = frequency_type
1387
+						}
1388
+						if items["frequency_type"] != nil && reflect.TypeOf(items["frequency_type"]).String() == "float64" {
1389
+							frequency_type := int64(items["frequency_type"].(float64))
1390
+							s.FrequencyType = frequency_type
1391
+						}
1392
+						if items["day_count"] != nil && reflect.TypeOf(items["day_count"]).String() == "string" {
1393
+							tmp_drugid := items["day_count"].(string)
1394
+							day_count, _ := strconv.ParseInt(tmp_drugid, 10, 64)
1395
+							s.DayCount = day_count
1396
+						}
1397
+						if items["day_count"] != nil && reflect.TypeOf(items["day_count"]).String() == "float64" {
1398
+							day_count := int64(items["day_count"].(float64))
1399
+							s.DayCount = day_count
1400
+						}
1401
+						if items["week_day"] != nil && reflect.TypeOf(items["week_day"]).String() == "string" {
1402
+							week_day, _ := items["week_day"].(string)
1403
+							s.WeekDay = week_day
1404
+						}
1405
+						if items["week_day"] != nil && reflect.TypeOf(items["week_day"]).String() == "float64" {
1406
+							week_day := config.ToString(items["week_day"].(float64))
1407
+							s.WeekDay = week_day
1408
+						}
1409
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "string" {
1410
+							price, _ := strconv.ParseFloat(items["price"].(string), 64)
1411
+							s.Price = price
1412
+						}
1413
+
1414
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "float64" {
1415
+							price := items["price"].(float64)
1416
+							s.Price = price
1417
+						}
1418
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "string" {
1419
+							total, _ := items["prescribing_number"].(string)
1420
+							//totals, _ := strconv.ParseInt(total, 10, 64)
1421
+							s.Count = total
1422
+						}
1423
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "float64" {
1424
+							total := config.ToString(items["prescribing_number"].(float64))
1425
+							//totals, _ := strconv.ParseInt(total, 10, 64)
1426
+							s.Count = total
1427
+						}
1428
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "string" {
1429
+							single_dose, _ := items["single_dose"].(string)
1430
+							s.SingleDose = single_dose
1431
+						}
1432
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "float64" {
1433
+							single_dose := config.ToString(items["single_dose"].(float64))
1434
+							s.SingleDose = single_dose
1435
+						}
1436
+						if items["delivery_way"] != nil && reflect.TypeOf(items["delivery_way"]).String() == "string" {
1437
+							delivery_way, _ := items["delivery_way"].(string)
1438
+							s.DeliveryWay = delivery_way
1439
+						}
1440
+						if items["execution_frequency"] != nil && reflect.TypeOf(items["execution_frequency"]).String() == "string" {
1441
+							execution_frequency, _ := items["execution_frequency"].(string)
1442
+							s.ExecutionFrequency = execution_frequency
1443
+						}
1444
+						if items["remark"] != nil && reflect.TypeOf(items["remark"]).String() == "string" {
1445
+							remark, _ := items["remark"].(string)
1446
+							s.Remark = remark
1447
+						}
1448
+						if items["day"] != nil && reflect.TypeOf(items["remark"]).String() == "string" {
1449
+							day, _ := items["number_days"].(string)
1450
+							s.Day = day
1451
+						}
1452
+						if items["day"] != nil && reflect.TypeOf(items["remark"]).String() == "float64" {
1453
+							day := config.ToString(items["number_days"].(float64))
1454
+							s.Day = day
1455
+						}
1456
+
1457
+						if items["unit"] != nil && reflect.TypeOf(items["unit"]).String() == "string" {
1458
+							unit, _ := items["unit"].(string)
1459
+							s.Unit = unit
1460
+						}
1461
+						err = service.ReplaceProjectPrescriptionTemplate(orgid, pp, drugid, ids, s, tx)
1462
+						if err != nil {
1463
+							return err
1464
+						}
1465
+
1466
+					}
1467
+					return nil
1468
+				}
1469
+			}
1470
+			return err
1471
+		})
1472
+	}
1473
+	if errs := g.Wait(); errs != nil {
1474
+		err = errs
1475
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1476
+		return
1477
+	}
1478
+	c.ServeSuccessJSON(map[string]interface{}{
1479
+		"list": "替换成功",
1480
+	})
1481
+	return
1482
+}
1483
+
1484
+//批量删除项目
1485
+func (c *HisConfigApiController) BatchDeleteItems() {
1486
+	var g errgroup.Group
1487
+	var err error
1488
+	tx := service.XTWriteDB().Begin()
1489
+	defer func() {
1490
+		if rec := recover(); rec != nil {
1491
+			err = fmt.Errorf("程序异常:%v", rec)
1492
+		}
1493
+		if err != nil {
1494
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1495
+			tx.Rollback()
1496
+		} else {
1497
+			tx.Commit()
1498
+		}
1499
+	}()
1500
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1501
+	types, _ := c.GetInt64("type", 2)       //1.药品 2.项目
1502
+	patient_id := c.GetString("patient_id") //患者
1503
+	replaced := c.GetString("replaced", "") //被删除的药品、项目、耗材id
1504
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1505
+	t_ids := ""
1506
+	if patient_id[len(patient_id)-1] == 44 {
1507
+		t_ids = patient_id[:len(patient_id)-1]
1508
+	} else {
1509
+		t_ids = patient_id
1510
+	}
1511
+	tmp_id := strings.Split(t_ids, ",")
1512
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1513
+	drugid, _ := strconv.ParseInt(replaced[1:], 10, 64)
1514
+	for _, v := range tmp_id {
1515
+		v := v
1516
+		g.Go(func() error {
1517
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1518
+			var err error
1519
+			err = service.DeleteProjectTemplate(orgid, pp, drugid, ids, tx)
1520
+			return err
1521
+		})
1522
+	}
1523
+	if errs := g.Wait(); errs != nil {
1524
+		err = errs
1525
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1526
+		return
1527
+	}
1528
+	c.ServeSuccessJSON(map[string]interface{}{
1529
+		"list": "删除成功",
1530
+	})
1531
+	return
1532
+}
1533
+
1534
+//批量删除药品
1535
+func (c *HisConfigApiController) DeleteDrugsBatch() {
1536
+	var g errgroup.Group
1537
+	var err error
1538
+	tx := service.XTWriteDB().Begin()
1539
+	defer func() {
1540
+		if rec := recover(); rec != nil {
1541
+			err = fmt.Errorf("程序异常:%v", rec)
1542
+		}
1543
+		if err != nil {
1544
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1545
+			tx.Rollback()
1546
+		} else {
1547
+			tx.Commit()
1548
+		}
1549
+	}()
1550
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1551
+	types, _ := c.GetInt64("type", 1)       //1.药品 2.项目
1552
+	patient_id := c.GetString("patient_id") //患者
1553
+	replaced := c.GetString("replaced", "") //被替换的药品、项目、耗材id
1554
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1555
+	t_ids := ""
1556
+	if patient_id[len(patient_id)-1] == 44 {
1557
+		t_ids = patient_id[:len(patient_id)-1]
1558
+	} else {
1559
+		t_ids = patient_id
1560
+	}
1561
+	tmp_id := strings.Split(t_ids, ",")
1562
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1563
+	drugid, _ := strconv.ParseInt(replaced, 10, 64)
1564
+	for _, v := range tmp_id {
1565
+		v := v
1566
+		g.Go(func() error {
1567
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1568
+			var err error
1569
+			err = service.DeletePrescriptionTemplate(orgid, pp, drugid, ids, tx)
1570
+			return err
1571
+		})
1572
+	}
1573
+	if errs := g.Wait(); errs != nil {
1574
+		err = errs
1575
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1576
+		return
1577
+	}
1578
+	c.ServeSuccessJSON(map[string]interface{}{
1579
+		"list": "删除成功",
1580
+	})
1581
+	return
1582
+}
1583
+
1584
+//批量添加
1585
+func (c *HisConfigApiController) AddsTemplate() {
1586
+	var g errgroup.Group
1587
+	var err error
1588
+	defer func() {
1589
+		if rec := recover(); rec != nil {
1590
+			err = fmt.Errorf("程序异常:%v", rec)
1591
+		}
1592
+		if err != nil {
1593
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1594
+		}
1595
+	}()
1596
+	//id, _ := c.GetInt64("id")
1597
+	name := c.GetString("name", "")
1598
+	mode_id, _ := c.GetInt64("mode_id", 0)
1599
+	types, _ := c.GetInt64("type", 1) //没啥用
1600
+	patient_id := c.GetString("patient_id")
1601
+	//patient_id, _ := c.GetInt64("patient_id", 0)
1602
+	if name == "" {
1603
+		name = service.DialysisModeName(mode_id)
1604
+	}
1605
+	adminInfo := c.GetAdminUserInfo()
1606
+	dataBody := make(map[string]interface{}, 0)
1607
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1608
+	if err != nil {
1609
+		utils.ErrorLog(err.Error())
1610
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1611
+		return
1612
+	}
1613
+	t_ids := ""
1614
+	if patient_id[len(patient_id)-1] == 44 {
1615
+		t_ids = patient_id[:len(patient_id)-1]
1616
+	} else {
1617
+		t_ids = patient_id
1618
+	}
1619
+	tmp_id := strings.Split(t_ids, ",")
1620
+	for _, v := range tmp_id {
1621
+		v := v
1622
+		g.Go(func() error {
1623
+			var err error
1624
+			pa, _ := strconv.ParseInt(v, 10, 64)
1625
+			tmp_bool_id := service.IsDialysisMode(adminInfo.CurrentOrgId, pa, mode_id)
1626
+
1627
+			var src_template models.HisPrescriptionTemplate
1628
+			if !tmp_bool_id {
1629
+				template := models.HisPrescriptionTemplate{
1630
+					UserOrgId: adminInfo.CurrentOrgId,
1631
+					PatientId: pa,
1632
+					Type:      types,
1633
+					Status:    1,
1634
+					Ctime:     time.Now().Unix(),
1635
+					Mtime:     time.Now().Unix(),
1636
+					Name:      name,
1637
+					Mode:      mode_id,
1638
+				}
1639
+				src_template = template
1640
+				service.CreateHisPrescriptionTemplate(&src_template)
1641
+			} else {
1642
+				//查询出该模板的id
1643
+				src_template, err = service.IdOfTheTemplate(adminInfo.CurrentOrgId, pa, mode_id)
1644
+				if err != nil {
1645
+					return err
1646
+				}
1647
+				src_template.Name = name
1648
+				src_template.Mode = mode_id
1649
+				service.SaveHisPrescriptionTemplate(&src_template)
1650
+			}
1651
+
1652
+			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1653
+				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1654
+				if len(prescriptions) > 0 {
1655
+					for _, item := range prescriptions {
1656
+						items := item.(map[string]interface{})
1657
+
1658
+						id := int64(0)
1659
+						//fmt.Println("111111111111111111111")
1660
+						//if items["type"] == nil {
1661
+						//	utils.ErrorLog("type")
1662
+						//	//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1663
+						//	fmt.Println("222222222222222")
1664
+						//	err = fmt.Errorf("参数错误")
1665
+						//	return err
1666
+						//}
1667
+						//fmt.Println("33333333333")
1668
+						//type1 := types
1669
+						med_type := ""
1670
+						var tmps float64
1671
+						if items["patient_value"] != nil && reflect.TypeOf(items["patient_value"]).String() == "float64" {
1672
+							tmps = items["patient_value"].(float64)
1673
+						}
1674
+						if items["patient_value"] != nil && reflect.TypeOf(items["patient_value"]).String() == "string" {
1675
+							tmps, _ = strconv.ParseFloat(items["patient_value"].(string), 64)
1676
+						}
1677
+						if tmps == 1 {
1678
+							med_type = "11"
1679
+						} else if tmps == 2 {
1680
+							med_type = "14"
1681
+						} else {
1682
+							err = fmt.Errorf("医疗类型参数错误")
1683
+						}
1684
+
1685
+						ctime := time.Now().Unix()
1686
+						prescription := &models.HisPrescriptionInfoTemplate{
1687
+							ID:          id,
1688
+							PatientId:   pa,
1689
+							UserOrgId:   adminInfo.CurrentOrgId,
1690
+							Ctime:       ctime,
1691
+							Mtime:       ctime,
1692
+							Type:        types,
1693
+							Modifier:    adminInfo.AdminUser.Id,
1694
+							Creator:     adminInfo.AdminUser.Id,
1695
+							Status:      1,
1696
+							PTemplateId: src_template.ID,
1697
+							MedType:     med_type,
1698
+						}
1699
+						service.CreateHisPrescriptionInfoTemplate(prescription)
1700
+
1701
+						if items["tableDatas"] != nil && reflect.TypeOf(items["tableDatas"]).String() == "[]interface {}" {
1702
+							advices := items["tableDatas"].([]interface{})
1703
+							//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
1704
+							groupNo := int64(0)
1705
+							ctime := time.Now().Unix()
1706
+							mtime := ctime
1707
+							if len(advices) > 0 {
1708
+								for k, advice := range advices {
1709
+									var s models.HisPrescriptionAdviceTemplate
1710
+									s.PrescriptionId = prescription.ID
1711
+									s.AdviceType = 2
1712
+									s.StopState = 2
1713
+									s.ExecutionState = 2
1714
+									s.Status = 1
1715
+									s.UserOrgId = adminInfo.CurrentOrgId
1716
+									s.Groupno = groupNo
1717
+									s.CreatedTime = ctime
1718
+									s.UpdatedTime = mtime
1719
+									s.PatientId = pa
1720
+									errcode := service.FensetAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
1721
+									if errcode > 0 {
1722
+										//c.ServeFailJSONWithSGJErrorCode(errcode)
1723
+										err = fmt.Errorf("参数错误")
1724
+										return err
1725
+									}
1726
+									if s.FrequencyType == 0 {
1727
+										s.FrequencyType = 1
1728
+									}
1729
+									s.Groupno = int64(k + 1) //序号
1730
+									if s.DrugId != 0 {
1731
+										service.CreateHisPrescriptionAdviceTemplate(&s)
1732
+									}
1733
+								}
1734
+							}
1735
+						}
1736
+						if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
1737
+							projects := items["project"].([]interface{})
1738
+							if len(projects) > 0 {
1739
+								for _, project := range projects {
1740
+									var p models.HisPrescriptionProjectTemplate
1741
+									p.PrescriptionId = prescription.ID
1742
+									p.Ctime = time.Now().Unix()
1743
+									p.Mtime = time.Now().Unix()
1744
+									p.PatientId = pa
1745
+									p.UserOrgId = adminInfo.CurrentOrgId
1746
+									p.Status = 1
1747
+									errcode := service.FensetProjectTemplateWithJSON(&p, project.(map[string]interface{}))
1748
+									if errcode > 0 {
1749
+										//c.ServeFailJSONWithSGJErrorCode(errcode)
1750
+										err = fmt.Errorf("参数错误")
1751
+										return err
1752
+									}
1753
+									if p.FrequencyType == 0 {
1754
+										p.FrequencyType = 1
1755
+									}
1756
+									if p.ProjectId != 0 {
1757
+										service.CreateHisPrescriptionProjectTemplate(&p)
1758
+									}
1759
+
1760
+								}
1761
+							}
1762
+						}
1763
+					}
1764
+					return nil
1765
+				}
1766
+			}
1767
+			return err
1768
+		})
1769
+	}
1770
+	if errs := g.Wait(); errs != nil {
1771
+		err = errs
1772
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1773
+		return
1774
+	}
1775
+	c.ServeSuccessJSON(map[string]interface{}{
1776
+		"list": "创建成功",
1777
+	})
1778
+	return
1779
+
1780
+}
1781
+
1782
+//根据透析模式和患者id获取该患者的处方内容
1783
+func (c *HisConfigApiController) PTemplateInformation() {
1784
+	var err error
1785
+	defer func() {
1786
+		if rec := recover(); rec != nil {
1787
+			err = fmt.Errorf("程序异常:%v", rec)
1788
+		}
1789
+		if err != nil {
1790
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1791
+		}
1792
+	}()
1793
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1794
+	mode_id, _ := c.GetInt64("mode_id", 0)    //透析模式
1795
+	patient_id, _ := c.GetInt64("patient_id") //患者
1796
+	list, err := service.PTemplateInformation(orgid, mode_id, patient_id)
1797
+	if err != nil {
1798
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1799
+		return
1800
+	}
1801
+	c.ServeSuccessJSON(map[string]interface{}{
1802
+		"list": list,
1803
+	})
1804
+	return
1805
+}
1806
+
1807
+//删除单条记录
1808
+func (c *HisConfigApiController) DeleteOne() {
1809
+	var err error
1810
+	defer func() {
1811
+		if rec := recover(); rec != nil {
1812
+			err = fmt.Errorf("程序异常:%v", rec)
1813
+		}
1814
+		if err != nil {
1815
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1816
+		}
1817
+	}()
1818
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1819
+	types, _ := c.GetInt64("type") //透析模式
1820
+	id, _ := c.GetInt64("id")      //患者
1821
+	err = service.DeleteOne(types, id)
1822
+	if err != nil {
1823
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1824
+		return
1825
+	}
1826
+	err = service.Scavenger(orgid)
1827
+	if err != nil {
1828
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1829
+		return
1830
+	}
1831
+	c.ServeSuccessJSON(map[string]interface{}{
1832
+		"list": "成功",
1833
+	})
1834
+	return
1835
+}

+ 12 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Visa fil

@@ -412,6 +412,7 @@ func (this *DialysisAPIController) DialysisRecord() {
412 412
 
413 413
 	go func() {
414 414
 		doctorAdvices, _ = service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
415
+
415 416
 		ch <- struct{}{}
416 417
 	}()
417 418
 
@@ -573,7 +574,7 @@ func (this *DialysisAPIController) DialysisRecord() {
573 574
 	if is_advice_open.IsAdviceOpen == 1 {
574 575
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
575 576
 	}
576
-
577
+	fmt.Println("doctorAdvices23344334344433434334343434wode", doctorAdvices)
577 578
 	returnData := map[string]interface{}{
578 579
 		"patient":                        patient,
579 580
 		"schedual":                       schedual,
@@ -1066,6 +1067,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1066 1067
 	machine_run := c.GetString("machine_run")
1067 1068
 	after_urea := c.GetString("after_urea")
1068 1069
 	pip_coagulation := c.GetString("pip_coagulation")
1070
+	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1069 1071
 	if id <= 0 {
1070 1072
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1071 1073
 		return
@@ -1169,6 +1171,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1169 1171
 		MachineRun:                   machine_run,
1170 1172
 		AfterUrea:                    after_urea,
1171 1173
 		PipCoagulation:               pip_coagulation,
1174
+		AccumulatedBloodVolume:       accumulated_blood_volume,
1172 1175
 	}
1173 1176
 
1174 1177
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -1754,6 +1757,14 @@ func (c *DialysisAPIController) Finish() {
1754 1757
 		tempassessmentAfterDislysis.UserOrgId = adminUserInfo.Org.Id
1755 1758
 	}
1756 1759
 
1760
+	//长沙南雅
1761
+	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
1762
+		//获取最后一条透析处方数据
1763
+		prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1764
+		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1765
+		tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration
1766
+	}
1767
+
1757 1768
 	if dialysisOrder.Stage == 1 {
1758 1769
 		temp_time := (float64(endDate.Unix()) - float64(dialysisOrder.StartTime)) / 3600
1759 1770
 		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)

+ 6 - 1
controllers/mobile_api_controllers/patient_api_controller.go Visa fil

@@ -2740,6 +2740,11 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2740 2740
 
2741 2741
 		evaluation.Suction = suction
2742 2742
 	}
2743
+	if dataBody["weight_befor_remake"] != nil && reflect.TypeOf(dataBody["weight_befor_remake"]).String() == "string" {
2744
+		weight_befor_remake := dataBody["weight_befor_remake"].(string)
2745
+
2746
+		evaluation.WeightBeforRemake = weight_befor_remake
2747
+	}
2743 2748
 	return
2744 2749
 }
2745 2750
 
@@ -3357,7 +3362,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
3357 3362
 
3358 3363
 	//临时医嘱
3359 3364
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
3360
-
3365
+	fmt.Println("DoctorAdvice3223323323232323223323323223332232332wode", DoctorAdvice)
3361 3366
 	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
3362 3367
 	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
3363 3368
 

+ 24 - 4
controllers/patient_api_controller.go Visa fil

@@ -82,6 +82,15 @@ func PatientApiRegistRouters() {
82 82
 
83 83
 //GetPatientsList 取患者列表
84 84
 func (c *PatientApiController) GetPatientsList() {
85
+	var err error
86
+	defer func() {
87
+		if rec := recover(); rec != nil {
88
+			err = fmt.Errorf("程序异常:%v", rec)
89
+		}
90
+		if err != nil {
91
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
92
+		}
93
+	}()
85 94
 	page, _ := c.GetInt64("page", 1)
86 95
 	limit, _ := c.GetInt64("limit", 10)
87 96
 	schedulType, _ := c.GetInt64("schedul_type", 0)
@@ -132,7 +141,9 @@ func (c *PatientApiController) GetPatientsList() {
132 141
 		theEndtTIme = theTime.Unix()
133 142
 	}
134 143
 
135
-	patients, total, _ := service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime)
144
+	var patients []*models.Patients
145
+	var total int64
146
+	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime)
136 147
 
137 148
 	c.ServeSuccessJSON(map[string]interface{}{
138 149
 		"patients": patients,
@@ -1103,7 +1114,15 @@ func (c *PatientApiController) CreateDryWeights() {
1103 1114
 }
1104 1115
 
1105 1116
 func (c *PatientApiController) CreateGroupAdvice() {
1106
-
1117
+	var err error
1118
+	defer func() {
1119
+		if rec := recover(); rec != nil {
1120
+			err = fmt.Errorf("程序异常:%v", rec)
1121
+		}
1122
+		if err != nil {
1123
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1124
+		}
1125
+	}()
1107 1126
 	patient, _ := c.GetInt64("id", 0)
1108 1127
 	groupNo, _ := c.GetInt64("groupno", 0)
1109 1128
 
@@ -1113,14 +1132,15 @@ func (c *PatientApiController) CreateGroupAdvice() {
1113 1132
 	}
1114 1133
 
1115 1134
 	adminUserInfo := c.GetAdminUserInfo()
1116
-	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
1135
+	var patientInfo models.Patients
1136
+	patientInfo, err = service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
1117 1137
 	if patientInfo.ID == 0 {
1118 1138
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1119 1139
 		return
1120 1140
 	}
1121 1141
 
1122 1142
 	dataBody := make(map[string]interface{}, 0)
1123
-	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1143
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1124 1144
 	if err != nil {
1125 1145
 		utils.ErrorLog(err.Error())
1126 1146
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 204 - 31
controllers/pharmacy_controller.go Visa fil

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"fmt"
8 9
 	"github.com/astaxie/beego"
9 10
 	"time"
10 11
 )
@@ -15,36 +16,42 @@ type PharmacyController struct {
15 16
 
16 17
 func PharmacyApiRegistRouters() {
17 18
 	beego.Router("/api/pharmacy/ceshili", &PharmacyController{}, "get:Tlili")
18
-	beego.Router("/api/pharmacy/todaynumber", &PharmacyController{}, "get:TodayNumber")                   //查询今天的待发药,已发药人数(
19
-	beego.Router("/api/pharmacy/waitingdrug", &PharmacyController{}, "get:WaitingDrug")                   //获取当天待发药的所有患者(
20
-	beego.Router("/api/pharmacy/issueddrugs", &PharmacyController{}, "get:IssuedDrug")                    //获取当天已发药的所有患者(
21
-	beego.Router("/api/pharmacy/getpharmacycontent", &PharmacyController{}, "get:GetPharmacyContent")     //获取当天该患者的所有信息(
22
-	beego.Router("/api/pharmacy/dispensingmedicine", &PharmacyController{}, "get:DispensingMedicine")     //患者发药按钮点击(
23
-	beego.Router("/api/pharmacy/drugwithdrawal", &PharmacyController{}, "get:DrugWithdrawal")             //退药按钮点击
24
-	beego.Router("/api/pharmacy/dispensingdetails", &PharmacyController{}, "get:DispensingDetails")       //获取发药明细的患者列表(
25
-	beego.Router("/api/pharmacy/prescriptiondetails", &PharmacyController{}, "get:PrescriptionDetails")   //发药明细-详情(
26
-	beego.Router("/api/pharmacy/dispensemedicine", &PharmacyController{}, "get:DispenseMedicine")         //获取当天已发药的药品(
27
-	beego.Router("/api/pharmacy/waitingmedicine", &PharmacyController{}, "get:WaitingMedicine")           //获取当天待发药的药品(
28
-	beego.Router("/api/pharmacy/getpatientswithdrugs", &PharmacyController{}, "get:GetPatientsWithDrugs") //获取当天该药品的所有患者(
29
-	beego.Router("/api/pharmacy/medicinedeparture", &PharmacyController{}, "get:MedicineDeparture")       //药品发药按钮点击(
30
-	beego.Router("/api/pharmacy/getcurrentname", &PharmacyController{}, "get:GetCurrentName")             //获取当前登录账号的名字(
19
+	beego.Router("/api/pharmacy/todaynumber", &PharmacyController{}, "get:TodayNumber")                     //查询今天的待发药,已发药人数(
20
+	beego.Router("/api/pharmacy/waitingdrug", &PharmacyController{}, "get:WaitingDrug")                     //获取当天待发药的所有患者(
21
+	beego.Router("/api/pharmacy/issueddrugs", &PharmacyController{}, "get:IssuedDrug")                      //获取当天已发药的所有患者(
22
+	beego.Router("/api/pharmacy/getpharmacycontent", &PharmacyController{}, "get:GetPharmacyContent")       //获取当天该患者的所有信息(
23
+	beego.Router("/api/pharmacy/dispensingmedicine", &PharmacyController{}, "get:DispensingMedicine")       //患者发药按钮点击(
24
+	beego.Router("/api/pharmacy/drugwithdrawal", &PharmacyController{}, "get:DrugWithdrawal")               //退药按钮点击
25
+	beego.Router("/api/pharmacy/dispensingdetails", &PharmacyController{}, "get:DispensingDetails")         //获取发药明细的患者列表(
26
+	beego.Router("/api/pharmacy/prescriptiondetails", &PharmacyController{}, "get:PrescriptionDetails")     //发药明细-详情(
27
+	beego.Router("/api/pharmacy/dispensemedicine", &PharmacyController{}, "get:DispenseMedicine")           //获取当天已发药的药品(
28
+	beego.Router("/api/pharmacy/waitingmedicine", &PharmacyController{}, "get:WaitingMedicine")             //获取当天待发药的药品(
29
+	beego.Router("/api/pharmacy/getpatientswithdrugs", &PharmacyController{}, "get:GetPatientsWithDrugs")   //获取当天该药品的所有患者(
30
+	beego.Router("/api/pharmacy/medicinedeparture", &PharmacyController{}, "get:MedicineDeparture")         //药品发药按钮点击(
31
+	beego.Router("/api/pharmacy/getcurrentname", &PharmacyController{}, "get:GetCurrentName")               //获取当前登录账号的名字(
32
+	beego.Router("/api/pharmacy/getpartitionlist", &PharmacyController{}, "get:GetPartitionList")           //获取当前机构的分区列表
33
+	beego.Router("/api/pharmacy/routeofadministration", &PharmacyController{}, "get:RouteOfAdministration") //获取当前机构的给药途径
31 34
 }
35
+
36
+//测试
32 37
 func (this *PharmacyController) Tlili() {
33
-	times := this.GetString("time", "")
34
-	timeLayout := "2006-01-02"
35
-	loc, _ := time.LoadLocation("Local")
36
-	var stime, etime int64
37
-	if times == "" {
38
-		stime, etime = service.GetNowTime()
39
-	} else {
40
-		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
41
-		stime = stmp.Unix()
42
-		etime = stime + 86399
38
+	var err error
39
+	defer func() {
40
+		if rec := recover(); rec != nil {
41
+			err = fmt.Errorf("程序异常:%v", rec)
42
+		}
43
+		if err != nil {
44
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
45
+		}
46
+	}()
47
+	var list2 []*models.ReplacementDrugs
48
+	list2, err = service.ReplacementDrugs(9675, false)
49
+	if err != nil {
50
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
51
+		return
43 52
 	}
44
-	orgid := this.GetAdminUserInfo().CurrentOrgId
45
-	service.InitDrugidIsNil(orgid, stime, etime)
46 53
 	this.ServeSuccessJSON(map[string]interface{}{
47
-		"list": "err",
54
+		"list": list2,
48 55
 	})
49 56
 	return
50 57
 }
@@ -60,6 +67,9 @@ func (this *PharmacyController) GetCurrentName() {
60 67
 func (this *PharmacyController) TodayNumber() {
61 68
 	var err error
62 69
 	defer func() {
70
+		if rec := recover(); rec != nil {
71
+			err = fmt.Errorf("程序异常:%v", rec)
72
+		}
63 73
 		if err != nil {
64 74
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
65 75
 		}
@@ -68,6 +78,16 @@ func (this *PharmacyController) TodayNumber() {
68 78
 	times := this.GetString("time", "")
69 79
 	timeLayout := "2006-01-02"
70 80
 	loc, _ := time.LoadLocation("Local")
81
+	//shift, err := this.GetInt64("shift", 0) //班次
82
+	//if err != nil {
83
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
84
+	//	return
85
+	//}
86
+	//partition, err := this.GetInt64("partition", 0) //分区
87
+	//if err != nil {
88
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
89
+	//	return
90
+	//}
71 91
 	var stime, etime int64
72 92
 	if times == "" {
73 93
 		stime, etime = service.GetNowTime()
@@ -100,6 +120,9 @@ func (this *PharmacyController) TodayNumber() {
100 120
 func (this *PharmacyController) IssuedDrug() {
101 121
 	var err error
102 122
 	defer func() {
123
+		if rec := recover(); rec != nil {
124
+			err = fmt.Errorf("程序异常:%v", rec)
125
+		}
103 126
 		if err != nil {
104 127
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
105 128
 		}
@@ -107,6 +130,16 @@ func (this *PharmacyController) IssuedDrug() {
107 130
 	keyword := this.GetString("keyword", "")
108 131
 	times := this.GetString("time", "")
109 132
 	orgid := this.GetAdminUserInfo().CurrentOrgId
133
+	shift, err := this.GetInt64("shift", 0) //班次
134
+	if err != nil {
135
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136
+		return
137
+	}
138
+	partition, err := this.GetInt64("partition", 0) //分区
139
+	if err != nil {
140
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
141
+		return
142
+	}
110 143
 	timeLayout := "2006-01-02"
111 144
 	loc, _ := time.LoadLocation("Local")
112 145
 	var stime, etime int64
@@ -125,20 +158,39 @@ func (this *PharmacyController) IssuedDrug() {
125 158
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
126 159
 		return
127 160
 	}
161
+	listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
162
+	if err != nil {
163
+		utils.ErrorLog(err.Error())
164
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
165
+		return
166
+	}
128 167
 	this.ServeSuccessJSON(map[string]interface{}{
129
-		"list": flist,
168
+		"list": listt,
130 169
 	})
131 170
 	return
132 171
 }
133 172
 func (this *PharmacyController) WaitingDrug() {
134 173
 	var err error
135 174
 	defer func() {
175
+		if rec := recover(); rec != nil {
176
+			err = fmt.Errorf("程序异常:%v", rec)
177
+		}
136 178
 		if err != nil {
137 179
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
138 180
 		}
139 181
 	}()
140 182
 	keyword := this.GetString("keyword", "")
141 183
 	times := this.GetString("time", "")
184
+	shift, err := this.GetInt64("shift", 0) //班次
185
+	if err != nil {
186
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
187
+		return
188
+	}
189
+	partition, err := this.GetInt64("partition", 0) //分区
190
+	if err != nil {
191
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
192
+		return
193
+	}
142 194
 	orgid := this.GetAdminUserInfo().CurrentOrgId
143 195
 	timeLayout := "2006-01-02"
144 196
 	loc, _ := time.LoadLocation("Local")
@@ -158,8 +210,14 @@ func (this *PharmacyController) WaitingDrug() {
158 210
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
159 211
 		return
160 212
 	}
213
+	listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
214
+	if err != nil {
215
+		utils.ErrorLog(err.Error())
216
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
217
+		return
218
+	}
161 219
 	this.ServeSuccessJSON(map[string]interface{}{
162
-		"list": flist,
220
+		"list": listt,
163 221
 	})
164 222
 	return
165 223
 }
@@ -168,6 +226,9 @@ func (this *PharmacyController) WaitingDrug() {
168 226
 func (this *PharmacyController) GetPharmacyContent() {
169 227
 	var err error
170 228
 	defer func() {
229
+		if rec := recover(); rec != nil {
230
+			err = fmt.Errorf("程序异常:%v", rec)
231
+		}
171 232
 		if err != nil {
172 233
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
173 234
 		}
@@ -207,6 +268,9 @@ func (this *PharmacyController) GetPharmacyContent() {
207 268
 func (this *PharmacyController) DispensingMedicine() {
208 269
 	var err error
209 270
 	defer func() {
271
+		if rec := recover(); rec != nil {
272
+			err = fmt.Errorf("程序异常:%v", rec)
273
+		}
210 274
 		if err != nil {
211 275
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
212 276
 		}
@@ -241,6 +305,9 @@ func (this *PharmacyController) DispensingMedicine() {
241 305
 func (this *PharmacyController) DrugWithdrawal() {
242 306
 	var err error
243 307
 	defer func() {
308
+		if rec := recover(); rec != nil {
309
+			err = fmt.Errorf("程序异常:%v", rec)
310
+		}
244 311
 		if err != nil {
245 312
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
246 313
 		}
@@ -276,6 +343,9 @@ func (this *PharmacyController) DrugWithdrawal() {
276 343
 func (this *PharmacyController) DispensingDetails() {
277 344
 	var err error
278 345
 	defer func() {
346
+		if rec := recover(); rec != nil {
347
+			err = fmt.Errorf("程序异常:%v", rec)
348
+		}
279 349
 		if err != nil {
280 350
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
281 351
 		}
@@ -321,6 +391,9 @@ func (this *PharmacyController) DispensingDetails() {
321 391
 func (this *PharmacyController) PrescriptionDetails() {
322 392
 	var err error
323 393
 	defer func() {
394
+		if rec := recover(); rec != nil {
395
+			err = fmt.Errorf("程序异常:%v", rec)
396
+		}
324 397
 		if err != nil {
325 398
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
326 399
 		}
@@ -351,6 +424,9 @@ func (this *PharmacyController) PrescriptionDetails() {
351 424
 func (this *PharmacyController) DispenseMedicine() {
352 425
 	var err error
353 426
 	defer func() {
427
+		if rec := recover(); rec != nil {
428
+			err = fmt.Errorf("程序异常:%v", rec)
429
+		}
354 430
 		if err != nil {
355 431
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
356 432
 		}
@@ -360,6 +436,7 @@ func (this *PharmacyController) DispenseMedicine() {
360 436
 	orgid := this.GetAdminUserInfo().CurrentOrgId
361 437
 	timeLayout := "2006-01-02"
362 438
 	loc, _ := time.LoadLocation("Local")
439
+	deliveryway := this.GetString("deliveryway", "")
363 440
 	var stime, etime int64
364 441
 	if times == "" {
365 442
 		stime, etime = service.GetNowTime()
@@ -376,8 +453,14 @@ func (this *PharmacyController) DispenseMedicine() {
376 453
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
377 454
 		return
378 455
 	}
456
+	llist, err := service.Administration(deliveryway, orgid, flist)
457
+	if err != nil {
458
+		utils.ErrorLog(err.Error())
459
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
460
+		return
461
+	}
379 462
 	this.ServeSuccessJSON(map[string]interface{}{
380
-		"list": flist,
463
+		"list": llist,
381 464
 	})
382 465
 	return
383 466
 }
@@ -386,6 +469,9 @@ func (this *PharmacyController) DispenseMedicine() {
386 469
 func (this *PharmacyController) WaitingMedicine() {
387 470
 	var err error
388 471
 	defer func() {
472
+		if rec := recover(); rec != nil {
473
+			err = fmt.Errorf("程序异常:%v", rec)
474
+		}
389 475
 		if err != nil {
390 476
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
391 477
 		}
@@ -395,6 +481,7 @@ func (this *PharmacyController) WaitingMedicine() {
395 481
 	orgid := this.GetAdminUserInfo().CurrentOrgId
396 482
 	timeLayout := "2006-01-02"
397 483
 	loc, _ := time.LoadLocation("Local")
484
+	deliveryway := this.GetString("deliveryway", "")
398 485
 	var stime, etime int64
399 486
 	if times == "" {
400 487
 		stime, etime = service.GetNowTime()
@@ -411,8 +498,14 @@ func (this *PharmacyController) WaitingMedicine() {
411 498
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
412 499
 		return
413 500
 	}
501
+	llist, err := service.Administration(deliveryway, orgid, flist)
502
+	if err != nil {
503
+		utils.ErrorLog(err.Error())
504
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
505
+		return
506
+	}
414 507
 	this.ServeSuccessJSON(map[string]interface{}{
415
-		"list": flist,
508
+		"list": llist,
416 509
 	})
417 510
 	return
418 511
 }
@@ -421,6 +514,9 @@ func (this *PharmacyController) WaitingMedicine() {
421 514
 func (this *PharmacyController) GetPatientsWithDrugs() {
422 515
 	var err error
423 516
 	defer func() {
517
+		if rec := recover(); rec != nil {
518
+			err = fmt.Errorf("程序异常:%v", rec)
519
+		}
424 520
 		if err != nil {
425 521
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
426 522
 		}
@@ -429,6 +525,21 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
429 525
 	is_medicine, _ := this.GetInt64("is_medicine", 0) //0:待发药,1:已发药
430 526
 	times := this.GetString("time", "")
431 527
 	orgid := this.GetAdminUserInfo().CurrentOrgId
528
+	deliveryway := this.GetString("deliveryway", "")
529
+	if deliveryway == "" {
530
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
531
+		return
532
+	}
533
+	shift, err := this.GetInt64("shift", 0) //班次
534
+	if err != nil {
535
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
536
+		return
537
+	}
538
+	partition, err := this.GetInt64("partition", 0) //分区
539
+	if err != nil {
540
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
541
+		return
542
+	}
432 543
 	timeLayout := "2006-01-02"
433 544
 	loc, _ := time.LoadLocation("Local")
434 545
 	var stime, etime int64
@@ -446,8 +557,21 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
446 557
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
447 558
 		return
448 559
 	}
560
+	listll, err := service.PartitionAndLayoutDrug(deliveryway, stime, etime, orgid, shift, partition, list)
561
+	if err != nil {
562
+		utils.ErrorLog(err.Error())
563
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
564
+		return
565
+	}
566
+	total, err := service.CalculateTheTotalAmount(listll, drug_id)
567
+	if err != nil {
568
+		utils.ErrorLog(err.Error())
569
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
570
+		return
571
+	}
449 572
 	this.ServeSuccessJSON(map[string]interface{}{
450
-		"list": list,
573
+		"list":  listll,
574
+		"total": total,
451 575
 	})
452 576
 	return
453 577
 }
@@ -456,6 +580,9 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
456 580
 func (this *PharmacyController) MedicineDeparture() {
457 581
 	var err error
458 582
 	defer func() {
583
+		if rec := recover(); rec != nil {
584
+			err = fmt.Errorf("程序异常:%v", rec)
585
+		}
459 586
 		if err != nil {
460 587
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
461 588
 		}
@@ -477,3 +604,49 @@ func (this *PharmacyController) MedicineDeparture() {
477 604
 	})
478 605
 	return
479 606
 }
607
+
608
+func (this *PharmacyController) GetPartitionList() {
609
+	var err error
610
+	defer func() {
611
+		if rec := recover(); rec != nil {
612
+			err = fmt.Errorf("程序异常:%v", rec)
613
+		}
614
+		if err != nil {
615
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
616
+		}
617
+	}()
618
+	orgid := this.GetAdminUserInfo().CurrentOrgId
619
+	tmp := []*models.DeviceZone{{ID: 0, Name: "全部分区"}}
620
+	list, err := service.GetAllValidDeviceZones02(orgid)
621
+	if err != nil {
622
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
623
+		return
624
+	}
625
+	this.ServeSuccessJSON(map[string]interface{}{
626
+		"list": append(tmp, list...),
627
+	})
628
+	return
629
+}
630
+
631
+func (this *PharmacyController) RouteOfAdministration() {
632
+	var err error
633
+	defer func() {
634
+		if rec := recover(); rec != nil {
635
+			err = fmt.Errorf("程序异常:%v", rec)
636
+		}
637
+		if err != nil {
638
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
639
+		}
640
+	}()
641
+	orgid := this.GetAdminUserInfo().CurrentOrgId
642
+	tmp := []*models.DrugwayDic{{ID: 0, Name: "全部"}}
643
+	list, _, err := service.GetDrugWayDics(orgid)
644
+	if err != nil {
645
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
646
+		return
647
+	}
648
+	this.ServeSuccessJSON(map[string]interface{}{
649
+		"list": append(tmp, list...),
650
+	})
651
+	return
652
+}

+ 0 - 1
controllers/stock_in_api_controller.go Visa fil

@@ -7021,7 +7021,6 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7021 7021
 	//更改审核状态
7022 7022
 	err := service.UpdateCheckWarehouseInfo(warehousing_info_id)
7023 7023
 	if err == nil {
7024
-
7025 7024
 		list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
7026 7025
 		Creator := this.GetAdminUserInfo().AdminUser.Id
7027 7026
 		for _, item := range list {

+ 3 - 0
controllers/supply_order_api_contorller.go Visa fil

@@ -125,6 +125,9 @@ func CheckParams(this *SupplyOrderApiController, m *map[string][]string) (map[st
125 125
 func (this *SupplyOrderApiController) GetSupplyList() {
126 126
 	var err error
127 127
 	defer func() {
128
+		if rec := recover(); rec != nil {
129
+			err = fmt.Errorf("程序异常:%v", rec)
130
+		}
128 131
 		if err != nil {
129 132
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
130 133
 		}

+ 1 - 0
models/data_models.go Visa fil

@@ -152,6 +152,7 @@ type FiledConfig struct {
152 152
 	CreateTime  int64  `gorm:"column:create_time" json:"create_time"`
153 153
 	UpdateTime  int64  `gorm:"column:update_time" json:"update_time"`
154 154
 	SysModule   int64  `gorm:"column:sys_module" json:"sys_module" form:"sys_module"`
155
+	IsWrite     int64  `gorm:"column:is_write" json:"is_write" form:"is_write"`
155 156
 }
156 157
 
157 158
 func (FiledConfig) TableName() string {

+ 1 - 1
models/device_models.go Visa fil

@@ -107,9 +107,9 @@ type DeviceZone struct {
107 107
 	OrgID      int64  `gorm:"column:org_id" json:"-"`
108 108
 	Name       string `json:"name"`
109 109
 	Type       int    `json:"type"`
110
-	Status     int8   `json:"-"`
111 110
 	CreateTime int64  `gorm:"column:ctime" json:"-"`
112 111
 	ModifyTime int64  `gorm:"column:mtime" json:"-"`
112
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
113 113
 }
114 114
 
115 115
 func (DeviceZone) TableName() string {

+ 2 - 0
models/dialysis.go Visa fil

@@ -320,6 +320,7 @@ type PredialysisEvaluation struct {
320 320
 	BloodPressureDuringDialysis    string  `gorm:"column:blood_pressure_during_dialysis" json:"blood_pressure_during_dialysis" form:"blood_pressure_during_dialysis"`
321 321
 	UreaBefor                      string  `gorm:"column:urea_befor" json:"urea_befor" form:"urea_befor"`
322 322
 	Suction                        string  `gorm:"column:suction" json:"suction" form:"suction"`
323
+	WeightBeforRemake              string  `gorm:"column:weight_befor_remake" json:"weight_befor_remake" form:"weight_befor_remake"`
323 324
 }
324 325
 
325 326
 func (PredialysisEvaluation) TableName() string {
@@ -640,6 +641,7 @@ type AssessmentAfterDislysis struct {
640 641
 	MachineRun                      string  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
641 642
 	AfterUrea                       string  `gorm:"column:after_urea" json:"after_urea" form:"after_urea"`
642 643
 	PipCoagulation                  string  `gorm:"column:pip_coagulation" json:"pip_coagulation" form:"pip_coagulation"`
644
+	AccumulatedBloodVolume          string  `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
643 645
 }
644 646
 
645 647
 func (AssessmentAfterDislysis) TableName() string {

+ 431 - 142
models/pharmacy_models.go Visa fil

@@ -2,183 +2,192 @@ package models
2 2
 
3 3
 //药房表
4 4
 type Pharmary struct {
5
-	ID			int64	`gorm:"column:id" json:"id" form:"id"`
6
-	UserOrgId	int64	`gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
-	PatientId  int64	`gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
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
-	RecordDate  int64	`gorm:"column:record_date" json:"record_date" form:"record_date"`
5
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
6
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
+	PatientId  int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
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
+	RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
12 12
 }
13 13
 
14
-func (Pharmary)TableName() string {
14
+func (Pharmary) TableName() string {
15 15
 	return "sgj_xt.xt_pharmacy"
16 16
 }
17 17
 
18 18
 type XtErrs struct {
19
-	OrgId			int64	`gorm:"column:org_id" json:"org_id" form:"org_id"`
20
-	Route			string	`gorm:"column:route" json:"route" form:"route"`
21
-	Parameter		string	`gorm:"column:parameter" json:"parameter" form:"parameter"`
22
-	Text_err		string	`gorm:"column:text_err" json:"text_err" form:"text_err"`
19
+	OrgId     int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
20
+	Route     string `gorm:"column:route" json:"route" form:"route"`
21
+	Parameter string `gorm:"column:parameter" json:"parameter" form:"parameter"`
22
+	Text_err  string `gorm:"column:text_err" json:"text_err" form:"text_err"`
23 23
 }
24
-func (XtErrs)TableName() string {
24
+
25
+func (XtErrs) TableName() string {
25 26
 	return "sgj_xt.xt_errs"
26 27
 }
27 28
 
28 29
 //病人
29 30
 type TmpPatient struct {
30
-	PatientID int64
31
-	Name string
32
-	DialysisNo string	//透析号
31
+	PatientID  int64
32
+	Name       string
33
+	DialysisNo string //透析号
33 34
 }
34 35
 
35 36
 //药品信息
36 37
 type PharmacyContent struct {
37
-	Name string		//名称
38
+	Name         string //名称
38 39
 	SingleDosage string //单次用量
39
-	Usage string	//用法
40
-	Frequency string //频率
41
-	Days string	//天数
42
-	Total string //总量
43
-	Doctor string	//开立医生
44
-	DataSources string	//数据来源
45
-	Remarks string	//备注
40
+	Usage        string //用法
41
+	Frequency    string //频率
42
+	Days         string //天数
43
+	Total        string //总量
44
+	Doctor       string //开立医生
45
+	DataSources  string //数据来源
46
+	Remarks      string //备注
46 47
 }
48
+
47 49
 //发药明细列表
48 50
 type DispensingList struct {
49
-	PatientID int64	//	患者id
50
-	Name string	//患者姓名
51
-	DoctorId	int64	//医生id
52
-	DoctorName string	//医生姓名
53
-	RecordTime	int64	//发药时间(转化前)
54
-	RecordDate 	string	//发药时间(转化后)
51
+	PatientID  int64  //	患者id
52
+	Name       string //患者姓名
53
+	DoctorId   int64  //医生id
54
+	DoctorName string //医生姓名
55
+	RecordTime int64  //发药时间(转化前)
56
+	RecordDate string //发药时间(转化后)
55 57
 }
56 58
 type PrescripDetailsList struct {
57 59
 	Name string //处方名
58
-	Id int64	//处方id
60
+	Id   int64  //处方id
59 61
 	Pres []*PrescripDetails
60 62
 }
63
+
61 64
 //处方详情
62 65
 type PrescripDetails struct {
63
-	Drugname string		//药品名称
66
+	Drugname     string //药品名称
64 67
 	SingleDosage string //单次用量
65
-	Usage string	//用法
66
-	Frequency string //频率
67
-	Days string	//天数
68
-	Total string //总量
69
-	UnitPrice string//单价
70
-	Remarks string	//备注
68
+	Usage        string //用法
69
+	Frequency    string //频率
70
+	Days         string //天数
71
+	Total        string //总量
72
+	UnitPrice    string //单价
73
+	Remarks      string //备注
71 74
 }
75
+
72 76
 //临时医嘱
73 77
 type StatOrder struct {
74
-	StartTime string//开始时间
75
-	Name string//医嘱名称
76
-	Specifications string //药品规格
77
-	PreQuantity string//开药数量
78
-	SingleDosage string//单次用量
79
-	RouteOfAdministration string//给药途径
80
-	ExecutionFrequency string//执行频率
78
+	StartTime             string //开始时间
79
+	Name                  string //医嘱名称
80
+	Specifications        string //药品规格
81
+	PreQuantity           string //开药数量
82
+	SingleDosage          string //单次用量
83
+	RouteOfAdministration string //给药途径
84
+	ExecutionFrequency    string //执行频率
81 85
 }
86
+
82 87
 //退库用的结构体
83 88
 type SpecialForStock struct {
84
-	BatchNumber 		string	`json:"batch_number"`
85
-	BatchNumberId		int64	`json:"batch_number_id"`
86
-	Dealer				string	`json:"dealer"`
87
-	DrugId				int64	`json:"drug_id"`
88
-	DrugName			string	`json:"drug_name"`
89
-	DrugType			int64	`json:"drug_type"`
90
-	DrugWarehouseInfo	interface{}	`json:"drug_warehouse_info"`
91
-	ExpiryDate			string	`json:"expiry_date"`
92
-	LastPrice			float64	`json:"last_price"`
93
-	Manufacturer		string	`json:"manufacturer"`
94
-	MaxUnit				string	`json:"max_unit"`
95
-	MinUnit				string	`json:"min_unit"`
96
-	Name 				string	`json:"name"`
97
-	Price 				string	`json:"price"`
98
-	ProductDate			string	`json:"product_date"`
99
-	RegisterAccount		string	`json:"register_account"`
100
-	Remark				string	`json:"remark"`
101
-	RetailPrice			string	`json:"retail_price"`
102
-	ReturnCount			string	`json:"return_count"`
103
-
89
+	BatchNumber       string      `json:"batch_number"`
90
+	BatchNumberId     int64       `json:"batch_number_id"`
91
+	Dealer            string      `json:"dealer"`
92
+	DrugId            int64       `json:"drug_id"`
93
+	DrugName          string      `json:"drug_name"`
94
+	DrugType          int64       `json:"drug_type"`
95
+	DrugWarehouseInfo interface{} `json:"drug_warehouse_info"`
96
+	ExpiryDate        string      `json:"expiry_date"`
97
+	LastPrice         float64     `json:"last_price"`
98
+	Manufacturer      string      `json:"manufacturer"`
99
+	MaxUnit           string      `json:"max_unit"`
100
+	MinUnit           string      `json:"min_unit"`
101
+	Name              string      `json:"name"`
102
+	Price             string      `json:"price"`
103
+	ProductDate       string      `json:"product_date"`
104
+	RegisterAccount   string      `json:"register_account"`
105
+	Remark            string      `json:"remark"`
106
+	RetailPrice       string      `json:"retail_price"`
107
+	ReturnCount       string      `json:"return_count"`
104 108
 }
109
+
105 110
 //药品发药药品列表
106 111
 type ListOfDrugs struct {
107
-	ID int64	`json:"id"`		//药品id
108
-	Name string	`json:"name"`	//药品 名称
109
-	Specifications string	`json:"specifications"` //规格
110
-	Stock string	`json:"stock"`  //库存(当前的仓库库存)
112
+	ID             int64  `json:"id"`             //药品id
113
+	Name           string `json:"name"`           //药品 名称
114
+	Specifications string `json:"specifications"` //规格
115
+	Stock          string `json:"stock"`          //库存(当前的仓库库存)
111 116
 }
117
+
112 118
 //病人信息
113 119
 type PatientInformation struct {
114
-	Id			string  `json:"id"`//hid表示his_doctor_advice_info的id ,xid表示xt_doctor_advice的id
115
-	Name 		string  `json:"name"`//患者姓名
116
-	SingleDosage string	`json:"single_dosage"` //单次用量
117
-	Usage string		`json:"usage"`//用法
118
-	Frequency string `json:"frequency"`//频率
119
-	Days string	`json:"days"`//天数
120
-	Total string `json:"total"`//总量
121
-	DataSources string	`json:"data_sources"`//数据来源
122
-	People	string	`json:"people"`//领药人
120
+	Id           string `json:"id"`            //hid表示his_doctor_advice_info的id ,xid表示xt_doctor_advice的id
121
+	PatientId    int64  `json:"patient_id"`    //患者id
122
+	Name         string `json:"name"`          //患者姓名
123
+	SingleDosage string `json:"single_dosage"` //单次用量
124
+	Usage        string `json:"usage"`         //用法
125
+	Frequency    string `json:"frequency"`     //频率
126
+	Days         string `json:"days"`          //天数
127
+	Total        string `json:"total"`         //总量
128
+	DataSources  string `json:"data_sources"`  //数据来源
129
+	People       string `json:"people"`        //领药人
130
+	Quantity     int64  `json:"quantity"`      //总量拆分——数据部分
131
+	Unit         string `json:"unit"`          //总量拆分——单位部分
123 132
 }
124 133
 type HisDoctorAdviceInfoL struct {
125
-	ID                    int64                  `gorm:"column:id" json:"id" form:"id"`
126
-	UserOrgId             int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
127
-	PatientId             int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
128
-	HisPatientId          int64                  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
129
-	AdviceType            int64                  `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
130
-	AdviceDate            int64                  `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
131
-	StartTime             int64                  `gorm:"column:start_time" json:"start_time" form:"start_time"`
132
-	AdviceName            string                 `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
133
-	AdviceDesc            string                 `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
134
-	ReminderDate          int64                  `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
135
-	SingleDose            float64                `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
136
-	SingleDoseUnit        string                 `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
137
-	PrescribingNumber     float64                `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
138
-	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
139
-	DeliveryWay           string                 `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
140
-	ExecutionFrequency    string                 `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
141
-	AdviceDoctor          int64                  `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
142
-	Status                int64                  `gorm:"column:status" json:"status" form:"status"`
143
-	CreatedTime           int64                  `gorm:"column:created_time" json:"created_time" form:"created_time"`
144
-	UpdatedTime           int64                  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
145
-	AdviceAffirm          string                 `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
146
-	Remark                string                 `gorm:"column:remark" json:"remark" form:"remark"`
147
-	StopTime              int64                  `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
148
-	StopReason            string                 `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
149
-	StopDoctor            int64                  `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
150
-	StopState             int64                  `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
151
-	ParentId              int64                  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
152
-	ExecutionTime         int64                  `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
153
-	ExecutionStaff        int64                  `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
154
-	ExecutionState        int64                  `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
155
-	Checker               int64                  `gorm:"column:checker" json:"checker" form:"checker"`
156
-	RecordDate            int64                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
157
-	DialysisOrderId       int64                  `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
158
-	CheckTime             int64                  `gorm:"column:check_time" json:"check_time" form:"check_time"`
159
-	CheckState            int64                  `gorm:"column:check_state" json:"check_state" form:"check_state"`
160
-	DrugSpec              float64                `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
161
-	DrugSpecUnit          string                 `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
162
-	Groupno               int64                  `gorm:"column:groupno" json:"groupno" form:"groupno"`
163
-	RemindType            int64                  `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
164
-	FrequencyType         int64                  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
165
-	DayCount              int64                  `gorm:"column:day_count" json:"day_count" form:"day_count"`
166
-	WeekDay               string                 `gorm:"column:week_day" json:"week_day" form:"week_day"`
167
-	TemplateId            string                 `gorm:"column:template_id" json:"template_id" form:"template_id"`
168
-	Modifier              int64                  `gorm:"column:modifier" json:"modifier" form:"modifier"`
169
-	DrugId                int64                  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
170
-	Price                 float64                `gorm:"column:price" json:"price" form:"price"`
171
-	PrescriptionId        int64                  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
172
-	MedListCodg           string                 `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
173
-	FeedetlSn             string                 `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
174
-	Day                   int64                  `gorm:"column:day" json:"day" form:"day"`
175
-	Diagnosis             int64                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
176
-	Way                   int64                  `gorm:"column:way" json:"way" form:"way"`
177
-	HospApprFlag          int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
178
-	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
179
-	IsMedicine			  int64					 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
180
-	People				  int64					 `gorm:"column:people" json:"people" form:"people"`
181
-	DispensingTime		  int64					 `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
134
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
135
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
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
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
139
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
140
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
141
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
142
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
143
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
144
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
145
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
146
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
147
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
148
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
149
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
150
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
151
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
152
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
153
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
154
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
155
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
156
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
157
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
158
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
159
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
160
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
161
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
162
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
163
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
164
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
165
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
166
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
167
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
168
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
169
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
170
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
171
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
172
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
173
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
174
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
175
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
176
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
177
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
178
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
179
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
180
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
181
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
182
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
183
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
184
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
185
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
186
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
187
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
188
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
189
+	People                int64   `gorm:"column:people" json:"people" form:"people"`
190
+	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
182 191
 }
183 192
 
184 193
 func (HisDoctorAdviceInfoL) TableName() string {
@@ -231,24 +240,304 @@ type XtDoctorAdviceL struct {
231 240
 	UserName              string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
232 241
 	CheckerName           string  `gorm:"column:user_name" json:"name" form:"name"`
233 242
 	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
234
-	IsMedicine			  int64	  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
235
-	People				  int64	  `gorm:"column:people" json:"people" form:"people"`
236
-	DispensingTime		  int64	  `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
243
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
244
+	People                int64   `gorm:"column:people" json:"people" form:"people"`
245
+	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
237 246
 }
238 247
 
239 248
 func (XtDoctorAdviceL) TableName() string {
240 249
 	return "sgj_xt.xt_doctor_advice"
241 250
 }
251
+
242 252
 type TmpTTT struct {
243 253
 	PatientID int64
244 254
 }
245 255
 type TmpLLL struct {
246
-	DrugId    int64
256
+	DrugId int64
247 257
 }
248 258
 type TmpID struct {
249
-	Id    int64
259
+	Id             int64
250 260
 	DispensingTime int64
251 261
 }
252
-type TmpAdviceDoctor  struct {
253
-	AdviceDoctor    int64
262
+type TmpAdviceDoctor struct {
263
+	AdviceDoctor int64
264
+}
265
+
266
+//替换药品名称
267
+type ReplacementDrugs struct {
268
+	Id   int64  `json:"id"`
269
+	Name string `json:"name"`
270
+}
271
+
272
+//病人
273
+type DialysisPatient struct {
274
+	ID   int64  `json:"id"`
275
+	Name string `json:"name"`
276
+}
277
+
278
+//项目下拉列表
279
+type DropDownList struct {
280
+	Id   string `json:"id"`
281
+	Name string `json:"name"`
282
+}
283
+type XtHisProjectL struct {
284
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
285
+	ProjectName                 string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
286
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
287
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
288
+	Price                       float64 `gorm:"column:price" json:"price" form:"price"`
289
+	Unit                        string  `gorm:"column:unit" json:"unit" form:"unit"`
290
+	CostClassify                int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
291
+	ExecutiveSection            int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
292
+	MedicalCoverage             int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
293
+	StatisticalClassification   int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"` //统计分类(组
294
+	DiseaseDirectory            int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
295
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
296
+	MedicalCode                 string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
297
+	TubeColor                   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
298
+	MedicalStatus               int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
299
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
300
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
301
+	DefaultNumber               string  `gorm:"column:default_number" json:"prescribing_number" form:"default_number"`
302
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
303
+	IsCharge                    int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
304
+	IsEstimate                  int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
305
+	IsWorkload                  int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
306
+	Sort                        string  `gorm:"column:sort" json:"sort" form:"sort"`
307
+	DoctorAdvice                int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
308
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
309
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
310
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
311
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
312
+	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
313
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
314
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
315
+	NumberDays                  string  `gorm:"column:number_days" json:"day" form:"number_days"`
316
+	Total                       string  `gorm:"column:total" json:"total" form:"total"`
317
+	Category                    int64   `gorm:"column:category" json:"category" form:"category"`
318
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
319
+	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
320
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
321
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
322
+	Translate                   string  `json:"translate"` //翻译——统计分类(组
323
+}
324
+
325
+func (XtHisProjectL) TableName() string {
326
+	return "sgj_xt.xt_his_project"
327
+}
328
+
329
+type GoodInfoL struct {
330
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
331
+	GoodCode               string  `gorm:"column:good_code" json:"good_code" form:"good_code"`
332
+	SpecificationName      string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
333
+	GoodTypeId             int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
334
+	GoodUnit               int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
335
+	BuyPrice               float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
336
+	SellPrice              float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
337
+	Remark                 string  `gorm:"column:remark" json:"remark" form:"remark"`
338
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
339
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
340
+	Manufacturer           int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
341
+	Dealer                 int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
342
+	ExpiryDateWarnDayCount int64   `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
343
+	StockWarnCount         int64   `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
344
+	IsReuse                int64   `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
345
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
346
+	FilmArea               string  `gorm:"column:film_area" json:"film_area" form:"film_area"`
347
+	IsUse                  int64   `gorm:"column:is_use" json:"is_use" form:"is_use"`
348
+	FilmMaterialQuality    string  `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
349
+	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
350
+	Modifier               int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
351
+	Creater                int64   `gorm:"column:creater" json:"creater" form:"creater"`
352
+	GoodName               string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
353
+	Pinyin                 string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
354
+	Wubi                   string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
355
+	GoodKind               int64   `gorm:"column:good_kind" json:"good_kind" form:"good_kind"` //组
356
+	MedicalInsuranceLevel  int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
357
+	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
358
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
359
+	ProvincesCode          string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
360
+
361
+	IsSpecialDiseases           int64                `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
362
+	IsRecord                    int64                `gorm:"column:is_record" json:"is_record" form:"is_record"`
363
+	StatisticsCategory          int64                `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
364
+	GoodStatus                  string               `gorm:"column:good_status" json:"good_status" form:"good_status"`
365
+	DefaultCount                int64                `gorm:"column:default_count" json:"default_count" form:"default_count"`
366
+	Sign                        int64                `gorm:"column:sign" json:"sign" form:"sign"`
367
+	IsDefault                   int64                `gorm:"column:is_default" json:"is_default" form:"is_default"`
368
+	IsChargeUse                 int64                `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
369
+	IsChargePredict             int64                `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
370
+	IsStatisticsWork            int64                `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
371
+	Sort                        int64                `gorm:"column:sort" json:"sort" form:"sort"`
372
+	IsDoctorUse                 int64                `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
373
+	Agent                       string               `gorm:"column:agent" json:"agent" form:"agent"`
374
+	GoodNumber                  string               `gorm:"column:good_number" json:"good_number" form:"good_number"`
375
+	GoodsType                   GoodsType            `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" json:"type"`
376
+	CommdityCode                string               `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
377
+	SocialSecurityDirectoryCode string               `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
378
+	ProductionType              string               `gorm:"column:production_type" json:"production_type" form:"production_type"`
379
+	SpecialMedical              string               `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
380
+	IsMark                      int64                `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
381
+	MinNumber                   int64                `gorm:"column:min_number" json:"min_number" form:"min_number"`
382
+	PackingUnit                 string               `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
383
+	PackingPrice                float64              `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
384
+	DefaultCountUnit            string               `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
385
+	MinUnit                     string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
386
+	Total                       float64              `gorm:"column:total" json:"total" form:"total"`
387
+	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
388
+	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
389
+	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
390
+	GoodSotckInfo               []*GoodSotckInfo     `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_stock_in"`
391
+	IsUser                      int64                `gorm:"column:is_user" json:"is_user" form:"is_user"`
392
+	Number                      string               `gorm:"column:number" json:"number" form:"number"`
393
+	IsWarehouse                 int64                `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
394
+	SumCount                    int64                `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
395
+	BatchRetaiPrice             float64              `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
396
+	SumInCount                  int64                `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
397
+	WarehousingInfo             []*WarehousingInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
398
+	Translate                   string               `json:"translate"` //翻译——统计分类(组
399
+}
400
+
401
+func (GoodInfoL) TableName() string {
402
+	return "sgj_xt.xt_good_information"
403
+}
404
+
405
+type BaseDrugLibL struct {
406
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
407
+	DrugName                    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
408
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
409
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
410
+	DrugAlias                   string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
411
+	DrugAliasPinyin             string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
412
+	DrugAliasWubi               string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
413
+	DrugCategory                int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
414
+	DrugSpec                    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
415
+	DrugType                    int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
416
+	DrugStockLimit              string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
417
+	DrugOriginPlace             string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
418
+	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
419
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
420
+	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
421
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
422
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
423
+	Dose                        string  `gorm:"column:dose" json:"dose" form:"dose"`
424
+	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
425
+	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
426
+	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
427
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
428
+	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
429
+	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
430
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
431
+	DrugClassify                string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
432
+	DrugDose                    float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
433
+	DrugDoseUnit                int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
434
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
435
+	ProvincesCode               string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
436
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
437
+	PharmacologyCategory        int64   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
438
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
439
+	Code                        string  `gorm:"column:code" json:"code" form:"code"`
440
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
441
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
442
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
443
+	DrugStatus                  string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
444
+	LimitRemark                 string  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
445
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
446
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
447
+	SingleDose                  float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
448
+	SingleDoseUnit              string  `json:"single_dose_unit"` //danwei
449
+	PrescribingNumber           float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
450
+	Label                       int64   `gorm:"column:label" json:"label" form:"label"`
451
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
452
+	IsUseDoctorAdvice           int64   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
453
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
454
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
455
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
456
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
457
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
458
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
459
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
460
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
461
+	DrugCode                    string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
462
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
463
+	PrescriptionMark            int64   `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
464
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
465
+	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
466
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
467
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
468
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
469
+	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
470
+	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
471
+	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
472
+	DrugDay               string                 `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
473
+	Total                 float64                `gorm:"column:total" json:"total" form:"total"`
474
+	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
475
+	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
476
+	IsUse                 int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
477
+	BatchRetaiPrice       float64                `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
478
+	SumCount              int64                  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
479
+	SumInCount            int64                  `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
480
+	IsPharmacy            int64                  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
481
+	List1                 interface{}            `json:"list_1"`
482
+	List2                 interface{}            `json:"list_2"`
483
+}
484
+
485
+func (BaseDrugLibL) TableName() string {
486
+	return "xt_base_drug"
487
+}
488
+
489
+//组
490
+type HisPrescriptionInfoTemplateL struct {
491
+	ID                             int64                              `gorm:"column:id" json:"id" form:"id"`
492
+	UserOrgId                      int64                              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
493
+	RecordDate                     int64                              `gorm:"column:record_date" json:"record_date" form:"record_date"`
494
+	PatientId                      int64                              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
495
+	Status                         int64                              `gorm:"column:status" json:"status" form:"status"`
496
+	Ctime                          int64                              `gorm:"column:ctime" json:"ctime" form:"ctime"`
497
+	Mtime                          int64                              `gorm:"column:mtime" json:"mtime" form:"mtime"`
498
+	Type                           int64                              `gorm:"column:type" json:"type" form:"type"`
499
+	Creator                        int64                              `gorm:"column:creator" json:"creator" form:"creator"`
500
+	Modifier                       int64                              `gorm:"column:modifier" json:"modifier" form:"modifier"`
501
+	PType                          int64                              `gorm:"column:p_type" json:"p_type" form:"p_type"`
502
+	PTemplateId                    int64                              `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
503
+	HisPrescriptionAdviceTemplate  []*HisPrescriptionAdviceTemplate   `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
504
+	HisPrescriptionProjectTemplate []*HisPrescriptionProjectTemplateL `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
505
+	MedType                        string                             `gorm:"column:med_type" json:"med_type" form:"med_type"`
506
+}
507
+
508
+func (HisPrescriptionInfoTemplateL) TableName() string {
509
+	return "his_prescription_info_template"
510
+}
511
+
512
+type HisPrescriptionProjectTemplateL struct {
513
+	ID                 int64         `gorm:"column:id" json:"id" form:"id"`
514
+	ProjectId          int64         `gorm:"column:project_id" json:"project_id" form:"project_id"`
515
+	Price              float64       `gorm:"column:price" json:"price" form:"price"`
516
+	UserOrgId          int64         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
517
+	Status             int64         `gorm:"column:status" json:"status" form:"status"`
518
+	Ctime              int64         `gorm:"column:ctime" json:"ctime" form:"ctime"`
519
+	Mtime              int64         `gorm:"column:mtime" json:"mtime" form:"mtime"`
520
+	PatientId          int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
521
+	HisPatientId       int64         `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
522
+	RecordDate         int64         `gorm:"column:record_date" json:"record_date" form:"record_date"`
523
+	Count              string        `gorm:"column:count" json:"count" form:"count"`
524
+	FeedetlSn          string        `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
525
+	MedListCodg        string        `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
526
+	SingleDose         string        `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
527
+	DeliveryWay        string        `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
528
+	ExecutionFrequency string        `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
529
+	Day                string        `gorm:"column:day" json:"day" form:"day"`
530
+	Remark             string        `gorm:"column:remark" json:"remark" form:"remark"`
531
+	Unit               string        `gorm:"column:unit" json:"unit" form:"unit"`
532
+	Type               int64         `gorm:"column:type" json:"type" form:"type"`
533
+	PrescriptionId     int64         `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
534
+	XtHisProject       XtHisProjectL `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
535
+	GoodInfo           GoodInfoL     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
536
+	FrequencyType      int64         `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
537
+	DayCount           int64         `gorm:"column:day_count" json:"day_count" form:"day_count"`
538
+	WeekDay            string        `gorm:"column:week_day" json:"week_day" form:"week_day"`
539
+}
540
+
541
+func (HisPrescriptionProjectTemplateL) TableName() string {
542
+	return "his_prescription_project_template"
254 543
 }

+ 1 - 1
service/auto_create_week_schedules_service.go Visa fil

@@ -142,7 +142,7 @@ func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.
142 142
 
143 143
 	now := time.Now()
144 144
 	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&week)
145
-	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", orgID, monday.Unix(), sunday.Unix()).Updates(map[string]interface{}{"status": 0, "mtime": now.Unix()}).Error
145
+	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", orgID, monday.Unix(), sunday.Unix()).Updates(map[string]interface{}{"status": 0, "updated_time": now.Unix()}).Error
146 146
 	//fmt.Println("disableErr323232332323232233222332232332",disableErr)
147 147
 	if disableErr != nil {
148 148
 		return disableErr

+ 2 - 2
service/data.go Visa fil

@@ -317,8 +317,8 @@ func BatchInspectionConfiguration(orgid int64) (err error) {
317 317
 	return
318 318
 }
319 319
 
320
-func ShowFiledConfig(org_id int64, isShow int, id int64) (err error) {
321
-	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"create_time": time.Now().Unix(), "update_time": time.Now().Unix(), "is_show": isShow}).Error
320
+func ShowFiledConfig(org_id int64, isShow int, is_write int, id int64) (err error) {
321
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"create_time": time.Now().Unix(), "update_time": time.Now().Unix(), "is_show": isShow, "is_write": is_write}).Error
322 322
 	return
323 323
 }
324 324
 

+ 1 - 1
service/dialysis_service.go Visa fil

@@ -131,7 +131,7 @@ func GetTotalDialysisCout(orgid int64, patientid int64) (order []*models.Dialysi
131 131
 //临时医嘱
132 132
 func FindDoctorAdviceOrderById(orgID int64, patientsId int64, recordDate int64) (patient []*models.DoctorAdvice, err error) {
133 133
 	err = readDb.Model(&models.DoctorAdvice{}).
134
-		Where("patient_id = ? and user_org_id=? and status=1 and record_date = ? and advice_type = 2", patientsId, orgID, recordDate).
134
+		Where("patient_id = ? and user_org_id=? and status=1 and advice_date = ? and advice_type = 2", patientsId, orgID, recordDate).
135 135
 		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").Order("start_time asc, groupno desc, advice_order desc, id asc").
136 136
 		Find(&patient).Error
137 137
 	return

+ 822 - 0
service/his_config_service.go Visa fil

@@ -1,7 +1,15 @@
1 1
 package service
2 2
 
3 3
 import (
4
+	"XT_New/enums"
4 5
 	"XT_New/models"
6
+	"XT_New/utils"
7
+	"fmt"
8
+	"github.com/astaxie/beego/config"
9
+	"golang.org/x/sync/errgroup"
10
+
11
+	"reflect"
12
+	"strconv"
5 13
 	"time"
6 14
 )
7 15
 
@@ -56,3 +64,817 @@ func DelelteHisPrescriptionProjectTemplate(id int64, user_org_id int64) (err err
56 64
 
57 65
 	return
58 66
 }
67
+
68
+//封装保存接口
69
+func FenCreatePrescriptionTemplate(id, mode_id, types, patient_id int64, name string, adminInfo *AdminUserInfo, dataBody map[string]interface{}) (err error) {
70
+	tmp_bool_id := IsDialysisMode(adminInfo.CurrentOrgId, patient_id, mode_id)
71
+
72
+	var src_template models.HisPrescriptionTemplate
73
+	if !tmp_bool_id {
74
+		template := models.HisPrescriptionTemplate{
75
+			UserOrgId: adminInfo.CurrentOrgId,
76
+			PatientId: patient_id,
77
+			Type:      types,
78
+			Status:    1,
79
+			Ctime:     time.Now().Unix(),
80
+			Mtime:     time.Now().Unix(),
81
+			Name:      name,
82
+			Mode:      mode_id,
83
+		}
84
+		src_template = template
85
+		CreateHisPrescriptionTemplate(&src_template)
86
+	} else {
87
+		//查询出该模板的id
88
+		err = XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and patient_id = ? and status = 1 and mode = ?", adminInfo.CurrentOrgId, patient_id, mode_id).Find(&src_template).Error
89
+		if err != nil {
90
+			return
91
+		}
92
+		src_template.Name = name
93
+		src_template.Mode = mode_id
94
+		SaveHisPrescriptionTemplate(&src_template)
95
+	}
96
+
97
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
98
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
99
+		if len(prescriptions) > 0 {
100
+			for _, item := range prescriptions {
101
+				items := item.(map[string]interface{})
102
+
103
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
104
+					utils.ErrorLog("id")
105
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106
+					err = fmt.Errorf("参数错误")
107
+					return
108
+				}
109
+
110
+				id := int64(items["id"].(float64))
111
+
112
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
113
+					utils.ErrorLog("type")
114
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
115
+					err = fmt.Errorf("参数错误")
116
+					return
117
+				}
118
+				types := int64(items["type"].(float64))
119
+
120
+				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
121
+					utils.ErrorLog("med_type")
122
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
123
+					err = fmt.Errorf("参数错误")
124
+					return
125
+				}
126
+				med_type := strconv.Itoa(int(items["med_type"].(float64)))
127
+
128
+				ctime := time.Now().Unix()
129
+				prescription := &models.HisPrescriptionInfoTemplate{
130
+					ID:          id,
131
+					PatientId:   patient_id,
132
+					UserOrgId:   adminInfo.CurrentOrgId,
133
+					Ctime:       ctime,
134
+					Mtime:       ctime,
135
+					Type:        types,
136
+					Modifier:    adminInfo.AdminUser.Id,
137
+					Creator:     adminInfo.AdminUser.Id,
138
+					Status:      1,
139
+					PTemplateId: src_template.ID,
140
+					MedType:     med_type,
141
+				}
142
+				CreateHisPrescriptionInfoTemplate(prescription)
143
+
144
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
145
+					advices := items["advices"].([]interface{})
146
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
147
+					groupNo := int64(0)
148
+					ctime := time.Now().Unix()
149
+					mtime := ctime
150
+					if len(advices) > 0 {
151
+						for _, advice := range advices {
152
+							var s models.HisPrescriptionAdviceTemplate
153
+							s.PrescriptionId = prescription.ID
154
+							s.AdviceType = 2
155
+							s.StopState = 2
156
+							s.ExecutionState = 2
157
+							s.Status = 1
158
+							s.UserOrgId = adminInfo.CurrentOrgId
159
+							s.Groupno = groupNo
160
+							s.CreatedTime = ctime
161
+							s.UpdatedTime = mtime
162
+							s.PatientId = patient_id
163
+							errcode := FensetAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
164
+							if errcode > 0 {
165
+								//c.ServeFailJSONWithSGJErrorCode(errcode)
166
+								err = fmt.Errorf("参数错误")
167
+								return
168
+							}
169
+							CreateHisPrescriptionAdviceTemplate(&s)
170
+						}
171
+					}
172
+				}
173
+				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
174
+					projects := items["project"].([]interface{})
175
+					if len(projects) > 0 {
176
+						for _, project := range projects {
177
+							var p models.HisPrescriptionProjectTemplate
178
+							p.PrescriptionId = prescription.ID
179
+							p.Ctime = time.Now().Unix()
180
+							p.Mtime = time.Now().Unix()
181
+							p.PatientId = patient_id
182
+							p.UserOrgId = adminInfo.CurrentOrgId
183
+							p.Status = 1
184
+							errcode := FensetProjectTemplateWithJSON(&p, project.(map[string]interface{}))
185
+							if errcode > 0 {
186
+								//c.ServeFailJSONWithSGJErrorCode(errcode)
187
+								err = fmt.Errorf("参数错误")
188
+								return
189
+							}
190
+							CreateHisPrescriptionProjectTemplate(&p)
191
+
192
+						}
193
+					}
194
+				}
195
+			}
196
+			return nil
197
+		}
198
+	}
199
+	return
200
+}
201
+
202
+//复制一个setProjectTemplateWithJSON接口
203
+func FensetProjectTemplateWithJSON(project *models.HisPrescriptionProjectTemplate, json map[string]interface{}) int {
204
+	if json["id"] != nil {
205
+		id := json["id"].(string)
206
+		if id != "" {
207
+			tmpPid := id[1:]
208
+			project_id, _ := strconv.ParseInt(tmpPid, 10, 64)
209
+			if id[0] == 112 {
210
+				project.Type = 2
211
+			}
212
+			if id[0] == 105 {
213
+				project.Type = 3
214
+			}
215
+			project.ProjectId = project_id
216
+		} else {
217
+			project.ProjectId = int64(0)
218
+		}
219
+
220
+	}
221
+	if json["frequency_type"] != nil && reflect.TypeOf(json["frequency_type"]).String() == "string" {
222
+		tmp_drugid := json["frequency_type"].(string)
223
+		frequency_type, _ := strconv.ParseInt(tmp_drugid, 10, 64)
224
+		project.FrequencyType = frequency_type
225
+	}
226
+	if json["frequency_type"] != nil && reflect.TypeOf(json["frequency_type"]).String() == "float64" {
227
+		frequency_type := int64(json["frequency_type"].(float64))
228
+		project.FrequencyType = frequency_type
229
+	}
230
+
231
+	if json["day_count"] != nil && reflect.TypeOf(json["day_count"]).String() == "string" {
232
+		tmp_drugid := json["day_count"].(string)
233
+		day_count, _ := strconv.ParseInt(tmp_drugid, 10, 64)
234
+		project.DayCount = day_count
235
+	}
236
+	if json["day_count"] != nil && reflect.TypeOf(json["day_count"]).String() == "float64" {
237
+		day_count := int64(json["day_count"].(float64))
238
+		project.DayCount = day_count
239
+	}
240
+
241
+	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
242
+		week_day, _ := json["week_day"].(string)
243
+		project.WeekDay = week_day
244
+	}
245
+	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "float64" {
246
+		week_day := config.ToString(json["week_day"].(float64))
247
+		project.WeekDay = week_day
248
+	}
249
+
250
+	//if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
251
+	//	types := int64(json["type"].(float64))
252
+	//	project.Type = types
253
+	//}
254
+	//if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
255
+	//	project_id := int64(json["project_id"].(float64))
256
+	//	project.ProjectId = project_id
257
+	//}
258
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "string" {
259
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
260
+		project.Price = price
261
+	}
262
+
263
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "float64" {
264
+		price := json["price"].(float64)
265
+		project.Price = price
266
+	}
267
+
268
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
269
+		total, _ := json["prescribing_number"].(string)
270
+		//totals, _ := strconv.ParseInt(total, 10, 64)
271
+		project.Count = total
272
+	}
273
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "float64" {
274
+		total := config.ToString(json["prescribing_number"].(float64))
275
+		//totals, _ := strconv.ParseInt(total, 10, 64)
276
+		project.Count = total
277
+	}
278
+
279
+	//if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
280
+	//	medical_code, _ := json["medical_code"].(string)
281
+	//	project.MedListCodg = medical_code
282
+	//}
283
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
284
+		single_dose, _ := json["single_dose"].(string)
285
+		project.SingleDose = single_dose
286
+	}
287
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "float64" {
288
+		single_dose := config.ToString(json["single_dose"].(float64))
289
+		project.SingleDose = single_dose
290
+	}
291
+
292
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
293
+		delivery_way, _ := json["delivery_way"].(string)
294
+		project.DeliveryWay = delivery_way
295
+	}
296
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
297
+		execution_frequency, _ := json["execution_frequency"].(string)
298
+		project.ExecutionFrequency = execution_frequency
299
+	}
300
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
301
+		remark, _ := json["remark"].(string)
302
+		project.Remark = remark
303
+	}
304
+	if json["day"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
305
+		day, _ := json["number_days"].(string)
306
+		project.Day = day
307
+	}
308
+	if json["day"] != nil && reflect.TypeOf(json["remark"]).String() == "float64" {
309
+		day := config.ToString(json["number_days"].(float64))
310
+		project.Day = day
311
+	}
312
+
313
+	if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
314
+		unit, _ := json["unit"].(string)
315
+		project.Unit = unit
316
+	}
317
+	return 0
318
+}
319
+
320
+//复制一个setAdviceTemplateWithJSON接口
321
+func FensetAdviceTemplateWithJSON(advice *models.HisPrescriptionAdviceTemplate, json map[string]interface{}) int {
322
+	//if json["advice_id"] != nil || reflect.TypeOf(json["advice_id"]).String() == "float64" {
323
+	//	advice_id := int64(json["advice_id"].(float64))
324
+	//	advice.ID = advice_id
325
+	//}
326
+
327
+	if json["drug_name"] == nil {
328
+		utils.ErrorLog("drug_name")
329
+		return enums.ErrorCodeParamWrong
330
+	}
331
+	var tmpdrugid int64
332
+	if json["drug_name"] != nil && reflect.TypeOf(json["drug_name"]).String() == "string" {
333
+		tmpdrugid, _ = strconv.ParseInt(json["drug_name"].(string), 10, 64)
334
+	}
335
+	if json["drug_name"] != nil && reflect.TypeOf(json["drug_name"]).String() == "float64" {
336
+		tmpdrugid = int64(json["drug_name"].(float64))
337
+	}
338
+
339
+	advice.AdviceName = FindDrugsName(tmpdrugid)
340
+	//adviceDesc, _ := json["advice_desc"].(string)
341
+	//advice.AdviceDesc = adviceDesc
342
+	//if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
343
+	//	drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
344
+	//	advice.DrugSpec = drugSpec
345
+	//}
346
+
347
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
348
+		remark, _ := json["remark"].(string)
349
+		advice.Remark = remark
350
+	}
351
+
352
+	if json["id"] == nil {
353
+		advice.DrugId = 0
354
+	} else {
355
+		if json["id"] != nil && reflect.TypeOf(json["id"]).String() == "string" {
356
+			tmp_drugid := json["id"].(string)
357
+			drug_id, _ := strconv.ParseInt(tmp_drugid, 10, 64)
358
+			advice.DrugId = drug_id
359
+		}
360
+		if json["id"] != nil && reflect.TypeOf(json["id"]).String() == "float64" {
361
+			drug_id := int64(json["id"].(float64))
362
+			advice.DrugId = drug_id
363
+		}
364
+	}
365
+
366
+	//if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
367
+	//	drugSpecUnit, _ := json["min_unit"].(string)
368
+	//	advice.DrugSpecUnit = drugSpecUnit
369
+	//}
370
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
371
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
372
+		advice.SingleDose = singleDose
373
+	}
374
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "float64" {
375
+		singleDose := json["single_dose"].(float64)
376
+		advice.SingleDose = singleDose
377
+	}
378
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
379
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
380
+		advice.SingleDoseUnit = singleDoseUnit
381
+	}
382
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
383
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
384
+		advice.PrescribingNumber = prescribingNumber
385
+	}
386
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "float64" {
387
+		prescribingNumber := json["prescribing_number"].(float64)
388
+		advice.PrescribingNumber = prescribingNumber
389
+	}
390
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
391
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
392
+		advice.PrescribingNumberUnit = prescribingNumberUnit
393
+	}
394
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
395
+		deliveryWay, _ := json["delivery_way"].(string)
396
+		advice.DeliveryWay = deliveryWay
397
+	}
398
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
399
+		executionFrequency, _ := json["execution_frequency"].(string)
400
+		advice.ExecutionFrequency = executionFrequency
401
+	}
402
+	fmt.Println("44444444444")
403
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "string" {
404
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
405
+		advice.Price = price
406
+	}
407
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "float64" {
408
+		price := json["price"].(float64)
409
+		advice.Price = price
410
+	}
411
+	//if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
412
+	//	med_list_codg, _ := json["medical_insurance_number"].(string)
413
+	//	advice.MedListCodg = med_list_codg
414
+	//}
415
+	//fmt.Println("333333333")
416
+	if json["day"] != nil && reflect.TypeOf(json["day"]).String() == "string" {
417
+		day, _ := strconv.ParseInt(json["day"].(string), 10, 64)
418
+		advice.Day = day
419
+	}
420
+	if json["day"] != nil && reflect.TypeOf(json["day"]).String() == "float64" {
421
+		day := int64(json["day"].(float64))
422
+		advice.Day = day
423
+	}
424
+	//if json["groupno"] != nil || reflect.TypeOf(json["groupno"]).String() == "float64" {
425
+	//	groupno := int64(json["groupno"].(float64))
426
+	//	advice.Groupno = groupno
427
+	//}
428
+
429
+	//if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {//原型图没画不考虑
430
+	//	frequency_type := int64(json["frequency_type"].(float64))
431
+	//	advice.FrequencyType = frequency_type
432
+	//}
433
+	//
434
+	//if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
435
+	//	day_count := int64(json["day_count"].(float64))
436
+	//	advice.DayCount = day_count
437
+	//}
438
+	//
439
+	//if json["week_day"] != nil || reflect.TypeOf(json["week_day"]).String() == "string" {
440
+	//	week_day, _ := json["week_day"].(string)
441
+	//	advice.WeekDay = week_day
442
+	//}
443
+	//fmt.Println("aaaaaaaaaaaaaaaaaaaaaaaaa")
444
+	return 0
445
+}
446
+
447
+//判断该患者是否有该透析模式
448
+func IsDialysisMode(orgid, patient_id, mode int64) bool {
449
+	var total int
450
+	XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and patient_id = ? and status = 1 and mode = ?", orgid, patient_id, mode).Count(&total)
451
+	if total > 0 {
452
+		return true
453
+	} else {
454
+		return false
455
+	}
456
+}
457
+
458
+//获取该透析模式的患者列表
459
+func GetDialysisModePatient(orgid, model int64) (list []*models.DialysisPatient, err error) {
460
+	var tmp []*models.DialysisPatient
461
+	err = XTReadDB().Raw("select id,name from xt_patients,(SELECT patient_id FROM his_prescription_template WHERE user_org_id = ? and "+
462
+		"mode = ? and status = 1)a where id = a.patient_id", orgid, model).Scan(&tmp).Error
463
+	if err != nil {
464
+		return
465
+	}
466
+	return tmp, err
467
+}
468
+
469
+//如果没有名字默认透析模式
470
+func DialysisModeName(mode int64) string {
471
+	tmp := make(map[int64]string)
472
+	tmp[1] = "HD"
473
+	tmp[2] = "HDF"
474
+	tmp[3] = "HD+HP"
475
+	tmp[4] = "HP"
476
+	tmp[5] = "HF"
477
+	tmp[6] = "SCUF"
478
+	tmp[7] = "IUF"
479
+	tmp[8] = "HFHD"
480
+	tmp[9] = "HFHD+HP"
481
+	tmp[10] = "PHF"
482
+	tmp[11] = "HFR"
483
+	tmp[12] = "HDF+HP"
484
+	tmp[13] = "CRRT"
485
+	tmp[14] = "腹水回输"
486
+	//tmp[15] = "HD前置换"
487
+	//tmp[16] = "HD后置换"
488
+	//tmp[17] = "HDF前置换"
489
+	//tmp[18] = "HDF后置换"
490
+	tmp[19] = "IUF+HD"
491
+	tmp[20] = "UF"
492
+	tmp[21] = "HD+"
493
+	tmp[22] = "血浆胆红素吸附+HDF"
494
+	tmp[23] = "血浆胆红素吸附"
495
+	tmp[24] = "I-HDF"
496
+	tmp[25] = "HD高通"
497
+	tmp[26] = "CVVH"
498
+	tmp[27] = "CVVHD"
499
+	tmp[28] = "CVVHDF"
500
+	tmp[29] = "PE"
501
+	tmp[30] = "血浆胆红素吸附+HP"
502
+	tmp[31] = "HPD"
503
+	tmp[32] = "HDP"
504
+	if v, ok := tmp[mode]; ok {
505
+		return v
506
+	}
507
+	return ""
508
+}
509
+
510
+//查询出该模板的id
511
+func IdOfTheTemplate(orgid, patient_id, mode_id int64) (src_template models.HisPrescriptionTemplate, err error) {
512
+	err = XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and "+
513
+		"patient_id = ? and status = 1 and mode = ?", orgid, patient_id, mode_id).Find(&src_template).Error
514
+	return src_template, err
515
+}
516
+
517
+//根据透析模式、患者姓名、药品项目获取处方内容
518
+func GetPrescriptionContent(mode, orgid, patient_id int64) (list []*models.HisPrescriptionInfoTemplate, err error) {
519
+	var tmp models.HisPrescriptionTemplate
520
+	err = XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and patient_id = ? and mode = ? and status = 1", orgid, patient_id, mode).Find(&tmp).Error
521
+	if err != nil {
522
+		return
523
+	}
524
+	var prescriptions []*models.HisPrescriptionInfoTemplate
525
+	prescriptions, err = GetHisPrescriptionTemplate(tmp.ID, orgid)
526
+	return prescriptions, err
527
+
528
+}
529
+
530
+//获取该透析模式患者列表(批量删除时用)药品
531
+func GetDialysisDrugDelect(orgid, model, drug_id int64) (list []*models.DialysisPatient, err error) {
532
+	var tmp []*models.DialysisPatient
533
+	err = XTReadDB().Raw("select id,name from xt_patients,("+
534
+		"select distinct patient_id from his_prescription_advice_template,("+
535
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
536
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
537
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
538
+		")hisa where status = 1 and prescription_id = hisa.id and drug_id = ?)a where id = a.patient_id", orgid, model, drug_id).Scan(&tmp).Error
539
+	if err != nil {
540
+		return
541
+	}
542
+	return tmp, err
543
+}
544
+
545
+//获取该透析模式患者列表(批量删除时用)项目
546
+func GetDialysisProjectDelect2(orgid, model, drug_id int64) (list []*models.DialysisPatient, err error) {
547
+	var tmp []*models.DialysisPatient
548
+	err = XTReadDB().Raw("select id,name from xt_patients,("+
549
+		"select distinct patient_id from his_prescription_project_template,("+
550
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
551
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
552
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
553
+		")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 2)a where id = a.patient_id", orgid, model, drug_id).Scan(&tmp).Error
554
+	if err != nil {
555
+		return
556
+	}
557
+	return tmp, err
558
+}
559
+
560
+//获取该透析模式患者列表(批量删除时用)耗材
561
+func GetDialysisProjectDelect3(orgid, model, drug_id int64) (list []*models.DialysisPatient, err error) {
562
+	var tmp []*models.DialysisPatient
563
+	err = XTReadDB().Raw("select id,name from xt_patients,("+
564
+		"select distinct patient_id from his_prescription_project_template,("+
565
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
566
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
567
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
568
+		")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 3)a where id = a.patient_id", orgid, model, drug_id).Scan(&tmp).Error
569
+	if err != nil {
570
+		return
571
+	}
572
+	return tmp, err
573
+}
574
+
575
+//根据透析模式删除药品
576
+func ModeDeleteDrug(orgid, model, drug_id int64, patient_id []int64) (err error) {
577
+	//开事务
578
+	tx := XTWriteDB().Begin()
579
+	defer func() {
580
+		if err != nil {
581
+			utils.ErrorLog("事务失败,原因为: %v", err)
582
+			tx.Rollback()
583
+		} else {
584
+			tx.Commit()
585
+		}
586
+	}()
587
+	var g errgroup.Group
588
+	var tmp []*models.DialysisPatient
589
+	err = tx.Raw("select his_prescription_advice_template.id from his_prescription_advice_template,("+
590
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
591
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
592
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
593
+		")hisa where status = 1 and prescription_id = hisa.id and drug_id = ? and patient_id in (?)", orgid, model, drug_id, patient_id).Scan(&tmp).Error
594
+	for _, v := range tmp {
595
+		g.Go(func() error {
596
+			tmp := v
597
+			var err error
598
+			err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
599
+				"status":       0,
600
+				"updated_time": time.Now().Unix(),
601
+			}).Error
602
+			return err
603
+		})
604
+	}
605
+	if errs := g.Wait(); errs != nil {
606
+		err = errs
607
+		return
608
+	}
609
+	return
610
+}
611
+
612
+//根据透析模式删除项目和耗材
613
+func ModeDelectItemsAndConsumables(orgid, model int64, drug_id string, patient_id []int64) (err error) {
614
+	//开事务
615
+	tx := XTWriteDB().Begin()
616
+	defer func() {
617
+		if err != nil {
618
+			utils.ErrorLog("事务失败,原因为: %v", err)
619
+			tx.Rollback()
620
+		} else {
621
+			tx.Commit()
622
+		}
623
+	}()
624
+	front := drug_id[:1]
625
+	after := drug_id[1:]
626
+	project_id, _ := strconv.ParseInt(after, 10, 64)
627
+	var g errgroup.Group
628
+	var tmp []*models.DialysisPatient
629
+	if front == "p" {
630
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
631
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
632
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
633
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
634
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 2 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
635
+		if err != nil {
636
+			return
637
+		}
638
+	}
639
+	if front == "i" {
640
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
641
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
642
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
643
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
644
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 3 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
645
+		if err != nil {
646
+			return
647
+		}
648
+	}
649
+	for _, v := range tmp {
650
+		g.Go(func() error {
651
+			tmp := v
652
+			var err error
653
+			err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
654
+				"status": 0,
655
+				"mtime":  time.Now().Unix(),
656
+			}).Error
657
+			return err
658
+		})
659
+	}
660
+	if errs := g.Wait(); errs != nil {
661
+		err = errs
662
+		return
663
+	}
664
+	return
665
+}
666
+
667
+//替换该透析模式药品
668
+func ReplaceDrug(orgid, model, drug_id int64, patient_id []int64, advice models.HisPrescriptionAdviceTemplate) (err error) {
669
+	//开事务
670
+	tx := XTWriteDB().Begin()
671
+	defer func() {
672
+		if err != nil {
673
+			utils.ErrorLog("事务失败,原因为: %v", err)
674
+			tx.Rollback()
675
+		} else {
676
+			tx.Commit()
677
+		}
678
+	}()
679
+	var g errgroup.Group
680
+	var tmp []*models.DialysisPatient
681
+	err = tx.Raw("select his_prescription_advice_template.id from his_prescription_advice_template,("+
682
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
683
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
684
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
685
+		")hisa where status = 1 and prescription_id = hisa.id and drug_id = ? and patient_id in (?)", orgid, model, drug_id, patient_id).Scan(&tmp).Error
686
+	for _, v := range tmp {
687
+		g.Go(func() error {
688
+			tmp := v
689
+			var err error
690
+			err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
691
+				"drug_id":                 advice.DrugId,
692
+				"single_dose":             advice.SingleDose,
693
+				"single_dose_unit":        advice.SingleDoseUnit,
694
+				"delivery_way":            advice.DeliveryWay,
695
+				"execution_frequency":     advice.ExecutionFrequency,
696
+				"day":                     advice.Day,
697
+				"prescribing_number":      advice.PrescribingNumber,
698
+				"prescribing_number_unit": advice.PrescribingNumberUnit,
699
+				"price":                   advice.Price,
700
+				"remark":                  advice.Remark,
701
+				"updated_time":            time.Now().Unix(),
702
+			}).Error
703
+			return err
704
+		})
705
+	}
706
+	if errs := g.Wait(); errs != nil {
707
+		err = errs
708
+		return
709
+	}
710
+	return
711
+}
712
+
713
+//替换该透析模式耗材
714
+func ReplaceItemsAndConsumables(orgid, model int64, drug_id string, patient_id []int64, project models.HisPrescriptionProjectTemplate) (err error) {
715
+	//开事务
716
+	tx := XTWriteDB().Begin()
717
+	defer func() {
718
+		if err != nil {
719
+			utils.ErrorLog("事务失败,原因为: %v", err)
720
+			tx.Rollback()
721
+		} else {
722
+			tx.Commit()
723
+		}
724
+	}()
725
+	front := drug_id[:1]
726
+	after := drug_id[1:]
727
+	project_id, _ := strconv.ParseInt(after, 10, 64)
728
+	var g errgroup.Group
729
+	var tmp []*models.DialysisPatient
730
+	if front == "p" {
731
+		project.Type = 2
732
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
733
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
734
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
735
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
736
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 2 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
737
+		if err != nil {
738
+			return
739
+		}
740
+	}
741
+	if front == "i" {
742
+		project.Type = 3
743
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
744
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
745
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
746
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
747
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 3 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
748
+		if err != nil {
749
+			return
750
+		}
751
+	}
752
+	for _, v := range tmp {
753
+		g.Go(func() error {
754
+			tmp := v
755
+			var err error
756
+			err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
757
+				"single_dose":         project.SingleDose,
758
+				"delivery_way":        project.DeliveryWay,
759
+				"execution_frequency": project.ExecutionFrequency,
760
+				"day":                 project.Day,
761
+				"count":               project.Count,
762
+				"price":               project.Price,
763
+				"remark":              project.Remark,
764
+				"type":                project.Type,
765
+				"mtime":               time.Now().Unix(),
766
+			}).Error
767
+			return err
768
+		})
769
+	}
770
+	if errs := g.Wait(); errs != nil {
771
+		err = errs
772
+		return
773
+	}
774
+	return
775
+}
776
+
777
+//跟据id查询药品、项目、耗材、套餐
778
+func QueryFourTables(id string, orgid int64) (tmp interface{}, err error) {
779
+	if id[0] == 112 {
780
+		after := id[1:]
781
+		var project []*models.XtHisProjectL
782
+		err = XTReadDB().Model(&project).Where("id = ?", after).Find(&project).Error
783
+		if err != nil {
784
+			return nil, err
785
+		} else {
786
+			for i := 0; i < len(project); i++ {
787
+				project[i].Translate, err = TranslateZu(project[i].StatisticalClassification, orgid, "统计分类")
788
+				if err != nil {
789
+					return nil, err
790
+				}
791
+			}
792
+			return project, err
793
+		}
794
+
795
+	} else if id[0] == 105 {
796
+		after := id[1:]
797
+		var good []*models.GoodInfoL
798
+		err = XTReadDB().Model(&models.GoodInfoL{}).Where("id = ?", after).Find(&good).Error
799
+		if err != nil {
800
+			return nil, err
801
+		} else {
802
+			for i := 0; i < len(good); i++ {
803
+				good[i].Translate = "耗材"
804
+			}
805
+			return good, err
806
+		}
807
+
808
+	} else if id[0] == 104 {
809
+		after := id[1:]
810
+		var team []*models.XtHisProjectTeam
811
+		err = XTReadDB().Model(&models.XtHisProjectTeam{}).Where("id = ?", after).Find(&team).Error
812
+		if err != nil {
813
+			return nil, err
814
+		} else {
815
+			return team, err
816
+		}
817
+
818
+	} else {
819
+		var lib []*models.BaseDrugLibL
820
+		err = XTReadDB().Model(&models.BaseDrugLibL{}).Where("id = ?", id).Find(&lib).Error
821
+		if err != nil {
822
+			return nil, err
823
+		} else {
824
+			for i := 0; i < len(lib); i++ {
825
+				lib[i].SingleDoseUnit = TypeConversion02(config.ToString(lib[i].DrugDoseUnit))
826
+				if err != nil {
827
+					return nil, err
828
+				}
829
+				type m struct {
830
+					Name string `json:"name"`
831
+				}
832
+				newM := []m{
833
+					{
834
+						lib[i].DoseUnit, //计量单位
835
+					},
836
+					{
837
+						lib[i].MinUnit, //拆零单位
838
+					},
839
+				}
840
+				newN := []m{
841
+					{
842
+						lib[i].MinUnit,
843
+					},
844
+					{
845
+						lib[i].MaxUnit,
846
+					},
847
+				}
848
+				lib[i].List1 = newM
849
+				lib[i].List2 = newN
850
+			}
851
+			return lib, err
852
+		}
853
+	}
854
+}
855
+
856
+//获取机构项目中所用的组
857
+func GetDataConfig(orgid int64) (dataconfig []*models.DictDataconfig, err error) {
858
+	err = XTReadDB().Raw("select * from xt_drug_data_config where parent_id in "+
859
+		"(select id from xt_drug_data_config where name = \"统计分类\" and parent_id = 0) "+
860
+		"and status =1 and (org_id = ? or org_id = 0)", orgid).Scan(&dataconfig).Error
861
+	return
862
+}
863
+
864
+//翻译项目中的组
865
+func TranslateZu(sc, orgid int64, types string) (s string, err error) {
866
+	var dataconfig []*models.DictDataconfig
867
+	tmp := "select * from xt_drug_data_config where parent_id in (select id from xt_drug_data_config where name = \"" + types + "\" and parent_id = 0) and value = " + config.ToString(sc) + " and status = 1 and (org_id = " + config.ToString(orgid) + " or org_id = 0)"
868
+
869
+	err = XTReadDB().Raw(tmp).Scan(&dataconfig).Error
870
+	if err != nil {
871
+		return
872
+	}
873
+	if len(dataconfig) > 1 {
874
+		err = fmt.Errorf("sql数据异常:%v", tmp)
875
+	}
876
+	if len(dataconfig) == 0 {
877
+		return "", err
878
+	}
879
+	return dataconfig[0].Name, err
880
+}

+ 14 - 0
service/his_service.go Visa fil

@@ -2211,6 +2211,20 @@ func GetHisPrescriptionTemplate(template_id int64, org_id int64) (prescription [
2211 2211
 	return
2212 2212
 }
2213 2213
 
2214
+//组
2215
+func GetHisPrescriptionTemplateL(template_id int64, org_id int64) (prescription []*models.HisPrescriptionInfoTemplateL, err error) {
2216
+	err = readDb.Model(&models.HisPrescriptionInfoTemplateL{}).
2217
+		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
2218
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
2219
+		}).
2220
+		Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
2221
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisProject").Preload("GoodInfo", "status=1")
2222
+		}).
2223
+		Where("status = 1 AND p_template_id = ? ", template_id).
2224
+		Find(&prescription).Error
2225
+	return
2226
+}
2227
+
2214 2228
 func FindHisConsumablesByID(orgID int64, patient_id int64, recordDate int64, good_id int64) (consumables models.DialysisBeforePrepare, err error) {
2215 2229
 	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
2216 2230
 	return

+ 19 - 0
service/mobile_dialysis_service.go Visa fil

@@ -627,6 +627,14 @@ func MobileGetPredialysisEvaluationOne(orgID int64, patientID int64, recordDate
627 627
 	return &record, nil
628 628
 }
629 629
 
630
+func MobileGetPredialysisEvaluationTwo(orgID int64, patientID int64, recordDate int64) (models.PredialysisEvaluation, error) {
631
+
632
+	var record models.PredialysisEvaluation
633
+	err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
634
+
635
+	return record, err
636
+}
637
+
630 638
 // 透前评估
631 639
 func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
632 640
 
@@ -635,6 +643,7 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
635 643
 	defer redis.Close()
636 644
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_before_dislysis"
637 645
 	assessment_before_dislysis_str, _ := redis.Get(key).Result()
646
+	redis.Set(key, "", time.Second)
638 647
 	if len(assessment_before_dislysis_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
639 648
 		err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
640 649
 		if err != nil {
@@ -756,6 +765,7 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
756 765
 	doctor_advices_str, _ := redis.Get(key).Result()
757 766
 
758 767
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
768
+
759 769
 		err := readDb.Model(&models.DoctorAdvice{}).
760 770
 			Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
761 771
 			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,is_medicine,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
@@ -902,6 +912,7 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
902 912
 
903 913
 	// cur_date := time.Now().Format("2006-01-02")
904 914
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
915
+	redis.Set(key, "", time.Second)
905 916
 	monitor_records_str, _ := redis.Get(key).Result()
906 917
 
907 918
 	if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -2950,6 +2961,14 @@ func GetLastDialysisPrescriptionByPatientId(orgid int64, patientid int64, record
2950 2961
 	return &prescription, nil
2951 2962
 }
2952 2963
 
2964
+func GetLastDialysisPrescriptionByPatientIdTwo(orgid int64, patientid int64, recorddate int64) (models.DialysisPrescription, error) {
2965
+
2966
+	prescription := models.DialysisPrescription{}
2967
+	err := readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patientid, recorddate).Find(&prescription).Error
2968
+
2969
+	return prescription, err
2970
+}
2971
+
2953 2972
 type HisMScheduleDoctorAdviceVM struct {
2954 2973
 	ID                     int64                            `gorm:"column:id" json:"id"`
2955 2974
 	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id"`

+ 2 - 2
service/patient_service.go Visa fil

@@ -74,7 +74,7 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
74 74
 //GetAllPatientList 返回全部患者的列表
75 75
 func GetAllPatientList(orgID int64) (patients []*models.Patients, total int64, err error) {
76 76
 
77
-	db := readDb.Table("xt_patients as p").Where("p.user_org_id=? and p.status=1 and p.lapseto = 1", orgID)
77
+	db := readDb.Table("xt_patients as p").Where("p.user_org_id=? and p.status=1", orgID)
78 78
 
79 79
 	err = db.Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time").Count(&total).Find(&patients).Error
80 80
 	return
@@ -572,7 +572,7 @@ func FindPatientWithDeviceByNo(orgID int64, no string, time int64) (patient mode
572 572
 		return db.Preload("DeviceNumber", "org_id = ?", orgID).
573 573
 			Preload("DeviceZone", "org_id = ?", orgID).
574 574
 			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
575
-	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status=1 and lapseto =1", orgID, no).First(&patient).Error
575
+	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status = 1", orgID, no).First(&patient).Error
576 576
 	return
577 577
 }
578 578
 

+ 589 - 1
service/pharmacy_service.go Visa fil

@@ -8,9 +8,11 @@ import (
8 8
 	"github.com/astaxie/beego/config"
9 9
 	"github.com/astaxie/beego/context"
10 10
 	"github.com/jinzhu/gorm"
11
+	"golang.org/x/sync/errgroup"
11 12
 	"math"
12 13
 	"strconv"
13 14
 	"strings"
15
+	"sync"
14 16
 	"time"
15 17
 )
16 18
 
@@ -527,6 +529,7 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
527 529
 		pp = append(pp, &models.PatientInformation{
528 530
 			Id:           "h" + config.ToString(v.ID),
529 531
 			Name:         FindUserName(v.PatientId),
532
+			PatientId:    v.PatientId,
530 533
 			SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
531 534
 			Usage:        v.DeliveryWay,
532 535
 			Frequency:    v.ExecutionFrequency,
@@ -534,6 +537,8 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
534 537
 			Total:        config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
535 538
 			DataSources:  "his处方",
536 539
 			People:       GetUserAdminName(v.People, orgid), //领药人!!!!!!!!!!!!!!!!!!!!!!
540
+			Quantity:     int64(v.PrescribingNumber),
541
+			Unit:         v.PrescribingNumberUnit,
537 542
 		})
538 543
 	}
539 544
 
@@ -554,6 +559,8 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
554 559
 			Total:        config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
555 560
 			DataSources:  "临时医嘱",
556 561
 			People:       GetUserAdminName(v.People, orgid), //领药人
562
+			Quantity:     int64(v.PrescribingNumber),
563
+			Unit:         v.PrescribingNumberUnit,
557 564
 		})
558 565
 	}
559 566
 	return
@@ -980,7 +987,7 @@ func GetUserAdminName(id, orgID int64) string {
980 987
 	return tmp.UserName
981 988
 }
982 989
 
983
-//根据id查询是否已发药,true已发药,false未发药
990
+//根据id查询是否已发药,true已发药,false未发药gai
984 991
 func GiveTheMedicine(id int64) bool {
985 992
 	var xue models.PharmacyDoctorAdvice
986 993
 	XTReadDB().Model(&models.PharmacyDoctorAdvice{}).Where("id = ?", id).Find(&xue)
@@ -1302,3 +1309,584 @@ func ChangeHisPrescriptionid(id string) (err error) {
1302 1309
 	}
1303 1310
 	return
1304 1311
 }
1312
+
1313
+//获取药品规格
1314
+func ReplacementDrugs(orgid int64, special bool) (list []*models.ReplacementDrugs, err error) {
1315
+	var g errgroup.Group
1316
+	var lib []*models.BaseDrugLib
1317
+	var lock sync.Mutex
1318
+	if special {
1319
+		err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_status not like '%停用%' AND status = 1 and is_special_diseases = 1", orgid).Find(&lib).Error
1320
+	} else {
1321
+		err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_status not like '%停用%'  AND status = 1 ", orgid).Find(&lib).Error
1322
+	}
1323
+	if err != nil {
1324
+		return
1325
+	}
1326
+	for _, v := range lib {
1327
+		v := v
1328
+		g.Go(func() error {
1329
+			var tmp models.Manufacturer
1330
+			err := readDb.Model(&models.Manufacturer{}).Where("id = ?", v.Manufacturer).Find(&tmp).Error
1331
+			if err != nil {
1332
+				return err
1333
+			}
1334
+			lock.Lock()
1335
+			list = append(list, &models.ReplacementDrugs{
1336
+				Id:   v.ID,
1337
+				Name: v.DrugName + " " + v.Dose + v.DoseUnit + "*" + config.ToString(v.MinNumber) + v.MinUnit + "/" + v.MaxUnit + " " + tmp.ManufacturerName,
1338
+			})
1339
+			lock.Unlock()
1340
+			return err
1341
+		})
1342
+	}
1343
+	if errs := g.Wait(); errs != nil {
1344
+		err = errs
1345
+		return
1346
+	}
1347
+	return
1348
+}
1349
+
1350
+//获取药品规格,不考虑特殊病
1351
+func ReplacementDrugsT(orgid int64) (list []*models.ReplacementDrugs, err error) {
1352
+	var lib []*models.BaseDrugLib
1353
+	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1 and drug_status not like '%停用%' ", orgid).Find(&lib).Error
1354
+	if err != nil {
1355
+		return
1356
+	}
1357
+	for _, v := range lib {
1358
+		var tmp models.Manufacturer
1359
+		err = readDb.Model(&models.Manufacturer{}).Where("id = ?", v.Manufacturer).Find(&tmp).Error
1360
+		if err != nil {
1361
+			return
1362
+		}
1363
+
1364
+		list = append(list, &models.ReplacementDrugs{
1365
+			Id:   v.ID,
1366
+			Name: v.DrugName + " " + v.Dose + v.DoseUnit + "*" + config.ToString(v.MinNumber) + v.MinUnit + "/" + v.PrescribingNumberUnit + " " + tmp.ManufacturerName,
1367
+		})
1368
+	}
1369
+	return
1370
+}
1371
+
1372
+//根据药品id获取药品名字
1373
+func IdToDrugName(id int64) (name string) {
1374
+	var lib models.BaseDrugLib
1375
+	readDb.Model(&models.BaseDrugLib{}).Where("id = ?", id).Find(&lib)
1376
+	return lib.DrugName
1377
+}
1378
+
1379
+//获取项目和耗材和套餐
1380
+func ProjectConsumables3(orgid int64) (list []*models.DropDownList, err error) {
1381
+
1382
+	var project []*models.XtHisProject
1383
+	project, err = GetHisProject(orgid)
1384
+	if err != nil {
1385
+		return
1386
+	}
1387
+	for _, v := range project {
1388
+		list = append(list, &models.DropDownList{
1389
+			Id:   "p" + config.ToString(v.ID),
1390
+			Name: v.ProjectName,
1391
+		})
1392
+	}
1393
+
1394
+	var good []*models.GoodInfo
1395
+	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and status = 1", orgid).Find(&good).Error
1396
+	if err != nil {
1397
+		return
1398
+	}
1399
+	for _, v := range good {
1400
+		list = append(list, &models.DropDownList{
1401
+			Id:   "i" + config.ToString(v.ID),
1402
+			Name: v.GoodName,
1403
+		})
1404
+	}
1405
+
1406
+	var team []*models.XtHisProjectTeam
1407
+	team, err = GetAllProjectTeam(orgid)
1408
+	if err != nil {
1409
+		return
1410
+	}
1411
+	for _, v := range team {
1412
+		list = append(list, &models.DropDownList{
1413
+			Id:   "h" + config.ToString(v.ID),
1414
+			Name: v.ProjectTeam,
1415
+		})
1416
+	}
1417
+
1418
+	return
1419
+}
1420
+
1421
+//获取项目和耗材
1422
+func ProjectConsumables2(orgid int64, special bool) (list []*models.DropDownList, err error) {
1423
+
1424
+	var project []*models.XtHisProject
1425
+	if special {
1426
+		err = XTReadDB().Model(&project).Where("user_org_id = ? and medical_status != 1 and status = 1 and disease_directory = 1", orgid).Find(&project).Error
1427
+	} else {
1428
+		err = XTReadDB().Model(&project).Where("user_org_id = ? and medical_status != 1 and status = 1", orgid).Find(&project).Error
1429
+	}
1430
+	if err != nil {
1431
+		return
1432
+	}
1433
+	for _, v := range project {
1434
+		list = append(list, &models.DropDownList{
1435
+			Id:   "p" + config.ToString(v.ID),
1436
+			Name: v.ProjectName,
1437
+		})
1438
+	}
1439
+
1440
+	var good []*models.GoodInfo
1441
+	if special {
1442
+		err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and good_status not like '%停用%' and status = 1 and is_special_diseases = 1", orgid).Find(&good).Error
1443
+	} else {
1444
+		err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and good_status not like '%停用%' and status = 1", orgid).Find(&good).Error
1445
+	}
1446
+	if err != nil {
1447
+		return
1448
+	}
1449
+	for _, v := range good {
1450
+		list = append(list, &models.DropDownList{
1451
+			Id:   "i" + config.ToString(v.ID),
1452
+			Name: v.GoodName + " " + v.SpecificationName,
1453
+		})
1454
+	}
1455
+
1456
+	return
1457
+}
1458
+
1459
+//获取项目和耗材不考虑特殊病
1460
+func ProjectConsumables2T(orgid int64) (list []*models.DropDownList, err error) {
1461
+
1462
+	var project []*models.XtHisProject
1463
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1 and medical_status != 1", orgid).Find(&project).Error
1464
+	if err != nil {
1465
+		return
1466
+	}
1467
+	for _, v := range project {
1468
+		list = append(list, &models.DropDownList{
1469
+			Id:   "p" + config.ToString(v.ID),
1470
+			Name: v.ProjectName,
1471
+		})
1472
+	}
1473
+
1474
+	var good []*models.GoodInfo
1475
+	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and status = 1 and good_status != 1", orgid).Find(&good).Error
1476
+	if err != nil {
1477
+		return
1478
+	}
1479
+	for _, v := range good {
1480
+		list = append(list, &models.DropDownList{
1481
+			Id:   "i" + config.ToString(v.ID),
1482
+			Name: v.GoodName + " " + v.SpecificationName,
1483
+		})
1484
+	}
1485
+
1486
+	return
1487
+}
1488
+
1489
+//查询药品
1490
+func FindPatientDrug(orgid, patient_id, drugid, mode int64) bool {
1491
+	var total int
1492
+	XTReadDB().Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and status = 1 and "+
1493
+		"prescription_id in (select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = 1 and p_template_id in ("+
1494
+		"select id from his_prescription_template where status= 1 and user_org_id = ? and mode = ?))", orgid, patient_id, drugid, orgid, orgid, mode).Count(&total)
1495
+	if total > 0 {
1496
+		return true
1497
+	}
1498
+	return false
1499
+}
1500
+
1501
+//查询项目
1502
+func FindPatientXiang(orgid, patient_id, drugid, mode int64) bool {
1503
+	var total int
1504
+	XTReadDB().Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and status = 1 and type = 2 and "+
1505
+		"prescription_id in (select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = 2 and p_template_id in ("+
1506
+		"select id from his_prescription_template where status= 1 and user_org_id = ? and mode = ?))", orgid, patient_id, drugid, orgid, orgid, mode).Count(&total)
1507
+	if total > 0 {
1508
+		return true
1509
+	}
1510
+	return false
1511
+}
1512
+
1513
+//查询耗材
1514
+func FindPatientXiang2(orgid, patient_id, drugid, mode int64) bool {
1515
+	var total int
1516
+	XTReadDB().Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and status = 1 and type = 3 and "+
1517
+		"prescription_id in (select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = 2 and p_template_id in ("+
1518
+		"select id from his_prescription_template where status= 1 and user_org_id = ? and mode = ?))", orgid, patient_id, drugid, orgid, orgid, mode).Count(&total)
1519
+	if total > 0 {
1520
+		return true
1521
+	}
1522
+	return false
1523
+}
1524
+
1525
+//types处方类型,1.药品 2.项目,model透析模式
1526
+func GetHisInfoTempalteId(model, orgid, types int64) (tp []int64) {
1527
+	type tmpid struct {
1528
+		Id int64
1529
+	}
1530
+	var tmp []*tmpid
1531
+	XTReadDB().Raw("select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = ? and p_template_id in ("+
1532
+		"select id from his_prescription_template where status = 1 and user_org_id = ? and mode = ?)", orgid, types, orgid, model).Scan(&tmp)
1533
+	for _, v := range tmp {
1534
+		tp = append(tp, v.Id)
1535
+	}
1536
+	return
1537
+}
1538
+
1539
+//替换药品处方模板
1540
+func ReplaceDrugPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, s models.HisPrescriptionAdviceTemplate, tx *gorm.DB) (err error) {
1541
+	err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and "+
1542
+		"status = 1 and prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1543
+		"drug_id":                 s.DrugId,
1544
+		"advice_name":             s.AdviceName,
1545
+		"single_dose":             s.SingleDose,
1546
+		"single_dose_unit":        s.SingleDoseUnit,
1547
+		"delivery_way":            s.DeliveryWay,
1548
+		"execution_frequency":     s.ExecutionFrequency,
1549
+		"day":                     s.Day,
1550
+		"prescribing_number":      s.PrescribingNumber,
1551
+		"prescribing_number_unit": s.PrescribingNumberUnit,
1552
+		"price":                   s.Price,
1553
+		"remark":                  s.Remark,
1554
+		"updated_time":            time.Now().Unix(),
1555
+	}).Error
1556
+	return err
1557
+}
1558
+
1559
+//替换项目模板
1560
+func ReplaceProjectPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, s models.HisPrescriptionProjectTemplate, tx *gorm.DB) (err error) {
1561
+	err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and "+
1562
+		"status = 1 and prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1563
+		"project_id":          s.ProjectId,
1564
+		"type":                s.Type,
1565
+		"frequency_type":      s.FrequencyType,
1566
+		"day_count":           s.DayCount,
1567
+		"week_day":            s.WeekDay,
1568
+		"price":               s.Price,
1569
+		"count":               s.Count,
1570
+		"single_dose":         s.SingleDose,
1571
+		"delivery_way":        s.DeliveryWay,
1572
+		"execution_frequency": s.ExecutionFrequency,
1573
+		"remark":              s.Remark,
1574
+		"day":                 s.Day,
1575
+		"unit":                s.Unit,
1576
+		"mtime":               time.Now().Unix(),
1577
+	}).Error
1578
+	return err
1579
+}
1580
+
1581
+//删除项目模板
1582
+func DeleteProjectTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gorm.DB) (err error) {
1583
+	err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and "+
1584
+		"prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1585
+		"status": 0,
1586
+		"mtime":  time.Now().Unix(),
1587
+	}).Error
1588
+	return err
1589
+}
1590
+
1591
+//删除处方模板
1592
+func DeletePrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gorm.DB) (err error) {
1593
+	err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and "+
1594
+		"prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1595
+		"status":       0,
1596
+		"updated_time": time.Now().Unix(),
1597
+	}).Error
1598
+	return err
1599
+}
1600
+
1601
+//根据透析模式和患者id获取该患者的处方内容
1602
+func PTemplateInformation(orgid, mode_id, patient_id int64) (tmp interface{}, err error) {
1603
+	//获取处方id
1604
+	var tt []*models.HisPrescriptionTemplate
1605
+	err = XTReadDB().Raw("select id from his_prescription_template where status = 1 and user_org_id = ? and mode = ? and patient_id = ?", orgid, mode_id, patient_id).Scan(&tt).Error
1606
+
1607
+	if len(tt) > 1 {
1608
+		err = fmt.Errorf("数据有误")
1609
+		return
1610
+	}
1611
+	x := make(map[int64]string, 0) //项目
1612
+	h := make(map[int64]string, 0) //耗材
1613
+	for _, v := range tt {
1614
+		var prescriptions []*models.HisPrescriptionInfoTemplateL
1615
+		prescriptions, err = GetHisPrescriptionTemplateL(v.ID, orgid)
1616
+		if err != nil {
1617
+			return
1618
+		}
1619
+		for i := 0; i < len(prescriptions); i++ {
1620
+			for j := 0; j < len(prescriptions[i].HisPrescriptionProjectTemplate); j++ {
1621
+				if prescriptions[i].HisPrescriptionProjectTemplate[j].Type == 2 {
1622
+					//项目
1623
+					if v, ok := x[prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.StatisticalClassification]; ok {
1624
+						prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.Translate = v
1625
+					} else {
1626
+						prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.Translate, err = TranslateZu(prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.StatisticalClassification, orgid, "统计分类")
1627
+						if err != nil {
1628
+							return
1629
+						}
1630
+						x[prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.StatisticalClassification] = prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.Translate
1631
+					}
1632
+
1633
+				}
1634
+				if prescriptions[i].HisPrescriptionProjectTemplate[j].Type == 3 {
1635
+					//耗材
1636
+					if v, ok := h[prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.GoodKind]; ok {
1637
+						prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.Translate = v
1638
+					} else {
1639
+						prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.Translate = "耗材"
1640
+						h[prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.GoodKind] = prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.Translate
1641
+					}
1642
+				}
1643
+			}
1644
+		}
1645
+		tmp = prescriptions
1646
+	}
1647
+	return
1648
+}
1649
+func DeleteOne(types, id int64) (err error) {
1650
+	if types == 1 {
1651
+		//药品
1652
+		err = XTWriteDB().Model(&models.HisPrescriptionAdviceTemplate{}).Where("id = ?", id).Updates(map[string]interface{}{
1653
+			"status":       0,
1654
+			"updated_time": time.Now().Unix(),
1655
+		}).Error
1656
+		if err != nil {
1657
+			return
1658
+		}
1659
+	} else if types == 2 {
1660
+		//项目
1661
+		err = XTWriteDB().Model(&models.HisPrescriptionProjectTemplateL{}).Where("id = ?", id).Updates(map[string]interface{}{
1662
+			"status": 0,
1663
+			"mtime":  time.Now().Unix(),
1664
+		}).Error
1665
+		if err != nil {
1666
+			return
1667
+		}
1668
+
1669
+	} else {
1670
+		err = fmt.Errorf("参数错误")
1671
+		return
1672
+	}
1673
+	return
1674
+
1675
+}
1676
+
1677
+//收尾工作
1678
+func Scavenger(orgid int64) (err error) {
1679
+	//开事务
1680
+	tx := XTWriteDB().Begin()
1681
+	defer func() {
1682
+		if err != nil {
1683
+			utils.ErrorLog("事务失败,原因为: %v", err)
1684
+			tx.Rollback()
1685
+		} else {
1686
+			tx.Commit()
1687
+		}
1688
+	}()
1689
+	//查询该机构的所有模板
1690
+	var tmp1 []*models.HisPrescriptionTemplate
1691
+	var tmp2 []*models.HisPrescriptionInfoTemplate
1692
+	deltmp1 := make([]int64, 0) //清除的数据
1693
+	deltmp2 := make([]int64, 0) //清除的数据
1694
+	err = tx.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and status = 1", orgid).Find(&tmp1).Error
1695
+	if err != nil {
1696
+		return
1697
+	}
1698
+	for _, v := range tmp1 {
1699
+		var total1 int
1700
+		tx.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? and p_template_id = ? and status = 1", orgid, v.ID).Count(&total1)
1701
+		if total1 == 0 {
1702
+			deltmp1 = append(deltmp1, v.ID)
1703
+		}
1704
+	}
1705
+	err = tx.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? and status = 1", orgid).Find(&tmp2).Error
1706
+	if err != nil {
1707
+		return
1708
+	}
1709
+	for _, v := range tmp2 {
1710
+		if v.Type == 1 {
1711
+			var total2 int
1712
+			tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and prescription_id = ? and status = 1", orgid, v.ID).Count(&total2)
1713
+			if total2 == 0 {
1714
+				deltmp2 = append(deltmp2, v.ID)
1715
+			}
1716
+		}
1717
+		if v.Type == 2 {
1718
+			var total3 int
1719
+			tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and prescription_id = ? and status = 1", orgid, v.ID).Count(&total3)
1720
+			if total3 == 0 {
1721
+				deltmp2 = append(deltmp2, v.ID)
1722
+			}
1723
+		}
1724
+	}
1725
+
1726
+	//清除1
1727
+	err = tx.Model(&models.HisPrescriptionTemplate{}).Where("id in (?)", deltmp1).Updates(map[string]interface{}{
1728
+		"status": 0,
1729
+		"mtime":  time.Now().Unix(),
1730
+	}).Error
1731
+	if err != nil {
1732
+		return
1733
+	}
1734
+	//清除1
1735
+	err = tx.Model(&models.HisPrescriptionInfoTemplate{}).Where("id in (?)", deltmp2).Updates(map[string]interface{}{
1736
+		"status": 0,
1737
+		"mtime":  time.Now().Unix(),
1738
+	}).Error
1739
+	if err != nil {
1740
+		return
1741
+	}
1742
+
1743
+	return
1744
+}
1745
+
1746
+//分区和收费(患者发药
1747
+func PartitionAndLayout(stime, etime, orgid, shift, partition int64, flist []*models.TmpPatient) (tmp []*models.TmpPatient, err error) {
1748
+	//获取排班
1749
+	var sch []*models.XtScheduleTwo
1750
+	ma := make(map[int64]int64)
1751
+	s := "user_org_id = ? and status = 1 and schedule_date >= ? and schedule_date <= ?"
1752
+	if shift != 0 {
1753
+		s = s + " and schedule_type = " + config.ToString(shift)
1754
+	}
1755
+	if partition != 0 {
1756
+		s = s + " and partition_id = " + config.ToString(partition)
1757
+	}
1758
+	if shift == 0 && partition == 0 {
1759
+		return flist, nil
1760
+	}
1761
+	err = XTWriteDB().Model(&models.XtScheduleTwo{}).Where(s, orgid, stime, etime).Find(&sch).Error
1762
+	if err != nil {
1763
+		return
1764
+	}
1765
+	for _, v := range sch {
1766
+		ma[v.PatientId] = v.PatientId
1767
+	}
1768
+	for _, v := range flist {
1769
+		if _, ok := ma[v.PatientID]; ok {
1770
+			tmp = append(tmp, v)
1771
+		}
1772
+	}
1773
+	return
1774
+}
1775
+
1776
+//分区和收费(药品发药
1777
+func PartitionAndLayoutDrug(deliveryway string, stime, etime, orgid, shift, partition int64, flist []*models.PatientInformation) (tmp []*models.PatientInformation, err error) {
1778
+	//获取排班
1779
+	var sch []*models.XtScheduleTwo
1780
+	ma := make(map[int64]int64)
1781
+	s := "user_org_id = ? and status = 1 and schedule_date >= ? and schedule_date <= ?"
1782
+	if shift != 0 {
1783
+		s = s + " and schedule_type = " + config.ToString(shift)
1784
+	}
1785
+	if partition != 0 {
1786
+		s = s + " and partition_id = " + config.ToString(partition)
1787
+	}
1788
+	if shift == 0 && partition == 0 {
1789
+		for _, v := range flist {
1790
+			ma[v.PatientId] = v.PatientId
1791
+		}
1792
+		for _, v := range flist {
1793
+			if _, ok := ma[v.PatientId]; ok && (v.Usage == deliveryway || deliveryway == "全部") {
1794
+				tmp = append(tmp, v)
1795
+			}
1796
+		}
1797
+		return tmp, nil
1798
+	}
1799
+	err = XTWriteDB().Model(&models.XtScheduleTwo{}).Where(s, orgid, stime, etime).Find(&sch).Error
1800
+	if err != nil {
1801
+		return
1802
+	}
1803
+	for _, v := range sch {
1804
+		ma[v.PatientId] = v.PatientId
1805
+	}
1806
+
1807
+	for _, v := range flist {
1808
+		if _, ok := ma[v.PatientId]; ok && (v.Usage == deliveryway || deliveryway == "全部") {
1809
+			tmp = append(tmp, v)
1810
+		}
1811
+	}
1812
+	return
1813
+}
1814
+
1815
+//给药途径
1816
+func Administration(deliveryway string, orgid int64, flist []*models.ListOfDrugs) (tmp []*models.ListOfDrugs, err error) {
1817
+	//查询药品
1818
+	var pp []*models.PharmacyBaseDrug
1819
+	s := "org_id = ? and status = 1"
1820
+	if deliveryway == "全部" {
1821
+		tmp = flist
1822
+		return
1823
+	} else {
1824
+		s = s + " and delivery_way = '" + deliveryway + "'"
1825
+	}
1826
+	err = XTReadDB().Model(&models.PharmacyBaseDrug{}).Where(s, orgid).Find(&pp).Error
1827
+	if err != nil {
1828
+		return
1829
+	}
1830
+	ma := make(map[int64]int64)
1831
+	for _, v := range pp {
1832
+		ma[v.ID] = v.ID
1833
+	}
1834
+	for _, v := range flist {
1835
+		if _, ok := ma[v.ID]; ok {
1836
+			tmp = append(tmp, v)
1837
+		}
1838
+	}
1839
+	return
1840
+}
1841
+
1842
+//计算总量
1843
+func CalculateTheTotalAmount(tmp []*models.PatientInformation, drug_id int64) (total string, err error) {
1844
+	//获取药品信息
1845
+	var t models.SpBaseDrug
1846
+	err = XTReadDB().Model(&models.SpBaseDrug{}).Where("id = ?", drug_id).Find(&t).Error
1847
+	if err != nil {
1848
+		return
1849
+	}
1850
+	terr, maxunit, minunit := int64(0), int64(0), int64(0) //terr异常的单位数量,maxunit包装单位数量,minunit拆零单位数量
1851
+	minmunber := t.MinNumber                               //拆零数量
1852
+	terrUnit := ""
1853
+	for _, v := range tmp {
1854
+		switch v.Unit {
1855
+		case t.MaxUnit:
1856
+			maxunit = maxunit + v.Quantity
1857
+		case t.MinUnit:
1858
+			minunit = minunit + v.Quantity
1859
+		default:
1860
+			terr = terr + v.Quantity
1861
+			terrUnit = v.Unit
1862
+		}
1863
+	}
1864
+	if minunit >= minmunber {
1865
+		if minmunber == 0 {
1866
+			err = fmt.Errorf("拆零数量不能为零")
1867
+			return
1868
+		}
1869
+		maxunit = maxunit + minunit/minmunber
1870
+		minunit = minunit % minmunber
1871
+
1872
+	}
1873
+	if terr > 0 {
1874
+		total = total + config.ToString(terr) + terrUnit
1875
+	}
1876
+	if maxunit > 0 {
1877
+		total = total + config.ToString(maxunit) + t.MaxUnit
1878
+	}
1879
+	if minunit > 0 {
1880
+		total = total + config.ToString(minunit) + t.MinUnit
1881
+	}
1882
+
1883
+	return
1884
+}
1885
+func GetAllValidDeviceZones02(orgID int64) ([]*models.DeviceZone, error) {
1886
+	var zones []*models.DeviceZone
1887
+	err := readDb.Model(&models.DeviceZone{}).Where("org_id = ? and status = 1", orgID).Find(&zones).Error
1888
+	if err != nil {
1889
+		return nil, err
1890
+	}
1891
+	return zones, nil
1892
+}

+ 152 - 36
service/stock_service.go Visa fil

@@ -753,8 +753,13 @@ func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id in
753 753
 }
754 754
 
755 755
 func CreateDrugFlowTwo(flow *models.DrugFlow) error {
756
-
757
-	err := XTWriteDB().Create(&flow).Error
756
+	tx := XTWriteDB().Begin()
757
+	err := tx.Create(&flow).Error
758
+	if err != nil {
759
+		tx.Rollback()
760
+		return err
761
+	}
762
+	tx.Commit()
758 763
 	return err
759 764
 }
760 765
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
@@ -4896,8 +4901,13 @@ func CreateStockFlow(warehousingInfo []*models.VmStockFlow) (err error) {
4896 4901
 }
4897 4902
 
4898 4903
 func CreateStockFlowOne(flow models.VmStockFlow) error {
4899
-
4900
-	err := XTWriteDB().Create(&flow).Error
4904
+	tx := XTWriteDB().Begin()
4905
+	err := tx.Create(&flow).Error
4906
+	if err != nil {
4907
+		tx.Rollback()
4908
+		return err
4909
+	}
4910
+	tx.Commit()
4901 4911
 	return err
4902 4912
 }
4903 4913
 
@@ -6564,8 +6574,13 @@ func ModifyGoodReduceInformationTwentyOne(good_id int64, waresing_count int64, s
6564 6574
 }
6565 6575
 
6566 6576
 func UpdateMedicalSumCount(drug_id int64, sum_count int64, sum_in_count int64, orgid int64) error {
6567
-
6568
-	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
6577
+	tx := XTWriteDB().Begin()
6578
+	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
6579
+	if err != nil {
6580
+		tx.Rollback()
6581
+		return err
6582
+	}
6583
+	tx.Commit()
6569 6584
 	return err
6570 6585
 }
6571 6586
 
@@ -7080,8 +7095,13 @@ func UpdateWarehouseDetail(info *models.WarehousingInfo, id int64) error {
7080 7095
 }
7081 7096
 
7082 7097
 func UpdateCheckWarehouseInfo(id int64) error {
7083
-
7084
-	err := XTWriteDB().Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7098
+	tx := XTWriteDB().Begin()
7099
+	err := tx.Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7100
+	if err != nil {
7101
+		tx.Rollback()
7102
+		return err
7103
+	}
7104
+	tx.Commit()
7085 7105
 	return err
7086 7106
 }
7087 7107
 
@@ -7092,29 +7112,58 @@ func GetWarehouseInfoList(id int64, orgid int64) (info []*models.WarehousingInfo
7092 7112
 }
7093 7113
 
7094 7114
 func UpdateWarehouseInfoByIdList(count int64, id int64) error {
7095
-
7096
-	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7097
-	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7115
+	tx := XTWriteDB().Begin()
7116
+	err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7117
+	if err != nil {
7118
+		tx.Rollback()
7119
+		return err
7120
+	}
7121
+	err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7122
+	if err != nil {
7123
+		tx.Rollback()
7124
+		return err
7125
+	}
7126
+	tx.Commit()
7098 7127
 	return err
7099 7128
 }
7100 7129
 
7101 7130
 func ReturnCheckWarehouseInfo(id int64) error {
7102
-
7103
-	err := XTWriteDB().Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7104
-	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7131
+	tx := XTWriteDB().Begin()
7132
+	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7133
+	if err != nil {
7134
+		tx.Rollback()
7135
+		return err
7136
+	}
7137
+	err = tx.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7138
+	tx.Commit()
7105 7139
 	return err
7106 7140
 }
7107 7141
 
7108 7142
 func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
7109
-
7110
-	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
7111
-	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7143
+	tx := XTWriteDB().Begin()
7144
+	err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
7145
+	if err != nil {
7146
+		tx.Rollback()
7147
+		return err
7148
+	}
7149
+	err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7150
+	if err != nil {
7151
+		tx.Rollback()
7152
+		return err
7153
+	}
7154
+	tx.Commit()
7112 7155
 	return err
7113 7156
 }
7114 7157
 
7115 7158
 func UpdateWarehouseInfoFlow(id int64) error {
7159
+	tx := XTWriteDB().Begin()
7160
+	err := tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0}).Error
7116 7161
 
7117
-	err := XTWriteDB().Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0}).Error
7162
+	if err != nil {
7163
+		tx.Rollback()
7164
+		return err
7165
+	}
7166
+	tx.Commit()
7118 7167
 	return err
7119 7168
 }
7120 7169
 
@@ -7158,8 +7207,13 @@ func UpdateWarehouseing(info *models.DrugWarehouseInfo) error {
7158 7207
 }
7159 7208
 
7160 7209
 func CheckWarehousingInfo(id int64, orgid int64) error {
7161
-
7162
-	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7210
+	tx := XTWriteDB().Begin()
7211
+	err := tx.Model(&models.DrugWarehouse{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7212
+	if err != nil {
7213
+		tx.Rollback()
7214
+		return err
7215
+	}
7216
+	tx.Commit()
7163 7217
 	return err
7164 7218
 }
7165 7219
 
@@ -7170,41 +7224,89 @@ func GetWarehousingInfoByList(id int64, orgid int64) (info []*models.DrugWarehou
7170 7224
 }
7171 7225
 
7172 7226
 func AddDrugWarehouseStockMaxNumber(count int64, id int64) error {
7173
-
7174
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7175
-	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7227
+	tx := XTWriteDB().Begin()
7228
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7229
+	if err != nil {
7230
+		tx.Rollback()
7231
+		return err
7232
+	}
7233
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7234
+	if err != nil {
7235
+		tx.Rollback()
7236
+		return err
7237
+	}
7238
+	tx.Commit()
7176 7239
 	return err
7177 7240
 }
7178 7241
 
7179 7242
 func UpdateWarehousingInfoFlow(id int64, orgid int64) error {
7180
-
7181
-	err := XTWriteDB().Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
7243
+	tx := XTWriteDB().Begin()
7244
+	err := tx.Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
7245
+	if err != nil {
7246
+		tx.Rollback()
7247
+		return err
7248
+	}
7249
+	tx.Commit()
7182 7250
 	return err
7183 7251
 }
7184 7252
 
7185 7253
 func AddDrugWarehouseStockMinNumber(count int64, id int64) error {
7186
-
7254
+	tx := XTWriteDB().Begin()
7187 7255
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
7256
+	if err != nil {
7257
+		tx.Rollback()
7258
+		return err
7259
+	}
7188 7260
 	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7261
+	tx.Commit()
7189 7262
 	return err
7190 7263
 }
7191 7264
 
7192 7265
 func ReturnCheckWarehouseingInfo(id int64, orgid int64) error {
7193
-
7266
+	tx := XTWriteDB().Begin()
7194 7267
 	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7268
+	if err != nil {
7269
+		tx.Rollback()
7270
+		return err
7271
+	}
7195 7272
 	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("warehousing_id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7273
+	if err != nil {
7274
+		tx.Rollback()
7275
+		return err
7276
+	}
7277
+	tx.Commit()
7196 7278
 	return err
7197 7279
 }
7198 7280
 
7199 7281
 func AddDrugReturnWarehouseStockMaxNumber(count int64, id int64) error {
7200
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7201
-	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7282
+	tx := XTWriteDB().Begin()
7283
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7284
+	if err != nil {
7285
+		tx.Rollback()
7286
+		return err
7287
+	}
7288
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7289
+	if err != nil {
7290
+		tx.Rollback()
7291
+		return err
7292
+	}
7293
+	tx.Commit()
7202 7294
 	return err
7203 7295
 }
7204 7296
 
7205 7297
 func AddDrugReturnWarehouseStockMinNumber(count int64, id int64) error {
7206
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
7207
-	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7298
+	tx := XTWriteDB().Begin()
7299
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
7300
+	if err != nil {
7301
+		tx.Rollback()
7302
+		return err
7303
+	}
7304
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7305
+	if err != nil {
7306
+		tx.Rollback()
7307
+		return err
7308
+	}
7309
+	tx.Commit()
7208 7310
 	return err
7209 7311
 }
7210 7312
 
@@ -7318,8 +7420,13 @@ func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) er
7318 7420
 }
7319 7421
 
7320 7422
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64) error {
7321
-
7322
-	err := XTReadDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7423
+	tx := XTWriteDB().Begin()
7424
+	err := tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7425
+	if err != nil {
7426
+		tx.Rollback()
7427
+		return err
7428
+	}
7429
+	tx.Commit()
7323 7430
 	return err
7324 7431
 }
7325 7432
 
@@ -7424,9 +7531,18 @@ func GetDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64) (info [
7424 7531
 }
7425 7532
 
7426 7533
 func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
7427
-
7428
-	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7429
-	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7534
+	tx := XTWriteDB().Begin()
7535
+	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7536
+	if err != nil {
7537
+		tx.Rollback()
7538
+		return err
7539
+	}
7540
+	err = tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7541
+	if err != nil {
7542
+		tx.Rollback()
7543
+		return err
7544
+	}
7545
+	tx.Commit()
7430 7546
 	return err
7431 7547
 }
7432 7548
 

+ 1 - 0
src/golang.org/x/sync

@@ -0,0 +1 @@
1
+Subproject commit f12130a5280420d36872ab0a7717d160c768df46