Sfoglia il codice sorgente

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

test_user 1 anno fa
parent
commit
a57f4c9aa6
3 ha cambiato i file con 59 aggiunte e 49 eliminazioni
  1. 1 1
      conf/app.conf
  2. 56 46
      controllers/sg/his_api_controller.go
  3. 2 2
      service/jsyb_service.go

+ 1 - 1
conf/app.conf Vedi File

@@ -45,7 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10088
48
+org_id = 10217
49 49
 mobile_token_expiration_second = 86400
50 50
 httpdomain = https://api.xt.kuyicloud.com
51 51
 sso_domain = https://sso.kuyicloud.com

+ 56 - 46
controllers/sg/his_api_controller.go Vedi File

@@ -6133,7 +6133,6 @@ func (c *HisApiController) GetUploadInfo() {
6133 6133
 	pay_way, _ := c.GetInt64("pay_way")
6134 6134
 	pay_price, _ := c.GetFloat("pay_price")
6135 6135
 	pay_card_no := c.GetString("pay_card_no")
6136
-	token := c.GetString("token")
6137 6136
 
6138 6137
 	discount_price, _ := c.GetFloat("discount_price")
6139 6138
 	preferential_price, _ := c.GetFloat("preferential_price")
@@ -6306,25 +6305,6 @@ func (c *HisApiController) GetUploadInfo() {
6306 6305
 
6307 6306
 		} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
6308 6307
 
6309
-			//江苏地区国家医保医疗类别
6310
-			//职工透析:医疗类别选特殊情况门诊9933
6311
-			//居民血透门慢: 医疗类别选门诊慢病1402
6312
-			//var med_type string
6313
-			//if his.Insutype == "310" {
6314
-			//	if reg_type == 14 {
6315
-			//		med_type = "9933"
6316
-			//	} else if reg_type == 11 {
6317
-			//		med_type = "11"
6318
-			//
6319
-			//	}
6320
-			//} else if his.Insutype == "390" {
6321
-			//	if reg_type == 14 {
6322
-			//		med_type = "1402"
6323
-			//	} else if reg_type == 11 {
6324
-			//		med_type = "11"
6325
-			//	}
6326
-			//}
6327
-
6328 6308
 			data := make(map[string]interface{})
6329 6309
 			client := &http.Client{}
6330 6310
 			data["psn_no"] = his.PsnNo
@@ -6356,7 +6336,6 @@ func (c *HisApiController) GetUploadInfo() {
6356 6336
 
6357 6337
 				//api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
6358 6338
 				//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
6359
-
6360 6339
 			} else {
6361 6340
 				req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
6362 6341
 
@@ -7023,7 +7002,7 @@ func (c *HisApiController) GetUploadInfo() {
7023 7002
 										psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
7024 7003
 									} else if his.IdCardType == 4 {
7025 7004
 										cert_no = his.Certno
7026
-										psn_info.VerifyNumber = token
7005
+										psn_info.VerifyNumber = psn_info.VerifyNumber
7027 7006
 									}
7028 7007
 									var api string
7029 7008
 									if miConfig.MdtrtareaAdmvs == "320921" {
@@ -8400,12 +8379,16 @@ func (c *HisApiController) GetPreUploadInfo() {
8400 8379
 		var req *http.Request
8401 8380
 		if miConfig.MdtrtareaAdmvs == "320921" {
8402 8381
 			req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
8403
-
8404
-			//api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
8405
-			//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
8406 8382
 		} else {
8407
-			req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
8408
-
8383
+			tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
8384
+			if len(tokens) > 0 {
8385
+				req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
8386
+			} else {
8387
+				c.ServeSuccessJSON(map[string]interface{}{
8388
+					"failed_code": -10,
8389
+					"msg":         "token无效",
8390
+				})
8391
+			}
8409 8392
 		}
8410 8393
 
8411 8394
 		resp, _ := client.Do(req)
@@ -8999,7 +8982,9 @@ func (c *HisApiController) GetPreUploadInfo() {
8999 8982
 								return
9000 8983
 							} else {
9001 8984
 								psn_info, _ := service.GetPsnByPatientId(his.PatientId)
9002
-								psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
8985
+								if his.IdCardType != 4 {
8986
+									psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
8987
+								}
9003 8988
 
9004 8989
 								bas := strings.Split(psn_info.CardInfo, "|")
9005 8990
 
@@ -12980,42 +12965,39 @@ func ConvertToString(src string, srcCode string, tagCode string) string {
12980 12965
 	return result
12981 12966
 }
12982 12967
 
12983
-func (c *HisApiController) ReadEleCard() {
12984
-	id_card_type, _ := c.GetInt64("id_card_type")
12985
-	admin_user_id, _ := c.GetInt64("admin_user_id")
12986
-	fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
12987
-	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
12988
-	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
12968
+func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
12969
+	roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
12970
+	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
12989 12971
 
12990 12972
 	if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
12991 12973
 		var api string
12992 12974
 		if miConfig.MdtrtareaAdmvs == "320921" {
12993 12975
 			api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
12994
-				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
12976
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
12995 12977
 			fmt.Println(api)
12996 12978
 
12997 12979
 		} else {
12998 12980
 			api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
12999
-				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
12981
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
13000 12982
 		}
13001 12983
 
13002 12984
 		resp, requestErr := http.Get(api)
13003 12985
 		if requestErr != nil {
13004 12986
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13005
-			return
12987
+			return ""
13006 12988
 		}
13007 12989
 
13008 12990
 		body, ioErr := ioutil.ReadAll(resp.Body)
13009 12991
 		if ioErr != nil {
13010 12992
 			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
13011 12993
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13012
-			return
12994
+			return ""
13013 12995
 		}
13014 12996
 		var respJSON map[string]interface{}
13015 12997
 		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
13016 12998
 			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
13017 12999
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13018
-			return
13000
+			return ""
13019 13001
 		}
13020 13002
 		var status string
13021 13003
 		status = respJSON["data"].(map[string]interface{})["status"].(string)
@@ -13029,7 +13011,6 @@ func (c *HisApiController) ReadEleCard() {
13029 13011
 			token = respJSON["data"].(map[string]interface{})["token"].(string)
13030 13012
 			busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
13031 13013
 			card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
13032
-
13033 13014
 			fmt.Println(card_info)
13034 13015
 			fmt.Println(busi_card_info)
13035 13016
 
@@ -13039,7 +13020,7 @@ func (c *HisApiController) ReadEleCard() {
13039 13020
 			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
13040 13021
 				utils.ErrorLog("解析失败:%v", err)
13041 13022
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13042
-				return
13023
+				return ""
13043 13024
 			}
13044 13025
 			res.ErrMsg = res10265.ErrMsg
13045 13026
 			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
@@ -13047,17 +13028,46 @@ func (c *HisApiController) ReadEleCard() {
13047 13028
 			res.Output = res10265.Output
13048 13029
 			res.InfRefmsgid = res10265.InfRefmsgid
13049 13030
 			if res.Infcode == 0 {
13050
-				c.ServeSuccessJSON(map[string]interface{}{
13051
-					"number": token,
13052
-				})
13031
+				patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
13032
+				if err == gorm.ErrRecordNotFound {
13033
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
13034
+					return ""
13035
+				} else if err != nil {
13036
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
13037
+					return ""
13038
+
13039
+				} else {
13040
+					Iinfos, _ := json.Marshal(res.Output.Iinfo)
13041
+					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
13042
+					infoStr := string(Iinfos)
13043
+					idetinfoStr := string(Idetinfos)
13044
+					psn := &models.HisPsn{
13045
+						PsnNo:        res.Output.Baseinfo.PsnNo,
13046
+						Age:          res.Output.Baseinfo.Age,
13047
+						PatientId:    patient.ID,
13048
+						Certno:       res.Output.Baseinfo.Certno,
13049
+						Brdy:         res.Output.Baseinfo.Brdy,
13050
+						Gend:         res.Output.Baseinfo.Gend,
13051
+						Naty:         res.Output.Baseinfo.Naty,
13052
+						PsnCertType:  res.Output.Baseinfo.PsnCertType,
13053
+						PsnName:      res.Output.Baseinfo.PsnName,
13054
+						Idetinfo:     idetinfoStr,
13055
+						Insuinfo:     infoStr,
13056
+						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
13057
+						CardInfo:     card_info,
13058
+						VerifyNumber: token,
13059
+					}
13060
+					service.CreateHisPsn(psn)
13061
+					return token
13062
+				}
13053 13063
 			}
13054 13064
 		} else {
13055 13065
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13056
-			return
13066
+			return ""
13057 13067
 		}
13058 13068
 	} else { //读卡失败
13059 13069
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13060
-		return
13070
+		return ""
13061 13071
 	}
13062 13072
 }
13063 13073
 

+ 2 - 2
service/jsyb_service.go Vedi File

@@ -722,8 +722,8 @@ func Jsyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
722 722
 			inputData["mdtrt_cert_type"] = "04"        // 就诊凭证类型
723 723
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
724 724
 		} else if id_card_type == 4 {
725
-			inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
726
-			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
725
+			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
726
+			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
727 727
 		} else {
728 728
 			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
729 729
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号