|
@@ -0,0 +1,818 @@
|
|
1
|
+package service
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "bytes"
|
|
5
|
+ "encoding/json"
|
|
6
|
+ "fmt"
|
|
7
|
+ "gdyb/models"
|
|
8
|
+ "io/ioutil"
|
|
9
|
+ "net/http"
|
|
10
|
+ "strconv"
|
|
11
|
+ "time"
|
|
12
|
+)
|
|
13
|
+
|
|
14
|
+// 门诊挂号
|
|
15
|
+func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, request_url string, verify_number string, cainfo string) (string, string) {
|
|
16
|
+ // 生成签名
|
|
17
|
+ // 生成签名
|
|
18
|
+ nonce := GetRandomString(32)
|
|
19
|
+ timestamp := time.Now().Unix()
|
|
20
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
21
|
+ tempTime := time.Unix(timestamp, 0)
|
|
22
|
+ timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
23
|
+
|
|
24
|
+ // 生成输入报文
|
|
25
|
+ inputMessage := SetJSInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
|
|
26
|
+ input := make(map[string]interface{})
|
|
27
|
+ inputData := make(map[string]interface{})
|
|
28
|
+ inputMessage["infno"] = "2201" // 交易编码
|
|
29
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
30
|
+ inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
|
|
31
|
+ inputData["begntime"] = timeFormatOne // 开始时间
|
|
32
|
+
|
|
33
|
+ if id_card_type == 1 {
|
|
34
|
+ inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
|
|
35
|
+ inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
|
|
36
|
+ } else if id_card_type == 3 {
|
|
37
|
+ inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
|
|
38
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
39
|
+ } else if id_card_type == 4 {
|
|
40
|
+ inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
|
|
41
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
42
|
+ } else {
|
|
43
|
+ inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
|
|
44
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
45
|
+
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
|
|
49
|
+ inputData["atddr_no"] = doctor_id // 医师编码
|
|
50
|
+ inputData["dr_name"] = doctor_name // 医师姓名
|
|
51
|
+ inputData["dept_code"] = dept_code // 科室编码
|
|
52
|
+ inputData["dept_name"] = dept // 科室名称
|
|
53
|
+ inputData["caty"] = "A03.06" // 科别
|
|
54
|
+ inputData["exp_content"] = "" //
|
|
55
|
+
|
|
56
|
+ input["data"] = inputData
|
|
57
|
+ inputMessage["input"] = input //交易输入
|
|
58
|
+
|
|
59
|
+ var requestLog string
|
|
60
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
61
|
+ requestLog = string(bytesData)
|
|
62
|
+ fmt.Println(string(bytesData))
|
|
63
|
+ if err != nil {
|
|
64
|
+ fmt.Println(err.Error())
|
|
65
|
+ return err.Error(), ""
|
|
66
|
+ }
|
|
67
|
+ reader := bytes.NewReader(bytesData)
|
|
68
|
+
|
|
69
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
70
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
71
|
+ request_url = gdyb_url
|
|
72
|
+
|
|
73
|
+ request, err := http.NewRequest("POST", request_url, reader)
|
|
74
|
+ if err != nil {
|
|
75
|
+ fmt.Println(err.Error())
|
|
76
|
+ return err.Error(), ""
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
80
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
81
|
+ request.Header.Set("x-tif-signature", signature)
|
|
82
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
83
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
84
|
+
|
|
85
|
+ client := http.Client{}
|
|
86
|
+ resp, err := client.Do(request)
|
|
87
|
+ if err != nil {
|
|
88
|
+ fmt.Println(err.Error())
|
|
89
|
+ return err.Error(), ""
|
|
90
|
+ }
|
|
91
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
92
|
+ if err != nil {
|
|
93
|
+ fmt.Println(err.Error())
|
|
94
|
+ return err.Error(), ""
|
|
95
|
+ }
|
|
96
|
+ str := string(respBytes)
|
|
97
|
+ fmt.Println(str)
|
|
98
|
+ return str, requestLog
|
|
99
|
+
|
|
100
|
+}
|
|
101
|
+
|
|
102
|
+// 门诊挂号撤销
|
|
103
|
+func Nmyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, cainfo string) (string, string) {
|
|
104
|
+ // 生成签名
|
|
105
|
+ // 生成签名
|
|
106
|
+ nonce := GetRandomString(32)
|
|
107
|
+ timestamp := time.Now().Unix()
|
|
108
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
109
|
+
|
|
110
|
+ // 生成输入报文
|
|
111
|
+ inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
|
|
112
|
+ input := make(map[string]interface{})
|
|
113
|
+ inputData := make(map[string]interface{})
|
|
114
|
+ inputMessage["infno"] = "2202" // 交易编码
|
|
115
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
116
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
117
|
+ inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
|
|
118
|
+ inputData["exp_content"] = "" //
|
|
119
|
+
|
|
120
|
+ input["data"] = inputData
|
|
121
|
+ inputMessage["input"] = input //交易输入
|
|
122
|
+
|
|
123
|
+ var requestLog string
|
|
124
|
+
|
|
125
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
126
|
+ fmt.Println(string(bytesData))
|
|
127
|
+ requestLog = string(bytesData)
|
|
128
|
+ if err != nil {
|
|
129
|
+ fmt.Println(err.Error())
|
|
130
|
+ return err.Error(), ""
|
|
131
|
+ }
|
|
132
|
+ reader := bytes.NewReader(bytesData)
|
|
133
|
+
|
|
134
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
135
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
136
|
+
|
|
137
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
138
|
+ if err != nil {
|
|
139
|
+ fmt.Println(err.Error())
|
|
140
|
+ return err.Error(), ""
|
|
141
|
+ }
|
|
142
|
+
|
|
143
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
144
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
145
|
+ request.Header.Set("x-tif-signature", signature)
|
|
146
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
147
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
148
|
+
|
|
149
|
+ client := http.Client{}
|
|
150
|
+ resp, err := client.Do(request)
|
|
151
|
+ if err != nil {
|
|
152
|
+ fmt.Println(err.Error())
|
|
153
|
+ return err.Error(), ""
|
|
154
|
+ }
|
|
155
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
156
|
+ if err != nil {
|
|
157
|
+ fmt.Println(err.Error())
|
|
158
|
+ return err.Error(), ""
|
|
159
|
+ }
|
|
160
|
+ str := string(respBytes)
|
|
161
|
+ fmt.Println(str)
|
|
162
|
+ return str, requestLog
|
|
163
|
+}
|
|
164
|
+
|
|
165
|
+// 门诊就诊信息上传
|
|
166
|
+func Nmyb2203(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, cainfo string) (string, string) {
|
|
167
|
+ // 生成签名
|
|
168
|
+ // 生成签名
|
|
169
|
+ nonce := GetRandomString(32)
|
|
170
|
+ timestamp := time.Now().Unix()
|
|
171
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
172
|
+ //tempTime := time.Unix(timestamp, 0)
|
|
173
|
+ //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
174
|
+ // 生成输入报文
|
|
175
|
+
|
|
176
|
+ tempTime := time.Unix(timestamp, 0)
|
|
177
|
+ timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
178
|
+ // 生成输入报文
|
|
179
|
+ inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
|
|
180
|
+ input := make(map[string]interface{})
|
|
181
|
+ inputData := make(map[string]interface{})
|
|
182
|
+ diseinfo := make([]map[string]interface{}, 0)
|
|
183
|
+
|
|
184
|
+ if med_type == "1111" || med_type == "1112" {
|
|
185
|
+ med_type = "11"
|
|
186
|
+ }
|
|
187
|
+
|
|
188
|
+ inputMessage["infno"] = "2203A" // 交易编码
|
|
189
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
190
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
191
|
+ inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
|
|
192
|
+ inputData["begntime"] = begin_time // 开始时间
|
|
193
|
+ inputData["main_cond_dscr"] = "" // 主要病情描述
|
|
194
|
+ inputData["dise_codg"] = sick_code // 病种编码
|
|
195
|
+ inputData["dise_name"] = sick_name // 病种名称
|
|
196
|
+ inputData["birctrl_type"] = "" // 计划生育手术类别
|
|
197
|
+ inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
|
|
198
|
+
|
|
199
|
+ for index, item := range config {
|
|
200
|
+ diseinfo_sun := make(map[string]interface{})
|
|
201
|
+ diseinfo_sun["diag_type"] = "1" // 诊断类别
|
|
202
|
+ diseinfo_sun["diag_srt_no"] = index // 诊断排序号
|
|
203
|
+ diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
|
|
204
|
+ diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
|
|
205
|
+ diseinfo_sun["diag_dept"] = department // 诊断科室
|
|
206
|
+ diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
|
|
207
|
+ diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
|
|
208
|
+ diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
|
|
209
|
+ diseinfo_sun["vali_flag"] = "1" // 有效标志
|
|
210
|
+ diseinfo = append(diseinfo, diseinfo_sun)
|
|
211
|
+ }
|
|
212
|
+ //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
|
|
213
|
+ inputData["exp_content"] = "" //
|
|
214
|
+
|
|
215
|
+ input["diseinfo"] = diseinfo
|
|
216
|
+ input["mdtrtinfo"] = inputData
|
|
217
|
+ inputMessage["input"] = input //交易输入
|
|
218
|
+ var requestLog string
|
|
219
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
220
|
+ fmt.Println(string(bytesData))
|
|
221
|
+ requestLog = string(bytesData)
|
|
222
|
+ if err != nil {
|
|
223
|
+ fmt.Println(err.Error())
|
|
224
|
+ return err.Error(), ""
|
|
225
|
+ }
|
|
226
|
+ reader := bytes.NewReader(bytesData)
|
|
227
|
+
|
|
228
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
229
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
230
|
+
|
|
231
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
232
|
+ if err != nil {
|
|
233
|
+ fmt.Println(err.Error())
|
|
234
|
+ return err.Error(), ""
|
|
235
|
+ }
|
|
236
|
+
|
|
237
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
238
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
239
|
+ request.Header.Set("x-tif-signature", signature)
|
|
240
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
241
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
242
|
+
|
|
243
|
+ client := http.Client{}
|
|
244
|
+ resp, err := client.Do(request)
|
|
245
|
+ if err != nil {
|
|
246
|
+ fmt.Println(err.Error())
|
|
247
|
+ return err.Error(), ""
|
|
248
|
+ }
|
|
249
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
250
|
+ if err != nil {
|
|
251
|
+ fmt.Println(err.Error())
|
|
252
|
+ return err.Error(), ""
|
|
253
|
+ }
|
|
254
|
+ str := string(respBytes)
|
|
255
|
+ fmt.Println(str)
|
|
256
|
+ return str, requestLog
|
|
257
|
+
|
|
258
|
+}
|
|
259
|
+
|
|
260
|
+// 门诊费用明细信息上传
|
|
261
|
+func Nmyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, diag_code string, request_url string, access_key string, new_doctor_name string, time_stamp_2203 string, cainfo string) (string, string) {
|
|
262
|
+ // 生成签名
|
|
263
|
+ timestamp := time.Now().Unix()
|
|
264
|
+ // 生成签名
|
|
265
|
+ nonce := GetRandomString(32)
|
|
266
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
267
|
+
|
|
268
|
+ var customs []*Custom
|
|
269
|
+ for _, item := range hisPrescription {
|
|
270
|
+ tm := time.Unix(item.PreTime, 0)
|
|
271
|
+
|
|
272
|
+ if item.Type == 1 { //药品
|
|
273
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
274
|
+ if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
|
|
275
|
+ //var randNum int
|
|
276
|
+ //randNum = rand.Intn(10000) + 1000
|
|
277
|
+ cus := &Custom{
|
|
278
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
|
|
279
|
+ Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
|
|
280
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
281
|
+ Price: fmt.Sprintf("%.4f", subItem.Price),
|
|
282
|
+ MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
|
|
283
|
+ HospApprFlag: subItem.HospApprFlag,
|
|
284
|
+ DoctorNumber: doctor_id,
|
|
285
|
+ DoctorName: new_doctor_name,
|
|
286
|
+ ProvinceDrugMedListCodg: "",
|
|
287
|
+ ProvinceGoodMedListCodg: "",
|
|
288
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
289
|
+ }
|
|
290
|
+
|
|
291
|
+ if subItem.BaseDrugLib.DrugClassify == "2" {
|
|
292
|
+ cus.ProvinceDrugMedListCodg = subItem.BaseDrugLib.ProvincesCode
|
|
293
|
+ }
|
|
294
|
+
|
|
295
|
+ customs = append(customs, cus)
|
|
296
|
+ }
|
|
297
|
+ }
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ if item.Type == 2 { //项目
|
|
301
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
302
|
+ //var randNum int
|
|
303
|
+ //randNum = rand.Intn(10000) + 1000
|
|
304
|
+ if subItem.Type == 2 {
|
|
305
|
+ if len(subItem.HisProject.MedicalCode) > 0 {
|
|
306
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
307
|
+ cus := &Custom{
|
|
308
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
|
|
309
|
+ Cut: fmt.Sprintf("%.4f", cnt),
|
|
310
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
311
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
312
|
+ MedListCodg: subItem.HisProject.MedicalCode,
|
|
313
|
+ DoctorNumber: doctor_id,
|
|
314
|
+ DoctorName: new_doctor_name,
|
|
315
|
+ HospApprFlag: -1,
|
|
316
|
+ ProvinceDrugMedListCodg: "",
|
|
317
|
+ ProvinceGoodMedListCodg: "",
|
|
318
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
319
|
+ }
|
|
320
|
+ customs = append(customs, cus)
|
|
321
|
+ }
|
|
322
|
+
|
|
323
|
+ } else if subItem.Type == 3 {
|
|
324
|
+ if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
|
|
325
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
326
|
+
|
|
327
|
+ cus := &Custom{
|
|
328
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
|
|
329
|
+ Cut: fmt.Sprintf("%.4f", cnt),
|
|
330
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
331
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
332
|
+ MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
|
|
333
|
+ HospApprFlag: -1,
|
|
334
|
+ DoctorNumber: doctor_id,
|
|
335
|
+ DoctorName: new_doctor_name,
|
|
336
|
+ ProvinceDrugMedListCodg: "",
|
|
337
|
+ ProvinceGoodMedListCodg: subItem.GoodInfo.ProvincesCode,
|
|
338
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
339
|
+ }
|
|
340
|
+ customs = append(customs, cus)
|
|
341
|
+ }
|
|
342
|
+
|
|
343
|
+ }
|
|
344
|
+
|
|
345
|
+ }
|
|
346
|
+ }
|
|
347
|
+
|
|
348
|
+ for _, subItem := range item.HisAdditionalCharge {
|
|
349
|
+ if len(subItem.XtHisAddtionConfig.Code) > 0 {
|
|
350
|
+ cus := &Custom{
|
|
351
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
|
|
352
|
+ Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
|
|
353
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
354
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
355
|
+ MedListCodg: subItem.XtHisAddtionConfig.Code,
|
|
356
|
+ HospApprFlag: -1,
|
|
357
|
+ DoctorNumber: doctor_id,
|
|
358
|
+ DoctorName: new_doctor_name,
|
|
359
|
+ }
|
|
360
|
+ customs = append(customs, cus)
|
|
361
|
+ }
|
|
362
|
+ }
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ // 生成输入报文
|
|
366
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
367
|
+
|
|
368
|
+ input := make(map[string]interface{})
|
|
369
|
+ feedetail := make([]map[string]interface{}, 0)
|
|
370
|
+ inputMessage["infno"] = "2204" // 交易编码
|
|
371
|
+
|
|
372
|
+ //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
|
|
373
|
+ for _, item := range customs {
|
|
374
|
+ feedetailInfo := make(map[string]interface{})
|
|
375
|
+ subfeedetailInfo := make(map[string]interface{})
|
|
376
|
+
|
|
377
|
+ feedetailInfo["feedetl_sn"] = item.FeedetlSn
|
|
378
|
+ feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
379
|
+ feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
380
|
+ feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
|
|
381
|
+ feedetailInfo["dise_codg"] = diag_code // 病种编码
|
|
382
|
+ feedetailInfo["rxno"] = "" // 处方号
|
|
383
|
+ feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
|
|
384
|
+ feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
|
|
385
|
+ feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
|
|
386
|
+ feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
|
|
387
|
+ feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
|
|
388
|
+ feedetailInfo["cnt"] = item.Cut // 数量
|
|
389
|
+ feedetailInfo["pric"] = item.Price // 单价
|
|
390
|
+ feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
|
|
391
|
+ feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
|
|
392
|
+ feedetailInfo["prd_days"] = "0" // 周期天数
|
|
393
|
+ feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
|
|
394
|
+ feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
|
|
395
|
+ feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
|
|
396
|
+
|
|
397
|
+ if fixmedins_code == "H32092103007" {
|
|
398
|
+ feedetailInfo["bilg_dr_codg"] = "D320923012139" // 开单医生编码
|
|
399
|
+ feedetailInfo["bilg_dr_name"] = "王曙光" // 开单医师姓名
|
|
400
|
+ feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
|
|
401
|
+ feedetailInfo["acord_dept_name"] = "" // 受单科室名称
|
|
402
|
+ feedetailInfo["orders_dr_code"] = "D320923012139" // 受单医生编码
|
|
403
|
+ feedetailInfo["orders_dr_name"] = "王曙光" // 受单医生姓名
|
|
404
|
+
|
|
405
|
+ } else {
|
|
406
|
+ feedetailInfo["bilg_dr_codg"] = "D371621008686" // 开单医生编码
|
|
407
|
+ feedetailInfo["bilg_dr_name"] = "王云刚" // 开单医师姓名
|
|
408
|
+ feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
|
|
409
|
+ feedetailInfo["acord_dept_name"] = "" // 受单科室名称
|
|
410
|
+ feedetailInfo["orders_dr_code"] = "D371621008686" // 受单医生编码
|
|
411
|
+ feedetailInfo["orders_dr_name"] = "王云刚" // 受单医生姓名
|
|
412
|
+
|
|
413
|
+ }
|
|
414
|
+
|
|
415
|
+ if balance_accounts_type == "8" {
|
|
416
|
+ feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
|
|
417
|
+ } else {
|
|
418
|
+ if item.HospApprFlag != -1 {
|
|
419
|
+ if item.HospApprFlag == 1 {
|
|
420
|
+ feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
|
|
421
|
+ } else if item.HospApprFlag == 2 {
|
|
422
|
+ feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
|
|
423
|
+ } else if item.HospApprFlag == 3 {
|
|
424
|
+ feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
|
|
425
|
+ } else {
|
|
426
|
+ feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
|
|
427
|
+ }
|
|
428
|
+ } else {
|
|
429
|
+ feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
|
|
430
|
+ }
|
|
431
|
+
|
|
432
|
+ }
|
|
433
|
+
|
|
434
|
+ feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
|
|
435
|
+ feedetailInfo["etip_flag"] = "" // 外检标志
|
|
436
|
+ feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
|
|
437
|
+ feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
|
|
438
|
+ feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
|
|
439
|
+ subfeedetailInfo["tcmherb_prov_code"] = item.ProvinceDrugMedListCodg
|
|
440
|
+ subfeedetailInfo["mcs_prov_code"] = item.ProvinceGoodMedListCodg
|
|
441
|
+ feedetailInfo["exp_content"] = subfeedetailInfo
|
|
442
|
+ feedetail = append(feedetail, feedetailInfo)
|
|
443
|
+ }
|
|
444
|
+
|
|
445
|
+ input["feedetail"] = feedetail
|
|
446
|
+ inputMessage["input"] = input //交易输入
|
|
447
|
+ var requestLog string
|
|
448
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
449
|
+ requestLog = string(bytesData)
|
|
450
|
+ fmt.Println(string(bytesData))
|
|
451
|
+
|
|
452
|
+ if err != nil {
|
|
453
|
+ fmt.Println(err.Error())
|
|
454
|
+ return "", ""
|
|
455
|
+ }
|
|
456
|
+
|
|
457
|
+ reader := bytes.NewReader(bytesData)
|
|
458
|
+
|
|
459
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
460
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
461
|
+
|
|
462
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
463
|
+ if err != nil {
|
|
464
|
+ fmt.Println(err.Error())
|
|
465
|
+ return "", ""
|
|
466
|
+ }
|
|
467
|
+
|
|
468
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
469
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
470
|
+ request.Header.Set("x-tif-signature", signature)
|
|
471
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
472
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
473
|
+
|
|
474
|
+ client := http.Client{}
|
|
475
|
+ resp, err := client.Do(request)
|
|
476
|
+ if err != nil {
|
|
477
|
+ fmt.Println(err.Error())
|
|
478
|
+ return "", ""
|
|
479
|
+ }
|
|
480
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
481
|
+ if err != nil {
|
|
482
|
+ fmt.Println(err.Error())
|
|
483
|
+ return "", ""
|
|
484
|
+ }
|
|
485
|
+ return string(respBytes), requestLog
|
|
486
|
+}
|
|
487
|
+
|
|
488
|
+// 门诊费用明细信息撤销
|
|
489
|
+func Nmyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, request_url string, access_key string, cainfo string) (string, string) {
|
|
490
|
+
|
|
491
|
+ // 生成签名
|
|
492
|
+ nonce := GetRandomString(32)
|
|
493
|
+ timestamp := time.Now().Unix()
|
|
494
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
495
|
+
|
|
496
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
497
|
+
|
|
498
|
+ input := make(map[string]interface{})
|
|
499
|
+ inputData := make(map[string]interface{})
|
|
500
|
+ inputMessage["infno"] = "2205" // 交易编码
|
|
501
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
502
|
+ inputData["chrg_bchno"] = "0000" // 收费批次号(来自2204生成的)
|
|
503
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
504
|
+ inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
|
|
505
|
+
|
|
506
|
+ input["data"] = inputData
|
|
507
|
+ inputMessage["input"] = input //交易输入
|
|
508
|
+
|
|
509
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
510
|
+ fmt.Println(string(bytesData))
|
|
511
|
+
|
|
512
|
+ var requestLog string
|
|
513
|
+ requestLog = string(bytesData)
|
|
514
|
+ if err != nil {
|
|
515
|
+ fmt.Println(err.Error())
|
|
516
|
+ return err.Error(), ""
|
|
517
|
+ }
|
|
518
|
+ reader := bytes.NewReader(bytesData)
|
|
519
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
520
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
521
|
+
|
|
522
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
523
|
+ fmt.Println(err)
|
|
524
|
+
|
|
525
|
+ fmt.Println(request)
|
|
526
|
+ if err != nil {
|
|
527
|
+ fmt.Println(err.Error())
|
|
528
|
+ return err.Error(), ""
|
|
529
|
+ }
|
|
530
|
+
|
|
531
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
532
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
533
|
+ request.Header.Set("x-tif-signature", signature)
|
|
534
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
535
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
536
|
+
|
|
537
|
+ client := http.Client{}
|
|
538
|
+ resp, err := client.Do(request)
|
|
539
|
+ if err != nil {
|
|
540
|
+ fmt.Println(err.Error())
|
|
541
|
+ return err.Error(), ""
|
|
542
|
+ }
|
|
543
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
544
|
+ if err != nil {
|
|
545
|
+ fmt.Println(err.Error())
|
|
546
|
+ return err.Error(), ""
|
|
547
|
+ }
|
|
548
|
+ str := string(respBytes)
|
|
549
|
+ fmt.Println(str)
|
|
550
|
+ return str, requestLog
|
|
551
|
+
|
|
552
|
+}
|
|
553
|
+
|
|
554
|
+// 门诊预结算
|
|
555
|
+func Nmyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
|
|
556
|
+
|
|
557
|
+ // 生成签名
|
|
558
|
+ nonce := GetRandomString(32)
|
|
559
|
+ timestamp := time.Now().Unix()
|
|
560
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
561
|
+
|
|
562
|
+ // 生成输入报文
|
|
563
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
564
|
+
|
|
565
|
+ input := make(map[string]interface{})
|
|
566
|
+ inputData := make(map[string]interface{})
|
|
567
|
+ inputMessage["infno"] = "2206" // 交易编码
|
|
568
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
569
|
+ if certificates == 3 {
|
|
570
|
+ inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
|
|
571
|
+ inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
|
572
|
+ } else {
|
|
573
|
+ if id_card_type == 1 {
|
|
574
|
+ inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
|
|
575
|
+ inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
|
576
|
+ } else if id_card_type == 3 {
|
|
577
|
+ inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
|
|
578
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
579
|
+ } else if id_card_type == 4 {
|
|
580
|
+ inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
|
|
581
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
582
|
+ } else {
|
|
583
|
+ inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
|
|
584
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
585
|
+ }
|
|
586
|
+ }
|
|
587
|
+ if insuplc_admdvs == "421300" {
|
|
588
|
+ if med_type == "11" || med_type == "1112" || med_type == "1111" {
|
|
589
|
+ inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
|
|
590
|
+ } else if med_type == "14" {
|
|
591
|
+ inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
|
|
592
|
+ }
|
|
593
|
+ } else {
|
|
594
|
+ inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
|
|
595
|
+ }
|
|
596
|
+ inputData["medfee_sumamt"] = total // 医疗费总额
|
|
597
|
+ inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
|
|
598
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
599
|
+ inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
|
|
600
|
+ inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
|
|
601
|
+ inputData["insutype"] = insutype // 险种类型
|
|
602
|
+ inputData["invono"] = "" // 发票号
|
|
603
|
+ inputData2 := make(map[string]interface{})
|
|
604
|
+ inputData2["trum_flag"] = ""
|
|
605
|
+ inputData2["rel_ttp_flag"] = ""
|
|
606
|
+ inputData2["otp_er_refl_flag"] = ""
|
|
607
|
+ inputData2["mdtrt_grp_type"] = mdtrt_grp_type
|
|
608
|
+ inputData2["need_ipt_flag"] = ""
|
|
609
|
+ inputData["exp_content"] = inputData2
|
|
610
|
+ input["data"] = inputData
|
|
611
|
+ inputMessage["input"] = input //交易输入
|
|
612
|
+
|
|
613
|
+ var requestLog string
|
|
614
|
+
|
|
615
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
616
|
+
|
|
617
|
+ requestLog = string(bytesData)
|
|
618
|
+ fmt.Println(string(bytesData))
|
|
619
|
+ if err != nil {
|
|
620
|
+ fmt.Println(err.Error())
|
|
621
|
+ return err.Error(), ""
|
|
622
|
+ }
|
|
623
|
+ reader := bytes.NewReader(bytesData)
|
|
624
|
+
|
|
625
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
626
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
627
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
628
|
+ if err != nil {
|
|
629
|
+ fmt.Println(err.Error())
|
|
630
|
+ return err.Error(), ""
|
|
631
|
+ }
|
|
632
|
+
|
|
633
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
634
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
635
|
+ request.Header.Set("x-tif-signature", signature)
|
|
636
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
637
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
638
|
+
|
|
639
|
+ client := http.Client{}
|
|
640
|
+ resp, err := client.Do(request)
|
|
641
|
+ if err != nil {
|
|
642
|
+ fmt.Println(err.Error())
|
|
643
|
+ return err.Error(), ""
|
|
644
|
+ }
|
|
645
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
646
|
+ if err != nil {
|
|
647
|
+ fmt.Println(err.Error())
|
|
648
|
+ return err.Error(), ""
|
|
649
|
+ }
|
|
650
|
+ str := string(respBytes)
|
|
651
|
+ fmt.Println(str)
|
|
652
|
+ return str, requestLog
|
|
653
|
+}
|
|
654
|
+
|
|
655
|
+// 门诊结算
|
|
656
|
+func Nmyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
|
|
657
|
+ // 生成签名
|
|
658
|
+ nonce := GetRandomString(32)
|
|
659
|
+ timestamp := time.Now().Unix()
|
|
660
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
661
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
662
|
+ input := make(map[string]interface{})
|
|
663
|
+ inputData := make(map[string]interface{})
|
|
664
|
+ inputMessage["infno"] = "2207" // 交易编码
|
|
665
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
666
|
+
|
|
667
|
+ if certificates == 3 {
|
|
668
|
+ inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
|
|
669
|
+ inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
|
|
670
|
+ } else {
|
|
671
|
+ if id_card_type == 1 {
|
|
672
|
+ inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
|
|
673
|
+ inputData["mdtrt_cert_no"] = certNo + "|" + verify_number // 就诊凭证编号
|
|
674
|
+ } else if id_card_type == 3 {
|
|
675
|
+ inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
|
|
676
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
677
|
+ } else if id_card_type == 4 {
|
|
678
|
+ inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
|
|
679
|
+ inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
|
|
680
|
+ } else {
|
|
681
|
+
|
|
682
|
+ }
|
|
683
|
+ }
|
|
684
|
+ if med_type == "1111" || med_type == "1112" {
|
|
685
|
+ med_type = "11"
|
|
686
|
+ }
|
|
687
|
+ if insuplc_admdvs == "421300" {
|
|
688
|
+ if med_type == "11" {
|
|
689
|
+ inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
|
|
690
|
+ } else if med_type == "14" {
|
|
691
|
+ inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
|
|
692
|
+ }
|
|
693
|
+ } else {
|
|
694
|
+ inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
|
|
695
|
+ }
|
|
696
|
+ inputData["medfee_sumamt"] = total // 医疗费总额
|
|
697
|
+ inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
|
|
698
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
699
|
+ inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
|
|
700
|
+ inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
|
|
701
|
+ inputData["insutype"] = insutype // 险种类型
|
|
702
|
+ inputData["invono"] = "" // 发票号
|
|
703
|
+
|
|
704
|
+ inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
|
|
705
|
+ inputData["overlmt_selfpay"] = overlmt_selfpay //
|
|
706
|
+ inputData["preselfpay_amt"] = preselfpay_amt //
|
|
707
|
+ inputData["inscp_scp_amt"] = inscp_scp_amt //
|
|
708
|
+ inputData2 := make(map[string]interface{})
|
|
709
|
+ inputData2["trum_flag"] = ""
|
|
710
|
+ inputData2["rel_ttp_flag"] = ""
|
|
711
|
+ inputData2["otp_er_refl_flag"] = ""
|
|
712
|
+ inputData2["mdtrt_grp_type"] = mdtrt_grp_type
|
|
713
|
+ inputData2["need_ipt_flag"] = ""
|
|
714
|
+ inputData["exp_content"] = inputData2
|
|
715
|
+
|
|
716
|
+ input["data"] = inputData
|
|
717
|
+ inputMessage["input"] = input //交易输入
|
|
718
|
+
|
|
719
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
720
|
+ fmt.Println(string(bytesData))
|
|
721
|
+ if err != nil {
|
|
722
|
+ fmt.Println(err.Error())
|
|
723
|
+ return err.Error(), ""
|
|
724
|
+ }
|
|
725
|
+ reader := bytes.NewReader(bytesData)
|
|
726
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
727
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
728
|
+
|
|
729
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
730
|
+ if err != nil {
|
|
731
|
+ fmt.Println(err.Error())
|
|
732
|
+ return err.Error(), ""
|
|
733
|
+ }
|
|
734
|
+
|
|
735
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
736
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
737
|
+ request.Header.Set("x-tif-signature", signature)
|
|
738
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
739
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
740
|
+
|
|
741
|
+ client := http.Client{}
|
|
742
|
+ resp, err := client.Do(request)
|
|
743
|
+ if err != nil {
|
|
744
|
+ fmt.Println(err.Error())
|
|
745
|
+ return err.Error(), ""
|
|
746
|
+ }
|
|
747
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
748
|
+ if err != nil {
|
|
749
|
+ fmt.Println(err.Error())
|
|
750
|
+ return err.Error(), ""
|
|
751
|
+ }
|
|
752
|
+ str := string(respBytes)
|
|
753
|
+ fmt.Println(str)
|
|
754
|
+ mjson, _ := json.Marshal(inputMessage)
|
|
755
|
+ str2 := string(mjson)
|
|
756
|
+ return str, str2
|
|
757
|
+}
|
|
758
|
+
|
|
759
|
+// 门诊结算撤销
|
|
760
|
+func Nmyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, cainfo string) (string, string) {
|
|
761
|
+ // 生成签名
|
|
762
|
+ nonce := GetRandomString(32)
|
|
763
|
+ timestamp := time.Now().Unix()
|
|
764
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
765
|
+
|
|
766
|
+ // 生成输入报文
|
|
767
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
768
|
+
|
|
769
|
+ input := make(map[string]interface{})
|
|
770
|
+ inputData := make(map[string]interface{})
|
|
771
|
+ inputMessage["infno"] = "2208" // 交易编码
|
|
772
|
+
|
|
773
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
774
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
775
|
+ inputData["setl_id"] = setlId // 结算 ID
|
|
776
|
+ inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
|
|
777
|
+
|
|
778
|
+ input["data"] = inputData
|
|
779
|
+ inputMessage["input"] = input //交易输入
|
|
780
|
+
|
|
781
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
782
|
+ fmt.Println(string(bytesData))
|
|
783
|
+ if err != nil {
|
|
784
|
+ fmt.Println(err.Error())
|
|
785
|
+ return err.Error(), ""
|
|
786
|
+ }
|
|
787
|
+ reader := bytes.NewReader(bytesData)
|
|
788
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
789
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
790
|
+
|
|
791
|
+ request, err := http.NewRequest("POST", gdyb_url, reader)
|
|
792
|
+ if err != nil {
|
|
793
|
+ fmt.Println(err.Error())
|
|
794
|
+ return err.Error(), ""
|
|
795
|
+ }
|
|
796
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
797
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
798
|
+ request.Header.Set("x-tif-signature", signature)
|
|
799
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
800
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
801
|
+
|
|
802
|
+ client := http.Client{}
|
|
803
|
+ resp, err := client.Do(request)
|
|
804
|
+ if err != nil {
|
|
805
|
+ fmt.Println(err.Error())
|
|
806
|
+ return err.Error(), ""
|
|
807
|
+ }
|
|
808
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
809
|
+ if err != nil {
|
|
810
|
+ fmt.Println(err.Error())
|
|
811
|
+ return err.Error(), ""
|
|
812
|
+ }
|
|
813
|
+ str := string(respBytes)
|
|
814
|
+ fmt.Println(str)
|
|
815
|
+ mjson, _ := json.Marshal(inputMessage)
|
|
816
|
+ str2 := string(mjson)
|
|
817
|
+ return str, str2
|
|
818
|
+}
|