Browse Source

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

csx 2 years ago
parent
commit
a11cabacd1
2 changed files with 104 additions and 2 deletions
  1. 1 1
      controllers/sg/his_api_controller.go
  2. 103 1
      service/gdyb_service.go

+ 1 - 1
controllers/sg/his_api_controller.go View File

@@ -4794,7 +4794,7 @@ func (c *HisApiController) GetRegisterInfo() {
4794 4794
 
4795 4795
 				infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
4796 4796
 			} else {
4797
-				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, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
4797
+				result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
4798 4798
 				saveLog(result, requestLog, "2201", "挂号")
4799 4799
 				if miConfig.Code == "H15049901371" {
4800 4800
 

+ 103 - 1
service/gdyb_service.go View File

@@ -453,6 +453,108 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, ope
453 453
 
454 454
 }
455 455
 
456
+func Gdyb2201A(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, record_time string) (string, string) {
457
+	fmt.Println(opera)
458
+
459
+	// 生成签名
460
+	nonce := GetRandomString(32)
461
+	timestamp := time.Now().Unix()
462
+	signature := setSignature(timestamp, nonce, secret_key)
463
+	//tempTime := time.Unix(timestamp, 0)
464
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
465
+
466
+	// 生成输入报文
467
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
468
+	input := make(map[string]interface{})
469
+	inputData := make(map[string]interface{})
470
+	inputMessage["infno"] = "2201"      // 交易编码
471
+	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
472
+	inputData["insutype"] = insutype    // 险种类型(来自1101接口返回)
473
+	inputData["begntime"] = record_time // 开始时间
474
+
475
+	if id_card_type == 1 {
476
+		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
477
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
478
+	} else {
479
+		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
480
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
481
+	}
482
+
483
+	inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
484
+	inputData["atddr_no"] = doctor_id    // 医师编码
485
+	inputData["dr_name"] = doctor_name   // 医师姓名
486
+	inputData["dept_code"] = dept_code   // 科室编码
487
+	inputData["dept_name"] = dept        // 科室名称
488
+	inputData["caty"] = "A03.06"         // 科别
489
+
490
+	input["data"] = inputData
491
+	inputMessage["input"] = input //交易输入
492
+
493
+	var requestLog string
494
+	bytesData, err := json.Marshal(inputMessage)
495
+	requestLog = string(bytesData)
496
+	fmt.Println(string(bytesData))
497
+	if err != nil {
498
+		fmt.Println(err.Error())
499
+		return err.Error(), ""
500
+	}
501
+	reader := bytes.NewReader(bytesData)
502
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
503
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
504
+
505
+	gdyb_url := beego.AppConfig.String("gdyb_url")
506
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
507
+
508
+	var url string
509
+	if fixmedins_code == "H15049901371" {
510
+		url = gdyb_url
511
+	} else {
512
+		url = gdyb_url + "2201"
513
+	}
514
+
515
+	if insuplc_admdvs == "421300" {
516
+		var json2 string
517
+		cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
518
+		out, err := cmd.Output()
519
+		if err != nil {
520
+			fmt.Println("error:", err.Error())
521
+		}
522
+		fmt.Println(string(out))
523
+
524
+		return hex.EncodeToString(out), requestLog
525
+	} else {
526
+		request, err := http.NewRequest("POST", url, reader)
527
+		if err != nil {
528
+			fmt.Println(err.Error())
529
+			return err.Error(), ""
530
+		}
531
+
532
+		request.Header.Set("Content-Type", "application/json;charset=UTF-8")
533
+		request.Header.Set("x-tif-paasid", gdyb_paasid)
534
+		request.Header.Set("x-tif-signature", signature)
535
+		request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
536
+		request.Header.Set("x-tif-nonce", nonce)
537
+
538
+		client := http.Client{}
539
+		resp, err := client.Do(request)
540
+		if err != nil {
541
+			fmt.Println(err.Error())
542
+			return err.Error(), ""
543
+		}
544
+		respBytes, err := ioutil.ReadAll(resp.Body)
545
+		if err != nil {
546
+			fmt.Println(err.Error())
547
+			return err.Error(), ""
548
+		}
549
+		str := string(respBytes)
550
+		fmt.Println(str)
551
+		return str, requestLog
552
+
553
+	}
554
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
555
+
556
+}
557
+
456 558
 // 门诊挂号撤销
457 559
 func Gdyb2202(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) (string, string) {
458 560
 	// 生成签名
@@ -4453,7 +4555,7 @@ func Gdyb1101D(certNo string, org_name string, doctor string, fixmedins_code str
4453 4555
 	}
4454 4556
 
4455 4557
 	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
4456
-	inputData["begntime"] = record_date // 开始时间
4558
+	inputData["begntime"] = ""          // 开始时间
4457 4559
 	inputData["psn_name"] = psn_name    // 人员姓名
4458 4560
 	input["data"] = inputData
4459 4561
 	inputMessage["input"] = input //交易输入