|
@@ -1421,104 +1421,110 @@ func (c *HisApiController) ReadCard() {
|
1421
|
1421
|
saveLog(result, requestLog, "1101", "获取人员信息")
|
1422
|
1422
|
fmt.Println(errMsgLog)
|
1423
|
1423
|
|
1424
|
|
- var dat map[string]interface{}
|
1425
|
|
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
1426
|
|
- fmt.Println(dat)
|
|
1424
|
+ if len(errMsgLog) > 0 {
|
|
1425
|
+
|
1427
|
1426
|
} else {
|
1428
|
|
- fmt.Println(err)
|
1429
|
|
- }
|
1430
|
1427
|
|
1431
|
|
- userJSONBytes, _ := json.Marshal(dat)
|
1432
|
|
- var res ResultTwo
|
1433
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
1434
|
|
- utils.ErrorLog("解析失败:%v", err)
|
1435
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1436
|
|
- return
|
1437
|
|
- }
|
1438
|
|
- res.ErrMsg = errMsgLog
|
1439
|
|
- if res.Infcode == 0 {
|
1440
|
|
- patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
|
1441
|
|
- if err == gorm.ErrRecordNotFound {
|
1442
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
1443
|
|
- return
|
1444
|
|
- } else if err != nil {
|
1445
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1428
|
+ var dat map[string]interface{}
|
|
1429
|
+ if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
|
1430
|
+ fmt.Println(dat)
|
|
1431
|
+ } else {
|
|
1432
|
+ fmt.Println(err)
|
|
1433
|
+ }
|
|
1434
|
+
|
|
1435
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
1436
|
+ var res ResultTwo
|
|
1437
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1438
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1439
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1446
|
1440
|
return
|
|
1441
|
+ }
|
|
1442
|
+ res.ErrMsg = errMsgLog
|
|
1443
|
+ if res.Infcode == 0 {
|
|
1444
|
+ patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
|
|
1445
|
+ if err == gorm.ErrRecordNotFound {
|
|
1446
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
1447
|
+ return
|
|
1448
|
+ } else if err != nil {
|
|
1449
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1450
|
+ return
|
1447
|
1451
|
|
1448
|
|
- } else {
|
1449
|
|
- fmt.Println(res)
|
1450
|
|
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
1451
|
|
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
1452
|
|
- infoStr := string(Iinfos)
|
1453
|
|
- idetinfoStr := string(Idetinfos)
|
1454
|
|
- psn := &models.HisPsn{
|
1455
|
|
- PsnNo: res.Output.Baseinfo.PsnNo,
|
1456
|
|
- Age: res.Output.Baseinfo.Age,
|
1457
|
|
- PatientId: patient.ID,
|
1458
|
|
- Certno: res.Output.Baseinfo.Certno,
|
1459
|
|
- Brdy: res.Output.Baseinfo.Brdy,
|
1460
|
|
- Gend: res.Output.Baseinfo.Gend,
|
1461
|
|
- Naty: res.Output.Baseinfo.Naty,
|
1462
|
|
- PsnCertType: res.Output.Baseinfo.PsnCertType,
|
1463
|
|
- PsnName: res.Output.Baseinfo.PsnName,
|
1464
|
|
- Idetinfo: idetinfoStr,
|
1465
|
|
- Insuinfo: infoStr,
|
1466
|
|
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
1467
|
|
- CardInfo: basStr,
|
1468
|
|
- VerifyNumber: "",
|
1469
|
|
- }
|
1470
|
|
- service.CreateHisPsn(psn)
|
|
1452
|
+ } else {
|
|
1453
|
+ fmt.Println(res)
|
|
1454
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
1455
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
1456
|
+ infoStr := string(Iinfos)
|
|
1457
|
+ idetinfoStr := string(Idetinfos)
|
|
1458
|
+ psn := &models.HisPsn{
|
|
1459
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
1460
|
+ Age: res.Output.Baseinfo.Age,
|
|
1461
|
+ PatientId: patient.ID,
|
|
1462
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
1463
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
1464
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
1465
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
1466
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
1467
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
1468
|
+ Idetinfo: idetinfoStr,
|
|
1469
|
+ Insuinfo: infoStr,
|
|
1470
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
1471
|
+ CardInfo: basStr,
|
|
1472
|
+ VerifyNumber: "",
|
|
1473
|
+ }
|
|
1474
|
+ service.CreateHisPsn(psn)
|
1471
|
1475
|
|
1472
|
|
- var rf []*ResultFive
|
1473
|
|
- json.Unmarshal([]byte(infoStr), &rf)
|
|
1476
|
+ var rf []*ResultFive
|
|
1477
|
+ json.Unmarshal([]byte(infoStr), &rf)
|
1474
|
1478
|
|
1475
|
|
- var insutypes []*ResultFive
|
1476
|
|
- var insutype string
|
1477
|
|
- var is390 int = 0
|
1478
|
|
- var is310 int = 0
|
|
1479
|
+ var insutypes []*ResultFive
|
|
1480
|
+ var insutype string
|
|
1481
|
+ var is390 int = 0
|
|
1482
|
+ var is310 int = 0
|
1479
|
1483
|
|
1480
|
|
- for _, item := range rf {
|
1481
|
|
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
1482
|
|
- insutypes = append(insutypes, item)
|
|
1484
|
+ for _, item := range rf {
|
|
1485
|
+ if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
|
1486
|
+ insutypes = append(insutypes, item)
|
|
1487
|
+ }
|
1483
|
1488
|
}
|
1484
|
|
- }
|
1485
|
1489
|
|
1486
|
|
- if len(insutypes) == 1 {
|
1487
|
|
- insutype = insutypes[0].Insutype
|
1488
|
|
- //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
|
1489
|
|
- } else {
|
1490
|
|
- for _, i := range insutypes {
|
1491
|
|
- if i.Insutype == "390" {
|
1492
|
|
- is390 = 1
|
1493
|
|
- }
|
|
1490
|
+ if len(insutypes) == 1 {
|
|
1491
|
+ insutype = insutypes[0].Insutype
|
|
1492
|
+ //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
|
|
1493
|
+ } else {
|
|
1494
|
+ for _, i := range insutypes {
|
|
1495
|
+ if i.Insutype == "390" {
|
|
1496
|
+ is390 = 1
|
|
1497
|
+ }
|
1494
|
1498
|
|
1495
|
|
- if i.Insutype == "310" {
|
1496
|
|
- is310 = 1
|
|
1499
|
+ if i.Insutype == "310" {
|
|
1500
|
+ is310 = 1
|
|
1501
|
+ }
|
1497
|
1502
|
}
|
1498
|
1503
|
}
|
1499
|
|
- }
|
1500
|
|
- if is390 == 1 {
|
1501
|
|
- insutype = "390"
|
1502
|
|
- }
|
|
1504
|
+ if is390 == 1 {
|
|
1505
|
+ insutype = "390"
|
|
1506
|
+ }
|
1503
|
1507
|
|
1504
|
|
- if is310 == 1 {
|
1505
|
|
- insutype = "310"
|
1506
|
|
- }
|
|
1508
|
+ if is310 == 1 {
|
|
1509
|
+ insutype = "310"
|
|
1510
|
+ }
|
1507
|
1511
|
|
1508
|
|
- if len(insutypes) == 0 {
|
1509
|
|
- insutype = "310"
|
1510
|
|
- }
|
|
1512
|
+ if len(insutypes) == 0 {
|
|
1513
|
+ insutype = "310"
|
|
1514
|
+ }
|
1511
|
1515
|
|
1512
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1513
|
|
- "patient": patient,
|
1514
|
|
- "number": cardnum,
|
1515
|
|
- "insutype": insutype,
|
1516
|
|
- })
|
|
1516
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1517
|
+ "patient": patient,
|
|
1518
|
+ "number": cardnum,
|
|
1519
|
+ "insutype": insutype,
|
|
1520
|
+ })
|
|
1521
|
+ }
|
|
1522
|
+ } else {
|
|
1523
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
1524
|
+ return
|
1517
|
1525
|
}
|
1518
|
|
- } else {
|
1519
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
1520
|
|
- return
|
1521
|
1526
|
}
|
|
1527
|
+
|
1522
|
1528
|
} else {
|
1523
|
1529
|
if initFlag == 0 {
|
1524
|
1530
|
c.TestGetBasBaseInit()
|