Bläddra i källkod

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

csx 3 år sedan
förälder
incheckning
812e873773
6 ändrade filer med 1380 tillägg och 243 borttagningar
  1. 1 1
      conf/app.conf
  2. 133 50
      controllers/js/jsyb_controller.go
  3. 502 136
      controllers/sg/his_api_controller.go
  4. 2 0
      models/his_models.go
  5. 64 1
      service/gdyb_service.go
  6. 678 55
      service/jsyb_service.go

+ 1 - 1
conf/app.conf Visa fil

@@ -45,7 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10188
48
+org_id = 9919
49 49
 mobile_token_expiration_second = 86400
50 50
 httpdomain = https://api.xt.kuyicloud.com
51 51
 sso_domain = https://sso.kuyicloud.com

+ 133 - 50
controllers/js/jsyb_controller.go Visa fil

@@ -26,6 +26,8 @@ func JSybRegistRouters() {
26 26
 	beego.Router("/jsyb/2207", &JSybController{}, "get:PostEight")
27 27
 	beego.Router("/jsyb/2208", &JSybController{}, "get:PostNine")
28 28
 	beego.Router("/jsyb/5203", &JSybController{}, "get:PostTen")
29
+	//beego.Router("/jsyb/readcard", &JSybController{}, "get:ReadCard")
30
+
29 31
 }
30 32
 
31 33
 func (c *JSybController) PostOne() {
@@ -41,11 +43,8 @@ func (c *JSybController) PostOne() {
41 43
 	certificates := c.GetString("certificates")
42 44
 	url := c.GetString("url")
43 45
 	ak := c.GetString("ak")
44
-	key := c.GetString("key")
45
-	time_stamp := c.GetString("time_stamp")
46 46
 
47
-	fmt.Println("url:" + key)
48
-	result, inputLog := service.Jsyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates, url, ak, key, time_stamp)
47
+	result, inputLog := service.Jsyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates, url, ak)
49 48
 	fmt.Println(result)
50 49
 	fmt.Println(inputLog)
51 50
 	var dat map[string]interface{}
@@ -86,17 +85,30 @@ func (c *JSybController) PostTwo() {
86 85
 	secret_key := c.GetString("secret_key")
87 86
 
88 87
 	id_card_type, _ := c.GetInt64("id_card_type")
88
+	url := c.GetString("url")
89
+	ak := c.GetString("ak")
90
+	doctor_name := c.GetString("doctor_name")
89 91
 
90
-	result, _ := service.Hbyb2201(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)
91
-
92
+	result, request_log := service.Jsyb2201(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, ak)
93
+	fmt.Println(result)
94
+	fmt.Println(request_log)
92 95
 	var dat map[string]interface{}
93 96
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
94
-		//fmt.Println(dat["status"])
97
+
98
+	} else {
99
+
100
+	}
101
+
102
+	var dat2 map[string]interface{}
103
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
104
+
95 105
 	} else {
106
+
96 107
 	}
97 108
 
98 109
 	c.ServeSuccessJSON(map[string]interface{}{
99
-		"pre": dat,
110
+		"pre":         dat,
111
+		"request_log": dat2,
100 112
 	})
101 113
 }
102 114
 func (c *JSybController) PostThree() {
@@ -109,15 +121,23 @@ func (c *JSybController) PostThree() {
109 121
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
110 122
 	secret_key := c.GetString("secret_key")
111 123
 	fixmedins_code := c.GetString("fixmedins_code")
112
-	result, requestLog := service.Hbyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
124
+	url := c.GetString("url")
125
+	ak := c.GetString("ak")
126
+	result, request_log := service.Jsyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak)
113 127
 	var dat map[string]interface{}
114 128
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
115 129
 	} else {
116 130
 	}
117 131
 
132
+	var dat2 map[string]interface{}
133
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
134
+
135
+	} else {
136
+
137
+	}
118 138
 	c.ServeSuccessJSON(map[string]interface{}{
119 139
 		"pre":         dat,
120
-		"request_log": requestLog,
140
+		"request_log": dat2,
121 141
 	})
122 142
 }
123 143
 
@@ -154,10 +174,17 @@ func (c *JSybController) PostFour() {
154 174
 	insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
155 175
 	mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
156 176
 	secret_key := respJSON["secret_key"].(string)
177
+	url := respJSON["url"].(string)
178
+	ak := respJSON["ak"].(string)
157 179
 
158
-	result, request_log := service.Hbyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config)
180
+	result, request_log := service.Jsyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, url, ak)
159 181
 
160
-	fmt.Println(request_log)
182
+	var dat2 map[string]interface{}
183
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
184
+
185
+	} else {
186
+
187
+	}
161 188
 
162 189
 	var dat map[string]interface{}
163 190
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -166,7 +193,8 @@ func (c *JSybController) PostFour() {
166 193
 
167 194
 	}
168 195
 	c.ServeSuccessJSON(map[string]interface{}{
169
-		"pre": dat,
196
+		"pre":         dat,
197
+		"request_log": dat2,
170 198
 	})
171 199
 }
172 200
 
@@ -206,24 +234,9 @@ func (c *JSybController) PostFive() {
206 234
 		utils.ErrorLog("解析失败:%v", err)
207 235
 		return
208 236
 	}
209
-	fmt.Println(respJSON["psn_no"].(string))
210
-	fmt.Println(respJSON["mdtrt_id"].(string))
211 237
 
212
-	fmt.Println(respJSON["chrg_bchno"].(string))
213
-	fmt.Println(respJSON["org_name"].(string))
214
-	fmt.Println(respJSON["doctor"].(string))
215
-	fmt.Println(respJSON["dept"].(string))
216
-
217
-	fmt.Println(respJSON["fixmedins_code"].(string))
218
-	fmt.Println(respJSON["dept_code"].(string))
219
-	fmt.Println(respJSON["doctor_id"].(string))
220
-
221
-	fmt.Println(respJSON["insuplc_admdvs"].(string))
222
-	fmt.Println(respJSON["mdtrtarea_admvs"].(string))
223
-	fmt.Println(respJSON["secret_key"].(string))
224
-
225
-	result, requestLog := service.Hbyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
226
-		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))
238
+	result, request_log := service.Jsyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
239
+		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["diag_code"].(string), respJSON["secret_key"].(string), respJSON["balance_accounts_type"].(string), respJSON["url"].(string), respJSON["ak"].(string), respJSON["new_doctor_name"].(string))
227 240
 
228 241
 	var dat map[string]interface{}
229 242
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -233,7 +246,7 @@ func (c *JSybController) PostFive() {
233 246
 	}
234 247
 
235 248
 	var dat2 map[string]interface{}
236
-	if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
249
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
237 250
 		fmt.Println(dat2)
238 251
 	} else {
239 252
 		fmt.Println(err)
@@ -241,7 +254,7 @@ func (c *JSybController) PostFive() {
241 254
 
242 255
 	c.ServeSuccessJSON(map[string]interface{}{
243 256
 		"pre":         dat,
244
-		"request_log": requestLog,
257
+		"request_log": dat2,
245 258
 	})
246 259
 }
247 260
 func (c *JSybController) PostSix() {
@@ -256,17 +269,27 @@ func (c *JSybController) PostSix() {
256 269
 
257 270
 	secret_key := c.GetString("secret_key")
258 271
 	fixmedins_code := c.GetString("fixmedins_code")
272
+	url := c.GetString("url")
273
+	ak := c.GetString("ak")
259 274
 
260
-	result, requestlog := service.Hbyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
261
-	fmt.Println(requestlog)
275
+	result, request_log := service.Jsyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak)
276
+	fmt.Println(request_log)
262 277
 	var dat map[string]interface{}
263 278
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
264 279
 		fmt.Println(dat)
265 280
 	} else {
266 281
 		fmt.Println(err)
267 282
 	}
283
+	var dat2 map[string]interface{}
284
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
285
+		fmt.Println(dat2)
286
+	} else {
287
+		fmt.Println(err)
288
+	}
289
+
268 290
 	c.ServeSuccessJSON(map[string]interface{}{
269
-		"pre": dat,
291
+		"pre":         dat,
292
+		"request_log": dat2,
270 293
 	})
271 294
 }
272 295
 func (c *JSybController) PostSeven() {
@@ -286,8 +309,11 @@ func (c *JSybController) PostSeven() {
286 309
 	id_card_type, _ := c.GetInt64("id_card_type")
287 310
 	certificates, _ := c.GetInt64("certificates")
288 311
 
289
-	result, requestlog := service.Hbyb2206(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)
290
-	fmt.Println(requestlog)
312
+	url := c.GetString("url")
313
+	ak := c.GetString("ak")
314
+
315
+	result, request_log := service.Jsyb2206(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)
316
+	fmt.Println(request_log)
291 317
 
292 318
 	var dat map[string]interface{}
293 319
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -295,8 +321,16 @@ func (c *JSybController) PostSeven() {
295 321
 	} else {
296 322
 		fmt.Println(err)
297 323
 	}
324
+
325
+	var dat2 map[string]interface{}
326
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
327
+		fmt.Println(dat2)
328
+	} else {
329
+		fmt.Println(err)
330
+	}
298 331
 	c.ServeSuccessJSON(map[string]interface{}{
299
-		"pre": dat,
332
+		"pre":         dat,
333
+		"request_log": dat2,
300 334
 	})
301 335
 }
302 336
 func (c *JSybController) PostEight() {
@@ -321,9 +355,12 @@ func (c *JSybController) PostEight() {
321 355
 	preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
322 356
 	inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
323 357
 
324
-	acct_used_flag, _ := c.GetInt64("acct_used_flag")
358
+	acct_used_flag := c.GetString("acct_used_flag")
325 359
 
326
-	result, srcRequest := service.Hbyb2207(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)
360
+	url := c.GetString("url")
361
+	ak := c.GetString("ak")
362
+
363
+	result, request_log := service.Jsyb2207(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)
327 364
 	var dat map[string]interface{}
328 365
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
329 366
 		fmt.Println(dat)
@@ -332,15 +369,15 @@ func (c *JSybController) PostEight() {
332 369
 	}
333 370
 
334 371
 	var dat2 map[string]interface{}
335
-	if err := json.Unmarshal([]byte(srcRequest), &dat2); err == nil {
372
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
336 373
 		fmt.Println(dat2)
337 374
 	} else {
338 375
 		fmt.Println(err)
339 376
 	}
340 377
 
341 378
 	c.ServeSuccessJSON(map[string]interface{}{
342
-		"pre":  dat,
343
-		"pre2": dat2,
379
+		"pre":         dat,
380
+		"request_log": dat2,
344 381
 	})
345 382
 }
346 383
 func (c *JSybController) PostNine() {
@@ -353,16 +390,26 @@ func (c *JSybController) PostNine() {
353 390
 	fixmedins_code := c.GetString("fixmedins_code")
354 391
 	insuplc_admdvs := c.GetString("insuplc_admdvs")
355 392
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
356
-	result, src_request := service.Hbyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
357
-	fmt.Println(src_request)
393
+	url := c.GetString("url")
394
+	ak := c.GetString("ak")
395
+	result, request_log := service.Jsyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak)
396
+	fmt.Println(request_log)
358 397
 	var dat map[string]interface{}
359 398
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
360 399
 		fmt.Println(dat)
361 400
 	} else {
362 401
 		fmt.Println(err)
363 402
 	}
403
+	var dat2 map[string]interface{}
404
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
405
+		fmt.Println(dat2)
406
+	} else {
407
+		fmt.Println(err)
408
+	}
409
+
364 410
 	c.ServeSuccessJSON(map[string]interface{}{
365
-		"pre": dat,
411
+		"pre":         dat,
412
+		"request_log": dat2,
366 413
 	})
367 414
 }
368 415
 func (c *JSybController) PostTen() {
@@ -371,12 +418,12 @@ func (c *JSybController) PostTen() {
371 418
 	setlId := c.GetString("setl_id")
372 419
 	org_name := c.GetString("org_name")
373 420
 	doctor := c.GetString("doctor")
374
-	med_type := c.GetString("med_type")
375
-
376 421
 	secret_key := c.GetString("secret_key")
377 422
 	fixmedins_code := c.GetString("fixmedins_code")
378 423
 	insuplc_admdvs := c.GetString("insuplc_admdvs")
379 424
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
425
+	url := c.GetString("url")
426
+	ak := c.GetString("ak")
380 427
 
381 428
 	baseParams := models.BaseParams{
382 429
 		SecretKey:      secret_key,
@@ -385,6 +432,8 @@ func (c *JSybController) PostTen() {
385 432
 		MdtrtareaAdmvs: mdtrtarea_admvs,
386 433
 		OrgName:        org_name,
387 434
 		Doctor:         doctor,
435
+		RequestUrl:     url,
436
+		AccessKey:      ak,
388 437
 	}
389 438
 
390 439
 	businessParams := models.BusinessParams{
@@ -393,14 +442,48 @@ func (c *JSybController) PostTen() {
393 442
 		SetlId:  setlId,
394 443
 	}
395 444
 
396
-	result := service.Hbyb5203(baseParams, businessParams, med_type)
445
+	result, request_log := service.Jsyb5203(baseParams, businessParams)
397 446
 	var dat map[string]interface{}
398 447
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
399 448
 		fmt.Println(dat)
400 449
 	} else {
401 450
 		fmt.Println(err)
402 451
 	}
452
+	var dat2 map[string]interface{}
453
+	if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
454
+		fmt.Println(dat2)
455
+	} else {
456
+		fmt.Println(err)
457
+	}
403 458
 	c.ServeSuccessJSON(map[string]interface{}{
404
-		"pre": dat,
459
+		"pre":         dat,
460
+		"request_log": dat2,
405 461
 	})
406 462
 }
463
+
464
+//var initFlag int64 = 0
465
+
466
+//func (c *JSybController) ReadCard() {
467
+//	if initFlag == 0 {
468
+//		c.TestGetBasBaseInit()
469
+//	}
470
+//}
471
+//
472
+//func (c *JSybController) TestGetBasBaseInit() {
473
+//	DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
474
+//	Iinit := DllDef.MustFindProc("Init")
475
+//	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
476
+//
477
+//	ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
478
+//	if ret != 0 {
479
+//		fmt.Println("SSCard的报错原因:", err)
480
+//		fmt.Println("SSCard的运算结果为:", ret)
481
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
482
+//		return
483
+//	}
484
+//
485
+//	result := int(ret)
486
+//	fmt.Println("SSCard的运算结果为1:", result)
487
+//	initFlag = 1
488
+//	return
489
+//}

+ 502 - 136
controllers/sg/his_api_controller.go Visa fil

@@ -32,52 +32,42 @@ type HisApiController struct {
32 32
 }
33 33
 
34 34
 func HisManagerApiRegistRouters() {
35
-	fmt.Println("----------")
35
+	//挂号
36 36
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
37
-	beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
37
+	//上传就诊信息-上传明细-结算
38 38
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
39
+	//查询
39 40
 	beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
41
+	//对总账
40 42
 	beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
43
+	//对明细
41 44
 	beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
45
+	//退费,退明细
42 46
 	beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
43
-	//beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
47
+	//退号
44 48
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
49
+	//退明细
45 50
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
51
+
46 52
 	beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
47
-	//beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
48
-	//beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
49 53
 	beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
50
-	//beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
51 54
 	beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
52
-	//beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
53 55
 	beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
54
-	//beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
55 56
 	beego.Router("/api/310", &HisApiController{}, "get:Check310")
56 57
 	beego.Router("/api/390", &HisApiController{}, "get:Check390")
57 58
 	beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
58
-	//备案撤销相关接口
59 59
 	beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
60 60
 	beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
61 61
 	beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
62 62
 	beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
63 63
 	beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
64 64
 	beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
65
-
66 65
 	beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
67 66
 	beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
68
-
69
-	//beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
70
-
71 67
 	beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
72
-
73 68
 	beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
74
-
75 69
 	beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
76
-
77
-	//beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
78
-
79 70
 	beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
80
-
81 71
 	beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
82 72
 
83 73
 }
@@ -2852,8 +2842,6 @@ func (c *HisApiController) GetRegisterInfo() {
2852 2842
 	medical_expenses, _ := c.GetFloat("medical_expenses")
2853 2843
 	social_type, _ := c.GetInt64("social_type")
2854 2844
 	med_type := c.GetString("social_type")
2855
-	key := c.GetString("key")
2856
-	time_stamp := c.GetString("time_stamp")
2857 2845
 
2858 2846
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2859 2847
 
@@ -2882,9 +2870,6 @@ func (c *HisApiController) GetRegisterInfo() {
2882 2870
 		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2883 2871
 	}
2884 2872
 
2885
-	//adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
2886
-	//diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
2887
-	//sickConfig, _ := service.FindSickById(sick_type)
2888 2873
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
2889 2874
 	if patient.ID == 0 {
2890 2875
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
@@ -2942,7 +2927,7 @@ func (c *HisApiController) GetRegisterInfo() {
2942 2927
 			var res ResultTwo
2943 2928
 			api := "http://192.168.3.111:9532/" + "jsyb/1101?cert_no=" + "" +
2944 2929
 				"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
2945
-				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber + "&key=" + key + "&time_stamp=" + time_stamp
2930
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
2946 2931
 			fmt.Println(api)
2947 2932
 			resp, requestErr := http.Get(api)
2948 2933
 			if requestErr != nil {
@@ -2973,6 +2958,19 @@ func (c *HisApiController) GetRegisterInfo() {
2973 2958
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2974 2959
 				return
2975 2960
 			}
2961
+			PsnNo = res.Output.Baseinfo.PsnNo
2962
+			PsnCertType = res.Output.Baseinfo.PsnCertType
2963
+			Certno = res.Output.Baseinfo.Certno
2964
+			PsnName = res.Output.Baseinfo.PsnName
2965
+			Gend = res.Output.Baseinfo.Gend
2966
+			Naty = res.Output.Baseinfo.Naty
2967
+			Brdy = res.Output.Baseinfo.Brdy
2968
+			Age = res.Output.Baseinfo.Age
2969
+			Iinfos, _ := json.Marshal(res.Output.Iinfo)
2970
+			Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
2971
+			infoStr = string(Iinfos)
2972
+			idetinfoStr = string(Idetinfos)
2973
+			infocode = res.Infcode
2976 2974
 
2977 2975
 		} else {
2978 2976
 			result, requestLog := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
@@ -3010,14 +3008,10 @@ func (c *HisApiController) GetRegisterInfo() {
3010 3008
 			idetinfoStr = string(Idetinfos)
3011 3009
 			if miConfig.Code == "H15049901371" {
3012 3010
 				infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
3013
-
3014 3011
 			} else {
3015
-
3016 3012
 				infocode = res.Infcode
3017 3013
 			}
3018
-
3019 3014
 		}
3020
-
3021 3015
 		if infocode == 0 {
3022 3016
 			his := models.VMHisPatient{
3023 3017
 				Name:                   name,
@@ -3163,6 +3157,39 @@ func (c *HisApiController) GetRegisterInfo() {
3163 3157
 				}
3164 3158
 				infocode = resThree.Infcode
3165 3159
 
3160
+			} else if miConfig.MdtrtareaAdmvs == "320921" {
3161
+				api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
3162
+					"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
3163
+					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
3164
+				resp, requestErr := http.Get(api)
3165
+				if requestErr != nil {
3166
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3167
+					return
3168
+				}
3169
+
3170
+				body, ioErr := ioutil.ReadAll(resp.Body)
3171
+				if ioErr != nil {
3172
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3173
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3174
+					return
3175
+				}
3176
+				var respJSON map[string]interface{}
3177
+				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
3178
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3179
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3180
+					return
3181
+				}
3182
+
3183
+				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3184
+				result, _ := json.Marshal(respJSON)
3185
+
3186
+				if err := json.Unmarshal([]byte(result), &resThree); err != nil {
3187
+					utils.ErrorLog("解析失败:%v", err)
3188
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3189
+					return
3190
+				}
3191
+				infocode = resThree.Infcode
3192
+
3166 3193
 			} else {
3167 3194
 
3168 3195
 				result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
@@ -3412,8 +3439,57 @@ func (c *HisApiController) GetUploadInfo() {
3412 3439
 				return
3413 3440
 			}
3414 3441
 
3442
+		} else if miConfig.MdtrtareaAdmvs == "320921" {
3443
+
3444
+			data := make(map[string]interface{})
3445
+			client := &http.Client{}
3446
+			data["psn_no"] = his.PsnNo
3447
+			data["mdtrt_id"] = his.Number
3448
+			data["doctor"] = roles.UserName
3449
+			data["department"] = department.Name
3450
+			data["org_name"] = miConfig.OrgName
3451
+			data["med_type"] = strconv.FormatInt(reg_type, 10)
3452
+			data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
3453
+			data["fixmedins_code"] = miConfig.Code
3454
+			data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
3455
+			data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
3456
+			data["secret_key"] = miConfig.SecretKey
3457
+			data["sick_code"] = sickConfig.CountryCode
3458
+			data["sick_name"] = sickConfig.ClassName
3459
+			data["url"] = miConfig.Url
3460
+			data["ak"] = miConfig.ChannelNumber
3461
+			data["dept"] = strconv.FormatInt(department.ID, 10)
3462
+			data["config"] = config
3463
+			bytesData, _ := json.Marshal(data)
3464
+			req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
3465
+			resp, _ := client.Do(req)
3466
+			defer resp.Body.Close()
3467
+			body, ioErr := ioutil.ReadAll(resp.Body)
3468
+			if ioErr != nil {
3469
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3470
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3471
+				return
3472
+			}
3473
+			var respJSON map[string]interface{}
3474
+			if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
3475
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3476
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3477
+				return
3478
+			}
3479
+
3480
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3481
+			userJSONBytes, _ := json.Marshal(respJSON)
3482
+			fmt.Println("log")
3483
+			fmt.Println(string(userJSONBytes))
3484
+
3485
+			if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
3486
+				utils.ErrorLog("解析失败:%v", err)
3487
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3488
+				return
3489
+			}
3490
+
3415 3491
 		} else {
3416
-			if miConfig.InsuplcAdmdvs == "440781" { //
3492
+			if miConfig.MdtrtareaAdmvs == "440781" { //
3417 3493
 				result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
3418 3494
 			} else {
3419 3495
 				if miConfig.Code == "H15049901371" {
@@ -3564,6 +3640,9 @@ func (c *HisApiController) GetUploadInfo() {
3564 3640
 			data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
3565 3641
 			data["secret_key"] = miConfig.SecretKey
3566 3642
 			data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
3643
+			data["url"] = miConfig.Url
3644
+			data["ak"] = miConfig.ChannelNumber
3645
+			data["new_doctor_name"] = patientPrescription.Doctor
3567 3646
 
3568 3647
 			var ids []int64
3569 3648
 
@@ -3604,6 +3683,34 @@ func (c *HisApiController) GetUploadInfo() {
3604 3683
 						return
3605 3684
 					}
3606 3685
 
3686
+				} else if miConfig.MdtrtareaAdmvs == "320921" {
3687
+					bytesData, _ := json.Marshal(data)
3688
+					req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
3689
+					resp, _ := client.Do(req)
3690
+					defer resp.Body.Close()
3691
+					body, ioErr := ioutil.ReadAll(resp.Body)
3692
+					if ioErr != nil {
3693
+						utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3694
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3695
+						return
3696
+					}
3697
+					var respJSON map[string]interface{}
3698
+					if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
3699
+						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3700
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3701
+						return
3702
+					}
3703
+
3704
+					respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3705
+					userJSONBytes, _ := json.Marshal(respJSON)
3706
+					fmt.Println("log")
3707
+					fmt.Println(string(userJSONBytes))
3708
+					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3709
+						utils.ErrorLog("解析失败:%v", err)
3710
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3711
+						return
3712
+					}
3713
+
3607 3714
 				} else {
3608 3715
 
3609 3716
 					if miConfig.Code == "H15049901371" {
@@ -3913,6 +4020,42 @@ func (c *HisApiController) GetUploadInfo() {
3913 4020
 
3914 4021
 							}
3915 4022
 
4023
+						} else if miConfig.MdtrtareaAdmvs == "320921" {
4024
+							api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
4025
+								his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
4026
+								"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
4027
+								"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
4028
+								"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
4029
+								"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
4030
+								"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
4031
+
4032
+							resp, requestErr := http.Get(api)
4033
+							if requestErr != nil {
4034
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4035
+								return
4036
+							}
4037
+							body, ioErr := ioutil.ReadAll(resp.Body)
4038
+							if ioErr != nil {
4039
+								utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
4040
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4041
+								return
4042
+							}
4043
+							var respJSON map[string]interface{}
4044
+							if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
4045
+								utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
4046
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4047
+								return
4048
+							}
4049
+
4050
+							respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
4051
+							result, _ := json.Marshal(respJSON)
4052
+
4053
+							if err := json.Unmarshal([]byte(result), &res); err != nil {
4054
+								utils.ErrorLog("解析失败:%v", err)
4055
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4056
+								return
4057
+							}
4058
+
3916 4059
 						} else {
3917 4060
 							if miConfig.Code == "H15049901371" {
3918 4061
 								//赤峰地区国家医保医疗类别
@@ -4218,6 +4361,44 @@ func (c *HisApiController) GetUploadInfo() {
4218 4361
 					return
4219 4362
 				}
4220 4363
 
4364
+			} else if miConfig.MdtrtareaAdmvs == "320921" {
4365
+				api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
4366
+					his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
4367
+					"&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
4368
+					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
4369
+					"&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
4370
+					"&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
4371
+					"&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
4372
+
4373
+				resp, requestErr := http.Get(api)
4374
+				if requestErr != nil {
4375
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4376
+					return
4377
+				}
4378
+
4379
+				body, ioErr := ioutil.ReadAll(resp.Body)
4380
+				if ioErr != nil {
4381
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
4382
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4383
+					return
4384
+				}
4385
+				var respJSON map[string]interface{}
4386
+				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
4387
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
4388
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4389
+					return
4390
+				}
4391
+
4392
+				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
4393
+				result, _ := json.Marshal(respJSON)
4394
+				fmt.Println("log")
4395
+				fmt.Println(string(result))
4396
+				if err := json.Unmarshal([]byte(result), &res); err != nil {
4397
+					utils.ErrorLog("解析失败:%v", err)
4398
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4399
+					return
4400
+				}
4401
+
4221 4402
 			} else {
4222 4403
 
4223 4404
 				var src_resquest string
@@ -5150,6 +5331,10 @@ func (c *HisApiController) GetPreUploadInfo() {
5150 5331
 		data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
5151 5332
 		data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
5152 5333
 		data["secret_key"] = miConfig.SecretKey
5334
+		data["url"] = miConfig.Url
5335
+		data["ak"] = miConfig.ChannelNumber
5336
+		data["new_doctor_name"] = patientPrescription.Doctor
5337
+
5153 5338
 		var ids []int64
5154 5339
 
5155 5340
 		for _, item := range prescriptions {
@@ -5188,6 +5373,34 @@ func (c *HisApiController) GetPreUploadInfo() {
5188 5373
 					return
5189 5374
 				}
5190 5375
 
5376
+			} else if miConfig.MdtrtareaAdmvs == "320921" {
5377
+				bytesData, _ := json.Marshal(data)
5378
+				req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
5379
+				resp, _ := client.Do(req)
5380
+				defer resp.Body.Close()
5381
+				body, ioErr := ioutil.ReadAll(resp.Body)
5382
+				if ioErr != nil {
5383
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
5384
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5385
+					return
5386
+				}
5387
+				var respJSON map[string]interface{}
5388
+				if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
5389
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
5390
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5391
+					return
5392
+				}
5393
+
5394
+				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
5395
+				userJSONBytes, _ := json.Marshal(respJSON)
5396
+				fmt.Println("log")
5397
+				fmt.Println(string(userJSONBytes))
5398
+				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
5399
+					utils.ErrorLog("解析失败:%v", err)
5400
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5401
+					return
5402
+				}
5403
+
5191 5404
 			} else {
5192 5405
 
5193 5406
 				if miConfig.Code == "H15049901371" {
@@ -5851,26 +6064,13 @@ func (c *HisApiController) GetPreUploadInfo() {
5851 6064
 func (c *HisApiController) Refund() {
5852 6065
 	order_id, _ := c.GetInt64("order_id")
5853 6066
 	admin_user_id, _ := c.GetInt64("admin_user_id")
5854
-	//record_time := c.GetString("record_time")
5855
-	//patient_id, _ := c.GetInt64("patient_id")
5856
-	//timeLayout := "2006-01-02"
5857
-	//loc, _ := time.LoadLocation("Local")
5858 6067
 	adminUser := c.GetAdminUserInfo()
5859
-	//theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
5860
-	//if err != nil {
5861
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5862
-	//	return
5863
-	//}
5864
-	//recordDateTime := theTime.Unix()
5865 6068
 	var order models.HisOrder
5866 6069
 	order, _ = service.GetHisOrderByID(order_id)
5867
-	//his, _ := service.GetHisPatientByNumber(order.MdtrtId)
5868
-
5869 6070
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
5870 6071
 	if order.ID == 0 {
5871 6072
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5872 6073
 		return
5873
-		//order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
5874 6074
 	}
5875 6075
 	his, _ := service.GetHisPatientByNumber(order.MdtrtId)
5876 6076
 
@@ -5914,6 +6114,36 @@ func (c *HisApiController) Refund() {
5914 6114
 				return
5915 6115
 			}
5916 6116
 
6117
+		} else if miConfig.MdtrtareaAdmvs == "320921" {
6118
+			api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
6119
+				"&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
6120
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
6121
+			resp3, requestErr3 := http.Get(api3)
6122
+			if requestErr3 != nil {
6123
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6124
+				return
6125
+			}
6126
+			body3, ioErr3 := ioutil.ReadAll(resp3.Body)
6127
+			if ioErr3 != nil {
6128
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
6129
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6130
+				return
6131
+			}
6132
+			var respJSON3 map[string]interface{}
6133
+			if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
6134
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
6135
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6136
+				return
6137
+			}
6138
+
6139
+			respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
6140
+			userJSONBytes3, _ := json.Marshal(respJSON3)
6141
+			if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
6142
+				utils.ErrorLog("解析失败:%v", err)
6143
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6144
+				return
6145
+			}
6146
+
5917 6147
 		} else {
5918 6148
 
5919 6149
 			if miConfig.Code == "H15049901371" {
@@ -5998,6 +6228,39 @@ func (c *HisApiController) Refund() {
5998 6228
 					return
5999 6229
 				}
6000 6230
 
6231
+			} else if miConfig.MdtrtareaAdmvs == "320921" {
6232
+
6233
+				api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
6234
+					"&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
6235
+					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
6236
+				resp3, requestErr3 := http.Get(api3)
6237
+				if requestErr3 != nil {
6238
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6239
+					return
6240
+				}
6241
+				body3, ioErr3 := ioutil.ReadAll(resp3.Body)
6242
+				if ioErr3 != nil {
6243
+					utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
6244
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6245
+					return
6246
+				}
6247
+				var respJSON3 map[string]interface{}
6248
+				if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
6249
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
6250
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6251
+					return
6252
+				}
6253
+
6254
+				respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
6255
+				userJSONBytes3, _ := json.Marshal(respJSON3)
6256
+				fmt.Println("log")
6257
+				fmt.Println(string(userJSONBytes3))
6258
+				if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
6259
+					utils.ErrorLog("解析失败:%v", err)
6260
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6261
+					return
6262
+				}
6263
+
6001 6264
 			} else {
6002 6265
 
6003 6266
 				if miConfig.Code == "H15049901371" {
@@ -6139,6 +6402,40 @@ func (c *HisApiController) RefundNumber() {
6139 6402
 				return
6140 6403
 			}
6141 6404
 
6405
+		} else if miConfig.MdtrtareaAdmvs == "320921" {
6406
+
6407
+			api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
6408
+				"&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
6409
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
6410
+			resp3, requestErr3 := http.Get(api3)
6411
+			if requestErr3 != nil {
6412
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6413
+				return
6414
+			}
6415
+
6416
+			body3, ioErr3 := ioutil.ReadAll(resp3.Body)
6417
+			if ioErr3 != nil {
6418
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
6419
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6420
+				return
6421
+			}
6422
+			var respJSON3 map[string]interface{}
6423
+			if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
6424
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
6425
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6426
+				return
6427
+			}
6428
+
6429
+			respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
6430
+			userJSONBytes3, _ := json.Marshal(respJSON3)
6431
+			fmt.Println("log")
6432
+			fmt.Println(string(userJSONBytes3))
6433
+			if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
6434
+				utils.ErrorLog("解析失败:%v", err)
6435
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6436
+				return
6437
+			}
6438
+
6142 6439
 		} else {
6143 6440
 			var api3 string
6144 6441
 
@@ -6303,6 +6600,48 @@ func (c *HisApiController) RefundDetail() {
6303 6600
 				return
6304 6601
 			}
6305 6602
 
6603
+			err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
6604
+			if err == nil {
6605
+				c.ServeSuccessJSON(map[string]interface{}{
6606
+					"msg": "撤销明细成功",
6607
+				})
6608
+				return
6609
+			} else {
6610
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6611
+				return
6612
+			}
6613
+		} else if miConfig.MdtrtareaAdmvs == "320921" {
6614
+			api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
6615
+				"&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
6616
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
6617
+			resp3, requestErr3 := http.Get(api3)
6618
+			if requestErr3 != nil {
6619
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6620
+				return
6621
+			}
6622
+			body3, ioErr3 := ioutil.ReadAll(resp3.Body)
6623
+			if ioErr3 != nil {
6624
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
6625
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6626
+				return
6627
+			}
6628
+			var respJSON3 map[string]interface{}
6629
+			if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
6630
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
6631
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6632
+				return
6633
+			}
6634
+
6635
+			respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
6636
+			userJSONBytes3, _ := json.Marshal(respJSON3)
6637
+			fmt.Println("log")
6638
+			fmt.Println(string(userJSONBytes3))
6639
+			if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
6640
+				utils.ErrorLog("解析失败:%v", err)
6641
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
6642
+				return
6643
+			}
6644
+
6306 6645
 			err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
6307 6646
 			if err == nil {
6308 6647
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -7005,7 +7344,43 @@ func (c *HisApiController) GetSettleAccounts() {
7005 7344
 				return
7006 7345
 			}
7007 7346
 
7347
+		} else if miConfig.MdtrtareaAdmvs == "320921" {
7348
+
7349
+			api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
7350
+				"&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
7351
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
7352
+			resp, requestErr := http.Get(api)
7353
+			if requestErr != nil {
7354
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7355
+				return
7356
+			}
7357
+
7358
+			body, ioErr := ioutil.ReadAll(resp.Body)
7359
+			if ioErr != nil {
7360
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
7361
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7362
+				return
7363
+			}
7364
+			var respJSON map[string]interface{}
7365
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
7366
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
7367
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7368
+				return
7369
+			}
7370
+
7371
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
7372
+			result, _ := json.Marshal(respJSON)
7373
+			fmt.Println("log")
7374
+			fmt.Println(string(result))
7375
+			if err := json.Unmarshal([]byte(result), &res); err != nil {
7376
+				utils.ErrorLog("解析失败:%v", err)
7377
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7378
+				return
7379
+			}
7380
+
7008 7381
 		} else {
7382
+			result2 := service.Gdyb5204(baseParams, businessParams)
7383
+			fmt.Println(result2)
7009 7384
 			result := service.Gdyb5203(baseParams, businessParams)
7010 7385
 			var dat map[string]interface{}
7011 7386
 			if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -7445,90 +7820,90 @@ func (c *HisApiController) CheckTreatment() {
7445 7820
 //
7446 7821
 //}
7447 7822
 
7448
-func (c *HisApiController) GetUploadDiag() {
7449
-	id, _ := c.GetInt64("id")
7450
-	record_time := c.GetString("record_time")
7451
-
7452
-	diagnosis_id, _ := c.GetInt64("diagnosis")
7453
-	sick_type, _ := c.GetInt64("sick_type")
7454
-	reg_type, _ := c.GetInt64("reg_type")
7455
-
7456
-	timeLayout := "2006-01-02"
7457
-	loc, _ := time.LoadLocation("Local")
7458
-	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
7459
-	if err != nil {
7460
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7461
-		return
7462
-	}
7463
-
7464
-	var patientPrescription models.HisPrescriptionInfo
7465
-	recordDateTime := theTime.Unix()
7466
-	adminInfo := c.GetAdminUserInfo()
7467
-	patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
7468
-
7469
-	if patientPrescription.ID == 0 {
7470
-		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
7471
-	}
7472
-
7473
-	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
7474
-	diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
7475
-	his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
7476
-	sickConfig, _ := service.FindSickById(sick_type)
7477
-	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
7478
-
7479
-	api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
7480
-		"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
7481
-		"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
7482
-		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
7483
-	resp2, requestErr2 := http.Get(api2)
7484
-	if requestErr2 != nil {
7485
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7486
-		return
7487
-	}
7488
-	body2, ioErr2 := ioutil.ReadAll(resp2.Body)
7489
-	if ioErr2 != nil {
7490
-		utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
7491
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7492
-		return
7493
-	}
7494
-	var respJSON2 map[string]interface{}
7495
-	if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
7496
-		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
7497
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7498
-		return
7499
-	}
7500
-	respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
7501
-	userJSONBytes2, _ := json.Marshal(respJSON2)
7502
-
7503
-	var res2 ResultSix
7504
-	if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
7505
-		utils.ErrorLog("解析失败:%v", err)
7506
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7507
-		return
7508
-	}
7509
-	if res2.Infcode != 0 {
7510
-		adminUser := c.GetAdminUserInfo()
7511
-		errlog := &models.HisOrderError{
7512
-			UserOrgId:  adminUser.CurrentOrgId,
7513
-			Ctime:      time.Now().Unix(),
7514
-			Mtime:      time.Now().Unix(),
7515
-			ErrMsg:     res2.ErrMsg,
7516
-			Status:     1,
7517
-			PatientId:  id,
7518
-			RecordTime: recordDateTime,
7519
-			Stage:      3,
7520
-		}
7521
-		service.CreateErrMsgLog(errlog)
7522
-
7523
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
7524
-		return
7525
-	}
7526
-
7527
-	c.ServeSuccessJSON(map[string]interface{}{
7528
-		"msg": "上传成功",
7529
-	})
7530
-
7531
-}
7823
+//func (c *HisApiController) GetUploadDiag() {
7824
+//	id, _ := c.GetInt64("id")
7825
+//	record_time := c.GetString("record_time")
7826
+//
7827
+//	diagnosis_id, _ := c.GetInt64("diagnosis")
7828
+//	sick_type, _ := c.GetInt64("sick_type")
7829
+//	reg_type, _ := c.GetInt64("reg_type")
7830
+//
7831
+//	timeLayout := "2006-01-02"
7832
+//	loc, _ := time.LoadLocation("Local")
7833
+//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
7834
+//	if err != nil {
7835
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7836
+//		return
7837
+//	}
7838
+//
7839
+//	var patientPrescription models.HisPrescriptionInfo
7840
+//	recordDateTime := theTime.Unix()
7841
+//	adminInfo := c.GetAdminUserInfo()
7842
+//	patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
7843
+//
7844
+//	if patientPrescription.ID == 0 {
7845
+//		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
7846
+//	}
7847
+//
7848
+//	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
7849
+//	diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
7850
+//	his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
7851
+//	sickConfig, _ := service.FindSickById(sick_type)
7852
+//	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
7853
+//
7854
+//	api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
7855
+//		"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
7856
+//		"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
7857
+//		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
7858
+//	resp2, requestErr2 := http.Get(api2)
7859
+//	if requestErr2 != nil {
7860
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7861
+//		return
7862
+//	}
7863
+//	body2, ioErr2 := ioutil.ReadAll(resp2.Body)
7864
+//	if ioErr2 != nil {
7865
+//		utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
7866
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7867
+//		return
7868
+//	}
7869
+//	var respJSON2 map[string]interface{}
7870
+//	if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
7871
+//		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
7872
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7873
+//		return
7874
+//	}
7875
+//	respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
7876
+//	userJSONBytes2, _ := json.Marshal(respJSON2)
7877
+//
7878
+//	var res2 ResultSix
7879
+//	if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
7880
+//		utils.ErrorLog("解析失败:%v", err)
7881
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
7882
+//		return
7883
+//	}
7884
+//	if res2.Infcode != 0 {
7885
+//		adminUser := c.GetAdminUserInfo()
7886
+//		errlog := &models.HisOrderError{
7887
+//			UserOrgId:  adminUser.CurrentOrgId,
7888
+//			Ctime:      time.Now().Unix(),
7889
+//			Mtime:      time.Now().Unix(),
7890
+//			ErrMsg:     res2.ErrMsg,
7891
+//			Status:     1,
7892
+//			PatientId:  id,
7893
+//			RecordTime: recordDateTime,
7894
+//			Stage:      3,
7895
+//		}
7896
+//		service.CreateErrMsgLog(errlog)
7897
+//
7898
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
7899
+//		return
7900
+//	}
7901
+//
7902
+//	c.ServeSuccessJSON(map[string]interface{}{
7903
+//		"msg": "上传成功",
7904
+//	})
7905
+//
7906
+//}
7532 7907
 
7533 7908
 type QueryResult struct {
7534 7909
 	ID             int64
@@ -8801,12 +9176,3 @@ func ConvertToString(src string, srcCode string, tagCode string) string {
8801 9176
 	result := string(cdata)
8802 9177
 	return result
8803 9178
 }
8804
-
8805
-//func (c *HisApiController)HandleCheckDetailAccount(){
8806
-//	psn_no, _ := c.GetString("psn_no")
8807
-//	psn_no, _ := c.GetString("psn_no")
8808
-//	psn_no, _ := c.GetString("psn_no")
8809
-//
8810
-//
8811
-//
8812
-//}

+ 2 - 0
models/his_models.go Visa fil

@@ -998,6 +998,8 @@ type BaseParams struct {
998 998
 	MdtrtareaAdmvs string
999 999
 	OrgName        string
1000 1000
 	Doctor         string
1001
+	RequestUrl     string
1002
+	AccessKey      string
1001 1003
 }
1002 1004
 
1003 1005
 type BusinessParams struct {

+ 64 - 1
service/gdyb_service.go Visa fil

@@ -1780,7 +1780,6 @@ type Params struct {
1780 1780
 	FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
1781 1781
 }
1782 1782
 
1783
-//文件上传
1784 1783
 //文件上传
1785 1784
 func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
1786 1785
 
@@ -2040,6 +2039,70 @@ func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams
2040 2039
 	return str
2041 2040
 }
2042 2041
 
2042
+func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
2043
+	// 生成签名
2044
+	nonce := GetRandomString(32)
2045
+	timestamp := time.Now().Unix()
2046
+	signature := setSignature(timestamp, nonce, baseParams.SecretKey)
2047
+
2048
+	// 生成输入报文
2049
+	inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
2050
+	input := make(map[string]interface{})
2051
+	inputData := make(map[string]interface{})
2052
+	inputMessage["infno"] = "5204" // 交易编码
2053
+	inputData["psn_no"] = businessParams.PsnNo
2054
+	inputData["setl_id"] = businessParams.SetlId
2055
+	inputData["mdtrt_id"] = businessParams.MdtrtId
2056
+	input["data"] = inputData
2057
+	inputMessage["input"] = input //交易输入
2058
+	bytesData, err := json.Marshal(inputMessage)
2059
+	fmt.Println(string(bytesData))
2060
+	if err != nil {
2061
+		fmt.Println(err.Error())
2062
+		return err.Error()
2063
+	}
2064
+	reader := bytes.NewReader(bytesData)
2065
+	gdyb_url := beego.AppConfig.String("gdyb_url")
2066
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
2067
+
2068
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
2069
+	//url := gdyb_url + "5203"
2070
+	var url string
2071
+	if baseParams.FixmedinsCode == "H15049901371" {
2072
+		url = gdyb_url
2073
+	} else {
2074
+		url = gdyb_url + "5204"
2075
+	}
2076
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
2077
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
2078
+
2079
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
2080
+	request, err := http.NewRequest("POST", url, reader)
2081
+	if err != nil {
2082
+		fmt.Println(err.Error())
2083
+		return err.Error()
2084
+	}
2085
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
2086
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
2087
+	request.Header.Set("x-tif-signature", signature)
2088
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
2089
+	request.Header.Set("x-tif-nonce", nonce)
2090
+	client := http.Client{}
2091
+	resp, err := client.Do(request)
2092
+	if err != nil {
2093
+		fmt.Println(err.Error())
2094
+		return err.Error()
2095
+	}
2096
+	respBytes, err := ioutil.ReadAll(resp.Body)
2097
+	if err != nil {
2098
+		fmt.Println(err.Error())
2099
+		return err.Error()
2100
+	}
2101
+	str := string(respBytes)
2102
+	fmt.Println(str)
2103
+	return str
2104
+}
2105
+
2043 2106
 func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
2044 2107
 	if med_type == "1111" || med_type == "1112" {
2045 2108
 		med_type = "11"

+ 678 - 55
service/jsyb_service.go Visa fil

@@ -1,24 +1,19 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"crypto/hmac"
5
-	"crypto/sha1"
6
-	"encoding/base64"
7 4
 	"encoding/json"
8 5
 	"fmt"
6
+	"gdyb/models"
9 7
 	"gdyb/utils/csbhttp"
10 8
 	"strconv"
11 9
 	"time"
12 10
 )
13 11
 
14 12
 // 人员基本信息
15
-func Jsyb1101(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 string, request_url string, access_key string, skey string, timestamp_str string) (string, string) {
16
-	//生成签名
17
-	nonce := GetRandomString(32)
13
+func Jsyb1101(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 string, request_url string, access_key string) (string, string) {
18 14
 	timestamp := time.Now().Unix()
19
-	//signature := setSignature(timestamp, nonce, secret_key)
20 15
 	//生成输入报文
21
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
16
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
22 17
 
23 18
 	input := make(map[string]interface{})
24 19
 	inputData := make(map[string]interface{})
@@ -50,55 +45,651 @@ func Jsyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
50 45
 	input["data"] = inputData
51 46
 	inputMessage["input"] = input //交易输入
52 47
 
53
-	//var inputLog string
48
+	var inputLog string
54 49
 	bytesData, _ := json.Marshal(inputMessage)
55
-	//inputLog = string(bytesData)
50
+	inputLog = string(bytesData)
56 51
 	fmt.Println(string(bytesData))
57 52
 	if err != nil {
58 53
 		fmt.Println(err.Error())
59 54
 		return err.Error(), ""
60 55
 	}
61
-	//reader := bytes.NewReader(bytesData)
62
-
63
-	//request, err := http.NewRequest("POST", "http://10.72.3.87:8086/CSB/1101", reader)
64
-	//if err != nil {
65
-	//	fmt.Println(err.Error())
66
-	//	return err.Error(), ""
67
-	//}
68
-	//key := "_api_access_key=" + access_key + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
69
-
70
-	//fmt.Println(skey)
71
-	//fmt.Println(timestamp_str)
72
-	//fmt.Println(access_key)
73
-	//
74
-	//request.Header.Set("Content-Type", "application/json")
75
-	//request.Header.Set("_api_timestamp", timestamp_str)
76
-	//request.Header.Set("_api_name", "hssServives")
77
-	//request.Header.Set("_api_version", "1.0.0")
78
-	//request.Header.Set("_api_access_key", access_key)
79
-	//request.Header.Set("_api_signature", skey)
80
-	//
81
-	//client := http.Client{}
82
-	//resp, err := client.Do(request)
83
-	//if err != nil {
84
-	//	fmt.Println(err.Error())
85
-	//	return err.Error(), ""
86
-	//}
87
-	//respBytes, err := ioutil.ReadAll(resp.Body)
88
-	//if err != nil {
89
-	//	fmt.Println(err.Error())
90
-	//	return err.Error(), ""
91
-	//}
92
-	//fmt.Println(string(respBytes))
93
-	//str := string(respBytes)
94
-	//return str, inputLog
95
-	//request_url = "http://10.72.3.87:8086/CSB/1101"
96
-	return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), ""
56
+	request_url = request_url + "1101"
57
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), inputLog
97 58
 }
98
-func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
59
+
60
+// 门诊挂号
61
+func Jsyb2201(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, access_key string) (string, string) {
62
+	fmt.Println(opera)
63
+
64
+	// 生成签名
65
+	timestamp := time.Now().Unix()
66
+	tempTime := time.Unix(timestamp, 0)
67
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
68
+
69
+	// 生成输入报文
70
+	inputMessage := SetJSInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
71
+	input := make(map[string]interface{})
72
+	inputData := make(map[string]interface{})
73
+	inputMessage["infno"] = "2201"        // 交易编码
74
+	inputData["psn_no"] = psnNo           // 人员编号 (来自1101接口返回)
75
+	inputData["insutype"] = insutype      // 险种类型(来自1101接口返回)
76
+	inputData["begntime"] = timeFormatOne // 开始时间
77
+
78
+	if id_card_type == 1 {
79
+		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
80
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
81
+	} else {
82
+		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
83
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
84
+	}
85
+
86
+	inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
87
+	inputData["atddr_no"] = doctor_id    // 医师编码
88
+	inputData["dr_name"] = doctor_name   // 医师姓名
89
+	inputData["dept_code"] = dept_code   // 科室编码
90
+	inputData["dept_name"] = dept        // 科室名称
91
+	inputData["caty"] = "A03.06"         // 科别
92
+
93
+	input["data"] = inputData
94
+	inputMessage["input"] = input //交易输入
95
+
96
+	var requestLog string
97
+	bytesData, err := json.Marshal(inputMessage)
98
+	requestLog = string(bytesData)
99
+	fmt.Println(string(bytesData))
100
+	if err != nil {
101
+		fmt.Println(err.Error())
102
+		return err.Error(), ""
103
+	}
104
+
105
+	request_url = request_url + "2201"
106
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
107
+
108
+}
109
+
110
+// 门诊挂号撤销
111
+func Jsyb2202(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, request_url string, access_key string) (string, string) {
112
+	// 生成签名
113
+	timestamp := time.Now().Unix()
114
+	// 生成输入报文
115
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
116
+	input := make(map[string]interface{})
117
+	inputData := make(map[string]interface{})
118
+	inputMessage["infno"] = "2202"       // 交易编码
119
+	inputData["psn_no"] = psnNo          // 人员编号 (来自1101接口返回)
120
+	inputData["mdtrt_id"] = mdtrtId      // 就诊 ID(来自2201接口返回)
121
+	inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
122
+
123
+	input["data"] = inputData
124
+	inputMessage["input"] = input //交易输入
125
+
126
+	var requestLog string
127
+
128
+	bytesData, err := json.Marshal(inputMessage)
129
+	fmt.Println(string(bytesData))
130
+	requestLog = string(bytesData)
131
+	if err != nil {
132
+		fmt.Println(err.Error())
133
+		return err.Error(), ""
134
+	}
135
+
136
+	request_url = request_url + "2202"
137
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
138
+}
139
+
140
+// 门诊就诊信息上传
141
+func Jsyb2203(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, request_url string, access_key string) (string, string) {
142
+	// 生成签名
143
+	timestamp := time.Now().Unix()
144
+	tempTime := time.Unix(timestamp, 0)
145
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
146
+	// 生成输入报文
147
+	inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
148
+	input := make(map[string]interface{})
149
+	inputData := make(map[string]interface{})
150
+	diseinfo := make([]map[string]interface{}, 0)
151
+
152
+	if med_type == "1111" || med_type == "1112" {
153
+		med_type = "11"
154
+	}
155
+
156
+	inputMessage["infno"] = "2203"        // 交易编码
157
+	inputData["mdtrt_id"] = mdtrtId       // 就诊 ID(来自2201接口返回)
158
+	inputData["psn_no"] = psnNo           // 人员编号 (来自1101接口返回)
159
+	inputData["med_type"] = med_type      // 医疗类别 16门诊特殊病
160
+	inputData["begntime"] = timeFormatOne // 开始时间
161
+	//inputData["begntime"] =  // 开始时间
162
+	inputData["main_cond_dscr"] = ""    // 主要病情描述
163
+	inputData["dise_codg"] = sick_code  // 病种编码
164
+	inputData["dise_name"] = sick_name  // 病种名称
165
+	inputData["birctrl_type"] = ""      // 计划生育手术类别
166
+	inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
167
+
168
+	for index, item := range config {
169
+		diseinfo_sun := make(map[string]interface{})
170
+		diseinfo_sun["diag_type"] = "1"              // 诊断类别
171
+		diseinfo_sun["diag_srt_no"] = index          // 诊断排序号
172
+		diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
173
+		diseinfo_sun["diag_name"] = item.ClassName   // 诊断名称
174
+		diseinfo_sun["diag_dept"] = department       // 诊断科室
175
+		diseinfo_sun["dise_dor_no"] = doctor_id      // 诊断医生编码
176
+		diseinfo_sun["dise_dor_name"] = doctor       // 诊断医生姓名
177
+		diseinfo_sun["diag_time"] = timeFormatOne    // 诊断时间
178
+		diseinfo_sun["vali_flag"] = "1"              // 有效标志
179
+		diseinfo = append(diseinfo, diseinfo_sun)
180
+	}
181
+
182
+	input["diseinfo"] = diseinfo
183
+	input["mdtrtinfo"] = inputData
184
+	inputMessage["input"] = input //交易输入
185
+	var requestLog string
186
+	bytesData, err := json.Marshal(inputMessage)
187
+	fmt.Println(string(bytesData))
188
+	requestLog = string(bytesData)
189
+	if err != nil {
190
+		fmt.Println(err.Error())
191
+		return err.Error(), ""
192
+	}
193
+	request_url = request_url + "2203"
194
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
195
+}
196
+
197
+// 门诊就诊信息上传
198
+func Jsyb2203A(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, request_url string, access_key string) (string, string) {
199
+	// 生成签名
200
+	timestamp := time.Now().Unix()
201
+	tempTime := time.Unix(timestamp, 0)
202
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
203
+
204
+	// 生成输入报文
205
+	inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
206
+	input := make(map[string]interface{})
207
+	inputData := make(map[string]interface{})
208
+	diseinfo := make([]map[string]interface{}, 0)
209
+
210
+	if med_type == "1111" || med_type == "1112" {
211
+		med_type = "11"
212
+	}
213
+
214
+	inputMessage["infno"] = "2203A"       // 交易编码
215
+	inputData["mdtrt_id"] = mdtrtId       // 就诊 ID(来自2201接口返回)
216
+	inputData["psn_no"] = psnNo           // 人员编号 (来自1101接口返回)
217
+	inputData["med_type"] = med_type      // 医疗类别 16门诊特殊病
218
+	inputData["begntime"] = timeFormatOne // 开始时间
219
+
220
+	inputData["main_cond_dscr"] = ""    // 主要病情描述
221
+	inputData["dise_codg"] = sick_code  // 病种编码
222
+	inputData["dise_name"] = sick_name  // 病种名称
223
+	inputData["birctrl_type"] = ""      // 计划生育手术类别
224
+	inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
225
+
226
+	inputData["matn_type"] = "" // 生育类别
227
+	inputData["geso_val"] = ""  // 孕周数
228
+
229
+	for index, item := range config {
230
+		diseinfo_sun := make(map[string]interface{})
231
+		diseinfo_sun["diag_type"] = "1"              // 诊断类别
232
+		diseinfo_sun["diag_srt_no"] = index          // 诊断排序号
233
+		diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
234
+		diseinfo_sun["diag_name"] = item.ClassName   // 诊断名称
235
+		diseinfo_sun["diag_dept"] = department       // 诊断科室
236
+		diseinfo_sun["dise_dor_no"] = doctor_id      // 诊断医生编码
237
+		diseinfo_sun["dise_dor_name"] = doctor       // 诊断医生姓名
238
+		diseinfo_sun["diag_time"] = timeFormatOne    // 诊断时间
239
+		diseinfo_sun["vali_flag"] = "1"              // 有效标志
240
+		diseinfo = append(diseinfo, diseinfo_sun)
241
+	}
242
+
243
+	input["diseinfo"] = diseinfo
244
+	input["mdtrtinfo"] = inputData
245
+	inputMessage["input"] = input //交易输入
246
+	var requestLog string
247
+	bytesData, err := json.Marshal(inputMessage)
248
+	fmt.Println(string(bytesData))
249
+	requestLog = string(bytesData)
250
+	if err != nil {
251
+		fmt.Println(err.Error())
252
+		return err.Error(), ""
253
+	}
254
+	request_url = request_url + "2203A"
255
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
256
+}
257
+
258
+//  门诊费用明细信息上传
259
+func Jsyb2204(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) (string, string) {
260
+	// 生成签名
261
+	timestamp := time.Now().Unix()
262
+	tempTime := time.Unix(timestamp, 0)
263
+	//timeFormat := tempTime.Format("20060102150405")
264
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
265
+	//chrgBchno := rand.Intn(100000) + 10000
266
+	var customs []*Custom
267
+
268
+	for _, item := range hisPrescription {
269
+
270
+		if item.Type == 1 { //药品
271
+			for _, subItem := range item.HisDoctorAdviceInfo {
272
+				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
273
+					//var randNum int
274
+					//randNum = rand.Intn(10000) + 1000
275
+					cus := &Custom{
276
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
277
+						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
278
+						FeedetlSn:        subItem.FeedetlSn,
279
+						Price:            fmt.Sprintf("%.4f", subItem.Price),
280
+						MedListCodg:      subItem.BaseDrugLib.MedicalInsuranceNumber,
281
+						HospApprFlag:     subItem.HospApprFlag,
282
+						DoctorNumber:     doctor_id,
283
+						DoctorName:       new_doctor_name,
284
+					}
285
+
286
+					customs = append(customs, cus)
287
+				}
288
+			}
289
+		}
290
+
291
+		if item.Type == 2 { //项目
292
+			for _, subItem := range item.HisPrescriptionProject {
293
+				//var randNum int
294
+				//randNum = rand.Intn(10000) + 1000
295
+				if subItem.Type == 2 {
296
+					if len(subItem.HisProject.MedicalCode) > 0 {
297
+						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
298
+						cus := &Custom{
299
+							DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
300
+							Cut:              fmt.Sprintf("%.4f", cnt),
301
+							FeedetlSn:        subItem.FeedetlSn,
302
+							Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
303
+							MedListCodg:      subItem.HisProject.MedicalCode,
304
+							DoctorNumber:     doctor_id,
305
+							DoctorName:       new_doctor_name,
306
+							HospApprFlag:     -1,
307
+						}
308
+						customs = append(customs, cus)
309
+					}
310
+
311
+				} else if subItem.Type == 3 {
312
+					if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
313
+						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
314
+
315
+						cus := &Custom{
316
+							DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
317
+							Cut:              fmt.Sprintf("%.4f", cnt),
318
+							FeedetlSn:        subItem.FeedetlSn,
319
+							Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
320
+							MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
321
+							HospApprFlag:     -1,
322
+							DoctorNumber:     doctor_id,
323
+							DoctorName:       new_doctor_name,
324
+						}
325
+						customs = append(customs, cus)
326
+					}
327
+
328
+				}
329
+
330
+			}
331
+		}
332
+
333
+		for _, subItem := range item.HisAdditionalCharge {
334
+			if len(subItem.XtHisAddtionConfig.Code) > 0 {
335
+				cus := &Custom{
336
+					DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
337
+					Cut:              fmt.Sprintf("%.4f", float64(subItem.Count)),
338
+					FeedetlSn:        subItem.FeedetlSn,
339
+					Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
340
+					MedListCodg:      subItem.XtHisAddtionConfig.Code,
341
+					HospApprFlag:     -1,
342
+					DoctorNumber:     doctor_id,
343
+					DoctorName:       new_doctor_name,
344
+				}
345
+				customs = append(customs, cus)
346
+			}
347
+		}
348
+	}
349
+
350
+	// 生成输入报文
351
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
352
+	input := make(map[string]interface{})
353
+	feedetail := make([]map[string]interface{}, 0)
354
+	inputMessage["infno"] = "2204" // 交易编码
355
+
356
+	//chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
357
+	for _, item := range customs {
358
+		feedetailInfo := make(map[string]interface{})
359
+		feedetailInfo["feedetl_sn"] = item.FeedetlSn
360
+		feedetailInfo["mdtrt_id"] = mdtrtId                          // 就诊 ID(来自2201接口返回)
361
+		feedetailInfo["psn_no"] = psnNo                              // 人员编号 (来自1101接口返回)
362
+		feedetailInfo["chrg_bchno"] = chrg_bchno                     // 收费批次号
363
+		feedetailInfo["dise_codg"] = diag_code                       // 病种编码
364
+		feedetailInfo["rxno"] = ""                                   // 处方号
365
+		feedetailInfo["rx_circ_flag"] = "0"                          // 外购处方标志
366
+		feedetailInfo["fee_ocur_time"] = timeFormatOne               // 费用发生时间
367
+		feedetailInfo["med_list_codg"] = item.MedListCodg            // 医疗目录编码
368
+		feedetailInfo["medins_list_codg"] = fixmedins_code           // 医药机构目录编码
369
+		feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
370
+		feedetailInfo["cnt"] = item.Cut                              // 数量
371
+		feedetailInfo["pric"] = item.Price                           // 单价
372
+		feedetailInfo["sin_dos_dscr"] = ""                           // 单次剂量描述
373
+		feedetailInfo["used_frqu_dscr"] = ""                         // 使用频次描述
374
+		feedetailInfo["prd_days"] = "0"                              // 周期天数
375
+		feedetailInfo["medc_way_dscr"] = ""                          // 用药途径描述
376
+		feedetailInfo["bilg_dept_codg"] = dept_code                  // 开单科室编码
377
+		feedetailInfo["bilg_dept_name"] = dept                       // 开单科室名称
378
+		feedetailInfo["bilg_dr_codg"] = item.DoctorNumber            // 开单医生编码
379
+		feedetailInfo["bilg_dr_name"] = item.DoctorName              // 开单医师姓名
380
+		feedetailInfo["acord_dept_codg"] = ""                        // 受单科室编码
381
+		feedetailInfo["acord_dept_name"] = ""                        // 受单科室名称
382
+		feedetailInfo["orders_dr_code"] = ""                         // 受单医生编码
383
+		feedetailInfo["orders_dr_name"] = ""                         // 受单医生姓名
384
+		if balance_accounts_type == "8" {
385
+			feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
386
+		} else {
387
+			if item.HospApprFlag != -1 {
388
+				if item.HospApprFlag == 1 {
389
+					feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
390
+				} else if item.HospApprFlag == 2 {
391
+					feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
392
+				} else if item.HospApprFlag == 3 {
393
+					feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
394
+				} else {
395
+					feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
396
+				}
397
+			} else {
398
+				feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
399
+			}
400
+
401
+		}
402
+
403
+		feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
404
+		feedetailInfo["etip_flag"] = ""        // 外检标志
405
+		feedetailInfo["etip_hosp_code"] = ""   // 外检医院编码
406
+		feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
407
+		feedetailInfo["matn_fee_flag"] = ""    // 生育费用标志
408
+		feedetail = append(feedetail, feedetailInfo)
409
+	}
410
+	input["feedetail"] = feedetail
411
+	inputMessage["input"] = input //交易输入
412
+	var requestLog string
413
+	bytesData, err := json.Marshal(inputMessage)
414
+	fmt.Println("----------")
415
+	fmt.Println(string(bytesData))
416
+	fmt.Println("----------")
417
+	requestLog = string(bytesData)
418
+	if err != nil {
419
+		fmt.Println(err.Error())
420
+		return "", ""
421
+	}
422
+	request_url = request_url + "2204"
423
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
424
+}
425
+
426
+//  门诊费用明细信息撤销
427
+func Jsyb2205(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) (string, string) {
428
+
429
+	timestamp := time.Now().Unix()
430
+
431
+	// 生成输入报文
432
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
433
+	input := make(map[string]interface{})
434
+	inputData := make(map[string]interface{})
435
+	inputMessage["infno"] = "2205" // 交易编码
436
+
437
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
438
+	inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
439
+	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
440
+
441
+	input["data"] = inputData
442
+	inputMessage["input"] = input //交易输入
443
+
444
+	bytesData, err := json.Marshal(inputMessage)
445
+	fmt.Println(string(bytesData))
446
+
447
+	var requestLog string
448
+	requestLog = string(bytesData)
449
+	if err != nil {
450
+		fmt.Println(err.Error())
451
+		return err.Error(), ""
452
+	}
453
+	request_url = request_url + "2205"
454
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
455
+}
456
+
457
+//  门诊预结算
458
+func Jsyb2206(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) (string, string) {
459
+
460
+	// 生成签名
461
+	timestamp := time.Now().Unix()
462
+	// 生成输入报文
463
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
464
+	input := make(map[string]interface{})
465
+	inputData := make(map[string]interface{})
466
+	inputMessage["infno"] = "2206" // 交易编码
467
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
468
+	if certificates == 3 {
469
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
470
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
471
+	} else {
472
+		if id_card_type == 1 {
473
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
474
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
475
+		} else {
476
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
477
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
478
+		}
479
+	}
480
+	if insuplc_admdvs == "421300" {
481
+		if med_type == "11" || med_type == "1112" || med_type == "1111" {
482
+			inputData["med_type"] = "110104" // 医疗类别 11 普通门诊  12 门诊挂号
483
+		} else if med_type == "14" {
484
+			inputData["med_type"] = "140110" // 医疗类别 11 普通门诊  12 门诊挂号
485
+		}
486
+	} else {
487
+		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
488
+	}
489
+
490
+	inputData["medfee_sumamt"] = total  // 医疗费总额
491
+	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算
492
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
493
+	inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
494
+	inputData["acct_used_flag"] = "0"   // 个人账户使用标志 0否 1是
495
+	inputData["insutype"] = insutype    // 险种类型
496
+	inputData["invono"] = ""            // 发票号
497
+
498
+	input["data"] = inputData
499
+	inputMessage["input"] = input //交易输入
500
+
501
+	var requestLog string
502
+
503
+	bytesData, err := json.Marshal(inputMessage)
504
+
505
+	requestLog = string(bytesData)
506
+	fmt.Println(string(bytesData))
507
+	if err != nil {
508
+		fmt.Println(err.Error())
509
+		return err.Error(), ""
510
+	}
511
+	request_url = request_url + "2206"
512
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), requestLog
513
+
514
+}
515
+
516
+//  门诊结算
517
+func Jsyb2207(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) (string, string) {
518
+	// 生成签名
519
+	timestamp := time.Now().Unix()
520
+
521
+	// 生成输入报文
522
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
523
+	input := make(map[string]interface{})
524
+	inputData := make(map[string]interface{})
525
+	inputMessage["infno"] = "2207" // 交易编码
526
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
527
+	if certificates == 3 {
528
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
529
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
530
+	} else {
531
+		if id_card_type == 1 {
532
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
533
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
534
+		} else {
535
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
536
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
537
+		}
538
+	}
539
+	if med_type == "1111" || med_type == "1112" {
540
+		med_type = "11"
541
+	}
542
+	if insuplc_admdvs == "421300" {
543
+		if med_type == "11" {
544
+			inputData["med_type"] = "110104" // 医疗类别 11 普通门诊  12 门诊挂号
545
+		} else if med_type == "14" {
546
+			inputData["med_type"] = "140101" // 医疗类别 11 普通门诊  12 门诊挂号
547
+		}
548
+	} else {
549
+		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
550
+	}
551
+	inputData["medfee_sumamt"] = total           // 医疗费总额
552
+	inputData["psn_setlway"] = "01"              // 个人结算方式 01 按项目结 02 按定额结算
553
+	inputData["mdtrt_id"] = mdtrtId              // 就诊 ID(来自2201接口返回)
554
+	inputData["chrg_bchno"] = chrgBchno          // 收费批次号(来自2204生成的)
555
+	inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
556
+	inputData["insutype"] = insutype             // 险种类型
557
+	inputData["invono"] = ""                     // 发票号
558
+
559
+	inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
560
+	inputData["overlmt_selfpay"] = overlmt_selfpay     //
561
+	inputData["preselfpay_amt"] = preselfpay_amt       //
562
+	inputData["inscp_scp_amt"] = inscp_scp_amt         //
563
+
564
+	input["data"] = inputData
565
+	inputMessage["input"] = input //交易输入
566
+
567
+	bytesData, err := json.Marshal(inputMessage)
568
+	fmt.Println(string(bytesData))
569
+	if err != nil {
570
+		fmt.Println(err.Error())
571
+		return err.Error(), ""
572
+	}
573
+	request_url = request_url + "2207"
574
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), string(bytesData)
575
+
576
+}
577
+
578
+func Jsyb2207A(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) (string, string) {
579
+	// 生成签名
580
+	timestamp := time.Now().Unix()
581
+
582
+	// 生成输入报文
583
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
584
+	input := make(map[string]interface{})
585
+	inputData := make(map[string]interface{})
586
+	inputMessage["infno"] = "2207A" // 交易编码
587
+	inputData["psn_no"] = psnNo     // 人员编号 (来自1101接口返回)
588
+	if certificates == 3 {
589
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
590
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
591
+	} else {
592
+		if id_card_type == 1 {
593
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
594
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
595
+		} else {
596
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
597
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
598
+		}
599
+	}
600
+	if med_type == "1111" || med_type == "1112" {
601
+		med_type = "11"
602
+	}
603
+	if insuplc_admdvs == "421300" {
604
+		if med_type == "11" {
605
+			inputData["med_type"] = "110104" // 医疗类别 11 普通门诊  12 门诊挂号
606
+		} else if med_type == "14" {
607
+			inputData["med_type"] = "140101" // 医疗类别 11 普通门诊  12 门诊挂号
608
+		}
609
+	} else {
610
+		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
611
+	}
612
+	inputData["medfee_sumamt"] = total           // 医疗费总额
613
+	inputData["psn_setlway"] = "01"              // 个人结算方式 01 按项目结 02 按定额结算
614
+	inputData["mdtrt_id"] = mdtrtId              // 就诊 ID(来自2201接口返回)
615
+	inputData["chrg_bchno"] = chrgBchno          // 收费批次号(来自2204生成的)
616
+	inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
617
+	inputData["insutype"] = insutype             // 险种类型
618
+	inputData["invono"] = ""                     // 发票号
619
+
620
+	inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
621
+	inputData["overlmt_selfpay"] = overlmt_selfpay     //
622
+	inputData["preselfpay_amt"] = preselfpay_amt       //
623
+	inputData["inscp_scp_amt"] = inscp_scp_amt         //
624
+
625
+	input["data"] = inputData
626
+	inputMessage["input"] = input //交易输入
627
+
628
+	bytesData, err := json.Marshal(inputMessage)
629
+	fmt.Println(string(bytesData))
630
+	if err != nil {
631
+		fmt.Println(err.Error())
632
+		return err.Error(), ""
633
+	}
634
+	request_url = request_url + "2207A"
635
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), string(bytesData)
636
+
637
+}
638
+
639
+//  门诊结算撤销
640
+func Jsyb2208(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) (string, string) {
641
+	timestamp := time.Now().Unix()
642
+	// 生成输入报文
643
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
644
+	input := make(map[string]interface{})
645
+	inputData := make(map[string]interface{})
646
+	inputMessage["infno"] = "2208" // 交易编码
647
+
648
+	inputData["psn_no"] = psnNo     // 人员编号 (来自1101接口返回)
649
+	inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
650
+	inputData["setl_id"] = setlId   // 结算 ID
651
+
652
+	input["data"] = inputData
653
+	inputMessage["input"] = input //交易输入
654
+
655
+	bytesData, err := json.Marshal(inputMessage)
656
+	fmt.Println(string(bytesData))
657
+	if err != nil {
658
+		fmt.Println(err.Error())
659
+		return err.Error(), ""
660
+	}
661
+	request_url = request_url + "2208"
662
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), string(bytesData)
663
+
664
+}
665
+
666
+func Jsyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) (string, string) {
667
+	timestamp := time.Now().Unix()
668
+	// 生成输入报文
669
+	inputMessage := SetJSInputMessage(timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
670
+	input := make(map[string]interface{})
671
+	inputData := make(map[string]interface{})
672
+	inputMessage["infno"] = "5203" // 交易编码
673
+	inputData["psn_no"] = businessParams.PsnNo
674
+	inputData["setl_id"] = businessParams.SetlId
675
+	inputData["mdtrt_id"] = businessParams.MdtrtId
676
+	input["data"] = inputData
677
+	inputMessage["input"] = input //交易输入
678
+	bytesData, err := json.Marshal(inputMessage)
679
+	fmt.Println(string(bytesData))
680
+	if err != nil {
681
+		fmt.Println(err.Error())
682
+		return err.Error(), ""
683
+	}
684
+	baseParams.RequestUrl = baseParams.RequestUrl + "5203"
685
+	return HttpRequest(baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, timestamp, string(bytesData)), string(bytesData)
686
+}
687
+
688
+//CBS总线
689
+func HttpRequest(url string, ak string, sk string, timestamp int64, json string) string {
99 690
 	fmt.Println(url)
100 691
 	//step 1. 设置请求参数
101
-	csbHP := csbhttp.NewHttpParams("http://10.72.3.87:8086/CSB/1101") //设置请求地址及url参数
692
+	csbHP := csbhttp.NewHttpParams(url) //设置请求地址及url参数
102 693
 	//设置调用方式 get 或者 post
103 694
 	csbHP.SetMethod("post")
104 695
 	//csbHP.AddParam("input", "")
@@ -134,13 +725,45 @@ func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte
134 725
 	}
135 726
 	return res
136 727
 }
137
-func hmacsha1(keyStr, value string) string {
138 728
 
139
-	key := []byte(keyStr)
140
-	mac := hmac.New(sha1.New, key)
141
-	mac.Write([]byte(value))
142
-	//进行base64编码
143
-	res := base64.StdEncoding.EncodeToString(mac.Sum(nil))
729
+// 生成基础报文
730
+func SetJSInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
731
+	// 生成签名
732
+	tempTime := time.Unix(timestamp, 0)
733
+	//timeFormat := tempTime.Format("20060102150405")
734
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
735
+	//randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
144 736
 
145
-	return res
737
+	month := time.Unix(1557042972, 0).Format("1")
738
+	year := time.Now().Format("2006")
739
+	month = time.Now().Format("01")
740
+	day := time.Now().Format("02")
741
+
742
+	hour := time.Now().Format("15")
743
+	min := time.Now().Format("04")
744
+	sec := time.Now().Format("05")
745
+
746
+	msec := time.Now().Format("000")
747
+
748
+	// 生成输入报文
749
+	inputMessage := make(map[string]interface{})
750
+	inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
751
+	inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs                                           // 就医地医保区划
752
+	inputMessage["insuplc_admdvs"] = insuplc_admdvs                                             // 参保地医保区划
753
+	inputMessage["recer_sys_code"] = "1"                                                        // 接收方系统代码
754
+	inputMessage["dev_no"] = ""                                                                 // 设备编号
755
+	inputMessage["dev_safe_info"] = ""                                                          // 设备安全信息
756
+	inputMessage["cainfo"] = ""                                                                 // 数字签名信息
757
+	inputMessage["signtype"] = ""                                                               // 签名类型
758
+	inputMessage["infver"] = "V1.0"                                                             // 接收方系统代码
759
+	inputMessage["opter_type"] = "1"                                                            // 经办人类别
760
+	inputMessage["opter"] = doctor                                                              // 经办人
761
+	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
762
+	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
763
+	inputMessage["fixmedins_code"] = fixmedins_code                                             // 定点医药机构编号
764
+	inputMessage["fixmedins_name"] = org_name
765
+	inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
766
+	//定点医药机构名称
767
+	inputMessage["sign_no"] = "" //交易签到流水号
768
+	return inputMessage
146 769
 }