陈少旭 1 년 전
부모
커밋
770ec95541
5개의 변경된 파일2388개의 추가작업 그리고 128개의 파일을 삭제
  1. 0 1
      controllers/js/jsyb_controller.go
  2. 352 22
      controllers/nm/nm_controller.go
  3. 1202 90
      controllers/sg/his_api_controller.go
  4. 16 15
      service/gdyb_service.go
  5. 818 0
      service/nm_service.go

+ 0 - 1
controllers/js/jsyb_controller.go 파일 보기

@@ -1217,7 +1217,6 @@ func (c *JSybController) PostThree() {
1217 1217
 		"request_log": dat2,
1218 1218
 	})
1219 1219
 }
1220
-
1221 1220
 func (c *JSybController) PostFour() {
1222 1221
 
1223 1222
 	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)

+ 352 - 22
controllers/nm/nm_controller.go 파일 보기

@@ -41,24 +41,369 @@ func NmybRegistRouters() {
41 41
 	beego.Router("/nmyb/2303", &NmController{}, "get:Post2303")
42 42
 	beego.Router("/nmyb/2304", &NmController{}, "get:Post2304")
43 43
 	beego.Router("/nmyb/2305", &NmController{}, "get:Post2305")
44
-
45 44
 	beego.Router("/nmyb/5203", &NmController{}, "get:Post5203")
46
-
47 45
 	beego.Router("/nmyb/readcard", &NmController{}, "get:ReadCard")
48
-
49 46
 	beego.Router("/nmyb/3201", &NmController{}, "get:Get3201")
50
-	beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
51
-
52 47
 	beego.Router("/nmyb/4101", &NmController{}, "post:Post4101")
53 48
 	beego.Router("/nmyb/2601", &NmController{}, "get:Get2601")
54
-
55 49
 	beego.Router("/api/token", &NmController{}, "get:GetToken")
56 50
 	beego.Router("/api/eleinfo", &NmController{}, "get:GetNewELeInfo")
57
-
58 51
 	beego.Router("/nmyb/4102", &NmController{}, "get:Post4102")
59 52
 	beego.Router("/nmyb/4103", &NmController{}, "get:Post4103")
60 53
 
54
+	beego.Router("/nmyb/2201", &NmController{}, "get:Post2201")
55
+	beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
56
+	beego.Router("/nmyb/2203", &NmController{}, "get:Post2203")
57
+	beego.Router("/nmyb/2204", &NmController{}, "get:Post2204")
58
+	beego.Router("/nmyb/2205", &NmController{}, "get:Post2205")
59
+	beego.Router("/nmyb/2206", &NmController{}, "get:Post2206")
60
+	beego.Router("/nmyb/2207", &NmController{}, "get:Post2207")
61
+	beego.Router("/nmyb/2208", &NmController{}, "get:Post2208")
62
+
63
+}
64
+
65
+func (c *NmController) Post2201() {
66
+	psnNo := c.GetString("psn_no")
67
+	insutype := c.GetString("insutype")
68
+	certNo := c.GetString("cert_no")
69
+	org_name := c.GetString("org_name")
70
+	doctor := c.GetString("doctor")
71
+	ipt_otp_no := c.GetString("ipt_otp_no")
72
+	dept := c.GetString("dept")
73
+	verify_number := c.GetString("verify_number")
74
+	fixmedins_code := c.GetString("fixmedins_code")
75
+	dept_code := c.GetString("dept_code")
76
+	doctor_id := c.GetString("doctor_id")
77
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
78
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
79
+	secret_key := c.GetString("secret_key")
80
+	id_card_type, _ := c.GetInt64("id_card_type")
81
+	doctor_name := c.GetString("doctor_name")
82
+	cainfo := c.GetString("cainfo")
83
+	result, request_log := service.Nmyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, verify_number, cainfo)
84
+	saveJsLog(result, request_log, "2201", "挂号", org_name)
85
+	var dat map[string]interface{}
86
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
87
+	} else {
88
+	}
89
+	var dat2 map[string]interface{}
90
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
91
+	} else {
92
+	}
93
+	c.ServeSuccessJSON(map[string]interface{}{
94
+		"pre":         dat,
95
+		"request_log": dat2,
96
+	})
97
+}
98
+func (c *NmController) Post2202() {
99
+	psnNo := c.GetString("psn_no")
100
+	mdtrtId := c.GetString("mdtrt_id")
101
+	iptOtpNo := c.GetString("ipt_otp_no")
102
+	org_name := c.GetString("org_name")
103
+	doctor := c.GetString("doctor")
104
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
105
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
106
+	secret_key := c.GetString("secret_key")
107
+	fixmedins_code := c.GetString("fixmedins_code")
108
+	cainfo := c.GetString("cainfo")
109
+
110
+	result, request_log := service.Nmyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, cainfo)
111
+	saveJsLog(result, request_log, "2202", "退号", org_name)
112
+	var dat map[string]interface{}
113
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
114
+	} else {
115
+	}
116
+
117
+	var dat2 map[string]interface{}
118
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
119
+
120
+	} else {
121
+
122
+	}
123
+	c.ServeSuccessJSON(map[string]interface{}{
124
+		"pre":         dat,
125
+		"request_log": dat2,
126
+	})
127
+}
128
+func (c *NmController) Post2203() {
129
+
130
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
131
+	var respJSON map[string]interface{}
132
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
133
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
134
+		return
135
+	}
136
+	userJSONBytes, _ := json.Marshal(respJSON["config"])
137
+	var config []*models.HisXtDiagnoseConfig
138
+	if err := json.Unmarshal(userJSONBytes, &config); err != nil {
139
+		utils.ErrorLog("解析失败:%v", err)
140
+		return
141
+	}
142
+	fmt.Println(respJSON["psn_no"].(string))
143
+	fmt.Println(respJSON["mdtrt_id"].(string))
144
+
145
+	psnNo := respJSON["psn_no"].(string)
146
+	mdtrtId := respJSON["mdtrt_id"].(string)
147
+	doctor := respJSON["doctor"].(string)
148
+	department := respJSON["department"].(string)
149
+
150
+	org_name := respJSON["org_name"].(string)
151
+	med_type := respJSON["med_type"].(string)
152
+	doctor_id := respJSON["doctor_id"].(string)
153
+	fixmedins_code := respJSON["fixmedins_code"].(string)
154
+	sick_code := respJSON["sick_code"].(string)
155
+	sick_name := respJSON["sick_name"].(string)
156
+	dept := respJSON["dept"].(string)
157
+
158
+	insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
159
+	mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
160
+	secret_key := respJSON["secret_key"].(string)
161
+
162
+	begin_time := respJSON["begin_time"].(string)
163
+	cainfo := respJSON["cainfo"].(string)
164
+
165
+	//cainfo := c.GetString("cainfo")
166
+
167
+	result, request_log := service.Nmyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, begin_time, cainfo)
168
+	saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
169
+	var dat2 map[string]interface{}
170
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
171
+
172
+	} else {
173
+
174
+	}
175
+
176
+	var dat map[string]interface{}
177
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
178
+
179
+	} else {
180
+
181
+	}
182
+
183
+	var dat3 int64
184
+	if err := json.Unmarshal([]byte(strconv.FormatInt(timeStamp, 10)), &dat3); err == nil {
185
+
186
+	} else {
187
+
188
+	}
189
+	c.ServeSuccessJSON(map[string]interface{}{
190
+		"pre":         dat,
191
+		"request_log": dat2,
192
+		"time_stamp":  dat3,
193
+	})
194
+}
195
+func (c *NmController) Post2204() {
196
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
197
+	var respJSON map[string]interface{}
198
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
199
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
200
+		return
201
+	}
202
+	userJSONBytes, _ := json.Marshal(respJSON["pre"])
203
+	var hp []*models.HisPrescription
204
+	if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
205
+		utils.ErrorLog("解析失败:%v", err)
206
+		return
207
+	}
208
+	//fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
209
+	result, request_log := service.Nmyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
210
+		respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string), respJSON["balance_accounts_type"].(string), respJSON["diag_code"].(string), respJSON["url"].(string), respJSON["ak"].(string), respJSON["new_doctor_name"].(string), "", respJSON["cainfo"].(string))
211
+
212
+	saveJsLog(result, request_log, "2204", "上传明细", respJSON["org_name"].(string))
213
+	var dat map[string]interface{}
214
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
215
+		fmt.Println(dat)
216
+	} else {
217
+		fmt.Println(err)
218
+	}
219
+
220
+	var dat2 map[string]interface{}
221
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
222
+		fmt.Println(dat2)
223
+	} else {
224
+		fmt.Println(err)
225
+	}
226
+
227
+	c.ServeSuccessJSON(map[string]interface{}{
228
+		"pre":         dat,
229
+		"request_log": dat2,
230
+	})
231
+}
232
+func (c *NmController) Post2205() {
233
+	psnNo := c.GetString("psn_no")
234
+	mdtrtId := c.GetString("mdtrt_id")
235
+	chrgBchno := c.GetString("chrg_bchno")
236
+	org_name := c.GetString("org_name")
237
+	doctor := c.GetString("doctor")
238
+
239
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
240
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
241
+
242
+	secret_key := c.GetString("secret_key")
243
+	fixmedins_code := c.GetString("fixmedins_code")
244
+	url := c.GetString("url")
245
+	ak := c.GetString("ak")
246
+	cainfo := c.GetString("cainfo")
247
+
248
+	result, request_log := service.Nmyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
249
+	fmt.Println(request_log)
250
+	saveJsLog(result, request_log, "2205", "撤销明细", org_name)
251
+	var dat map[string]interface{}
252
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
253
+		fmt.Println(dat)
254
+	} else {
255
+		fmt.Println(err)
256
+	}
257
+	var dat2 map[string]interface{}
258
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
259
+		fmt.Println(dat2)
260
+	} else {
261
+		fmt.Println(err)
262
+	}
263
+
264
+	c.ServeSuccessJSON(map[string]interface{}{
265
+		"pre":         dat,
266
+		"request_log": dat2,
267
+	})
61 268
 }
269
+func (c *NmController) Post2206() {
270
+	psnNo := c.GetString("psn_no")
271
+	mdtrtId := c.GetString("mdtrt_id")
272
+	chrgBchno := c.GetString("chrg_bchno")
273
+	certNo := c.GetString("cert_no")
274
+	insutype := c.GetString("insutype")
275
+	total := c.GetString("total")
276
+	org_name := c.GetString("org_name")
277
+	doctor := c.GetString("doctor")
278
+	fixmedins_code := c.GetString("fixmedins_code")
279
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
280
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
281
+	secret_key := c.GetString("secret_key")
282
+	med_type := c.GetString("med_type")
283
+	id_card_type, _ := c.GetInt64("id_card_type")
284
+	certificates, _ := c.GetInt64("certificates")
285
+	verify_number := c.GetString("verify_number")
286
+	cainfo := c.GetString("cainfo")
287
+	mdtrt_grp_type := c.GetString("mdtrt_grp_type")
288
+
289
+	url := c.GetString("url")
290
+	ak := c.GetString("ak")
291
+
292
+	var result string
293
+	var request_log string
294
+
295
+	result, request_log = service.Nmyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, 0, 0, 0, 0, certificates, url, ak, verify_number, cainfo, mdtrt_grp_type)
296
+
297
+	saveJsLog(result, request_log, "2206", "预结算", org_name)
298
+	var dat map[string]interface{}
299
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
300
+		fmt.Println(dat)
301
+	} else {
302
+		fmt.Println(err)
303
+	}
304
+
305
+	var dat2 map[string]interface{}
306
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
307
+		fmt.Println(dat2)
308
+	} else {
309
+		fmt.Println(err)
310
+	}
311
+	c.ServeSuccessJSON(map[string]interface{}{
312
+		"pre":         dat,
313
+		"request_log": dat2,
314
+	})
315
+}
316
+func (c *NmController) Post2207() {
317
+	psnNo := c.GetString("psn_no")
318
+	mdtrtId := c.GetString("mdtrt_id")
319
+	chrgBchno := c.GetString("chrg_bchno")
320
+	certNo := c.GetString("cert_no")
321
+	insutype := c.GetString("insutype")
322
+	total := c.GetString("total")
323
+	org_name := c.GetString("org_name")
324
+	doctor := c.GetString("doctor")
325
+	fixmedins_code := c.GetString("fixmedins_code")
326
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
327
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
328
+	secret_key := c.GetString("secret_key")
329
+	med_type := c.GetString("med_type")
330
+	id_card_type, _ := c.GetInt64("id_card_type")
331
+	certificates, _ := c.GetInt64("certificates")
332
+
333
+	fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
334
+	overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
335
+	preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
336
+	inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
337
+
338
+	acct_used_flag := c.GetString("acct_used_flag")
339
+
340
+	url := c.GetString("url")
341
+	ak := c.GetString("ak")
342
+	verify_number := c.GetString("verify_number")
343
+	cainfo := c.GetString("cainfo")
344
+	mdtrt_grp_type := c.GetString("mdtrt_grp_type")
345
+
346
+	var result string
347
+	var request_log string
348
+
349
+	result, request_log = service.Nmyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt, certificates, acct_used_flag, url, ak, verify_number, cainfo, mdtrt_grp_type)
350
+
351
+	saveJsLog(result, request_log, "2207", "结算", org_name)
352
+	var dat map[string]interface{}
353
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
354
+		fmt.Println(dat)
355
+	} else {
356
+		fmt.Println(err)
357
+	}
358
+
359
+	var dat2 map[string]interface{}
360
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
361
+		fmt.Println(dat2)
362
+	} else {
363
+		fmt.Println(err)
364
+	}
365
+
366
+	c.ServeSuccessJSON(map[string]interface{}{
367
+		"pre":         dat,
368
+		"request_log": dat2,
369
+	})
370
+}
371
+func (c *NmController) Post2208() {
372
+	psnNo := c.GetString("psn_no")
373
+	mdtrtId := c.GetString("mdtrt_id")
374
+	setlId := c.GetString("setl_id")
375
+	org_name := c.GetString("org_name")
376
+	doctor := c.GetString("doctor")
377
+	secret_key := c.GetString("secret_key")
378
+	fixmedins_code := c.GetString("fixmedins_code")
379
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
380
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
381
+	url := c.GetString("url")
382
+	ak := c.GetString("ak")
383
+	cainfo := c.GetString("cainfo")
384
+
385
+	result, request_log := service.Nmyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
386
+	saveJsLog(result, request_log, "2208", "退费", org_name)
387
+	fmt.Println(request_log)
388
+	var dat map[string]interface{}
389
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
390
+		fmt.Println(dat)
391
+	} else {
392
+		fmt.Println(err)
393
+	}
394
+	var dat2 map[string]interface{}
395
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
396
+		fmt.Println(dat2)
397
+	} else {
398
+		fmt.Println(err)
399
+	}
400
+
401
+	c.ServeSuccessJSON(map[string]interface{}{
402
+		"pre":         dat,
403
+		"request_log": dat2,
404
+	})
405
+}
406
+
62 407
 func (c *NmController) GetNewELeInfo() {
63 408
 	token := c.GetString("token")
64 409
 	user_name := c.GetString("user_name")
@@ -311,21 +656,6 @@ func (c *NmController) Post4101() {
311 656
 	})
312 657
 }
313 658
 
314
-func (c *NmController) Post2202() {
315
-
316
-	result, requestLog := service.Gdyb2202("150000CFSJM100000100005413", "20211227145332876188", "2021122714565410808111489", "赤峰费森血液透析中心", "李彩星", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", "H15049901371")
317
-	var dat map[string]interface{}
318
-	if err := json.Unmarshal([]byte(result), &dat); err == nil {
319
-	} else {
320
-	}
321
-
322
-	c.ServeSuccessJSON(map[string]interface{}{
323
-		"pre":         dat,
324
-		"request_log": requestLog,
325
-	})
326
-
327
-}
328
-
329 659
 func (c *NmController) Post5203() {
330 660
 	fmt.Println("------")
331 661
 	org_name := c.GetString("org_name")

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1202 - 90
controllers/sg/his_api_controller.go


+ 16 - 15
service/gdyb_service.go 파일 보기

@@ -31,7 +31,7 @@ const (
31 31
 	SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" //     secretKey 私钥
32 32
 )
33 33
 
34
-//机构信息
34
+// 机构信息
35 35
 func Gdyb1201(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) string {
36 36
 	// 生成签名
37 37
 	nonce := GetRandomString(32)
@@ -848,7 +848,7 @@ type Result struct {
848 848
 	OrderId        int64   `json:"order_id" form:"order_id"`
849 849
 }
850 850
 
851
-//  门诊费用明细信息上传
851
+// 门诊费用明细信息上传
852 852
 func Gdyb2204(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, new_doctor_id int64, diag_code string) (string, string) {
853 853
 	// 生成签名
854 854
 	nonce := GetRandomString(32)
@@ -1083,7 +1083,7 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
1083 1083
 	//return &result
1084 1084
 }
1085 1085
 
1086
-//  门诊费用明细信息撤销
1086
+// 门诊费用明细信息撤销
1087 1087
 func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) (string, string) {
1088 1088
 	// 生成签名
1089 1089
 	nonce := GetRandomString(32)
@@ -1174,8 +1174,9 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
1174 1174
 
1175 1175
 }
1176 1176
 
1177
-//  门诊预结算
1178
-//func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
1177
+//	门诊预结算
1178
+//
1179
+// func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
1179 1180
 func Gdyb2206(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) (string, string) {
1180 1181
 
1181 1182
 	// 生成签名
@@ -1185,6 +1186,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1185 1186
 
1186 1187
 	// 生成输入报文
1187 1188
 	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
1189
+
1188 1190
 	input := make(map[string]interface{})
1189 1191
 	inputData := make(map[string]interface{})
1190 1192
 	inputMessage["infno"] = "2206" // 交易编码
@@ -1298,7 +1300,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1298 1300
 
1299 1301
 }
1300 1302
 
1301
-//  门诊结算
1303
+// 门诊结算
1302 1304
 func Gdyb2207(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, token string) (string, string) {
1303 1305
 	// 生成签名
1304 1306
 	nonce := GetRandomString(32)
@@ -1553,7 +1555,7 @@ func Gdyb2207A(psnNo string, mdtrtId string, chrgBchno string, certNo string, in
1553 1555
 
1554 1556
 }
1555 1557
 
1556
-//  门诊结算撤销
1558
+// 门诊结算撤销
1557 1559
 func Gdyb2208(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) {
1558 1560
 	// 生成签名
1559 1561
 	nonce := GetRandomString(32)
@@ -1644,7 +1646,7 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
1644 1646
 
1645 1647
 }
1646 1648
 
1647
-//确认订单
1649
+// 确认订单
1648 1650
 func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
1649 1651
 	// 生成签名
1650 1652
 	nonce := GetRandomString(32)
@@ -1733,7 +1735,7 @@ func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_adm
1733 1735
 	return str
1734 1736
 }
1735 1737
 
1736
-//  医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
1738
+// 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
1737 1739
 func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams) string {
1738 1740
 	fmt.Println("11222333-----")
1739 1741
 
@@ -1817,7 +1819,7 @@ type Params struct {
1817 1819
 	FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
1818 1820
 }
1819 1821
 
1820
-//文件上传
1822
+// 文件上传
1821 1823
 func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
1822 1824
 
1823 1825
 	// 生成签名
@@ -2883,7 +2885,6 @@ type Struct4101 struct {
2883 2885
 	DoctorCode     string
2884 2886
 }
2885 2887
 
2886
-//
2887 2888
 func Gdyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64) (string, string) {
2888 2889
 	// 生成签名
2889 2890
 	nonce := GetRandomString(32)
@@ -4125,7 +4126,7 @@ func Gdyb2601(psnNo string, omsgid string, oinfno string, org_name string, docto
4125 4126
 	return str
4126 4127
 }
4127 4128
 
4128
-//人员信息版本3
4129
+// 人员信息版本3
4129 4130
 func Gdyb1101B(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, name string, cardNumber string) string {
4130 4131
 	//生成签名
4131 4132
 	nonce := GetRandomString(32)
@@ -4624,7 +4625,7 @@ func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_adm
4624 4625
 
4625 4626
 }
4626 4627
 
4627
-//人员信息版本4
4628
+// 人员信息版本4
4628 4629
 func Gdyb1101C(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, string) {
4629 4630
 	//生成签名
4630 4631
 	nonce := GetRandomString(32)
@@ -5328,7 +5329,7 @@ func Gdyb9001Two(org_name string, doctor string, fixmedins_code string, insuplc_
5328 5329
 
5329 5330
 }
5330 5331
 
5331
-//获取本机ip
5332
+// 获取本机ip
5332 5333
 func GetLocalIp() string {
5333 5334
 	addrs, err := net.InterfaceAddrs()
5334 5335
 	if err != nil {
@@ -5344,7 +5345,7 @@ func GetLocalIp() string {
5344 5345
 	return ""
5345 5346
 }
5346 5347
 
5347
-//获取本机Mac
5348
+// 获取本机Mac
5348 5349
 func GetMac() string {
5349 5350
 	interfaces, err := net.Interfaces()
5350 5351
 	if err != nil {

+ 818 - 0
service/nm_service.go 파일 보기

@@ -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
+}