|
@@ -22,6 +22,162 @@ func IntegrationConfigRegistRouters() {
|
22
|
22
|
beego.Router("/api/adminhis/edit", &IntegrationConfigApiController{}, "post:EditAdminHis")
|
23
|
23
|
beego.Router("/api/adminhis/create", &IntegrationConfigApiController{}, "post:CreateAdminHis")
|
24
|
24
|
|
|
25
|
+ beego.Router("/api/patienthis/getinterface", &IntegrationConfigApiController{}, "post:GetInterface")
|
|
26
|
+ beego.Router("/api/patienthis/saveinterface", &IntegrationConfigApiController{}, "post:SaveInterface")
|
|
27
|
+ beego.Router("/api/integration/synclist", &IntegrationConfigApiController{}, "get:GetSyncList")
|
|
28
|
+ beego.Router("/api/integration/sysinspectionlist", &IntegrationConfigApiController{}, "get:GetSysInspectionList")
|
|
29
|
+ beego.Router("/api/patienthis/saveinspectionsysitemid", &IntegrationConfigApiController{}, "post:SaveInspectionSysItemId")
|
|
30
|
+}
|
|
31
|
+
|
|
32
|
+func (c *IntegrationConfigApiController) SaveInspectionSysItemId() {
|
|
33
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
34
|
+ org_id,_ := c.GetInt64("org_id",0)
|
|
35
|
+ sys_item_id,_ := c.GetInt64("sys_item_id",0)
|
|
36
|
+ id,_ := c.GetInt64("id",0)
|
|
37
|
+ if org_id != adminUserInfo.CurrentOrgId || sys_item_id<= 0 || id <= 0 {
|
|
38
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ inspection_reference := &models.InspectionReference{
|
|
42
|
+ ID : id,
|
|
43
|
+ SysItemId : sys_item_id,
|
|
44
|
+ UpdatedTime : time.Now().Unix(),
|
|
45
|
+ }
|
|
46
|
+ err := service.UpdateSysItemIdByID(inspection_reference)
|
|
47
|
+ if err != nil {
|
|
48
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
49
|
+ }
|
|
50
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
51
|
+ "inspection_reference": inspection_reference,
|
|
52
|
+ })
|
|
53
|
+ return
|
|
54
|
+}
|
|
55
|
+
|
|
56
|
+func (c *IntegrationConfigApiController) GetSysInspectionList() {
|
|
57
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
58
|
+ sysInspection,ownerInspection,err := service.GetSysInspectionList(adminUserInfo.CurrentOrgId)
|
|
59
|
+ if err != nil {
|
|
60
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ type InspectionStruce struct {
|
|
64
|
+ ProjectName string `gorm:"-" json:"project_name" form:"project_name"`
|
|
65
|
+ ProjectId int64 `gorm:"-" json:"project_id" form:"project_id"`
|
|
66
|
+ InspectionReference []*models.InspectionReference `gorm:"-" json:"inspection_reference" form:"inspection_reference"`
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ sysInspec := make(map[int64]*InspectionStruce, 0)
|
|
70
|
+ ownerInspec := make(map[int64]*InspectionStruce, 0)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+ for _, item := range sysInspection {
|
|
75
|
+ result := sysInspec[item.ProjectId]
|
|
76
|
+ if result == nil {
|
|
77
|
+ result = new(InspectionStruce)
|
|
78
|
+ result.ProjectName = item.ProjectName
|
|
79
|
+ result.ProjectId = item.ProjectId
|
|
80
|
+ }
|
|
81
|
+ result.InspectionReference = append(result.InspectionReference, item)
|
|
82
|
+ sysInspec[item.ProjectId] = result
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ for _, oitem := range ownerInspection {
|
|
86
|
+ oresult := ownerInspec[oitem.ProjectId]
|
|
87
|
+ if oresult == nil {
|
|
88
|
+ oresult = new(InspectionStruce)
|
|
89
|
+ oresult.ProjectName = oitem.ProjectName
|
|
90
|
+ oresult.ProjectId = oitem.ProjectId
|
|
91
|
+ }
|
|
92
|
+ oresult.InspectionReference = append(oresult.InspectionReference, oitem)
|
|
93
|
+ ownerInspec[oitem.ProjectId] = oresult
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
97
|
+ "sysInspec": sysInspec,
|
|
98
|
+ "ownerInspec": ownerInspec,
|
|
99
|
+ })
|
|
100
|
+ return
|
|
101
|
+}
|
|
102
|
+
|
|
103
|
+func (c *IntegrationConfigApiController) GetSyncList() {
|
|
104
|
+ page, _ := c.GetInt64("page", 1)
|
|
105
|
+ limit, _ := c.GetInt64("limit", 10)
|
|
106
|
+
|
|
107
|
+ if page <= 0 {
|
|
108
|
+ page = 1
|
|
109
|
+ }
|
|
110
|
+ if limit <= 0 {
|
|
111
|
+ limit = 10
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
115
|
+ patients, total, _ := service.GetSyncList(adminUserInfo.CurrentOrgId, page, limit)
|
|
116
|
+
|
|
117
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
118
|
+ "list": patients,
|
|
119
|
+ "total": total,
|
|
120
|
+ })
|
|
121
|
+ return
|
|
122
|
+}
|
|
123
|
+
|
|
124
|
+func (c *IntegrationConfigApiController) SaveInterface() {
|
|
125
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
126
|
+ ID,_ := c.GetInt64("id",0)
|
|
127
|
+ OrgId := adminUserInfo.CurrentOrgId
|
|
128
|
+ Creater := adminUserInfo.AdminUser.Id
|
|
129
|
+ Pattern,_ := c.GetInt("pattern",0)
|
|
130
|
+ Dbhost := c.GetString("dbhost")
|
|
131
|
+ Dbuser := c.GetString("dbuser")
|
|
132
|
+ Dbpassword := c.GetString("dbpassword")
|
|
133
|
+ Dbname := c.GetString("dbname")
|
|
134
|
+ InterfaceUrl := c.GetString("interface_url")
|
|
135
|
+ InterFaceToken := c.GetString("interface_token")
|
|
136
|
+ AllowIp := c.GetString("allow_ip")
|
|
137
|
+ AllowToken := c.GetString("allow_token")
|
|
138
|
+ SyncFrequency,_ := c.GetInt("sync_frequency")
|
|
139
|
+ Status := 1
|
|
140
|
+ UpdatedTime := time.Now().Unix()
|
|
141
|
+ interfaceinfo := &models.MiddleInterface{
|
|
142
|
+ ID : ID,
|
|
143
|
+ OrgId : OrgId ,
|
|
144
|
+ Creater : Creater ,
|
|
145
|
+ Pattern : Pattern ,
|
|
146
|
+ Dbhost : Dbhost ,
|
|
147
|
+ Dbuser : Dbuser ,
|
|
148
|
+ Dbpassword : Dbpassword ,
|
|
149
|
+ Dbname : Dbname ,
|
|
150
|
+ InterfaceUrl : InterfaceUrl ,
|
|
151
|
+ InterFaceToken : InterFaceToken ,
|
|
152
|
+ AllowIp : AllowIp ,
|
|
153
|
+ AllowToken : AllowToken ,
|
|
154
|
+ SyncFrequency : SyncFrequency ,
|
|
155
|
+ Status : Status ,
|
|
156
|
+ UpdatedTime : UpdatedTime ,
|
|
157
|
+ }
|
|
158
|
+ if ID <= 0 {
|
|
159
|
+ interfaceinfo.CreatedTime = time.Now().Unix()
|
|
160
|
+ }
|
|
161
|
+ err:= service.SaveInterface(interfaceinfo)
|
|
162
|
+
|
|
163
|
+ if err == nil {
|
|
164
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
165
|
+ "interfaceinfo": interfaceinfo,
|
|
166
|
+ })
|
|
167
|
+ } else {
|
|
168
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
169
|
+ }
|
|
170
|
+ return
|
|
171
|
+}
|
|
172
|
+
|
|
173
|
+func (c *IntegrationConfigApiController) GetInterface() {
|
|
174
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
175
|
+ interfaceinfo, _ := service.GetInterface(adminUserInfo.CurrentOrgId)
|
|
176
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
177
|
+ "interfaceinfo": interfaceinfo,
|
|
178
|
+ })
|
|
179
|
+ return
|
|
180
|
+
|
25
|
181
|
}
|
26
|
182
|
|
27
|
183
|
func (c *IntegrationConfigApiController) GetPatientsList() {
|
|
@@ -43,7 +199,6 @@ func (c *IntegrationConfigApiController) GetPatientsList() {
|
43
|
199
|
"total": total,
|
44
|
200
|
})
|
45
|
201
|
return
|
46
|
|
-
|
47
|
202
|
}
|
48
|
203
|
|
49
|
204
|
func (c *IntegrationConfigApiController) EditPatientHis() {
|