浏览代码

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

csx 2 年前
父节点
当前提交
dea76aed45
共有 3 个文件被更改,包括 59 次插入49 次删除
  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 查看文件

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

+ 56 - 46
controllers/sg/his_api_controller.go 查看文件

6133
 	pay_way, _ := c.GetInt64("pay_way")
6133
 	pay_way, _ := c.GetInt64("pay_way")
6134
 	pay_price, _ := c.GetFloat("pay_price")
6134
 	pay_price, _ := c.GetFloat("pay_price")
6135
 	pay_card_no := c.GetString("pay_card_no")
6135
 	pay_card_no := c.GetString("pay_card_no")
6136
-	token := c.GetString("token")
6137
 
6136
 
6138
 	discount_price, _ := c.GetFloat("discount_price")
6137
 	discount_price, _ := c.GetFloat("discount_price")
6139
 	preferential_price, _ := c.GetFloat("preferential_price")
6138
 	preferential_price, _ := c.GetFloat("preferential_price")
6306
 
6305
 
6307
 		} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
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
 			data := make(map[string]interface{})
6308
 			data := make(map[string]interface{})
6329
 			client := &http.Client{}
6309
 			client := &http.Client{}
6330
 			data["psn_no"] = his.PsnNo
6310
 			data["psn_no"] = his.PsnNo
6356
 
6336
 
6357
 				//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 +
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
 				//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
6338
 				//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
6359
-
6360
 			} else {
6339
 			} else {
6361
 				req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
6340
 				req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
6362
 
6341
 
7023
 										psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
7002
 										psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
7024
 									} else if his.IdCardType == 4 {
7003
 									} else if his.IdCardType == 4 {
7025
 										cert_no = his.Certno
7004
 										cert_no = his.Certno
7026
-										psn_info.VerifyNumber = token
7005
+										psn_info.VerifyNumber = psn_info.VerifyNumber
7027
 									}
7006
 									}
7028
 									var api string
7007
 									var api string
7029
 									if miConfig.MdtrtareaAdmvs == "320921" {
7008
 									if miConfig.MdtrtareaAdmvs == "320921" {
8400
 		var req *http.Request
8379
 		var req *http.Request
8401
 		if miConfig.MdtrtareaAdmvs == "320921" {
8380
 		if miConfig.MdtrtareaAdmvs == "320921" {
8402
 			req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
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
 		} else {
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
 		resp, _ := client.Do(req)
8394
 		resp, _ := client.Do(req)
8999
 								return
8982
 								return
9000
 							} else {
8983
 							} else {
9001
 								psn_info, _ := service.GetPsnByPatientId(his.PatientId)
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
 								bas := strings.Split(psn_info.CardInfo, "|")
8989
 								bas := strings.Split(psn_info.CardInfo, "|")
9005
 
8990
 
12978
 	return result
12963
 	return result
12979
 }
12964
 }
12980
 
12965
 
12981
-func (c *HisApiController) ReadEleCard() {
12982
-	id_card_type, _ := c.GetInt64("id_card_type")
12983
-	admin_user_id, _ := c.GetInt64("admin_user_id")
12984
-	fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
12985
-	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
12986
-	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
12966
+func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
12967
+	roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
12968
+	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
12987
 
12969
 
12988
 	if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
12970
 	if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
12989
 		var api string
12971
 		var api string
12990
 		if miConfig.MdtrtareaAdmvs == "320921" {
12972
 		if miConfig.MdtrtareaAdmvs == "320921" {
12991
 			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 +
12973
 			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 +
12992
-				"&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
12974
+				"&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
12993
 			fmt.Println(api)
12975
 			fmt.Println(api)
12994
 
12976
 
12995
 		} else {
12977
 		} else {
12996
 			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 +
12978
 			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 +
12997
-				"&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
12979
+				"&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
12998
 		}
12980
 		}
12999
 
12981
 
13000
 		resp, requestErr := http.Get(api)
12982
 		resp, requestErr := http.Get(api)
13001
 		if requestErr != nil {
12983
 		if requestErr != nil {
13002
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
12984
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13003
-			return
12985
+			return ""
13004
 		}
12986
 		}
13005
 
12987
 
13006
 		body, ioErr := ioutil.ReadAll(resp.Body)
12988
 		body, ioErr := ioutil.ReadAll(resp.Body)
13007
 		if ioErr != nil {
12989
 		if ioErr != nil {
13008
 			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
12990
 			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
13009
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
12991
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13010
-			return
12992
+			return ""
13011
 		}
12993
 		}
13012
 		var respJSON map[string]interface{}
12994
 		var respJSON map[string]interface{}
13013
 		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
12995
 		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
13014
 			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
12996
 			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
13015
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
12997
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13016
-			return
12998
+			return ""
13017
 		}
12999
 		}
13018
 		var status string
13000
 		var status string
13019
 		status = respJSON["data"].(map[string]interface{})["status"].(string)
13001
 		status = respJSON["data"].(map[string]interface{})["status"].(string)
13027
 			token = respJSON["data"].(map[string]interface{})["token"].(string)
13009
 			token = respJSON["data"].(map[string]interface{})["token"].(string)
13028
 			busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
13010
 			busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
13029
 			card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
13011
 			card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
13030
-
13031
 			fmt.Println(card_info)
13012
 			fmt.Println(card_info)
13032
 			fmt.Println(busi_card_info)
13013
 			fmt.Println(busi_card_info)
13033
 
13014
 
13037
 			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
13018
 			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
13038
 				utils.ErrorLog("解析失败:%v", err)
13019
 				utils.ErrorLog("解析失败:%v", err)
13039
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13020
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13040
-				return
13021
+				return ""
13041
 			}
13022
 			}
13042
 			res.ErrMsg = res10265.ErrMsg
13023
 			res.ErrMsg = res10265.ErrMsg
13043
 			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
13024
 			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
13045
 			res.Output = res10265.Output
13026
 			res.Output = res10265.Output
13046
 			res.InfRefmsgid = res10265.InfRefmsgid
13027
 			res.InfRefmsgid = res10265.InfRefmsgid
13047
 			if res.Infcode == 0 {
13028
 			if res.Infcode == 0 {
13048
-				c.ServeSuccessJSON(map[string]interface{}{
13049
-					"number": token,
13050
-				})
13029
+				patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
13030
+				if err == gorm.ErrRecordNotFound {
13031
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
13032
+					return ""
13033
+				} else if err != nil {
13034
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
13035
+					return ""
13036
+
13037
+				} else {
13038
+					Iinfos, _ := json.Marshal(res.Output.Iinfo)
13039
+					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
13040
+					infoStr := string(Iinfos)
13041
+					idetinfoStr := string(Idetinfos)
13042
+					psn := &models.HisPsn{
13043
+						PsnNo:        res.Output.Baseinfo.PsnNo,
13044
+						Age:          res.Output.Baseinfo.Age,
13045
+						PatientId:    patient.ID,
13046
+						Certno:       res.Output.Baseinfo.Certno,
13047
+						Brdy:         res.Output.Baseinfo.Brdy,
13048
+						Gend:         res.Output.Baseinfo.Gend,
13049
+						Naty:         res.Output.Baseinfo.Naty,
13050
+						PsnCertType:  res.Output.Baseinfo.PsnCertType,
13051
+						PsnName:      res.Output.Baseinfo.PsnName,
13052
+						Idetinfo:     idetinfoStr,
13053
+						Insuinfo:     infoStr,
13054
+						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
13055
+						CardInfo:     card_info,
13056
+						VerifyNumber: token,
13057
+					}
13058
+					service.CreateHisPsn(psn)
13059
+					return token
13060
+				}
13051
 			}
13061
 			}
13052
 		} else {
13062
 		} else {
13053
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13063
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13054
-			return
13064
+			return ""
13055
 		}
13065
 		}
13056
 	} else { //读卡失败
13066
 	} else { //读卡失败
13057
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13067
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13058
-		return
13068
+		return ""
13059
 	}
13069
 	}
13060
 }
13070
 }
13061
 
13071
 

+ 2 - 2
service/jsyb_service.go 查看文件

722
 			inputData["mdtrt_cert_type"] = "04"        // 就诊凭证类型
722
 			inputData["mdtrt_cert_type"] = "04"        // 就诊凭证类型
723
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
723
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
724
 		} else if id_card_type == 4 {
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
 		} else {
727
 		} else {
728
 			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
728
 			inputData["mdtrt_cert_type"] = "01"        // 就诊凭证类型
729
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
729
 			inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号