|
@@ -151,8 +151,8 @@ func (c *HisApiController) Sscard() {
|
151
|
151
|
adminUser := c.GetAdminUserInfo()
|
152
|
152
|
miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
153
|
153
|
|
154
|
|
- //r := CardInit()
|
155
|
|
- //fmt.Println(r)
|
|
154
|
+ r := CardInit()
|
|
155
|
+ fmt.Println(r)
|
156
|
156
|
//if r == 0 {
|
157
|
157
|
switch id_card_type {
|
158
|
158
|
case 1:
|
|
@@ -666,6 +666,22 @@ type ResultEleven struct {
|
666
|
666
|
WarnMsg interface{} `json:"warn_msg"`
|
667
|
667
|
}
|
668
|
668
|
|
|
669
|
+type ResultTwelve struct {
|
|
670
|
+ Cainfo string `json:"cainfo"`
|
|
671
|
+ ErrMsg string `json:"err_msg"`
|
|
672
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
673
|
+ Infcode int64 `json:"infcode"`
|
|
674
|
+ Output struct {
|
|
675
|
+ MdtrtId string `json:"mdtrt_id"`
|
|
676
|
+ ChrgBchno string `json:"chrg_bchno"`
|
|
677
|
+ PsnNo string `json:"psn_no"`
|
|
678
|
+ } `json:"output"`
|
|
679
|
+ RefmsgTime string `json:"refmsg_time"`
|
|
680
|
+ RespondTime string `json:"respond_time"`
|
|
681
|
+ Signtype interface{} `json:"signtype"`
|
|
682
|
+ WarnMsg interface{} `json:"warn_msg"`
|
|
683
|
+}
|
|
684
|
+
|
669
|
685
|
type Custom struct {
|
670
|
686
|
DetItemFeeSumamt string
|
671
|
687
|
Cut string
|
|
@@ -1357,19 +1373,48 @@ func (c *HisApiController) GetUploadInfo() {
|
1357
|
1373
|
setlDetail, _ := json.Marshal(res.Output.Setldetail)
|
1358
|
1374
|
detailStr := string(setlDetail)
|
1359
|
1375
|
order.SetlDetail = detailStr
|
1360
|
|
- err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
1376
|
+ err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
1361
|
1377
|
err = service.UpDateOrder(order)
|
1362
|
1378
|
|
1363
|
1379
|
//订单确认
|
1364
|
|
- service.Gdyb6201(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, order)
|
1365
|
|
-
|
1366
|
|
- if err == nil {
|
1367
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1368
|
|
- "msg": "预结算成功",
|
1369
|
|
- })
|
|
1380
|
+ result := service.Gdyb6201(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, order)
|
|
1381
|
+
|
|
1382
|
+ var dat map[string]interface{}
|
|
1383
|
+ if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
|
1384
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
1385
|
+ var res ResultTwelve
|
|
1386
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1387
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1388
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1389
|
+ return
|
|
1390
|
+ }
|
|
1391
|
+ if res.Infcode == 0 {
|
|
1392
|
+ if err == nil {
|
|
1393
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1394
|
+ "msg": "预结算成功",
|
|
1395
|
+ })
|
|
1396
|
+ } else {
|
|
1397
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
|
|
1398
|
+ return
|
|
1399
|
+ }
|
|
1400
|
+
|
|
1401
|
+ } else {
|
|
1402
|
+ adminUser := c.GetAdminUserInfo()
|
|
1403
|
+ errlog := &models.HisOrderError{
|
|
1404
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1405
|
+ Ctime: time.Now().Unix(),
|
|
1406
|
+ Mtime: time.Now().Unix(),
|
|
1407
|
+ ErrMsg: res.ErrMsg,
|
|
1408
|
+ Status: 1,
|
|
1409
|
+ PatientId: id,
|
|
1410
|
+ RecordTime: recordDateTime,
|
|
1411
|
+ Stage: 7,
|
|
1412
|
+ }
|
|
1413
|
+ service.CreateErrMsgLog(errlog)
|
|
1414
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
1415
|
+ }
|
1370
|
1416
|
} else {
|
1371
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
|
1372
|
|
- return
|
|
1417
|
+ fmt.Println(err)
|
1373
|
1418
|
}
|
1374
|
1419
|
|
1375
|
1420
|
}
|
|
@@ -1413,9 +1458,17 @@ func (c *HisApiController) GetUploadInfo() {
|
1413
|
1458
|
func (c *HisApiController) GetSettleInfo() {
|
1414
|
1459
|
id, _ := c.GetInt64("id")
|
1415
|
1460
|
record_time := c.GetString("record_time")
|
|
1461
|
+ //pay_way, _ := c.GetInt64("pay_way")
|
|
1462
|
+ //pay_price, _ := c.GetFloat("pay_price")
|
|
1463
|
+ //pay_card_no := c.GetString("pay_card_no")
|
|
1464
|
+ //discount_price, _ := c.GetFloat("discount_price")
|
|
1465
|
+ //preferential_price, _ := c.GetFloat("preferential_price")
|
|
1466
|
+ //reality_price, _ := c.GetFloat("reality_price")
|
|
1467
|
+ //found_price, _ := c.GetFloat("found_price")
|
|
1468
|
+ //medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
|
|
1469
|
+ //private_price, _ := c.GetFloat("private_price")
|
1416
|
1470
|
settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
1417
|
1471
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
1418
|
|
- order_id, _ := c.GetInt64("order_id")
|
1419
|
1472
|
|
1420
|
1473
|
timeLayout := "2006-01-02"
|
1421
|
1474
|
loc, _ := time.LoadLocation("Local")
|
|
@@ -1429,8 +1482,13 @@ func (c *HisApiController) GetSettleInfo() {
|
1429
|
1482
|
|
1430
|
1483
|
var prescriptions []*models.HisPrescription
|
1431
|
1484
|
|
|
1485
|
+ var start_time int64
|
|
1486
|
+ var end_time int64
|
|
1487
|
+
|
|
1488
|
+ data := make(map[string]interface{})
|
1432
|
1489
|
if settle_accounts_type == 1 { //日结
|
1433
|
1490
|
prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
|
1491
|
+ data["pre"] = prescriptions
|
1434
|
1492
|
|
1435
|
1493
|
} else { //月结
|
1436
|
1494
|
start_time_str := c.GetString("start_time")
|
|
@@ -1443,36 +1501,34 @@ func (c *HisApiController) GetSettleInfo() {
|
1443
|
1501
|
return
|
1444
|
1502
|
}
|
1445
|
1503
|
recordStartTime := theStartTime.Unix()
|
|
1504
|
+ start_time = recordStartTime
|
1446
|
1505
|
theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
1447
|
1506
|
if err != nil {
|
1448
|
1507
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1449
|
1508
|
return
|
1450
|
1509
|
}
|
1451
|
1510
|
recordEndTime := theEndTime.Unix()
|
|
1511
|
+ end_time = recordEndTime
|
1452
|
1512
|
prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
|
|
1513
|
+ data["pre"] = prescriptions
|
1453
|
1514
|
|
1454
|
1515
|
}
|
1455
|
1516
|
|
1456
|
1517
|
roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
|
|
1518
|
+
|
1457
|
1519
|
his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
|
1520
|
+ timestamp := time.Now().Unix()
|
|
1521
|
+ tempTime := time.Unix(timestamp, 0)
|
|
1522
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
1523
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
1524
|
+ chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
1458
|
1525
|
miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
1459
|
1526
|
patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
1460
|
|
- //department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
1461
|
|
- order, err := service.GetHisOrderByID(order_id)
|
1462
|
|
-
|
1463
|
|
- if err != nil {
|
1464
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
|
1465
|
|
- return
|
1466
|
|
- }
|
1467
|
|
-
|
1468
|
1527
|
strconv.FormatInt(his.PatientId, 10)
|
1469
|
1528
|
|
1470
|
|
- var ids []int64
|
1471
|
|
- for _, item := range prescriptions {
|
1472
|
|
- ids = append(ids, item.ID)
|
1473
|
|
- }
|
1474
|
1529
|
config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
1475
|
1530
|
if config.IsOpen == 1 { //对接了医保,走医保流程
|
|
1531
|
+
|
1476
|
1532
|
var total float64
|
1477
|
1533
|
for _, item := range prescriptions {
|
1478
|
1534
|
if item.Type == 1 { //药品
|
|
@@ -1498,22 +1554,20 @@ func (c *HisApiController) GetSettleInfo() {
|
1498
|
1554
|
json.Unmarshal([]byte(his.Iinfo), &rf)
|
1499
|
1555
|
psn_no := his.PsnNo
|
1500
|
1556
|
mdtrt_id := his.Number
|
1501
|
|
- chrg_bchno := order.Number
|
|
1557
|
+ chrg_bchno := chrg_bchno
|
1502
|
1558
|
cert_no := his.Certno
|
1503
|
1559
|
insutype := rf[0].Insutype
|
1504
|
1560
|
|
1505
|
1561
|
if his.IdCardType == 1 {
|
1506
|
1562
|
cert_no = his.MedicalInsuranceNumber
|
1507
|
|
-
|
1508
|
1563
|
} else {
|
1509
|
1564
|
cert_no = his.Certno
|
1510
|
1565
|
}
|
1511
|
1566
|
|
1512
|
|
- api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
|
|
1567
|
+ api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
1513
|
1568
|
insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
1514
|
1569
|
"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
|
1515
|
1570
|
miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
|
1516
|
|
-
|
1517
|
1571
|
resp, requestErr := http.Get(api)
|
1518
|
1572
|
if requestErr != nil {
|
1519
|
1573
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -1602,8 +1656,9 @@ func (c *HisApiController) GetSettleInfo() {
|
1602
|
1656
|
setlDetail, _ := json.Marshal(res.Output.Setldetail)
|
1603
|
1657
|
detailStr := string(setlDetail)
|
1604
|
1658
|
order.SetlDetail = detailStr
|
1605
|
|
- err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
1659
|
+ err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
1606
|
1660
|
err = service.UpDateOrder(order)
|
|
1661
|
+
|
1607
|
1662
|
if err == nil {
|
1608
|
1663
|
c.ServeSuccessJSON(map[string]interface{}{
|
1609
|
1664
|
"msg": "结算成功",
|
|
@@ -1613,7 +1668,6 @@ func (c *HisApiController) GetSettleInfo() {
|
1613
|
1668
|
return
|
1614
|
1669
|
}
|
1615
|
1670
|
}
|
1616
|
|
-
|
1617
|
1671
|
}
|
1618
|
1672
|
}
|
1619
|
1673
|
|