|
@@ -42,41 +42,192 @@ func HisManagerApiRegistRouters() {
|
42
|
42
|
beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
|
43
|
43
|
beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
|
44
|
44
|
beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
|
|
45
|
+
|
|
46
|
+ beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
|
|
47
|
+
|
|
48
|
+}
|
|
49
|
+
|
|
50
|
+func (c *HisApiController) GetHisPatientInfo() {
|
|
51
|
+
|
|
52
|
+ medical_insurance_card := c.GetString("medical_insurance_card")
|
|
53
|
+ id_card_type, _ := c.GetInt64("id_card_type")
|
|
54
|
+ id_card := c.GetString("id_card")
|
|
55
|
+
|
|
56
|
+ adminInfo := c.GetAdminUserInfo()
|
|
57
|
+ config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
|
|
58
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
|
|
59
|
+
|
|
60
|
+ appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
|
|
61
|
+
|
|
62
|
+ IdCardNo := ""
|
|
63
|
+
|
|
64
|
+ if id_card_type == 1 {
|
|
65
|
+ IdCardNo = medical_insurance_card
|
|
66
|
+ } else if id_card_type == 2 {
|
|
67
|
+ IdCardNo = id_card
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ if config.IsOpen == 1 {
|
|
71
|
+
|
|
72
|
+ api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
|
73
|
+ resp, requestErr := http.Get(api)
|
|
74
|
+ if requestErr != nil {
|
|
75
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
76
|
+ return
|
|
77
|
+ }
|
|
78
|
+ defer resp.Body.Close()
|
|
79
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
80
|
+ if ioErr != nil {
|
|
81
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
82
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
83
|
+ return
|
|
84
|
+ }
|
|
85
|
+ var respJSON map[string]interface{}
|
|
86
|
+
|
|
87
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
88
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
89
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
90
|
+ return
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
94
|
+ userJSONBytes, _ := json.Marshal(userJSON)
|
|
95
|
+ var res ResultTwo
|
|
96
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
97
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
98
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
99
|
+ return
|
|
100
|
+ }
|
|
101
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
102
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
103
|
+ infoStr := string(Iinfos)
|
|
104
|
+ idetinfoStr := string(Idetinfos)
|
|
105
|
+
|
|
106
|
+ if res.Infcode == 0 {
|
|
107
|
+ his := models.VMHisPatient{
|
|
108
|
+ Status: 1,
|
|
109
|
+ Ctime: time.Now().Unix(),
|
|
110
|
+ Mtime: time.Now().Unix(),
|
|
111
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
112
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
113
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
114
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
115
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
116
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
117
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
118
|
+ Age: res.Output.Baseinfo.Age,
|
|
119
|
+ Iinfo: infoStr,
|
|
120
|
+ Idetinfo: idetinfoStr,
|
|
121
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
122
|
+ IsReturn: 1,
|
|
123
|
+ IdCardType: id_card_type,
|
|
124
|
+ }
|
|
125
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
126
|
+ "info": his,
|
|
127
|
+ })
|
|
128
|
+ } else {
|
|
129
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
130
|
+ return
|
|
131
|
+ }
|
|
132
|
+ }
|
|
133
|
+
|
45
|
134
|
}
|
46
|
135
|
|
47
|
136
|
func (c *HisApiController) Sscard() {
|
48
|
137
|
id_card_type, _ := c.GetInt64("id_card_type")
|
49
|
138
|
adminUser := c.GetAdminUserInfo()
|
|
139
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
|
140
|
+
|
50
|
141
|
r := CardInit()
|
51
|
142
|
if r == 0 {
|
52
|
143
|
switch id_card_type {
|
53
|
144
|
case 1:
|
54
|
145
|
basStr, err := GetBasBaseInfo()
|
55
|
|
- fmt.Println("~~~~~")
|
56
|
|
- fmt.Println(basStr)
|
57
|
|
- fmt.Println("~~~~~")
|
58
|
146
|
|
59
|
147
|
if err != nil {
|
60
|
148
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
61
|
149
|
return
|
62
|
150
|
|
63
|
151
|
} else {
|
|
152
|
+
|
64
|
153
|
bas := strings.Split(basStr, "|")
|
65
|
154
|
basNumber := bas[1]
|
66
|
|
- patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
|
67
|
|
- if err == gorm.ErrRecordNotFound {
|
68
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
155
|
+
|
|
156
|
+ appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
|
|
157
|
+
|
|
158
|
+ api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
|
|
159
|
+ resp, requestErr := http.Get(api)
|
|
160
|
+ if requestErr != nil {
|
|
161
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
69
|
162
|
return
|
|
163
|
+ }
|
|
164
|
+ defer resp.Body.Close()
|
|
165
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
166
|
+ if ioErr != nil {
|
|
167
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
168
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
169
|
+ return
|
|
170
|
+ }
|
|
171
|
+ var respJSON map[string]interface{}
|
70
|
172
|
|
71
|
|
- } else if err != nil {
|
72
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
173
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
174
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
175
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
176
|
+ return
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+ userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
180
|
+ userJSONBytes, _ := json.Marshal(userJSON)
|
|
181
|
+ var res ResultTwo
|
|
182
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
183
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
184
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
73
|
185
|
return
|
|
186
|
+ }
|
|
187
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
188
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
189
|
+ infoStr := string(Iinfos)
|
|
190
|
+ idetinfoStr := string(Idetinfos)
|
|
191
|
+
|
|
192
|
+ if res.Infcode == 0 {
|
|
193
|
+ his := models.VMHisPatient{
|
|
194
|
+ Status: 1,
|
|
195
|
+ Ctime: time.Now().Unix(),
|
|
196
|
+ Mtime: time.Now().Unix(),
|
|
197
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
198
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
199
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
200
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
201
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
202
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
203
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
204
|
+ Age: res.Output.Baseinfo.Age,
|
|
205
|
+ Iinfo: infoStr,
|
|
206
|
+ Idetinfo: idetinfoStr,
|
|
207
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
208
|
+ IsReturn: 1,
|
|
209
|
+ IdCardType: id_card_type,
|
|
210
|
+ }
|
74
|
211
|
|
|
212
|
+ patient, err := service.GetPatientByNumber(his.Certno, adminUser.CurrentOrgId)
|
|
213
|
+ if err == gorm.ErrRecordNotFound {
|
|
214
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
215
|
+ return
|
|
216
|
+
|
|
217
|
+ } else if err != nil {
|
|
218
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
219
|
+ return
|
|
220
|
+
|
|
221
|
+ } else {
|
|
222
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
223
|
+ "patient": patient,
|
|
224
|
+ "info": his,
|
|
225
|
+ "number": basNumber,
|
|
226
|
+ })
|
|
227
|
+ }
|
75
|
228
|
} else {
|
76
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
77
|
|
- "patient": patient,
|
78
|
|
- "number": basNumber,
|
79
|
|
- })
|
|
229
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
230
|
+ return
|
80
|
231
|
}
|
81
|
232
|
|
82
|
233
|
}
|
|
@@ -84,9 +235,6 @@ func (c *HisApiController) Sscard() {
|
84
|
235
|
break
|
85
|
236
|
case 2:
|
86
|
237
|
SFZStr, err := GetSFZBaseInfo()
|
87
|
|
- fmt.Println("~~~~~----")
|
88
|
|
- fmt.Println(SFZStr)
|
89
|
|
- fmt.Println("~~~~~---")
|
90
|
238
|
if err != nil {
|
91
|
239
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
92
|
240
|
return
|
|
@@ -95,34 +243,87 @@ func (c *HisApiController) Sscard() {
|
95
|
243
|
|
96
|
244
|
id_card_str := strings.Split(SFZStr, "^")
|
97
|
245
|
id_card_number := id_card_str[0]
|
98
|
|
- patient, err := service.GetPatientByIDCard(id_card_number, adminUser.CurrentOrgId)
|
99
|
|
- if err == gorm.ErrRecordNotFound {
|
100
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
246
|
+ appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
|
|
247
|
+
|
|
248
|
+ api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
|
|
249
|
+ resp, requestErr := http.Get(api)
|
|
250
|
+ if requestErr != nil {
|
|
251
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
101
|
252
|
return
|
|
253
|
+ }
|
|
254
|
+ defer resp.Body.Close()
|
|
255
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
256
|
+ if ioErr != nil {
|
|
257
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
258
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
259
|
+ return
|
|
260
|
+ }
|
|
261
|
+ var respJSON map[string]interface{}
|
102
|
262
|
|
103
|
|
- } else if err != nil {
|
104
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
263
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
264
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
265
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
266
|
+ return
|
|
267
|
+ }
|
|
268
|
+
|
|
269
|
+ userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
270
|
+ userJSONBytes, _ := json.Marshal(userJSON)
|
|
271
|
+ var res ResultTwo
|
|
272
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
273
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
274
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
105
|
275
|
return
|
|
276
|
+ }
|
|
277
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
278
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
279
|
+ infoStr := string(Iinfos)
|
|
280
|
+ idetinfoStr := string(Idetinfos)
|
|
281
|
+
|
|
282
|
+ if res.Infcode == 0 {
|
|
283
|
+ his := models.VMHisPatient{
|
|
284
|
+ Status: 1,
|
|
285
|
+ Ctime: time.Now().Unix(),
|
|
286
|
+ Mtime: time.Now().Unix(),
|
|
287
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
288
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
289
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
290
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
291
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
292
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
293
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
294
|
+ Age: res.Output.Baseinfo.Age,
|
|
295
|
+ Iinfo: infoStr,
|
|
296
|
+ Idetinfo: idetinfoStr,
|
|
297
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
298
|
+ IsReturn: 1,
|
|
299
|
+ IdCardType: id_card_type,
|
|
300
|
+ }
|
106
|
301
|
|
|
302
|
+ patient, err := service.GetPatientByNumber(his.Certno, adminUser.CurrentOrgId)
|
|
303
|
+ if err == gorm.ErrRecordNotFound {
|
|
304
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
305
|
+ return
|
|
306
|
+
|
|
307
|
+ } else if err != nil {
|
|
308
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
309
|
+ return
|
|
310
|
+
|
|
311
|
+ } else {
|
|
312
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
313
|
+ "patient": patient,
|
|
314
|
+ "info": his,
|
|
315
|
+ "number": id_card_number,
|
|
316
|
+ })
|
|
317
|
+ }
|
107
|
318
|
} else {
|
108
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
109
|
|
- "patient": patient,
|
110
|
|
- })
|
|
319
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
320
|
+ return
|
111
|
321
|
}
|
112
|
322
|
|
113
|
323
|
}
|
114
|
324
|
break
|
115
|
325
|
case 3:
|
116
|
|
- //QRStr, err :=GetQRBaseInfo()
|
117
|
|
- //if err != nil{
|
118
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
119
|
|
- // return
|
120
|
|
- //
|
121
|
|
- //}else{
|
122
|
|
- //
|
123
|
|
- //
|
124
|
|
- //
|
125
|
|
- //}
|
|
326
|
+
|
126
|
327
|
break
|
127
|
328
|
|
128
|
329
|
}
|