Browse Source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 3 years ago
parent
commit
9d81bb0c58
1 changed files with 116 additions and 19 deletions
  1. 116 19
      controllers/sg/his_api_controller.go

+ 116 - 19
controllers/sg/his_api_controller.go View File

@@ -527,16 +527,16 @@ type ResultTwo struct {
527 527
 		} `json:"baseinfo"`
528 528
 		Idetinfo []interface{} `json:"idetinfo"`
529 529
 		Iinfo    []struct {
530
-			Balc                   float64     `json:"balc"`
531
-			CvlservFlag            string      `json:"cvlserv_flag"`
532
-			EmpName                string      `json:"emp_name"`
533
-			InsuplcAdmdvs          string      `json:"insuplc_admdvs"`
534
-			Insutype               string      `json:"insutype"`
535
-			PausInsuDansuplcAdmdvs string      `json:"paus_insu_dansuplc_admdvs"`
536
-			PausInsuDate           interface{} `json:"paus_insu_date"`
537
-			PsnInsuDate            string      `json:"psn_insu_date"`
538
-			PsnInsuStas            string      `json:"psn_insu_stas"`
539
-			PsnType                string      `json:"psn_type"`
530
+			Balc                   float64 `json:"balc"`
531
+			CvlservFlag            string  `json:"cvlserv_flag"`
532
+			EmpName                string  `json:"emp_name"`
533
+			InsuplcAdmdvs          string  `json:"insuplc_admdvs"`
534
+			Insutype               string  `json:"insutype"`
535
+			PausInsuDansuplcAdmdvs string  `json:"paus_insu_dansuplc_admdvs"`
536
+			PausInsuDate           string  `json:"paus_insu_date"`
537
+			PsnInsuDate            string  `json:"psn_insu_date"`
538
+			PsnInsuStas            string  `json:"psn_insu_stas"`
539
+			PsnType                string  `json:"psn_type"`
540 540
 		} `json:"insuinfo"`
541 541
 	} `json:"output"`
542 542
 	RefmsgTime  string      `json:"refmsg_time"`
@@ -595,7 +595,16 @@ type ResultFour struct {
595 595
 	WarnMsg     string `json:"warn_msg"`
596 596
 }
597 597
 type ResultFive struct {
598
-	Insutype string `json:"insutype"`
598
+	Balc                   float64 `json:"balc"`
599
+	CvlservFlag            string  `json:"cvlserv_flag"`
600
+	EmpName                string  `json:"emp_name"`
601
+	InsuplcAdmdvs          string  `json:"insuplc_admdvs"`
602
+	Insutype               string  `json:"insutype"`
603
+	PausInsuDansuplcAdmdvs string  `json:"paus_insu_dansuplc_admdvs"`
604
+	PausInsuDate           string  `json:"paus_insu_date"`
605
+	PsnInsuDate            string  `json:"psn_insu_date"`
606
+	PsnInsuStas            string  `json:"psn_insu_stas"`
607
+	PsnType                string  `json:"psn_type"`
599 608
 }
600 609
 type ResultSix struct {
601 610
 	Cainfo      interface{} `json:"cainfo"`
@@ -976,9 +985,41 @@ func (c *HisApiController) GetRegisterInfo() {
976 985
 				IdCardNo = patient.IdCardNo
977 986
 			}
978 987
 
988
+			var insutypes []string
989
+
990
+			var insutype string
991
+			var is390 int = 0
992
+			var is310 int = 0
993
+
994
+			for _, item := range res.Output.Iinfo {
995
+				if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
996
+					insutypes = append(insutypes, item.Insutype)
997
+				}
998
+			}
999
+
1000
+			if len(insutypes) == 1 {
1001
+				insutype = insutypes[0]
1002
+			} else {
1003
+				for _, i := range insutypes {
1004
+					if i == "390" {
1005
+						is390 = 1
1006
+					}
1007
+
1008
+					if i == "310" {
1009
+						is310 = 1
1010
+					}
1011
+				}
1012
+			}
1013
+			if is390 == 1 {
1014
+				insutype = "390"
1015
+			}
1016
+			if is310 == 1 {
1017
+				insutype = "310"
1018
+			}
1019
+
979 1020
 			if count <= 0 {
980 1021
 				api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
981
-					res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1022
+					insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
982 1023
 					"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
983 1024
 					"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
984 1025
 				resp, requestErr := http.Get(api)
@@ -1021,8 +1062,13 @@ func (c *HisApiController) GetRegisterInfo() {
1021 1062
 						Stage:      2,
1022 1063
 					}
1023 1064
 					service.CreateErrMsgLog(errlog)
1024
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
1065
+					c.ServeSuccessJSON(map[string]interface{}{
1066
+						"failed_code": -10,
1067
+						"msg":         res.ErrMsg,
1068
+					})
1025 1069
 					return
1070
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
1071
+					//return
1026 1072
 				}
1027 1073
 
1028 1074
 				his.Number = res.Output.Data.MdtrtID
@@ -1079,9 +1125,13 @@ func (c *HisApiController) GetRegisterInfo() {
1079 1125
 							Stage:      3,
1080 1126
 						}
1081 1127
 						service.CreateErrMsgLog(errlog)
1082
-
1083
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
1128
+						c.ServeSuccessJSON(map[string]interface{}{
1129
+							"failed_code": -10,
1130
+							"msg":         res.ErrMsg,
1131
+						})
1084 1132
 						return
1133
+						//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
1134
+						//return
1085 1135
 					}
1086 1136
 
1087 1137
 					c.ServeSuccessJSON(map[string]interface{}{
@@ -1110,8 +1160,14 @@ func (c *HisApiController) GetRegisterInfo() {
1110 1160
 				Stage:      1,
1111 1161
 			}
1112 1162
 			service.CreateErrMsgLog(errlog)
1113
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
1163
+
1164
+			c.ServeSuccessJSON(map[string]interface{}{
1165
+				"failed_code": -10,
1166
+				"msg":         res.ErrMsg,
1167
+			})
1114 1168
 			return
1169
+
1170
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
1115 1171
 		}
1116 1172
 	} else {
1117 1173
 		timeStr := time.Now().Format("2006-01-02")
@@ -1402,8 +1458,39 @@ func (c *HisApiController) GetUploadInfo() {
1402 1458
 				mdtrt_id := his.Number
1403 1459
 				chrg_bchno := chrg_bchno
1404 1460
 				cert_no := his.Certno
1405
-				insutype := rf[0].Insutype
1406 1461
 
1462
+				var insutypes []string
1463
+
1464
+				var insutype string
1465
+				var is390 int = 0
1466
+				var is310 int = 0
1467
+
1468
+				for _, item := range rf {
1469
+					if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
1470
+						insutypes = append(insutypes, item.Insutype)
1471
+					}
1472
+				}
1473
+
1474
+				if len(insutypes) == 1 {
1475
+					insutype = insutypes[0]
1476
+				} else {
1477
+					for _, i := range insutypes {
1478
+						if i == "390" {
1479
+							is390 = 1
1480
+						}
1481
+
1482
+						if i == "310" {
1483
+							is310 = 1
1484
+						}
1485
+					}
1486
+				}
1487
+				if is390 == 1 {
1488
+					insutype = "390"
1489
+				}
1490
+
1491
+				if is310 == 1 {
1492
+					insutype = "310"
1493
+				}
1407 1494
 				if his.IdCardType == 1 {
1408 1495
 					cert_no = his.MedicalInsuranceNumber
1409 1496
 
@@ -1456,8 +1543,13 @@ func (c *HisApiController) GetUploadInfo() {
1456 1543
 						RecordTime: recordDateTime,
1457 1544
 						Stage:      6,
1458 1545
 					}
1546
+					c.ServeSuccessJSON(map[string]interface{}{
1547
+						"failed_code": -10,
1548
+						"msg":         res.ErrMsg,
1549
+					})
1550
+					return
1459 1551
 					service.CreateErrMsgLog(errlog)
1460
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1552
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1461 1553
 					return
1462 1554
 				} else {
1463 1555
 					order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
@@ -1546,8 +1638,13 @@ func (c *HisApiController) GetUploadInfo() {
1546 1638
 				Stage:      4,
1547 1639
 			}
1548 1640
 			service.CreateErrMsgLog(errlog)
1549
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
1641
+			c.ServeSuccessJSON(map[string]interface{}{
1642
+				"failed_code": -10,
1643
+				"msg":         res.ErrMsg,
1644
+			})
1550 1645
 			return
1646
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
1647
+			//return
1551 1648
 		}
1552 1649
 
1553 1650
 	} else {