csx 4 年之前
父節點
當前提交
441fb39a93
共有 2 個文件被更改,包括 87 次插入30 次删除
  1. 84 30
      controllers/his_api_controller.go
  2. 3 0
      enums/error_code.go

+ 84 - 30
controllers/his_api_controller.go 查看文件

151
 	adminUser := c.GetAdminUserInfo()
151
 	adminUser := c.GetAdminUserInfo()
152
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
152
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
153
 
153
 
154
-	//r := CardInit()
155
-	//fmt.Println(r)
154
+	r := CardInit()
155
+	fmt.Println(r)
156
 	//if r == 0 {
156
 	//if r == 0 {
157
 	switch id_card_type {
157
 	switch id_card_type {
158
 	case 1:
158
 	case 1:
666
 	WarnMsg     interface{} `json:"warn_msg"`
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
 type Custom struct {
685
 type Custom struct {
670
 	DetItemFeeSumamt string
686
 	DetItemFeeSumamt string
671
 	Cut              string
687
 	Cut              string
1357
 					setlDetail, _ := json.Marshal(res.Output.Setldetail)
1373
 					setlDetail, _ := json.Marshal(res.Output.Setldetail)
1358
 					detailStr := string(setlDetail)
1374
 					detailStr := string(setlDetail)
1359
 					order.SetlDetail = detailStr
1375
 					order.SetlDetail = detailStr
1360
-					err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1376
+					err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1361
 					err = service.UpDateOrder(order)
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
 					} else {
1416
 					} else {
1371
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
1372
-						return
1417
+						fmt.Println(err)
1373
 					}
1418
 					}
1374
 
1419
 
1375
 				}
1420
 				}
1413
 func (c *HisApiController) GetSettleInfo() {
1458
 func (c *HisApiController) GetSettleInfo() {
1414
 	id, _ := c.GetInt64("id")
1459
 	id, _ := c.GetInt64("id")
1415
 	record_time := c.GetString("record_time")
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
 	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
1470
 	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
1417
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1471
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1418
-	order_id, _ := c.GetInt64("order_id")
1419
 
1472
 
1420
 	timeLayout := "2006-01-02"
1473
 	timeLayout := "2006-01-02"
1421
 	loc, _ := time.LoadLocation("Local")
1474
 	loc, _ := time.LoadLocation("Local")
1429
 
1482
 
1430
 	var prescriptions []*models.HisPrescription
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
 	if settle_accounts_type == 1 { //日结
1489
 	if settle_accounts_type == 1 { //日结
1433
 		prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
1490
 		prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
1491
+		data["pre"] = prescriptions
1434
 
1492
 
1435
 	} else { //月结
1493
 	} else { //月结
1436
 		start_time_str := c.GetString("start_time")
1494
 		start_time_str := c.GetString("start_time")
1443
 			return
1501
 			return
1444
 		}
1502
 		}
1445
 		recordStartTime := theStartTime.Unix()
1503
 		recordStartTime := theStartTime.Unix()
1504
+		start_time = recordStartTime
1446
 		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
1505
 		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
1447
 		if err != nil {
1506
 		if err != nil {
1448
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1507
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1449
 			return
1508
 			return
1450
 		}
1509
 		}
1451
 		recordEndTime := theEndTime.Unix()
1510
 		recordEndTime := theEndTime.Unix()
1511
+		end_time = recordEndTime
1452
 		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
1512
 		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
1513
+		data["pre"] = prescriptions
1453
 
1514
 
1454
 	}
1515
 	}
1455
 
1516
 
1456
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1517
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1518
+
1457
 	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
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
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1525
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1459
 	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
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
 	strconv.FormatInt(his.PatientId, 10)
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
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1529
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1475
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1530
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1531
+
1476
 		var total float64
1532
 		var total float64
1477
 		for _, item := range prescriptions {
1533
 		for _, item := range prescriptions {
1478
 			if item.Type == 1 { //药品
1534
 			if item.Type == 1 { //药品
1498
 		json.Unmarshal([]byte(his.Iinfo), &rf)
1554
 		json.Unmarshal([]byte(his.Iinfo), &rf)
1499
 		psn_no := his.PsnNo
1555
 		psn_no := his.PsnNo
1500
 		mdtrt_id := his.Number
1556
 		mdtrt_id := his.Number
1501
-		chrg_bchno := order.Number
1557
+		chrg_bchno := chrg_bchno
1502
 		cert_no := his.Certno
1558
 		cert_no := his.Certno
1503
 		insutype := rf[0].Insutype
1559
 		insutype := rf[0].Insutype
1504
 
1560
 
1505
 		if his.IdCardType == 1 {
1561
 		if his.IdCardType == 1 {
1506
 			cert_no = his.MedicalInsuranceNumber
1562
 			cert_no = his.MedicalInsuranceNumber
1507
-
1508
 		} else {
1563
 		} else {
1509
 			cert_no = his.Certno
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
 			insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
1568
 			insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
1514
 			"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
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
 			miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
1570
 			miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
1516
-
1517
 		resp, requestErr := http.Get(api)
1571
 		resp, requestErr := http.Get(api)
1518
 		if requestErr != nil {
1572
 		if requestErr != nil {
1519
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1573
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1602
 			setlDetail, _ := json.Marshal(res.Output.Setldetail)
1656
 			setlDetail, _ := json.Marshal(res.Output.Setldetail)
1603
 			detailStr := string(setlDetail)
1657
 			detailStr := string(setlDetail)
1604
 			order.SetlDetail = detailStr
1658
 			order.SetlDetail = detailStr
1605
-			err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1659
+			err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1606
 			err = service.UpDateOrder(order)
1660
 			err = service.UpDateOrder(order)
1661
+
1607
 			if err == nil {
1662
 			if err == nil {
1608
 				c.ServeSuccessJSON(map[string]interface{}{
1663
 				c.ServeSuccessJSON(map[string]interface{}{
1609
 					"msg": "结算成功",
1664
 					"msg": "结算成功",
1613
 				return
1668
 				return
1614
 			}
1669
 			}
1615
 		}
1670
 		}
1616
-
1617
 	}
1671
 	}
1618
 }
1672
 }
1619
 
1673
 

+ 3 - 0
enums/error_code.go 查看文件

238
 	ErrorCodeHisFailedException = 20076
238
 	ErrorCodeHisFailedException = 20076
239
 
239
 
240
 	ErrorCodeHisOrderNoExistParamWrong = 30000
240
 	ErrorCodeHisOrderNoExistParamWrong = 30000
241
+
242
+	ErrorCodePreSettleFaildParamWrong = 30001
241
 )
243
 )
242
 
244
 
243
 var ErrCodeMsgs = map[int]string{
245
 var ErrCodeMsgs = map[int]string{
458
 
460
 
459
 	ErrorCodeHisFailedException: "获取人员信息失败",
461
 	ErrorCodeHisFailedException: "获取人员信息失败",
460
 
462
 
463
+	ErrorCodePreSettleFaildParamWrong:  "预结算失败",
461
 	ErrorCodeHisOrderNoExistParamWrong: "订单不存在",
464
 	ErrorCodeHisOrderNoExistParamWrong: "订单不存在",
462
 }
465
 }
463
 
466