|
@@ -0,0 +1,930 @@
|
|
1
|
+package service
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "bytes"
|
|
5
|
+ "encoding/json"
|
|
6
|
+ "fmt"
|
|
7
|
+ "gdyb/models"
|
|
8
|
+ "github.com/astaxie/beego"
|
|
9
|
+ "io/ioutil"
|
|
10
|
+ "net/http"
|
|
11
|
+ "strconv"
|
|
12
|
+ "time"
|
|
13
|
+ _ "unsafe"
|
|
14
|
+)
|
|
15
|
+
|
|
16
|
+// 人员基本信息
|
|
17
|
+func ZHGdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) string {
|
|
18
|
+ //生成签名
|
|
19
|
+ nonce := GetRandomString(32)
|
|
20
|
+ timestamp := time.Now().Unix()
|
|
21
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
22
|
+ //生成输入报文
|
|
23
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
24
|
+ input := make(map[string]interface{})
|
|
25
|
+ inputData := make(map[string]interface{})
|
|
26
|
+ inputMessage["infno"] = "1101" // 交易编码
|
|
27
|
+
|
|
28
|
+ if certificates == 3 {
|
|
29
|
+ inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
|
|
30
|
+ inputData["certno"] = certNo // 证件号码
|
|
31
|
+ inputData["psn_cert_type"] = "99" // 人员证件类型
|
|
32
|
+
|
|
33
|
+ } else {
|
|
34
|
+ if id_card_type == 1 {
|
|
35
|
+ inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
|
|
36
|
+ inputData["card_sn"] = card_sn // 卡识别码
|
|
37
|
+ inputData["certno"] = certNo // 证件号码
|
|
38
|
+ inputData["psn_cert_type"] = "1" // 人员证件类型
|
|
39
|
+
|
|
40
|
+ } else {
|
|
41
|
+ inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
|
|
42
|
+ inputData["card_sn"] = "" // 卡识别码
|
|
43
|
+ inputData["certno"] = certNo // 证件号码
|
|
44
|
+ inputData["psn_cert_type"] = "1" // 人员证件类型
|
|
45
|
+ }
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
|
49
|
+ inputData["begntime"] = "" // 开始时间
|
|
50
|
+ inputData["psn_name"] = "" // 人员姓名
|
|
51
|
+ input["data"] = inputData
|
|
52
|
+ inputMessage["input"] = input //交易输入
|
|
53
|
+
|
|
54
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
55
|
+ fmt.Println(string(bytesData))
|
|
56
|
+ if err != nil {
|
|
57
|
+ fmt.Println(err.Error())
|
|
58
|
+ return err.Error()
|
|
59
|
+ }
|
|
60
|
+ reader := bytes.NewReader(bytesData)
|
|
61
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
62
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
63
|
+
|
|
64
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
|
|
65
|
+ url := gdyb_url + "1101"
|
|
66
|
+
|
|
67
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
|
|
68
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
69
|
+ if err != nil {
|
|
70
|
+ fmt.Println(err.Error())
|
|
71
|
+ return err.Error()
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
75
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
76
|
+ request.Header.Set("x-tif-signature", signature)
|
|
77
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
78
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
79
|
+
|
|
80
|
+ client := http.Client{}
|
|
81
|
+ resp, err := client.Do(request)
|
|
82
|
+ if err != nil {
|
|
83
|
+ fmt.Println(err.Error())
|
|
84
|
+ return err.Error()
|
|
85
|
+ }
|
|
86
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
87
|
+ if err != nil {
|
|
88
|
+ fmt.Println(err.Error())
|
|
89
|
+ return err.Error()
|
|
90
|
+ }
|
|
91
|
+ fmt.Println(string(respBytes))
|
|
92
|
+ str := string(respBytes)
|
|
93
|
+ return str
|
|
94
|
+}
|
|
95
|
+
|
|
96
|
+type DiseinfoStruct struct {
|
|
97
|
+ PsnNo string
|
|
98
|
+ DiagType string
|
|
99
|
+ MaindiagFlag string
|
|
100
|
+ DiagSrtNo string
|
|
101
|
+ DiagCode string
|
|
102
|
+ DiagName string
|
|
103
|
+ DiagDept string
|
|
104
|
+ DiseDorNo string
|
|
105
|
+ DiseDorName string
|
|
106
|
+ DiagTime string
|
|
107
|
+}
|
|
108
|
+type Struct2401 struct {
|
|
109
|
+ PsnNo string
|
|
110
|
+ Insutype string
|
|
111
|
+ MdtrtCertType string
|
|
112
|
+ MdtrtCertNo string
|
|
113
|
+ MedType string
|
|
114
|
+ IptNo string
|
|
115
|
+ AtddrNo string
|
|
116
|
+ ChfpdrName string
|
|
117
|
+ AdmDiagDscr string
|
|
118
|
+ AdmDeptCodg string
|
|
119
|
+ AdmDeptName string
|
|
120
|
+ AdmBed string
|
|
121
|
+ DscgMaindiagCode string
|
|
122
|
+ DscgMaindiagName string
|
|
123
|
+ Diseinfo []DiseinfoStruct
|
|
124
|
+ Begntime string
|
|
125
|
+ DiseCodg string
|
|
126
|
+ DiseName string
|
|
127
|
+}
|
|
128
|
+
|
|
129
|
+// 住院登记
|
|
130
|
+func ZHGdyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) string {
|
|
131
|
+ // 生成签名
|
|
132
|
+ nonce := GetRandomString(32)
|
|
133
|
+ timestamp := time.Now().Unix()
|
|
134
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
135
|
+ //tempTime := time.Unix(timestamp, 0)
|
|
136
|
+ //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
137
|
+
|
|
138
|
+ // 生成输入报文
|
|
139
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
140
|
+ input := make(map[string]interface{})
|
|
141
|
+ inputData := make(map[string]interface{})
|
|
142
|
+ inputMessage["infno"] = "2201" // 交易编码
|
|
143
|
+ inputData["psn_no"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
|
|
144
|
+ inputData["insutype"] = struct2401.Insutype // 险种类型(来自1101接口返回)
|
|
145
|
+ inputData["tel"] = ""
|
|
146
|
+ inputData["coner_name"] = ""
|
|
147
|
+ inputData["begntime"] = struct2401.Begntime // 开始时间
|
|
148
|
+ inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
|
|
149
|
+ inputData["mdtrt_cert_no"] = struct2401.MdtrtCertNo // 就诊凭证编号
|
|
150
|
+ inputData["med_type"] = struct2401.MedType // 就诊凭证编号
|
|
151
|
+ inputData["ipt_no"] = struct2401.IptNo // 住院/门诊号
|
|
152
|
+ inputData["medrcdno"] = ""
|
|
153
|
+ inputData["atddr_no"] = struct2401.AtddrNo
|
|
154
|
+ inputData["chfpdr_name"] = struct2401.ChfpdrName
|
|
155
|
+ inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
|
|
156
|
+ inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
|
|
157
|
+ inputData["adm_dept_name"] = struct2401.AdmDeptName
|
|
158
|
+ inputData["adm_bed"] = struct2401.AdmBed
|
|
159
|
+ inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
|
|
160
|
+ inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
|
|
161
|
+ inputData["main_cond_dscr"] = ""
|
|
162
|
+ inputData["dise_codg"] = ""
|
|
163
|
+ inputData["dise_name"] = ""
|
|
164
|
+ inputData["oprn_oprt_code"] = ""
|
|
165
|
+ inputData["oprn_oprt_name"] = ""
|
|
166
|
+ inputData["fpsc_no"] = ""
|
|
167
|
+ inputData["matn_type"] = ""
|
|
168
|
+ inputData["birctrl_type"] = ""
|
|
169
|
+ inputData["latechb_flag"] = ""
|
|
170
|
+ inputData["geso_val"] = ""
|
|
171
|
+ inputData["fetts"] = ""
|
|
172
|
+ inputData["fetus_cnt"] = ""
|
|
173
|
+ inputData["pret_flag"] = ""
|
|
174
|
+ inputData["birctrl_matn_date"] = ""
|
|
175
|
+ inputData["dise_type_code"] = ""
|
|
176
|
+
|
|
177
|
+ inputDataArr := make([]map[string]interface{}, 0)
|
|
178
|
+ for _, item := range struct2401.Diseinfo {
|
|
179
|
+ inputDataTwo := make(map[string]interface{})
|
|
180
|
+ inputDataTwo["psn_no"] = item.PsnNo
|
|
181
|
+ inputDataTwo["diag_type"] = item.DiagType
|
|
182
|
+ inputDataTwo["maindiag_flag"] = item.MaindiagFlag
|
|
183
|
+ inputDataTwo["diag_srt_no"] = item.DiagSrtNo
|
|
184
|
+ inputDataTwo["diag_code"] = item.DiagCode
|
|
185
|
+ inputDataTwo["diag_name"] = item.DiagName
|
|
186
|
+ inputDataTwo["adm_cond"] = ""
|
|
187
|
+ inputDataTwo["diag_dept"] = item.DiagDept
|
|
188
|
+ inputDataTwo["dise_dor_no"] = item.DiseDorNo
|
|
189
|
+ inputDataTwo["dise_dor_name"] = item.DiseDorName
|
|
190
|
+ inputDataTwo["diag_time"] = item.DiagTime
|
|
191
|
+ inputDataArr = append(inputDataArr, inputDataTwo)
|
|
192
|
+ }
|
|
193
|
+ input["mdtrtinfo"] = inputData
|
|
194
|
+ input["diseinfo"] = inputDataArr
|
|
195
|
+ inputMessage["input"] = input //交易输入
|
|
196
|
+
|
|
197
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
198
|
+ fmt.Println(string(bytesData))
|
|
199
|
+ if err != nil {
|
|
200
|
+ fmt.Println(err.Error())
|
|
201
|
+ return err.Error()
|
|
202
|
+ }
|
|
203
|
+ reader := bytes.NewReader(bytesData)
|
|
204
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
205
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
206
|
+ url := gdyb_url + "2401"
|
|
207
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
208
|
+ if err != nil {
|
|
209
|
+ fmt.Println(err.Error())
|
|
210
|
+ return err.Error()
|
|
211
|
+ }
|
|
212
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
213
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
214
|
+ request.Header.Set("x-tif-signature", signature)
|
|
215
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
216
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
217
|
+
|
|
218
|
+ client := http.Client{}
|
|
219
|
+ resp, err := client.Do(request)
|
|
220
|
+ if err != nil {
|
|
221
|
+ fmt.Println(err.Error())
|
|
222
|
+ return err.Error()
|
|
223
|
+ }
|
|
224
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
225
|
+ if err != nil {
|
|
226
|
+ fmt.Println(err.Error())
|
|
227
|
+ return err.Error()
|
|
228
|
+ }
|
|
229
|
+ str := string(respBytes)
|
|
230
|
+ fmt.Println(str)
|
|
231
|
+ return str
|
|
232
|
+}
|
|
233
|
+
|
|
234
|
+//住院撤销
|
|
235
|
+func ZHGdyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) string {
|
|
236
|
+ // 生成签名
|
|
237
|
+ nonce := GetRandomString(32)
|
|
238
|
+ timestamp := time.Now().Unix()
|
|
239
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
240
|
+
|
|
241
|
+ // 生成输入报文
|
|
242
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
243
|
+ input := make(map[string]interface{})
|
|
244
|
+ inputData := make(map[string]interface{})
|
|
245
|
+ inputMessage["infno"] = "2404" // 交易编码
|
|
246
|
+ inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
|
|
247
|
+ inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
|
|
248
|
+ input["data"] = inputData
|
|
249
|
+ inputMessage["input"] = input //交易输入
|
|
250
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
251
|
+ fmt.Println(string(bytesData))
|
|
252
|
+ if err != nil {
|
|
253
|
+ fmt.Println(err.Error())
|
|
254
|
+ return err.Error()
|
|
255
|
+ }
|
|
256
|
+ reader := bytes.NewReader(bytesData)
|
|
257
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
258
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
259
|
+ url := gdyb_url + "2404"
|
|
260
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
261
|
+ if err != nil {
|
|
262
|
+ fmt.Println(err.Error())
|
|
263
|
+ return err.Error()
|
|
264
|
+ }
|
|
265
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
266
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
267
|
+ request.Header.Set("x-tif-signature", signature)
|
|
268
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
269
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
270
|
+
|
|
271
|
+ client := http.Client{}
|
|
272
|
+ resp, err := client.Do(request)
|
|
273
|
+ if err != nil {
|
|
274
|
+ fmt.Println(err.Error())
|
|
275
|
+ return err.Error()
|
|
276
|
+ }
|
|
277
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
278
|
+ if err != nil {
|
|
279
|
+ fmt.Println(err.Error())
|
|
280
|
+ return err.Error()
|
|
281
|
+ }
|
|
282
|
+ str := string(respBytes)
|
|
283
|
+ fmt.Println(str)
|
|
284
|
+ return str
|
|
285
|
+}
|
|
286
|
+
|
|
287
|
+//出院撤销
|
|
288
|
+func ZHGdyb2405(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) string {
|
|
289
|
+ // 生成签名
|
|
290
|
+ nonce := GetRandomString(32)
|
|
291
|
+ timestamp := time.Now().Unix()
|
|
292
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
293
|
+
|
|
294
|
+ // 生成输入报文
|
|
295
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
296
|
+ input := make(map[string]interface{})
|
|
297
|
+ inputData := make(map[string]interface{})
|
|
298
|
+ inputMessage["infno"] = "2405" // 交易编码
|
|
299
|
+ inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
|
|
300
|
+ inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
|
|
301
|
+ input["data"] = inputData
|
|
302
|
+ inputMessage["input"] = input //交易输入
|
|
303
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
304
|
+ fmt.Println(string(bytesData))
|
|
305
|
+ if err != nil {
|
|
306
|
+ fmt.Println(err.Error())
|
|
307
|
+ return err.Error()
|
|
308
|
+ }
|
|
309
|
+ reader := bytes.NewReader(bytesData)
|
|
310
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
311
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
312
|
+ url := gdyb_url + "2405"
|
|
313
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
314
|
+ if err != nil {
|
|
315
|
+ fmt.Println(err.Error())
|
|
316
|
+ return err.Error()
|
|
317
|
+ }
|
|
318
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
319
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
320
|
+ request.Header.Set("x-tif-signature", signature)
|
|
321
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
322
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
323
|
+
|
|
324
|
+ client := http.Client{}
|
|
325
|
+ resp, err := client.Do(request)
|
|
326
|
+ if err != nil {
|
|
327
|
+ fmt.Println(err.Error())
|
|
328
|
+ return err.Error()
|
|
329
|
+ }
|
|
330
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
331
|
+ if err != nil {
|
|
332
|
+ fmt.Println(err.Error())
|
|
333
|
+ return err.Error()
|
|
334
|
+ }
|
|
335
|
+ str := string(respBytes)
|
|
336
|
+ fmt.Println(str)
|
|
337
|
+ return str
|
|
338
|
+}
|
|
339
|
+
|
|
340
|
+type Diseinfo2402Struct struct {
|
|
341
|
+ MdtrtId string
|
|
342
|
+ PsnNo string
|
|
343
|
+ DiagType string
|
|
344
|
+ MaindiagFlag string
|
|
345
|
+ DiagSrtNo string
|
|
346
|
+ DiagCode string
|
|
347
|
+ DiagName string
|
|
348
|
+ DiagDept string
|
|
349
|
+ DiseDorNo string
|
|
350
|
+ DiseDorName string
|
|
351
|
+ DiagTime string
|
|
352
|
+}
|
|
353
|
+type Struct2402 struct {
|
|
354
|
+ MdtrtId string
|
|
355
|
+ PsnNo string
|
|
356
|
+ Insutype string
|
|
357
|
+ Endtime string
|
|
358
|
+ DscgDeptCodg string
|
|
359
|
+ DscgDeptName string
|
|
360
|
+ DscgWay string
|
|
361
|
+ Diseinfo []Diseinfo2402Struct
|
|
362
|
+}
|
|
363
|
+
|
|
364
|
+// 出院
|
|
365
|
+func ZHGdyb2402(struct2402 Struct2402, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
|
|
366
|
+
|
|
367
|
+ // 生成签名
|
|
368
|
+ nonce := GetRandomString(32)
|
|
369
|
+ timestamp := time.Now().Unix()
|
|
370
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
371
|
+ //tempTime := time.Unix(timestamp, 0)
|
|
372
|
+ //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
373
|
+
|
|
374
|
+ // 生成输入报文
|
|
375
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
376
|
+ input := make(map[string]interface{})
|
|
377
|
+ inputData := make(map[string]interface{})
|
|
378
|
+ inputMessage["infno"] = "2402" // 交易编码
|
|
379
|
+ inputData["mdtrt_id"] = struct2402.MdtrtId // 人员编号 (来自1101接口返回)
|
|
380
|
+ inputData["psn_no"] = struct2402.PsnNo // 人员编号 (来自1101接口返回)
|
|
381
|
+ inputData["insutype"] = struct2402.Insutype // 险种类型(来自1101接口返回)
|
|
382
|
+ inputData["endtime"] = struct2402.Endtime // 结束时间
|
|
383
|
+ inputData["dise_codg"] = "" // 就诊凭证类型
|
|
384
|
+
|
|
385
|
+ inputData["dise_name"] = "" // 就诊凭证类型
|
|
386
|
+ inputData["oprn_oprt_code"] = "" // 就诊凭证类型
|
|
387
|
+ inputData["oprn_oprt_name"] = "" // 就诊凭证类型
|
|
388
|
+ inputData["fpsc_no"] = "" // 就诊凭证类型
|
|
389
|
+
|
|
390
|
+ inputData["matn_type"] = "" // 就诊凭证类型
|
|
391
|
+ inputData["birctrl_type"] = "" // 就诊凭证类型
|
|
392
|
+ inputData["latechb_flag"] = "" // 就诊凭证类型
|
|
393
|
+ inputData["geso_val"] = ""
|
|
394
|
+ inputData["fetts"] = ""
|
|
395
|
+ inputData["fetus_cnt"] = ""
|
|
396
|
+ inputData["pret_flag"] = ""
|
|
397
|
+ inputData["birctrl_matn_date"] = ""
|
|
398
|
+ inputData["cop_flag"] = ""
|
|
399
|
+
|
|
400
|
+ inputData["dscg_dept_codg"] = struct2402.DscgDeptCodg
|
|
401
|
+ inputData["dscg_dept_name"] = struct2402.DscgDeptName
|
|
402
|
+ inputData["dscg_bed"] = ""
|
|
403
|
+ inputData["dscg_way"] = struct2402.DscgWay
|
|
404
|
+ inputData["die_date"] = ""
|
|
405
|
+
|
|
406
|
+ inputDataArr := make([]map[string]interface{}, 0)
|
|
407
|
+ for _, item := range struct2402.Diseinfo {
|
|
408
|
+ inputDataTwo := make(map[string]interface{})
|
|
409
|
+ inputDataTwo["psn_no"] = item.PsnNo
|
|
410
|
+ inputDataTwo["diag_type"] = item.DiagType
|
|
411
|
+ inputDataTwo["maindiag_flag"] = item.MaindiagFlag
|
|
412
|
+ inputDataTwo["diag_srt_no"] = item.DiagSrtNo
|
|
413
|
+ inputDataTwo["diag_code"] = item.DiagCode
|
|
414
|
+ inputDataTwo["diag_name"] = item.DiagName
|
|
415
|
+ inputDataTwo["adm_cond"] = ""
|
|
416
|
+ inputDataTwo["diag_dept"] = item.DiagDept
|
|
417
|
+ inputDataTwo["dise_dor_no"] = item.DiseDorNo
|
|
418
|
+ inputDataTwo["dise_dor_name"] = item.DiseDorName
|
|
419
|
+ inputDataTwo["diag_time"] = item.DiagTime
|
|
420
|
+ inputDataArr = append(inputDataArr, inputDataTwo)
|
|
421
|
+ }
|
|
422
|
+
|
|
423
|
+ input["mdtrtinfo"] = inputData
|
|
424
|
+ input["diseinfo"] = inputDataArr
|
|
425
|
+
|
|
426
|
+ inputMessage["input"] = input //交易输入
|
|
427
|
+
|
|
428
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
429
|
+ fmt.Println(string(bytesData))
|
|
430
|
+ if err != nil {
|
|
431
|
+ fmt.Println(err.Error())
|
|
432
|
+ return err.Error()
|
|
433
|
+ }
|
|
434
|
+ reader := bytes.NewReader(bytesData)
|
|
435
|
+
|
|
436
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
437
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
438
|
+ url := gdyb_url + "2402"
|
|
439
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
|
|
440
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
|
|
441
|
+
|
|
442
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
|
|
443
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
444
|
+ if err != nil {
|
|
445
|
+ fmt.Println(err.Error())
|
|
446
|
+ return err.Error()
|
|
447
|
+ }
|
|
448
|
+
|
|
449
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
450
|
+ //request.Header.Set("x-tif-paasid", "test_hosp")
|
|
451
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
452
|
+
|
|
453
|
+ request.Header.Set("x-tif-signature", signature)
|
|
454
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
455
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
456
|
+
|
|
457
|
+ client := http.Client{}
|
|
458
|
+ resp, err := client.Do(request)
|
|
459
|
+ if err != nil {
|
|
460
|
+ fmt.Println(err.Error())
|
|
461
|
+ return err.Error()
|
|
462
|
+ }
|
|
463
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
464
|
+ if err != nil {
|
|
465
|
+ fmt.Println(err.Error())
|
|
466
|
+ return err.Error()
|
|
467
|
+ }
|
|
468
|
+ str := string(respBytes)
|
|
469
|
+ fmt.Println(str)
|
|
470
|
+ return str
|
|
471
|
+}
|
|
472
|
+
|
|
473
|
+type ZHCustom struct {
|
|
474
|
+ DetItemFeeSumamt string
|
|
475
|
+ Cut string
|
|
476
|
+ FeedetlSn string
|
|
477
|
+ Price string
|
|
478
|
+ MedListCodg string
|
|
479
|
+ LmtUsedFlag int64
|
|
480
|
+ HospApprFlag int64
|
|
481
|
+}
|
|
482
|
+type ZHRequestResult struct {
|
|
483
|
+ Output Output `json:"output" form:"output"`
|
|
484
|
+ Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
|
|
485
|
+ WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
|
|
486
|
+ Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
|
|
487
|
+ ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
|
|
488
|
+ RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
|
|
489
|
+ InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
|
|
490
|
+}
|
|
491
|
+type ZHOutput struct {
|
|
492
|
+ Result Result `json:"result" form:"result"`
|
|
493
|
+}
|
|
494
|
+type ZHResult struct {
|
|
495
|
+ BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
|
|
496
|
+ MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
|
|
497
|
+ DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
|
|
498
|
+ HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
|
|
499
|
+ FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
|
|
500
|
+
|
|
501
|
+ FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
|
|
502
|
+ UploadDate int64 `json:"upload_date" form:"upload_date"`
|
|
503
|
+ AdviceId int64 `json:"advice_id" form:"advice_id"`
|
|
504
|
+ Cnt int64 `json:"cnt" form:"cnt"`
|
|
505
|
+ Pric float64 `json:"pric" form:"pric"`
|
|
506
|
+ PatientId int64 `json:"patient_id" form:"patient_id"`
|
|
507
|
+ PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
|
|
508
|
+ SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
|
|
509
|
+ OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
|
|
510
|
+ PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
|
|
511
|
+ Status int64 `json:"status" form:"status"`
|
|
512
|
+ Memo string `json:"memo" form:"memo"`
|
|
513
|
+ FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
|
|
514
|
+ Mtime int64 `json:"mtime" form:"mtime"`
|
|
515
|
+ InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
|
|
516
|
+ DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
|
|
517
|
+ Ctime int64 `json:"ctime" form:"ctime"`
|
|
518
|
+ ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
|
|
519
|
+ ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
|
|
520
|
+ LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
|
|
521
|
+ ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
|
|
522
|
+ UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
|
|
523
|
+ HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
|
|
524
|
+ OrderId int64 `json:"order_id" form:"order_id"`
|
|
525
|
+}
|
|
526
|
+
|
|
527
|
+// 住院费用明细信息上传
|
|
528
|
+func ZHGdyb2301(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, med_type string) string {
|
|
529
|
+ // 生成签名
|
|
530
|
+ nonce := GetRandomString(32)
|
|
531
|
+ timestamp := time.Now().Unix()
|
|
532
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
533
|
+ tempTime := time.Unix(timestamp, 0)
|
|
534
|
+ //timeFormat := tempTime.Format("20060102150405")
|
|
535
|
+ timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
|
|
536
|
+ //chrgBchno := rand.Intn(100000) + 10000
|
|
537
|
+
|
|
538
|
+ var customs []*Custom
|
|
539
|
+
|
|
540
|
+ for _, item := range hisPrescription {
|
|
541
|
+ if item.Type == 1 { //药品
|
|
542
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
543
|
+ if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
|
|
544
|
+ //var randNum int
|
|
545
|
+ //randNum = rand.Intn(10000) + 1000
|
|
546
|
+ cus := &Custom{
|
|
547
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
|
|
548
|
+ Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
|
|
549
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
550
|
+ Price: fmt.Sprintf("%.2f", subItem.Price),
|
|
551
|
+ MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
|
|
552
|
+ HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
|
|
553
|
+ }
|
|
554
|
+
|
|
555
|
+ customs = append(customs, cus)
|
|
556
|
+ }
|
|
557
|
+ }
|
|
558
|
+ }
|
|
559
|
+
|
|
560
|
+ if item.Type == 2 { //项目
|
|
561
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
562
|
+ //var randNum int
|
|
563
|
+ //randNum = rand.Intn(10000) + 1000
|
|
564
|
+ if len(subItem.HisProject.MedicalCode) > 0 {
|
|
565
|
+
|
|
566
|
+ cus := &Custom{
|
|
567
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
|
|
568
|
+ Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
|
|
569
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
570
|
+ Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
|
|
571
|
+ MedListCodg: subItem.HisProject.MedicalCode,
|
|
572
|
+ HospApprFlag: -1,
|
|
573
|
+ }
|
|
574
|
+ customs = append(customs, cus)
|
|
575
|
+ }
|
|
576
|
+ }
|
|
577
|
+ }
|
|
578
|
+
|
|
579
|
+ for _, subItem := range item.HisAdditionalCharge {
|
|
580
|
+ if len(subItem.XtHisAddtionConfig.Code) > 0 {
|
|
581
|
+ cus := &Custom{
|
|
582
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
|
|
583
|
+ Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
|
|
584
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
585
|
+ Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
|
|
586
|
+ MedListCodg: subItem.XtHisAddtionConfig.Code,
|
|
587
|
+ HospApprFlag: -1,
|
|
588
|
+ }
|
|
589
|
+ customs = append(customs, cus)
|
|
590
|
+ }
|
|
591
|
+ }
|
|
592
|
+ }
|
|
593
|
+
|
|
594
|
+ // 生成输入报文
|
|
595
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
596
|
+ input := make(map[string]interface{})
|
|
597
|
+ feedetail := make([]map[string]interface{}, 0)
|
|
598
|
+ inputMessage["infno"] = "2301" // 交易编码
|
|
599
|
+
|
|
600
|
+ //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
|
|
601
|
+ for _, item := range customs {
|
|
602
|
+ feedetailInfo := make(map[string]interface{})
|
|
603
|
+ feedetailInfo["feedetl_sn"] = item.FeedetlSn
|
|
604
|
+ feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
605
|
+ feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
606
|
+ feedetailInfo["med_type"] = med_type
|
|
607
|
+ feedetailInfo["fee_ocur_time"] = timeFormatOne // 费用发生时间
|
|
608
|
+ feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
|
|
609
|
+ feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
|
|
610
|
+ feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
|
|
611
|
+ feedetailInfo["cnt"] = item.Cut // 数量
|
|
612
|
+ feedetailInfo["pric"] = item.Price // 单价
|
|
613
|
+ feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
|
|
614
|
+ feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
|
|
615
|
+ feedetailInfo["bilg_dr_codg"] = doctor_id // 开单医生编码
|
|
616
|
+ feedetailInfo["bilg_dr_name"] = doctor
|
|
617
|
+ feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
|
|
618
|
+ feedetailInfo["acord_dept_name"] = "" // 受单科室名称
|
|
619
|
+ feedetailInfo["orders_dr_code"] = "" // 受单医生编码
|
|
620
|
+ feedetailInfo["orders_dr_name"] = "" // 受单医生姓名
|
|
621
|
+ feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
|
|
622
|
+ feedetailInfo["dise_codg"] = "" // 病种编码
|
|
623
|
+ feedetailInfo["rxno"] = "" // 处方号
|
|
624
|
+ feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
|
|
625
|
+ feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
|
|
626
|
+ feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
|
|
627
|
+ feedetailInfo["prd_days"] = "0" // 周期天数
|
|
628
|
+ feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
|
|
629
|
+ // 开单医师姓名
|
|
630
|
+
|
|
631
|
+ if item.HospApprFlag != -1 {
|
|
632
|
+ if item.HospApprFlag == 1 {
|
|
633
|
+ feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
|
|
634
|
+ } else if item.HospApprFlag == 2 {
|
|
635
|
+ feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
|
|
636
|
+ } else if item.HospApprFlag == 3 {
|
|
637
|
+ feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
|
|
638
|
+ } else {
|
|
639
|
+ feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
|
|
640
|
+ }
|
|
641
|
+ } else {
|
|
642
|
+ feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
|
|
643
|
+ }
|
|
644
|
+
|
|
645
|
+ feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
|
|
646
|
+ feedetailInfo["etip_flag"] = "" // 外检标志
|
|
647
|
+ feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
|
|
648
|
+ feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
|
|
649
|
+ feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
|
|
650
|
+ feedetail = append(feedetail, feedetailInfo)
|
|
651
|
+ }
|
|
652
|
+ input["feedetail"] = feedetail
|
|
653
|
+ inputMessage["input"] = input //交易输入
|
|
654
|
+
|
|
655
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
656
|
+ fmt.Println("----------")
|
|
657
|
+ fmt.Println(string(bytesData))
|
|
658
|
+ fmt.Println("----------")
|
|
659
|
+
|
|
660
|
+ if err != nil {
|
|
661
|
+ fmt.Println(err.Error())
|
|
662
|
+ return ""
|
|
663
|
+ }
|
|
664
|
+ reader := bytes.NewReader(bytesData)
|
|
665
|
+
|
|
666
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
667
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
668
|
+ url := gdyb_url + "2301"
|
|
669
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
670
|
+ if err != nil {
|
|
671
|
+ fmt.Println(err.Error())
|
|
672
|
+ return ""
|
|
673
|
+ }
|
|
674
|
+
|
|
675
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
676
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
677
|
+ request.Header.Set("x-tif-signature", signature)
|
|
678
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
679
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
680
|
+
|
|
681
|
+ client := http.Client{}
|
|
682
|
+ resp, err := client.Do(request)
|
|
683
|
+ if err != nil {
|
|
684
|
+ fmt.Println(err.Error())
|
|
685
|
+ return ""
|
|
686
|
+ }
|
|
687
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
688
|
+ if err != nil {
|
|
689
|
+ fmt.Println(err.Error())
|
|
690
|
+ return ""
|
|
691
|
+ }
|
|
692
|
+ return string(respBytes)
|
|
693
|
+
|
|
694
|
+}
|
|
695
|
+
|
|
696
|
+// 住院费用明细信息撤销
|
|
697
|
+func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
|
|
698
|
+ // 生成签名
|
|
699
|
+ nonce := GetRandomString(32)
|
|
700
|
+ timestamp := time.Now().Unix()
|
|
701
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
702
|
+
|
|
703
|
+ // 生成输入报文
|
|
704
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
705
|
+ input := make(map[string]interface{})
|
|
706
|
+ inputData := make(map[string]interface{})
|
|
707
|
+ inputMessage["infno"] = "2302" // 交易编码
|
|
708
|
+
|
|
709
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID
|
|
710
|
+ inputData["feedetl_sn"] = "0000" //
|
|
711
|
+ inputData["psn_no"] = psnNo // 人员编号
|
|
712
|
+
|
|
713
|
+ input["data"] = inputData
|
|
714
|
+ inputMessage["input"] = input //交易输入
|
|
715
|
+
|
|
716
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
717
|
+ fmt.Println(string(bytesData))
|
|
718
|
+ if err != nil {
|
|
719
|
+ fmt.Println(err.Error())
|
|
720
|
+ return err.Error()
|
|
721
|
+ }
|
|
722
|
+ reader := bytes.NewReader(bytesData)
|
|
723
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
724
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
725
|
+
|
|
726
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
|
|
727
|
+ url := gdyb_url + "2302"
|
|
728
|
+
|
|
729
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
|
|
730
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
|
|
731
|
+
|
|
732
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
|
|
733
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
734
|
+ fmt.Println(err)
|
|
735
|
+
|
|
736
|
+ fmt.Println(request)
|
|
737
|
+ if err != nil {
|
|
738
|
+ fmt.Println(err.Error())
|
|
739
|
+ return err.Error()
|
|
740
|
+ }
|
|
741
|
+
|
|
742
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
743
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
744
|
+ request.Header.Set("x-tif-signature", signature)
|
|
745
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
746
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
747
|
+
|
|
748
|
+ client := http.Client{}
|
|
749
|
+ resp, err := client.Do(request)
|
|
750
|
+ if err != nil {
|
|
751
|
+ fmt.Println(err.Error())
|
|
752
|
+ return err.Error()
|
|
753
|
+ }
|
|
754
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
755
|
+ if err != nil {
|
|
756
|
+ fmt.Println(err.Error())
|
|
757
|
+ return err.Error()
|
|
758
|
+ }
|
|
759
|
+ str := string(respBytes)
|
|
760
|
+ fmt.Println(str)
|
|
761
|
+ return str
|
|
762
|
+}
|
|
763
|
+
|
|
764
|
+// 住院结算
|
|
765
|
+func ZHGdyb2304(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, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
|
|
766
|
+ // 生成签名
|
|
767
|
+ nonce := GetRandomString(32)
|
|
768
|
+ timestamp := time.Now().Unix()
|
|
769
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
770
|
+
|
|
771
|
+ // 生成输入报文
|
|
772
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
773
|
+ input := make(map[string]interface{})
|
|
774
|
+ inputData := make(map[string]interface{})
|
|
775
|
+ inputMessage["infno"] = "2304" // 交易编码
|
|
776
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
777
|
+ if certificates == 3 {
|
|
778
|
+ inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
|
|
779
|
+ inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
|
780
|
+ } else {
|
|
781
|
+ if id_card_type == 1 {
|
|
782
|
+ inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
|
|
783
|
+ inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
|
784
|
+ } else {
|
|
785
|
+ inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
|
|
786
|
+ inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
|
787
|
+ }
|
|
788
|
+ }
|
|
789
|
+
|
|
790
|
+ inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
|
|
791
|
+ inputData["medfee_sumamt"] = total // 医疗费总额
|
|
792
|
+ inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
|
|
793
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
794
|
+ inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
|
|
795
|
+ inputData["acct_used_flag"] = "1" // 个人账户使用标志 0否 1是
|
|
796
|
+ inputData["insutype"] = insutype // 险种类型
|
|
797
|
+ inputData["invono"] = "" // 发票号
|
|
798
|
+
|
|
799
|
+ inputData["mid_setl_flag"] = "" // 中途结算标志
|
|
800
|
+
|
|
801
|
+ inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
|
|
802
|
+ inputData["overlmt_selfpay"] = overlmt_selfpay //
|
|
803
|
+ inputData["preselfpay_amt"] = preselfpay_amt //
|
|
804
|
+ inputData["inscp_scp_amt"] = inscp_scp_amt //
|
|
805
|
+
|
|
806
|
+ input["data"] = inputData
|
|
807
|
+ inputMessage["input"] = input //交易输入
|
|
808
|
+
|
|
809
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
810
|
+ fmt.Println(string(bytesData))
|
|
811
|
+ if err != nil {
|
|
812
|
+ fmt.Println(err.Error())
|
|
813
|
+ return err.Error(), ""
|
|
814
|
+ }
|
|
815
|
+ reader := bytes.NewReader(bytesData)
|
|
816
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
817
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
818
|
+
|
|
819
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
|
|
820
|
+ url := gdyb_url + "2304"
|
|
821
|
+
|
|
822
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
|
|
823
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
|
|
824
|
+
|
|
825
|
+ //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
|
|
826
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
827
|
+ if err != nil {
|
|
828
|
+ fmt.Println(err.Error())
|
|
829
|
+ return err.Error(), ""
|
|
830
|
+ }
|
|
831
|
+
|
|
832
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
833
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
834
|
+ request.Header.Set("x-tif-signature", signature)
|
|
835
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
836
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
837
|
+
|
|
838
|
+ client := http.Client{}
|
|
839
|
+ resp, err := client.Do(request)
|
|
840
|
+ if err != nil {
|
|
841
|
+ fmt.Println(err.Error())
|
|
842
|
+ return err.Error(), ""
|
|
843
|
+ }
|
|
844
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
845
|
+ if err != nil {
|
|
846
|
+ fmt.Println(err.Error())
|
|
847
|
+ return err.Error(), ""
|
|
848
|
+ }
|
|
849
|
+ str := string(respBytes)
|
|
850
|
+ fmt.Println(str)
|
|
851
|
+ mjson, _ := json.Marshal(inputMessage)
|
|
852
|
+ str2 := string(mjson)
|
|
853
|
+
|
|
854
|
+ return str, str2
|
|
855
|
+}
|
|
856
|
+
|
|
857
|
+// 住院结算撤销
|
|
858
|
+func Gdyb2305(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
|
|
859
|
+ // 生成签名
|
|
860
|
+ nonce := GetRandomString(32)
|
|
861
|
+ timestamp := time.Now().Unix()
|
|
862
|
+ signature := setSignature(timestamp, nonce, secret_key)
|
|
863
|
+
|
|
864
|
+ // 生成输入报文
|
|
865
|
+ inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
|
|
866
|
+ input := make(map[string]interface{})
|
|
867
|
+ inputData := make(map[string]interface{})
|
|
868
|
+ inputMessage["infno"] = "2305" // 交易编码
|
|
869
|
+
|
|
870
|
+ inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
|
|
871
|
+ inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
|
|
872
|
+ inputData["setl_id"] = setlId // 结算 ID
|
|
873
|
+
|
|
874
|
+ input["data"] = inputData
|
|
875
|
+ inputMessage["input"] = input //交易输入
|
|
876
|
+
|
|
877
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
878
|
+ fmt.Println(string(bytesData))
|
|
879
|
+ if err != nil {
|
|
880
|
+ fmt.Println(err.Error())
|
|
881
|
+ return err.Error(), ""
|
|
882
|
+ }
|
|
883
|
+ reader := bytes.NewReader(bytesData)
|
|
884
|
+ gdyb_url := beego.AppConfig.String("gdyb_url")
|
|
885
|
+ gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
|
|
886
|
+ url := gdyb_url + "2305"
|
|
887
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
888
|
+ if err != nil {
|
|
889
|
+ fmt.Println(err.Error())
|
|
890
|
+ return err.Error(), ""
|
|
891
|
+ }
|
|
892
|
+
|
|
893
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
894
|
+ request.Header.Set("x-tif-paasid", gdyb_paasid)
|
|
895
|
+ request.Header.Set("x-tif-signature", signature)
|
|
896
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
897
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
898
|
+
|
|
899
|
+ client := http.Client{}
|
|
900
|
+ resp, err := client.Do(request)
|
|
901
|
+ if err != nil {
|
|
902
|
+ fmt.Println(err.Error())
|
|
903
|
+ return err.Error(), ""
|
|
904
|
+ }
|
|
905
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
906
|
+ if err != nil {
|
|
907
|
+ fmt.Println(err.Error())
|
|
908
|
+ return err.Error(), ""
|
|
909
|
+ }
|
|
910
|
+ str := string(respBytes)
|
|
911
|
+ fmt.Println(str)
|
|
912
|
+ mjson, _ := json.Marshal(inputMessage)
|
|
913
|
+ str2 := string(mjson)
|
|
914
|
+ return str, str2
|
|
915
|
+}
|
|
916
|
+
|
|
917
|
+func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
|
|
918
|
+ err = writeDb.Save(&record).Error
|
|
919
|
+ return
|
|
920
|
+}
|
|
921
|
+
|
|
922
|
+func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err error) {
|
|
923
|
+ err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
|
|
924
|
+ return
|
|
925
|
+}
|
|
926
|
+
|
|
927
|
+func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
|
|
928
|
+ err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 AND user_org_id = ?", id, user_org_id).Last(&record).Error
|
|
929
|
+ return
|
|
930
|
+}
|