Browse Source

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

test_user 2 years ago
parent
commit
a57f4c9aa6
3 changed files with 59 additions and 49 deletions
  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 View File

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 View File

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
 
12980
 	return result
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
 	if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
12972
 	if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
12991
 		var api string
12973
 		var api string
12992
 		if miConfig.MdtrtareaAdmvs == "320921" {
12974
 		if miConfig.MdtrtareaAdmvs == "320921" {
12993
 			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 +
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
 			fmt.Println(api)
12977
 			fmt.Println(api)
12996
 
12978
 
12997
 		} else {
12979
 		} else {
12998
 			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 +
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
 		resp, requestErr := http.Get(api)
12984
 		resp, requestErr := http.Get(api)
13003
 		if requestErr != nil {
12985
 		if requestErr != nil {
13004
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
12986
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13005
-			return
12987
+			return ""
13006
 		}
12988
 		}
13007
 
12989
 
13008
 		body, ioErr := ioutil.ReadAll(resp.Body)
12990
 		body, ioErr := ioutil.ReadAll(resp.Body)
13009
 		if ioErr != nil {
12991
 		if ioErr != nil {
13010
 			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
12992
 			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
13011
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
12993
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13012
-			return
12994
+			return ""
13013
 		}
12995
 		}
13014
 		var respJSON map[string]interface{}
12996
 		var respJSON map[string]interface{}
13015
 		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
12997
 		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
13016
 			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
12998
 			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
13017
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
12999
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13018
-			return
13000
+			return ""
13019
 		}
13001
 		}
13020
 		var status string
13002
 		var status string
13021
 		status = respJSON["data"].(map[string]interface{})["status"].(string)
13003
 		status = respJSON["data"].(map[string]interface{})["status"].(string)
13029
 			token = respJSON["data"].(map[string]interface{})["token"].(string)
13011
 			token = respJSON["data"].(map[string]interface{})["token"].(string)
13030
 			busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
13012
 			busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
13031
 			card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
13013
 			card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
13032
-
13033
 			fmt.Println(card_info)
13014
 			fmt.Println(card_info)
13034
 			fmt.Println(busi_card_info)
13015
 			fmt.Println(busi_card_info)
13035
 
13016
 
13039
 			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
13020
 			if err := json.Unmarshal([]byte(result), &res10265); err != nil {
13040
 				utils.ErrorLog("解析失败:%v", err)
13021
 				utils.ErrorLog("解析失败:%v", err)
13041
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13022
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13042
-				return
13023
+				return ""
13043
 			}
13024
 			}
13044
 			res.ErrMsg = res10265.ErrMsg
13025
 			res.ErrMsg = res10265.ErrMsg
13045
 			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
13026
 			infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
13047
 			res.Output = res10265.Output
13028
 			res.Output = res10265.Output
13048
 			res.InfRefmsgid = res10265.InfRefmsgid
13029
 			res.InfRefmsgid = res10265.InfRefmsgid
13049
 			if res.Infcode == 0 {
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
 		} else {
13064
 		} else {
13055
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13065
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13056
-			return
13066
+			return ""
13057
 		}
13067
 		}
13058
 	} else { //读卡失败
13068
 	} else { //读卡失败
13059
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13069
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
13060
-		return
13070
+		return ""
13061
 	}
13071
 	}
13062
 }
13072
 }
13063
 
13073
 

+ 2 - 2
service/jsyb_service.go View File

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 // 就诊凭证编号