|
@@ -29,13 +29,6 @@ type HisApiController struct {
|
29
|
29
|
BaseAuthAPIController
|
30
|
30
|
}
|
31
|
31
|
|
32
|
|
-var (
|
33
|
|
- DllTestDef, _ = syscall.LoadDLL("SSCard.dll")
|
34
|
|
- add, _ = DllTestDef.FindProc("Init")
|
35
|
|
- ReadCardBas, _ = DllTestDef.FindProc("ReadCardBas")
|
36
|
|
- ReadIDCardBas, _ = DllTestDef.FindProc("ReadSFZ")
|
37
|
|
-)
|
38
|
|
-
|
39
|
32
|
func HisManagerApiRegistRouters() {
|
40
|
33
|
beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
|
41
|
34
|
beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
|
|
@@ -260,87 +253,87 @@ func (c *HisApiController) Sscard() {
|
260
|
253
|
|
261
|
254
|
break
|
262
|
255
|
case 2:
|
263
|
|
- SFZStr, err := GetSFZBaseInfo()
|
264
|
|
- if err != nil {
|
265
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
266
|
|
- return
|
267
|
|
-
|
268
|
|
- } else {
|
269
|
|
-
|
270
|
|
- id_card_str := strings.Split(SFZStr, "^")
|
271
|
|
- id_card_number := id_card_str[0]
|
272
|
|
- //appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
|
273
|
|
- //
|
274
|
|
- //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)
|
275
|
|
- //resp, requestErr := http.Get(api)
|
276
|
|
- //if requestErr != nil {
|
277
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
278
|
|
- // return
|
279
|
|
- //}
|
280
|
|
- //defer resp.Body.Close()
|
281
|
|
- //body, ioErr := ioutil.ReadAll(resp.Body)
|
282
|
|
- //if ioErr != nil {
|
283
|
|
- // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
284
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
285
|
|
- // return
|
286
|
|
- //}
|
287
|
|
- //var respJSON map[string]interface{}
|
288
|
|
- //
|
289
|
|
- //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
290
|
|
- // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
291
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
292
|
|
- // return
|
293
|
|
- //}
|
294
|
|
- //
|
295
|
|
- //userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
296
|
|
- //userJSONBytes, _ := json.Marshal(userJSON)
|
297
|
|
- //var res ResultTwo
|
298
|
|
- //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
299
|
|
- // utils.ErrorLog("解析失败:%v", err)
|
300
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
301
|
|
- // return
|
302
|
|
- //}
|
303
|
|
- //Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
304
|
|
- //Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
305
|
|
- //infoStr := string(Iinfos)
|
306
|
|
- //idetinfoStr := string(Idetinfos)
|
307
|
|
- //
|
308
|
|
- //if res.Infcode == 0 {
|
309
|
|
- // his := models.VMHisPatient{
|
310
|
|
- // Status: 1,
|
311
|
|
- // Ctime: time.Now().Unix(),
|
312
|
|
- // Mtime: time.Now().Unix(),
|
313
|
|
- // PsnNo: res.Output.Baseinfo.PsnNo,
|
314
|
|
- // PsnCertType: res.Output.Baseinfo.PsnCertType,
|
315
|
|
- // Certno: res.Output.Baseinfo.Certno,
|
316
|
|
- // PsnName: res.Output.Baseinfo.PsnName,
|
317
|
|
- // Gend: res.Output.Baseinfo.Gend,
|
318
|
|
- // Naty: res.Output.Baseinfo.Naty,
|
319
|
|
- // Brdy: res.Output.Baseinfo.Brdy,
|
320
|
|
- // Age: res.Output.Baseinfo.Age,
|
321
|
|
- // Iinfo: infoStr,
|
322
|
|
- // Idetinfo: idetinfoStr,
|
323
|
|
- // UserOrgId: adminUser.CurrentOrgId,
|
324
|
|
- // IsReturn: 1,
|
325
|
|
- // IdCardType: id_card_type,
|
326
|
|
- // }
|
327
|
|
-
|
328
|
|
- patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
|
329
|
|
- if err == gorm.ErrRecordNotFound {
|
330
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
331
|
|
- return
|
332
|
|
-
|
333
|
|
- } else if err != nil {
|
334
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
335
|
|
- return
|
336
|
|
-
|
337
|
|
- } else {
|
338
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
339
|
|
- "patient": patient,
|
340
|
|
- "number": id_card_number,
|
341
|
|
- })
|
342
|
|
- }
|
343
|
|
- }
|
|
256
|
+ ////SFZStr, err := GetSFZBaseInfo()
|
|
257
|
+ //if err != nil {
|
|
258
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
|
259
|
+ // return
|
|
260
|
+ //
|
|
261
|
+ //} else {
|
|
262
|
+ //
|
|
263
|
+ // id_card_str := strings.Split(SFZStr, "^")
|
|
264
|
+ // id_card_number := id_card_str[0]
|
|
265
|
+ //appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
|
|
266
|
+ //
|
|
267
|
+ //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)
|
|
268
|
+ //resp, requestErr := http.Get(api)
|
|
269
|
+ //if requestErr != nil {
|
|
270
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
271
|
+ // return
|
|
272
|
+ //}
|
|
273
|
+ //defer resp.Body.Close()
|
|
274
|
+ //body, ioErr := ioutil.ReadAll(resp.Body)
|
|
275
|
+ //if ioErr != nil {
|
|
276
|
+ // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
277
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
278
|
+ // return
|
|
279
|
+ //}
|
|
280
|
+ //var respJSON map[string]interface{}
|
|
281
|
+ //
|
|
282
|
+ //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
283
|
+ // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
284
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
285
|
+ // return
|
|
286
|
+ //}
|
|
287
|
+ //
|
|
288
|
+ //userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
289
|
+ //userJSONBytes, _ := json.Marshal(userJSON)
|
|
290
|
+ //var res ResultTwo
|
|
291
|
+ //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
292
|
+ // utils.ErrorLog("解析失败:%v", err)
|
|
293
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
294
|
+ // return
|
|
295
|
+ //}
|
|
296
|
+ //Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
297
|
+ //Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
298
|
+ //infoStr := string(Iinfos)
|
|
299
|
+ //idetinfoStr := string(Idetinfos)
|
|
300
|
+ //
|
|
301
|
+ //if res.Infcode == 0 {
|
|
302
|
+ // his := models.VMHisPatient{
|
|
303
|
+ // Status: 1,
|
|
304
|
+ // Ctime: time.Now().Unix(),
|
|
305
|
+ // Mtime: time.Now().Unix(),
|
|
306
|
+ // PsnNo: res.Output.Baseinfo.PsnNo,
|
|
307
|
+ // PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
308
|
+ // Certno: res.Output.Baseinfo.Certno,
|
|
309
|
+ // PsnName: res.Output.Baseinfo.PsnName,
|
|
310
|
+ // Gend: res.Output.Baseinfo.Gend,
|
|
311
|
+ // Naty: res.Output.Baseinfo.Naty,
|
|
312
|
+ // Brdy: res.Output.Baseinfo.Brdy,
|
|
313
|
+ // Age: res.Output.Baseinfo.Age,
|
|
314
|
+ // Iinfo: infoStr,
|
|
315
|
+ // Idetinfo: idetinfoStr,
|
|
316
|
+ // UserOrgId: adminUser.CurrentOrgId,
|
|
317
|
+ // IsReturn: 1,
|
|
318
|
+ // IdCardType: id_card_type,
|
|
319
|
+ // }
|
|
320
|
+
|
|
321
|
+ // patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
|
|
322
|
+ // if err == gorm.ErrRecordNotFound {
|
|
323
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
324
|
+ // return
|
|
325
|
+ //
|
|
326
|
+ // } else if err != nil {
|
|
327
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
328
|
+ // return
|
|
329
|
+ //
|
|
330
|
+ // } else {
|
|
331
|
+ // c.ServeSuccessJSON(map[string]interface{}{
|
|
332
|
+ // "patient": patient,
|
|
333
|
+ // "number": id_card_number,
|
|
334
|
+ // })
|
|
335
|
+ // }
|
|
336
|
+ //}
|
344
|
337
|
break
|
345
|
338
|
case 3:
|
346
|
339
|
|
|
@@ -349,37 +342,31 @@ func (c *HisApiController) Sscard() {
|
349
|
342
|
}
|
350
|
343
|
}
|
351
|
344
|
|
352
|
|
-func StrPtr2(s string) uintptr {
|
353
|
|
- return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
|
354
|
|
-}
|
355
|
|
-
|
356
|
345
|
func GetBasBaseInfo() (jsonStr string, err error) {
|
357
|
|
-
|
358
|
|
- fmt.Println(ReadCardBas)
|
359
|
|
- h := syscall.NewLazyDLL("SSCard.dll")
|
360
|
|
- proc := h.NewProc("ReadCardBas")
|
361
|
|
-
|
362
|
|
- str := ""
|
363
|
|
- str1 := ""
|
364
|
|
- r, _, _ := proc.Call(StrPtr2(str), IntPtr(1024), StrPtr2(str1), IntPtr(1024))
|
365
|
|
-
|
366
|
|
- fmt.Println(r)
|
367
|
|
- fmt.Println(str)
|
368
|
|
-
|
369
|
|
- return str, nil
|
370
|
|
-}
|
371
|
|
-
|
372
|
|
-func GetSFZBaseInfo() (jsonStr string, err error) {
|
373
|
|
- //handle := syscall.MustLoadDLL("SSCard.dll")
|
|
346
|
+ handle := syscall.MustLoadDLL("SSCard.dll")
|
|
347
|
+ ReadCardBas := handle.MustFindProc("ReadCardBas")
|
374
|
348
|
|
375
|
349
|
str := make([]byte, 256)
|
376
|
350
|
str1 := make([]byte, 256)
|
377
|
|
- r, _, _ := ReadIDCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
|
|
351
|
+ r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
|
378
|
352
|
|
379
|
353
|
fmt.Println(r)
|
|
354
|
+ fmt.Println(string(str))
|
|
355
|
+
|
380
|
356
|
return string(str), nil
|
381
|
357
|
}
|
382
|
358
|
|
|
359
|
+//func GetSFZBaseInfo() (jsonStr string, err error) {
|
|
360
|
+// //handle := syscall.MustLoadDLL("SSCard.dll")
|
|
361
|
+//
|
|
362
|
+// str := make([]byte, 256)
|
|
363
|
+// str1 := make([]byte, 256)
|
|
364
|
+// r, _, _ := ReadIDCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
|
|
365
|
+//
|
|
366
|
+// fmt.Println(r)
|
|
367
|
+// return string(str), nil
|
|
368
|
+//}
|
|
369
|
+
|
383
|
370
|
//func GetQRBaseInfo() (jsonStr string, err error) {
|
384
|
371
|
// handle := syscall.LoadDLL("SSCard.dll")
|
385
|
372
|
// ReadCardBas := handle.FindProc("GetQRBase")
|
|
@@ -394,15 +381,26 @@ func GetSFZBaseInfo() (jsonStr string, err error) {
|
394
|
381
|
//}
|
395
|
382
|
|
396
|
383
|
func CardInit() int {
|
|
384
|
+ DllTestDef := syscall.MustLoadDLL("SSCard.dll")
|
|
385
|
+ add := DllTestDef.MustFindProc("Init")
|
397
|
386
|
ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
|
398
|
387
|
if err != nil {
|
399
|
388
|
fmt.Println("SSCard的运算结果为:", ret)
|
400
|
389
|
}
|
401
|
|
- fmt.Println(err)
|
402
|
390
|
result := int(ret)
|
403
|
391
|
return result
|
404
|
392
|
}
|
405
|
393
|
|
|
394
|
+//func CardInit() int {
|
|
395
|
+// ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
|
|
396
|
+// if err != nil {
|
|
397
|
+// fmt.Println("SSCard的运算结果为:", ret)
|
|
398
|
+// }
|
|
399
|
+// fmt.Println(err)
|
|
400
|
+// result := int(ret)
|
|
401
|
+// return result
|
|
402
|
+//}
|
|
403
|
+
|
406
|
404
|
func IntPtr(n int) uintptr {
|
407
|
405
|
return uintptr(n)
|
408
|
406
|
}
|