|
@@ -1233,6 +1233,401 @@ func (c *SZHisApiController) GetRegisterInfo() {
|
1233
|
1233
|
}
|
1234
|
1234
|
|
1235
|
1235
|
//func (c *SZHisApiController) GetInfo() {
|
|
1236
|
+func (c *SZHisApiController) GetRegisterInfo() {
|
|
1237
|
+ adminInfo := c.GetAdminUserInfo()
|
|
1238
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
1239
|
+ patient_id, _ := c.GetInt64("id")
|
|
1240
|
+ record_time := c.GetString("record_time")
|
|
1241
|
+ settlementValue, _ := c.GetInt64("settlement_value")
|
|
1242
|
+ medical_insurance_card := c.GetString("medical_insurance_card")
|
|
1243
|
+ name := c.GetString("name")
|
|
1244
|
+ id_card_type, _ := c.GetInt64("id_card_type")
|
|
1245
|
+ certificates, _ := c.GetInt64("certificates")
|
|
1246
|
+ medical_care, _ := c.GetInt64("medical_care")
|
|
1247
|
+ birthday := c.GetString("birthday")
|
|
1248
|
+ id_card := c.GetString("id_card")
|
|
1249
|
+ register_type, _ := c.GetInt64("register")
|
|
1250
|
+ doctor, _ := c.GetInt64("doctor")
|
|
1251
|
+ department, _ := c.GetInt64("department")
|
|
1252
|
+ gender, _ := c.GetInt64("sex")
|
|
1253
|
+ registration_fee, _ := c.GetFloat("registration_fee")
|
|
1254
|
+ medical_expenses, _ := c.GetFloat("medical_expenses")
|
|
1255
|
+ social_type, _ := c.GetInt64("social_type")
|
|
1256
|
+
|
|
1257
|
+ is_yidi, _ := c.GetInt64("is_yidi")
|
|
1258
|
+
|
|
1259
|
+ timeLayout := "2006-01-02"
|
|
1260
|
+ loc, _ := time.LoadLocation("Local")
|
|
1261
|
+ birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
|
|
1262
|
+ birthUnix := birthdays.Unix()
|
|
1263
|
+
|
|
1264
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
1265
|
+ if err != nil {
|
|
1266
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1267
|
+ return
|
|
1268
|
+ }
|
|
1269
|
+
|
|
1270
|
+ var patient service.Patients
|
|
1271
|
+ if patient_id == 0 {
|
|
1272
|
+ patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
|
|
1273
|
+ } else {
|
|
1274
|
+ patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
|
|
1275
|
+ }
|
|
1276
|
+
|
|
1277
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
|
|
1278
|
+ if patient.ID == 0 {
|
|
1279
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
1280
|
+ return
|
|
1281
|
+ }
|
|
1282
|
+ if len(patient.IdCardNo) == 0 {
|
|
1283
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
|
|
1284
|
+ return
|
|
1285
|
+ }
|
|
1286
|
+
|
|
1287
|
+ adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
|
|
1288
|
+ his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
|
|
1289
|
+
|
|
1290
|
+ var custom_code string
|
|
1291
|
+ var custom_project_name string
|
|
1292
|
+ var allPrice float64
|
|
1293
|
+
|
|
1294
|
+ switch register_type {
|
|
1295
|
+ case 1:
|
|
1296
|
+ custom_code = "110100002"
|
|
1297
|
+ custom_project_name = "普通门诊"
|
|
1298
|
+ allPrice = 10
|
|
1299
|
+ break
|
|
1300
|
+ case 3:
|
|
1301
|
+ custom_code = "110200002-2"
|
|
1302
|
+ custom_project_name = "主任医师"
|
|
1303
|
+ allPrice = 10
|
|
1304
|
+
|
|
1305
|
+ break
|
|
1306
|
+ case 2:
|
|
1307
|
+ custom_code = "110200002-3"
|
|
1308
|
+ custom_project_name = "副主任医师"
|
|
1309
|
+ allPrice = 10
|
|
1310
|
+
|
|
1311
|
+ break
|
|
1312
|
+ case 4:
|
|
1313
|
+ custom_code = "0"
|
|
1314
|
+ custom_project_name = "免受诊金"
|
|
1315
|
+ allPrice = 0
|
|
1316
|
+ break
|
|
1317
|
+ case 5:
|
|
1318
|
+ custom_code = "110200002-1"
|
|
1319
|
+ custom_project_name = "专家"
|
|
1320
|
+ allPrice = 10
|
|
1321
|
+
|
|
1322
|
+ break
|
|
1323
|
+ }
|
|
1324
|
+
|
|
1325
|
+ if his.ID == 0 {
|
|
1326
|
+
|
|
1327
|
+ var doctor_name string
|
|
1328
|
+ var doctor_code string
|
|
1329
|
+ if adminRole.ID == 0 {
|
|
1330
|
+
|
|
1331
|
+ doctor_name = ""
|
|
1332
|
+ doctor_code = "1001"
|
|
1333
|
+ doctor_name = ""
|
|
1334
|
+ doctor_code = ""
|
|
1335
|
+
|
|
1336
|
+ } else {
|
|
1337
|
+ doctor_name = adminRole.UserName
|
|
1338
|
+ doctor_code = strconv.FormatInt(admin_user_id, 10)
|
|
1339
|
+
|
|
1340
|
+ }
|
|
1341
|
+ month := time.Unix(1557042972, 0).Format("1")
|
|
1342
|
+ year := time.Now().Format("2006")
|
|
1343
|
+ month = time.Now().Format("01")
|
|
1344
|
+ day := time.Now().Format("02")
|
|
1345
|
+
|
|
1346
|
+ //流水号
|
|
1347
|
+ //
|
|
1348
|
+ number := miConfig.Code + year + month + day +
|
|
1349
|
+ fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
|
|
1350
|
+ mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
|
|
1351
|
+ fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
|
|
1352
|
+ //1.判断读卡类型
|
|
1353
|
+ //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
|
|
1354
|
+ yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
|
|
1355
|
+ fmt.Println(yiliao_number)
|
|
1356
|
+ fmt.Println(id_card_number)
|
|
1357
|
+ fmt.Println(verifyCode)
|
|
1358
|
+ fmt.Println(version_code)
|
|
1359
|
+ fmt.Println(ret4)
|
|
1360
|
+
|
|
1361
|
+ dept_code := "0305"
|
|
1362
|
+ is_yidi = 1
|
|
1363
|
+ tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
|
|
1364
|
+ //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
|
|
1365
|
+ if tempPatient.ID == patient_id {
|
|
1366
|
+ if ret4 == 0 { //本地卡流程
|
|
1367
|
+ if is_yidi == 1 {
|
|
1368
|
+ //本地就医流程
|
|
1369
|
+ //挂号
|
|
1370
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
|
|
1371
|
+ var dat map[string]interface{}
|
|
1372
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
1373
|
+ fmt.Println(dat)
|
|
1374
|
+ } else {
|
|
1375
|
+ fmt.Println(err)
|
|
1376
|
+ }
|
|
1377
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
1378
|
+ var res ResultOne
|
|
1379
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1380
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1381
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1382
|
+ return
|
|
1383
|
+ }
|
|
1384
|
+ if res.Transreturncode == "00000000" {
|
|
1385
|
+ his := models.VMHisPatient{
|
|
1386
|
+ Name: name,
|
|
1387
|
+ Gender: gender,
|
|
1388
|
+ Birthday: birthUnix,
|
|
1389
|
+ MedicalTreatmentType: medical_care,
|
|
1390
|
+ IdType: certificates,
|
|
1391
|
+ IdCardNo: id_card,
|
|
1392
|
+ BalanceAccountsType: settlementValue,
|
|
1393
|
+ SocialType: social_type,
|
|
1394
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
1395
|
+ RegisterType: register_type,
|
|
1396
|
+ RegisterCost: registration_fee,
|
|
1397
|
+ TreatmentCost: medical_expenses,
|
|
1398
|
+ Status: 1,
|
|
1399
|
+ Ctime: time.Now().Unix(),
|
|
1400
|
+ Mtime: time.Now().Unix(),
|
|
1401
|
+ Iinfo: resp_result,
|
|
1402
|
+ PatientId: patient.ID,
|
|
1403
|
+ RecordDate: theTime.Unix(),
|
|
1404
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
1405
|
+ AdminUserId: admin_user_id,
|
|
1406
|
+ IsReturn: 1,
|
|
1407
|
+ IdCardType: id_card_type,
|
|
1408
|
+ Doctor: doctor,
|
|
1409
|
+ Departments: department,
|
|
1410
|
+ YiliaoNumber: yiliao_number,
|
|
1411
|
+ MzNumber: number,
|
|
1412
|
+ Number: mz_number,
|
|
1413
|
+ }
|
|
1414
|
+ service.CreateHisPatientTwo(&his)
|
|
1415
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1416
|
+ "msg": "挂号成功",
|
|
1417
|
+ })
|
|
1418
|
+ } else {
|
|
1419
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1420
|
+ "failed_code": -10,
|
|
1421
|
+ "msg": res.Transreturnmessage,
|
|
1422
|
+ })
|
|
1423
|
+ return
|
|
1424
|
+ }
|
|
1425
|
+
|
|
1426
|
+ } else {
|
|
1427
|
+ //异地就医流程
|
|
1428
|
+ //异地走鉴权流程
|
|
1429
|
+ //authResult := CardAuth(number)
|
|
1430
|
+ //fmt.Println(authResult)
|
|
1431
|
+
|
|
1432
|
+ //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
|
|
1433
|
+ //if tempPatient.ID == patient_id {
|
|
1434
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
|
1435
|
+ var dat map[string]interface{}
|
|
1436
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
1437
|
+ fmt.Println(dat)
|
|
1438
|
+ } else {
|
|
1439
|
+ fmt.Println(err)
|
|
1440
|
+ }
|
|
1441
|
+
|
|
1442
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
1443
|
+
|
|
1444
|
+ var res ResultOne
|
|
1445
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1446
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1447
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1448
|
+ return
|
|
1449
|
+ }
|
|
1450
|
+ if res.Transreturncode == "00000000" {
|
|
1451
|
+ his := models.VMHisPatient{
|
|
1452
|
+ Name: name,
|
|
1453
|
+ Gender: gender,
|
|
1454
|
+ Birthday: birthUnix,
|
|
1455
|
+ MedicalTreatmentType: medical_care,
|
|
1456
|
+ IdType: certificates,
|
|
1457
|
+ IdCardNo: id_card,
|
|
1458
|
+ BalanceAccountsType: settlementValue,
|
|
1459
|
+ SocialType: social_type,
|
|
1460
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
1461
|
+ RegisterType: register_type,
|
|
1462
|
+ RegisterCost: registration_fee,
|
|
1463
|
+ TreatmentCost: medical_expenses,
|
|
1464
|
+ Status: 1,
|
|
1465
|
+ Ctime: time.Now().Unix(),
|
|
1466
|
+ Mtime: time.Now().Unix(),
|
|
1467
|
+ Iinfo: resp_result,
|
|
1468
|
+ PatientId: patient.ID,
|
|
1469
|
+ RecordDate: theTime.Unix(),
|
|
1470
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
1471
|
+ AdminUserId: admin_user_id,
|
|
1472
|
+ IsReturn: 1,
|
|
1473
|
+ IdCardType: id_card_type,
|
|
1474
|
+ Doctor: doctor,
|
|
1475
|
+ Departments: department,
|
|
1476
|
+ YiliaoNumber: yiliao_number,
|
|
1477
|
+ MzNumber: number,
|
|
1478
|
+ Number: mz_number,
|
|
1479
|
+ }
|
|
1480
|
+ service.CreateHisPatientTwo(&his)
|
|
1481
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1482
|
+ "msg": "挂号成功",
|
|
1483
|
+ })
|
|
1484
|
+ } else {
|
|
1485
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1486
|
+ "failed_code": -10,
|
|
1487
|
+ "msg": res.Transreturnmessage,
|
|
1488
|
+ })
|
|
1489
|
+ return
|
|
1490
|
+ }
|
|
1491
|
+
|
|
1492
|
+ }
|
|
1493
|
+
|
|
1494
|
+ } else { //异地卡流程
|
|
1495
|
+ //readCardBasResult := ReadCardBasHSM(number)
|
|
1496
|
+ //fmt.Println(readCardBasResult)
|
|
1497
|
+ //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
|
|
1498
|
+ if is_yidi == 1 { //1本地就医
|
|
1499
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
|
1500
|
+ var dat map[string]interface{}
|
|
1501
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
1502
|
+ fmt.Println(dat)
|
|
1503
|
+ } else {
|
|
1504
|
+ fmt.Println(err)
|
|
1505
|
+ }
|
|
1506
|
+
|
|
1507
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
1508
|
+
|
|
1509
|
+ var res ResultOne
|
|
1510
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1511
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1512
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1513
|
+ return
|
|
1514
|
+ }
|
|
1515
|
+ if res.Transreturncode == "00000000" {
|
|
1516
|
+ his := models.VMHisPatient{
|
|
1517
|
+ Name: name,
|
|
1518
|
+ Gender: gender,
|
|
1519
|
+ Birthday: birthUnix,
|
|
1520
|
+ MedicalTreatmentType: medical_care,
|
|
1521
|
+ IdType: certificates,
|
|
1522
|
+ IdCardNo: id_card,
|
|
1523
|
+ BalanceAccountsType: settlementValue,
|
|
1524
|
+ SocialType: social_type,
|
|
1525
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
1526
|
+ RegisterType: register_type,
|
|
1527
|
+ RegisterCost: registration_fee,
|
|
1528
|
+ TreatmentCost: medical_expenses,
|
|
1529
|
+ Status: 1,
|
|
1530
|
+ Ctime: time.Now().Unix(),
|
|
1531
|
+ Mtime: time.Now().Unix(),
|
|
1532
|
+ Iinfo: resp_result,
|
|
1533
|
+ PatientId: patient.ID,
|
|
1534
|
+ RecordDate: theTime.Unix(),
|
|
1535
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
1536
|
+ AdminUserId: admin_user_id,
|
|
1537
|
+ IsReturn: 1,
|
|
1538
|
+ IdCardType: id_card_type,
|
|
1539
|
+ Doctor: doctor,
|
|
1540
|
+ Departments: department,
|
|
1541
|
+ YiliaoNumber: yiliao_number,
|
|
1542
|
+ MzNumber: number,
|
|
1543
|
+ Number: mz_number,
|
|
1544
|
+ }
|
|
1545
|
+ service.CreateHisPatientTwo(&his)
|
|
1546
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1547
|
+ "msg": "挂号成功",
|
|
1548
|
+ })
|
|
1549
|
+ } else {
|
|
1550
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1551
|
+ "failed_code": -10,
|
|
1552
|
+ "msg": res.Transreturnmessage,
|
|
1553
|
+ })
|
|
1554
|
+ return
|
|
1555
|
+ }
|
|
1556
|
+
|
|
1557
|
+ } else { //异地就医需要走鉴权流程
|
|
1558
|
+ //authResult := CardAuth(number)
|
|
1559
|
+ //fmt.Println(authResult)
|
|
1560
|
+ resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
|
|
1561
|
+ var dat map[string]interface{}
|
|
1562
|
+ if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
|
|
1563
|
+ fmt.Println(dat)
|
|
1564
|
+ } else {
|
|
1565
|
+ fmt.Println(err)
|
|
1566
|
+ }
|
|
1567
|
+
|
|
1568
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
1569
|
+
|
|
1570
|
+ var res ResultOne
|
|
1571
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1572
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1573
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1574
|
+ return
|
|
1575
|
+ }
|
|
1576
|
+ if res.Transreturncode == "00000000" {
|
|
1577
|
+ his := models.VMHisPatient{
|
|
1578
|
+ Name: name,
|
|
1579
|
+ Gender: gender,
|
|
1580
|
+ Birthday: birthUnix,
|
|
1581
|
+ MedicalTreatmentType: medical_care,
|
|
1582
|
+ IdType: certificates,
|
|
1583
|
+ IdCardNo: id_card,
|
|
1584
|
+ BalanceAccountsType: settlementValue,
|
|
1585
|
+ SocialType: social_type,
|
|
1586
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
1587
|
+ RegisterType: register_type,
|
|
1588
|
+ RegisterCost: registration_fee,
|
|
1589
|
+ TreatmentCost: medical_expenses,
|
|
1590
|
+ Status: 1,
|
|
1591
|
+ Ctime: time.Now().Unix(),
|
|
1592
|
+ Mtime: time.Now().Unix(),
|
|
1593
|
+ Iinfo: resp_result,
|
|
1594
|
+ PatientId: patient.ID,
|
|
1595
|
+ RecordDate: theTime.Unix(),
|
|
1596
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
1597
|
+ AdminUserId: admin_user_id,
|
|
1598
|
+ IsReturn: 1,
|
|
1599
|
+ IdCardType: id_card_type,
|
|
1600
|
+ Doctor: doctor,
|
|
1601
|
+ Departments: department,
|
|
1602
|
+ YiliaoNumber: yiliao_number,
|
|
1603
|
+ MzNumber: number,
|
|
1604
|
+ Number: mz_number,
|
|
1605
|
+ }
|
|
1606
|
+ service.CreateHisPatientTwo(&his)
|
|
1607
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1608
|
+ "msg": "挂号成功",
|
|
1609
|
+ })
|
|
1610
|
+ } else {
|
|
1611
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1612
|
+ "failed_code": -10,
|
|
1613
|
+ "msg": res.Transreturnmessage,
|
|
1614
|
+ })
|
|
1615
|
+ return
|
|
1616
|
+ }
|
|
1617
|
+
|
|
1618
|
+ }
|
|
1619
|
+ }
|
|
1620
|
+ } else {
|
|
1621
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
1622
|
+ return
|
|
1623
|
+ }
|
|
1624
|
+ } else {
|
|
1625
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
1626
|
+ return
|
|
1627
|
+ }
|
|
1628
|
+}
|
|
1629
|
+
|
|
1630
|
+//func (c *SZHisApiController) GetRegisterInfo() {
|
1236
|
1631
|
// adminInfo := c.GetAdminUserInfo()
|
1237
|
1632
|
// miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
|
1238
|
1633
|
// month := time.Unix(1557042972, 0).Format("1")
|