Просмотр исходного кода

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

csx 3 лет назад
Родитель
Сommit
0329384ea2
3 измененных файлов: 119 добавлений и 6 удалений
  1. 1 1
      conf/app.conf
  2. 62 1
      controllers/sg/his_api_controller.go
  3. 56 4
      service/gdyb_service.go

+ 1 - 1
conf/app.conf Просмотреть файл

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

+ 62 - 1
controllers/sg/his_api_controller.go Просмотреть файл

79
 
79
 
80
 	beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
80
 	beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
81
 
81
 
82
+	beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
83
+
82
 	//beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
84
 	//beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
83
 	//beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
85
 	//beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
84
 	//beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
86
 	//beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
85
 
87
 
88
+}
89
+func (c *HisApiController) CheckInsutype() {
90
+	his_patient_id, _ := c.GetInt64("his_patient_id")
91
+	admin_user_id, _ := c.GetInt64("admin_user_id")
92
+	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
93
+	his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
94
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
95
+	result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
96
+
97
+	var dat map[string]interface{}
98
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
99
+		fmt.Println(dat)
100
+	} else {
101
+		fmt.Println(err)
102
+	}
103
+
104
+	userJSONBytes, _ := json.Marshal(dat)
105
+	var res Result90100
106
+	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
107
+		utils.ErrorLog("解析失败:%v", err)
108
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
109
+		return
110
+	}
111
+
112
+	if res.Infcode != 0 {
113
+		c.ServeSuccessJSON(map[string]interface{}{
114
+			"failed_code": -10,
115
+			"msg":         res.ErrMsg,
116
+		})
117
+		return
118
+	} else {
119
+		fmt.Println(res)
120
+
121
+	}
122
+
86
 }
123
 }
87
 func (c *HisApiController) CheckCardPWD() {
124
 func (c *HisApiController) CheckCardPWD() {
88
 	card_pwd := c.GetString("card_pwd")
125
 	card_pwd := c.GetString("card_pwd")
1611
 	WarnInfo    interface{} `json:"warn_info"`
1648
 	WarnInfo    interface{} `json:"warn_info"`
1612
 }
1649
 }
1613
 
1650
 
1651
+type Result90100 struct {
1652
+	ErrMsg      string `json:"err_msg"`
1653
+	InfRefmsgid string `json:"inf_refmsgid"`
1654
+	Infcode     int64  `json:"infcode"`
1655
+	Output      struct {
1656
+		PoolareaNo          string `json:"poolarea_no"`
1657
+		PoolareaNoName      string `json:"poolarea_no_name"`
1658
+		Insutype            string `json:"insutype"`
1659
+		InsutypeName        string `json:"insutype_name"`
1660
+		ClctType            string `json:"clct_type"`
1661
+		ClctTypeName        string `json:"clct_type_name"`
1662
+		ClctFlag            string `json:"clct_flag"`
1663
+		ClctFlagName        string `json:"clct_flag_name"`
1664
+		AccrymBegn          string `json:"accrym_begn"`
1665
+		AccrymEnd           string `json:"accrym_end"`
1666
+		ClctTime            string `json:"clct_time"`
1667
+		ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
1668
+	} `json:"output"`
1669
+	RefmsgTime  string      `json:"refmsg_time"`
1670
+	RespondTime string      `json:"respond_time"`
1671
+	Signtype    interface{} `json:"signtype"`
1672
+	WarnInfo    interface{} `json:"warn_info"`
1673
+}
1674
+
1614
 type Custom struct {
1675
 type Custom struct {
1615
 	DetItemFeeSumamt string
1676
 	DetItemFeeSumamt string
1616
 	Cut              string
1677
 	Cut              string
4769
 			yiliao_leibie = "普通住院"
4830
 			yiliao_leibie = "普通住院"
4770
 			break
4831
 			break
4771
 		}
4832
 		}
4772
-
4833
+		x
4773
 		departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
4834
 		departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
4774
 
4835
 
4775
 		if res.Infcode == 0 {
4836
 		if res.Infcode == 0 {

+ 56 - 4
service/gdyb_service.go Просмотреть файл

162
 			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
162
 			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
163
 			inputData["card_sn"] = card_sn      // 卡识别码
163
 			inputData["card_sn"] = card_sn      // 卡识别码
164
 			inputData["certno"] = certNo        // 证件号码
164
 			inputData["certno"] = certNo        // 证件号码
165
-			inputData["psn_cert_type"] = "01"    // 人员证件类型
165
+			inputData["psn_cert_type"] = "01"   // 人员证件类型
166
 
166
 
167
 		} else {
167
 		} else {
168
 			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
168
 			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
169
 			inputData["card_sn"] = ""           // 卡识别码
169
 			inputData["card_sn"] = ""           // 卡识别码
170
 			inputData["certno"] = certNo        // 证件号码
170
 			inputData["certno"] = certNo        // 证件号码
171
-			inputData["psn_cert_type"] = "01"    // 人员证件类型
171
+			inputData["psn_cert_type"] = "01"   // 人员证件类型
172
 		}
172
 		}
173
 	}
173
 	}
174
 
174
 
2506
 	inputMessage["signtype"] = ""                                                               // 签名类型
2506
 	inputMessage["signtype"] = ""                                                               // 签名类型
2507
 	inputMessage["infver"] = "V1.0"                                                             // 接收方系统代码
2507
 	inputMessage["infver"] = "V1.0"                                                             // 接收方系统代码
2508
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
2508
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
2509
-	inputMessage["opter"] = doctor                                                             // 经办人
2509
+	inputMessage["opter"] = doctor                                                              // 经办人
2510
 	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
2510
 	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
2511
 	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
2511
 	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
2512
 	inputMessage["fixmedins_code"] = fixmedins_code                                             // 定点医药机构编号
2512
 	inputMessage["fixmedins_code"] = fixmedins_code                                             // 定点医药机构编号
2800
 	} else {
2800
 	} else {
2801
 		if id_card_type == 1 {
2801
 		if id_card_type == 1 {
2802
 			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
2802
 			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
2803
-			inputData["card_sn"] = ""      // 卡识别码
2803
+			inputData["card_sn"] = ""           // 卡识别码
2804
 			inputData["certno"] = certNo        // 证件号码
2804
 			inputData["certno"] = certNo        // 证件号码
2805
 			inputData["psn_cert_type"] = "01"   // 人员证件类型
2805
 			inputData["psn_cert_type"] = "01"   // 人员证件类型
2806
 
2806
 
2921
 	str := string(respBytes)
2921
 	str := string(respBytes)
2922
 	return str
2922
 	return str
2923
 }
2923
 }
2924
+func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
2925
+	//生成签名
2926
+	nonce := GetRandomString(32)
2927
+	timestamp := time.Now().Unix()
2928
+	signature := setSignature(timestamp, nonce, secret_key)
2929
+	//生成输入报文
2930
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
2931
+	input := make(map[string]interface{})
2932
+	inputData := make(map[string]interface{})
2933
+	inputMessage["infno"] = "90100" // 交易编码
2934
+	inputData["psn_no"] = psn_no    // 开始时间
2935
+	input["data"] = inputData
2936
+	inputMessage["input"] = input //交易输入
2937
+
2938
+	bytesData, err := json.Marshal(inputMessage)
2939
+	fmt.Println(string(bytesData))
2940
+	if err != nil {
2941
+		fmt.Println(err.Error())
2942
+		return err.Error()
2943
+	}
2944
+	reader := bytes.NewReader(bytesData)
2945
+	gdyb_url := beego.AppConfig.String("gdyb_url")
2946
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
2947
+
2948
+	url := gdyb_url + "90100"
2949
+	request, err := http.NewRequest("POST", url, reader)
2950
+	if err != nil {
2951
+		fmt.Println(err.Error())
2952
+		return err.Error()
2953
+	}
2954
+
2955
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
2956
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
2957
+	request.Header.Set("x-tif-signature", signature)
2958
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
2959
+	request.Header.Set("x-tif-nonce", nonce)
2960
+
2961
+	client := http.Client{}
2962
+	resp, err := client.Do(request)
2963
+	if err != nil {
2964
+		fmt.Println(err.Error())
2965
+		return err.Error()
2966
+	}
2967
+	respBytes, err := ioutil.ReadAll(resp.Body)
2968
+	if err != nil {
2969
+		fmt.Println(err.Error())
2970
+		return err.Error()
2971
+	}
2972
+	fmt.Println(string(respBytes))
2973
+	str := string(respBytes)
2974
+	return str
2975
+}