Selaa lähdekoodia

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

test_user 3 viikkoa sitten
vanhempi
commit
a749421dcb
2 muutettua tiedostoa jossa 152 lisäystä ja 29 poistoa
  1. 47 2
      controllers/sg/his_api_controller.go
  2. 105 27
      service/gdyb_service.go

+ 47 - 2
controllers/sg/his_api_controller.go Näytä tiedosto

@@ -158,6 +158,8 @@ func HisManagerApiRegistRouters() {
158 158
 	beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
159 159
 	beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
160 160
 
161
+	beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
162
+
161 163
 	beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
162 164
 
163 165
 	beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
@@ -9108,7 +9110,45 @@ func (c *HisApiController) GetBL4201A() {
9108 9110
 
9109 9111
 }
9110 9112
 
9111
-func (c *HisApiController) Get2505() {
9113
+func (c *HisApiController) Get3103() {
9114
+	admin_user_id, _ := c.GetInt64("admin_user_id")
9115
+	warm_type, _ := c.GetInt64("warm_type")
9116
+	fk_state, _ := c.GetInt64("fk_state")
9117
+	warm_ids := c.GetString("warm_ids")
9118
+	desc := c.GetString("desc")
9119
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
9120
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
9121
+	result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
9122
+	saveLog(result, requestLog, "3103", "反馈")
9123
+	var res2 ResultSix
9124
+	var respJSON2 map[string]interface{}
9125
+	if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
9126
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
9127
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9128
+		return
9129
+	}
9130
+	userJSONBytes2, _ := json.Marshal(respJSON2)
9131
+	if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
9132
+		utils.ErrorLog("解析失败:%v", err)
9133
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9134
+		return
9135
+	}
9136
+	if res2.Infcode != 0 {
9137
+		c.ServeSuccessJSON(map[string]interface{}{
9138
+			"failed_code": -10,
9139
+			"msg":         res2.ErrMsg,
9140
+		})
9141
+		return
9142
+
9143
+	} else {
9144
+		c.ServeSuccessJSON(map[string]interface{}{
9145
+			"msg": "反馈成功",
9146
+		})
9147
+		return
9148
+	}
9149
+}
9150
+
9151
+func (c *HisApiController) Get3103() {
9112 9152
 	admin_user_id, _ := c.GetInt64("admin_user_id")
9113 9153
 	miConfig, _ := service.FindMedicalInsuranceInfo(10375)
9114 9154
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
@@ -26964,6 +27004,7 @@ func (c *HisApiController) GetRegisterInfo() {
26964 27004
 									c.ServeSuccessJSON(map[string]interface{}{
26965 27005
 										"failed_code": -10,
26966 27006
 										"failed_type": 100,
27007
+										"warm_type":   1,
26967 27008
 										"msg":         res3101.Output.Result,
26968 27009
 									})
26969 27010
 									return
@@ -30519,6 +30560,7 @@ func (c *HisApiController) GetUploadInfo() {
30519 30560
 								c.ServeSuccessJSON(map[string]interface{}{
30520 30561
 									"failed_code": -10,
30521 30562
 									"failed_type": 100,
30563
+									"warm_type":   2,
30522 30564
 									"msg":         result3101.Output.Result,
30523 30565
 								})
30524 30566
 								return
@@ -32472,6 +32514,7 @@ func (c *HisApiController) GetPreUploadInfo() {
32472 32514
 									c.ServeSuccessJSON(map[string]interface{}{
32473 32515
 										"failed_code": -10,
32474 32516
 										"failed_type": 100,
32517
+										"warm_type":   1,
32475 32518
 										"msg":         result3101.Output.Result,
32476 32519
 									})
32477 32520
 									return
@@ -33730,7 +33773,8 @@ func (c *HisApiController) GetPreUploadInfo() {
33730 33773
 									c.ServeSuccessJSON(map[string]interface{}{
33731 33774
 										"failed_code": -10,
33732 33775
 										"failed_type": 100,
33733
-										"msg":         result3101.Output.Result,
33776
+
33777
+										"msg": result3101.Output.Result,
33734 33778
 									})
33735 33779
 
33736 33780
 									return
@@ -33881,6 +33925,7 @@ func (c *HisApiController) GetPreUploadInfo() {
33881 33925
 										c.ServeSuccessJSON(map[string]interface{}{
33882 33926
 											"failed_code": -10,
33883 33927
 											"failed_type": 100,
33928
+											"warm_type":   2,
33884 33929
 											"msg":         result3101.Output.Result,
33885 33930
 										})
33886 33931
 										return

+ 105 - 27
service/gdyb_service.go Näytä tiedosto

@@ -217,7 +217,7 @@ func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code str
217 217
 
218 218
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
219 219
 
220
- {
220
+	{
221 221
 		request, err := http.NewRequest("POST", url, reader)
222 222
 		if err != nil {
223 223
 			fmt.Println(err.Error())
@@ -307,7 +307,7 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, ope
307 307
 		url = gdyb_url + "2201"
308 308
 	}
309 309
 
310
-	  {
310
+	{
311 311
 		request, err := http.NewRequest("POST", url, reader)
312 312
 		if err != nil {
313 313
 			fmt.Println(err.Error())
@@ -413,7 +413,7 @@ func Gdyb2201A(psnNo string, insutype string, certNo string, org_name string, op
413 413
 		url = gdyb_url + "2201"
414 414
 	}
415 415
 
416
-	  {
416
+	{
417 417
 		fmt.Println(url)
418 418
 		fmt.Println(gdyb_paasid)
419 419
 		fmt.Println(secret_key)
@@ -734,7 +734,7 @@ func Gdyb2203c(psnNo string, mdtrtId string, doctor string, department string, o
734 734
 	} else {
735 735
 		url = gdyb_url + "2203"
736 736
 	}
737
- {
737
+	{
738 738
 		request, err := http.NewRequest("POST", url, reader)
739 739
 		if err != nil {
740 740
 			fmt.Println(err.Error())
@@ -843,7 +843,7 @@ func Gdyb2203A(psnNo string, mdtrtId string, doctor string, department string, o
843 843
 		url = gdyb_url + "2203"
844 844
 	}
845 845
 
846
- {
846
+	{
847 847
 
848 848
 		request, err := http.NewRequest("POST", url, reader)
849 849
 		if err != nil {
@@ -942,7 +942,7 @@ func Gdyb2203d(psnNo string, mdtrtId string, doctor string, department string, o
942 942
 	var url string
943 943
 
944 944
 	url = gdyb_url + "2203"
945
-{
945
+	{
946 946
 
947 947
 		request, err := http.NewRequest("POST", url, reader)
948 948
 		if err != nil {
@@ -1242,7 +1242,7 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
1242 1242
 
1243 1243
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
1244 1244
 
1245
- {
1245
+	{
1246 1246
 
1247 1247
 		request, err := http.NewRequest("POST", url, reader)
1248 1248
 		if err != nil {
@@ -1551,7 +1551,7 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
1551 1551
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
1552 1552
 
1553 1553
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
1554
-{
1554
+	{
1555 1555
 		request, err := http.NewRequest("POST", url, reader)
1556 1556
 		fmt.Println(err)
1557 1557
 
@@ -1626,7 +1626,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1626 1626
 			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
1627 1627
 		}
1628 1628
 	}
1629
-	 {
1629
+	{
1630 1630
 		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
1631 1631
 	}
1632 1632
 
@@ -1671,7 +1671,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1671 1671
 
1672 1672
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
1673 1673
 
1674
-	 {
1674
+	{
1675 1675
 		request, err := http.NewRequest("POST", url, reader)
1676 1676
 		if err != nil {
1677 1677
 			fmt.Println(err.Error())
@@ -1743,7 +1743,7 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1743 1743
 	if med_type == "1111" || med_type == "1112" {
1744 1744
 		med_type = "11"
1745 1745
 	}
1746
- {
1746
+	{
1747 1747
 		inputData["med_type"] = med_type // 医疗类别 11 普通门诊  12 门诊挂号
1748 1748
 	}
1749 1749
 	inputData["medfee_sumamt"] = total           // 医疗费总额
@@ -1786,7 +1786,7 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
1786 1786
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
1787 1787
 
1788 1788
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
1789
- {
1789
+	{
1790 1790
 
1791 1791
 		request, err := http.NewRequest("POST", url, reader)
1792 1792
 		if err != nil {
@@ -1893,7 +1893,7 @@ func Gdyb2207A(psnNo string, mdtrtId string, chrgBchno string, certNo string, in
1893 1893
 
1894 1894
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
1895 1895
 
1896
- {
1896
+	{
1897 1897
 
1898 1898
 		request, err := http.NewRequest("POST", url, reader)
1899 1899
 		if err != nil {
@@ -1982,7 +1982,7 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
1982 1982
 
1983 1983
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
1984 1984
 
1985
-	 {
1985
+	{
1986 1986
 		request, err := http.NewRequest("POST", url, reader)
1987 1987
 		if err != nil {
1988 1988
 			fmt.Println(err.Error())
@@ -5795,7 +5795,7 @@ func Gdyb3260(org_name string, doctor string, fixmedins_code string, insuplc_adm
5795 5795
 	} else {
5796 5796
 		url = gdyb_url + "3260"
5797 5797
 	}
5798
- {
5798
+	{
5799 5799
 
5800 5800
 		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
5801 5801
 		request, err := http.NewRequest("POST", url, reader)
@@ -6237,7 +6237,7 @@ func Gdyb3262(org_name string, doctor string, fixmedins_code string, insuplc_adm
6237 6237
 		url = gdyb_url + "3262"
6238 6238
 	}
6239 6239
 
6240
-	 {
6240
+	{
6241 6241
 
6242 6242
 		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
6243 6243
 		request, err := http.NewRequest("POST", url, reader)
@@ -6329,7 +6329,7 @@ func Gdyb9001(org_name string, doctor string, fixmedins_code string, insuplc_adm
6329 6329
 		url = gdyb_url + "9001"
6330 6330
 	}
6331 6331
 
6332
- {
6332
+	{
6333 6333
 
6334 6334
 		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
6335 6335
 
@@ -6414,7 +6414,7 @@ func Gdyb9001Two(org_name string, doctor string, fixmedins_code string, insuplc_
6414 6414
 		url = gdyb_url + "9001"
6415 6415
 	}
6416 6416
 
6417
-	 {
6417
+	{
6418 6418
 
6419 6419
 		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
6420 6420
 
@@ -6578,7 +6578,7 @@ func Gdyb1101D(certNo string, org_name string, doctor string, fixmedins_code str
6578 6578
 		url = gdyb_url + "1101"
6579 6579
 	}
6580 6580
 
6581
- {
6581
+	{
6582 6582
 
6583 6583
 		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
6584 6584
 		request, err := http.NewRequest("POST", url, reader)
@@ -6747,7 +6747,6 @@ func Gdyb3501(struct3501 models.Struct3501, secret_key string) (string, string)
6747 6747
 	input["invinfo"] = inputData
6748 6748
 	inputMessage["input"] = input //交易输入
6749 6749
 
6750
-
6751 6750
 	bytesData, err := json.Marshal(inputMessage)
6752 6751
 	fmt.Println(string(bytesData))
6753 6752
 	if err != nil {
@@ -7063,12 +7062,12 @@ func Gdyb3505(struct3505 models.Struct3505, secret_key string) (string, string)
7063 7062
 	inputData["rxno"] = struct3505.Rxno                   // 人员编号 (来自1101接口返回)
7064 7063
 	inputData["rx_circ_flag"] = struct3505.RxCircFlag     // 人员编号 (来自1101接口返回)
7065 7064
 
7066
-	inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
7067
-	inputData["stoout_no"] = struct3505.StooutNo   // 人员编号 (来自1101接口返回)
7065
+	inputData["rtal_docno"] = struct3505.RtalDocno          // 人员编号 (来自1101接口返回)
7066
+	inputData["stoout_no"] = struct3505.StooutNo            // 人员编号 (来自1101接口返回)
7068 7067
 	inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
7069 7068
 
7070 7069
 	inputData["bchno"] = struct3505.Bchno                          // 人员编号 (来自1101接口返回)
7071
-	inputData["drug_trac_codg"] = "--"        // 人员编号 (来自1101接口返回)
7070
+	inputData["drug_trac_codg"] = "--"                             // 人员编号 (来自1101接口返回)
7072 7071
 	inputData["drug_prod_barc"] = struct3505.DrugProdBarc          // 人员编号 (来自1101接口返回)
7073 7072
 	inputData["shelf_posi"] = struct3505.ShelfPosi                 // 人员编号 (来自1101接口返回)
7074 7073
 	inputData["sel_retn_cnt"] = struct3505.SelRetnCnt              // 人员编号 (来自1101接口返回)
@@ -7214,9 +7213,9 @@ func Gdyb3507(struct3507 models.Struct3507, secret_key string) (string, string)
7214 7213
 	inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
7215 7214
 	input := make(map[string]interface{})
7216 7215
 	inputData := make(map[string]interface{})
7217
-	inputMessage["infno"] = "3507"                          // 交易编码
7216
+	inputMessage["infno"] = "3507"                           // 交易编码
7218 7217
 	inputData["fixmedins_bchno"] = struct3507.FixmedinsBchno // 人员编号 (来自1101接口返回)
7219
-	inputData["inv_data_type"] = struct3507.InvDataType     // 人员编号 (来自1101接口返回)
7218
+	inputData["inv_data_type"] = struct3507.InvDataType      // 人员编号 (来自1101接口返回)
7220 7219
 
7221 7220
 	input["data"] = inputData
7222 7221
 	inputMessage["input"] = input //交易输入
@@ -8538,7 +8537,7 @@ func Gzyb3505(struct3505 models.Struct3505, secret_key string) (string, string)
8538 8537
 	inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
8539 8538
 	codes := strings.Split(struct3505.DrugTracCodg, ",")
8540 8539
 
8541
-	inputData["drug_trac_codg"] = codes[0]          // 人员编号 (来自1101接口返回)
8540
+	inputData["drug_trac_codg"] = codes[0]                         // 人员编号 (来自1101接口返回)
8542 8541
 	inputData["drug_prod_barc"] = struct3505.DrugProdBarc          // 人员编号 (来自1101接口返回)
8543 8542
 	inputData["shelf_posi"] = struct3505.ShelfPosi                 // 人员编号 (来自1101接口返回)
8544 8543
 	inputData["sel_retn_cnt"] = struct3505.SelRetnCnt              // 人员编号 (来自1101接口返回)
@@ -8550,7 +8549,7 @@ func Gzyb3505(struct3505 models.Struct3505, secret_key string) (string, string)
8550 8549
 
8551 8550
 	//codes = strings.Split(struct3505.DrugTracCodg, ",")
8552 8551
 	for _, item := range codes {
8553
-		if len(item) > 0{
8552
+		if len(item) > 0 {
8554 8553
 			druginputData := make(map[string]interface{})
8555 8554
 			druginputData["drug_trac_codg"] = item
8556 8555
 			feedetail = append(feedetail, druginputData)
@@ -9311,3 +9310,82 @@ func SetGZInputMessage(nonce string, timestamp int64, org_name string, doctor st
9311 9310
 	//inputMessage["sign_no"] = "GZYBCS4101A20220202"
9312 9311
 	return inputMessage
9313 9312
 }
9313
+
9314
+func Gdyb3103(org_name string, opera string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, warm_type int64, ids string, dspo_way int64, desc string) (string, string) {
9315
+	fmt.Println(opera)
9316
+
9317
+	// 生成签名
9318
+	nonce := GetRandomString(32)
9319
+	timestamp := time.Now().Unix()
9320
+	signature := setSignature(timestamp, nonce, secret_key)
9321
+
9322
+	// 生成输入报文
9323
+	inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
9324
+	input := make(map[string]interface{})
9325
+	inputData := make(map[string]interface{})
9326
+	inputMessage["infno"] = "3103" // 交易编码
9327
+
9328
+	inputData["warn_type"] = warm_type // 人员编号 (来自1101接口返回)
9329
+
9330
+	id_arr := strings.Split(ids, "~")
9331
+	feedetail := make([]map[string]interface{}, 0)
9332
+	for _, item := range id_arr {
9333
+		feedetailInfo := make(map[string]interface{})
9334
+		feedetailInfo["warn_rslt_id"] = item
9335
+		feedetailInfo["dspo_way"] = dspo_way // 就诊 ID(来自2201接口返回)
9336
+		feedetailInfo["dspo_way_rea"] = desc // 人员编号 (来自1101接口返回)
9337
+		feedetail = append(feedetail, feedetailInfo)
9338
+	}
9339
+	inputData["warns"] = feedetail
9340
+	input["data"] = inputData
9341
+	inputMessage["input"] = input //交易输入
9342
+
9343
+	var requestLog string
9344
+	bytesData, err := json.Marshal(inputMessage)
9345
+	requestLog = string(bytesData)
9346
+	fmt.Println(string(bytesData))
9347
+	if err != nil {
9348
+		fmt.Println(err.Error())
9349
+		return err.Error(), ""
9350
+	}
9351
+	reader := bytes.NewReader(bytesData)
9352
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
9353
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
9354
+
9355
+	gdyb_url := beego.AppConfig.String("gdyb_url")
9356
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
9357
+
9358
+	var url string
9359
+
9360
+	url = gdyb_url + "3103"
9361
+
9362
+	{
9363
+		request, err := http.NewRequest("POST", url, reader)
9364
+		if err != nil {
9365
+			fmt.Println(err.Error())
9366
+			return err.Error(), ""
9367
+		}
9368
+
9369
+		request.Header.Set("Content-Type", "application/json;charset=UTF-8")
9370
+		request.Header.Set("x-tif-paasid", gdyb_paasid)
9371
+		request.Header.Set("x-tif-signature", signature)
9372
+		request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
9373
+		request.Header.Set("x-tif-nonce", nonce)
9374
+
9375
+		client := http.Client{}
9376
+		resp, err := client.Do(request)
9377
+		if err != nil {
9378
+			fmt.Println(err.Error())
9379
+			return err.Error(), ""
9380
+		}
9381
+		respBytes, err := ioutil.ReadAll(resp.Body)
9382
+		if err != nil {
9383
+			fmt.Println(err.Error())
9384
+			return err.Error(), ""
9385
+		}
9386
+		str := string(respBytes)
9387
+		fmt.Println(str)
9388
+		return str, requestLog
9389
+
9390
+	}
9391
+}