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