Browse Source

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

csx 3 years ago
parent
commit
8aa419e3b1
4 changed files with 459 additions and 187 deletions
  1. 195 181
      controllers/sg/his_api_controller.go
  2. 27 0
      models/yb_models.go
  3. 232 0
      service/gdyb_service.go
  4. 5 6
      service/jsyb_service.go

+ 195 - 181
controllers/sg/his_api_controller.go View File

@@ -70,6 +70,10 @@ func HisManagerApiRegistRouters() {
70 70
 	beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
71 71
 	beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
72 72
 
73
+	beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
74
+	beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
75
+	beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
76
+
73 77
 }
74 78
 func (c *HisApiController) GetPsnNcdsInfo() {
75 79
 	admin_user_id, _ := c.GetInt64("admin_user_id")
@@ -9078,142 +9082,205 @@ func (c *HisApiController) ReversalData() {
9078 9082
 		fmt.Println(result)
9079 9083
 	}
9080 9084
 }
9081
-func (c *HisApiController) ReversalOtherData() {
9082
-	var customData []*CustomData
9083
-
9084
-	custom := &CustomData{
9085
-		MsgId: "H44022900158202103301714472004",
9086
-		PsnNo: "44020000001101329945",
9087
-		Info:  "2208",
9088
-	}
9089
-	customData = append(customData, custom)
9090
-
9091
-	custom1 := &CustomData{
9092
-		MsgId: "H4402290015820210330172057803",
9093
-		PsnNo: "44020000001101161813",
9094
-		Info:  "2208",
9095
-	}
9096
-	customData = append(customData, custom1)
9097
-	custom2 := &CustomData{
9098
-		MsgId: "H44022900158202103301705198813",
9099
-		PsnNo: "44190000133097375417",
9100
-		Info:  "2208",
9101
-	}
9102
-	customData = append(customData, custom2)
9103
-	custom3 := &CustomData{
9104
-		MsgId: "H44022900158202103301715524756",
9105
-		PsnNo: "44020000001100187221",
9106
-		Info:  "2208",
9107
-	}
9108
-	customData = append(customData, custom3)
9109
-	custom4 := &CustomData{
9110
-		MsgId: "H44022900158202103301730376224",
9111
-		PsnNo: "44020000001101959155",
9112
-		Info:  "2208",
9113
-	}
9114
-	customData = append(customData, custom4)
9115
-	custom5 := &CustomData{
9116
-		MsgId: "H44022900158202103301748008725",
9117
-		PsnNo: "44020000001104246641",
9118
-		Info:  "2208",
9119
-	}
9120
-	customData = append(customData, custom5)
9121
-	custom6 := &CustomData{
9122
-		MsgId: "H44022900158202103301718096755",
9123
-		PsnNo: "44020000001102211860",
9124
-		Info:  "2208",
9125
-	}
9126
-	customData = append(customData, custom6)
9127
-	custom7 := &CustomData{
9128
-		MsgId: "H44022900158202103301736551640",
9129
-		PsnNo: "44020000001102687718",
9130
-		Info:  "2208",
9131
-	}
9132
-
9133
-	customData = append(customData, custom7)
9134
-
9135
-	custom8 := &CustomData{
9136
-		MsgId: "H44022900158202103301743097676",
9137
-		PsnNo: "44020000001102127785",
9138
-		Info:  "2208",
9139
-	}
9140
-	customData = append(customData, custom8)
9141
-	custom9 := &CustomData{
9142
-		MsgId: "H44022900158202103301712304203",
9143
-		PsnNo: "44020000001101518097",
9144
-		Info:  "2208",
9145
-	}
9146
-	customData = append(customData, custom9)
9147
-	custom10 := &CustomData{
9148
-		MsgId: "H44022900158202103301738448785",
9149
-		PsnNo: "44020000001100500813",
9150
-		Info:  "2208",
9151
-	}
9152
-	customData = append(customData, custom10)
9153
-
9154
-	custom11 := &CustomData{
9155
-		MsgId: "H44022900158202103301732455843",
9156
-		PsnNo: "44020000001102690557",
9157
-		Info:  "2208",
9158
-	}
9159
-
9160
-	customData = append(customData, custom11)
9161
-
9162
-	custom12 := &CustomData{
9163
-		MsgId: "H44022900158202103301745421708",
9164
-		PsnNo: "44020000001102211928",
9165
-		Info:  "2208",
9085
+func (c *HisApiController) GetAllopatry() {
9086
+	year := c.GetString("year")
9087
+	month := c.GetString("month")
9088
+	admin_user_id, _ := c.GetInt64("admin_user_id")
9089
+	adminUser := c.GetAdminUserInfo()
9090
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
9091
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
9092
+	result, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
9093
+	var dat map[string]interface{}
9094
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
9095
+		fmt.Println(dat)
9096
+	} else {
9097
+		fmt.Println(err)
9166 9098
 	}
9167
-	customData = append(customData, custom12)
9168
-
9169
-	custom1212 := &CustomData{
9170
-		MsgId: "H440229001582021033017351627",
9171
-		PsnNo: "44020000001102481733",
9172
-		Info:  "2208",
9099
+	userJSONBytes, _ := json.Marshal(dat)
9100
+	var res2 models.Result3260
9101
+	if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
9102
+		utils.ErrorLog("解析失败:%v", err)
9103
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9104
+		return
9173 9105
 	}
9174
-	customData = append(customData, custom1212)
9106
+	c.ServeSuccessJSON(map[string]interface{}{
9107
+		"result": res2,
9108
+	})
9175 9109
 
9176
-	custom13 := &CustomData{
9177
-		MsgId: "H44022900158202103301740327951",
9178
-		PsnNo: "44020000001103174866",
9179
-		Info:  "2208",
9180
-	}
9181
-	customData = append(customData, custom13)
9182
-	custom14 := &CustomData{
9183
-		MsgId: "H4402290015820210330174922668",
9184
-		PsnNo: "44020000001102927272",
9185
-		Info:  "2208",
9186
-	}
9187
-	customData = append(customData, custom14)
9188
-	custom15 := &CustomData{
9189
-		MsgId: "H44022900158202103301752362273",
9190
-		PsnNo: "44020000001102942890",
9191
-		Info:  "2208",
9110
+}
9111
+func (c *HisApiController) ComfirmAllopatry() {
9112
+	year := c.GetString("year")
9113
+	month := c.GetString("month")
9114
+	admin_user_id, _ := c.GetInt64("admin_user_id")
9115
+	adminUser := c.GetAdminUserInfo()
9116
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
9117
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
9118
+	result, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
9119
+	var dat map[string]interface{}
9120
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
9121
+		fmt.Println(dat)
9122
+	} else {
9123
+		fmt.Println(err)
9192 9124
 	}
9193
-	customData = append(customData, custom15)
9194
-
9195
-	custom16 := &CustomData{
9196
-		MsgId: "H44022900158202103301751082917",
9197
-		PsnNo: "44020000001101662162",
9198
-		Info:  "2208",
9125
+	userJSONBytes, _ := json.Marshal(dat)
9126
+	var res2 models.Result3261
9127
+	if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
9128
+		utils.ErrorLog("解析失败:%v", err)
9129
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
9130
+		return
9199 9131
 	}
9200
-	customData = append(customData, custom16)
9132
+	c.ServeSuccessJSON(map[string]interface{}{
9133
+		"result": res2,
9134
+	})
9201 9135
 
9202
-	custom17 := &CustomData{
9203
-		MsgId: "H44022900158202103301754147728",
9204
-		PsnNo: "44020000000229014511",
9205
-		Info:  "2208",
9206
-	}
9207
-	customData = append(customData, custom17)
9136
+}
9208 9137
 
9209
-	adminUser := c.GetAdminUserInfo()
9210
-	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
9138
+//func (c *HisApiController) RefundAllopatry() {
9139
+//	year := c.GetString("year")
9140
+//	month := c.GetString("month")
9141
+//	admin_user_id, _ := c.GetInt64("admin_user_id")
9142
+//	adminUser := c.GetAdminUserInfo()
9143
+//	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
9144
+//	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
9145
+//
9146
+//}
9211 9147
 
9212
-	for _, item := range customData {
9213
-		result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
9214
-		fmt.Println(result)
9215
-	}
9216
-}
9148
+//func (c *HisApiController) ReversalOtherData() {
9149
+//	var customData []*CustomData
9150
+//
9151
+//	custom := &CustomData{
9152
+//		MsgId: "H44022900158202103301714472004",
9153
+//		PsnNo: "44020000001101329945",
9154
+//		Info:  "2208",
9155
+//	}
9156
+//	customData = append(customData, custom)
9157
+//
9158
+//	custom1 := &CustomData{
9159
+//		MsgId: "H4402290015820210330172057803",
9160
+//		PsnNo: "44020000001101161813",
9161
+//		Info:  "2208",
9162
+//	}
9163
+//	customData = append(customData, custom1)
9164
+//	custom2 := &CustomData{
9165
+//		MsgId: "H44022900158202103301705198813",
9166
+//		PsnNo: "44190000133097375417",
9167
+//		Info:  "2208",
9168
+//	}
9169
+//	customData = append(customData, custom2)
9170
+//	custom3 := &CustomData{
9171
+//		MsgId: "H44022900158202103301715524756",
9172
+//		PsnNo: "44020000001100187221",
9173
+//		Info:  "2208",
9174
+//	}
9175
+//	customData = append(customData, custom3)
9176
+//	custom4 := &CustomData{
9177
+//		MsgId: "H44022900158202103301730376224",
9178
+//		PsnNo: "44020000001101959155",
9179
+//		Info:  "2208",
9180
+//	}
9181
+//	customData = append(customData, custom4)
9182
+//	custom5 := &CustomData{
9183
+//		MsgId: "H44022900158202103301748008725",
9184
+//		PsnNo: "44020000001104246641",
9185
+//		Info:  "2208",
9186
+//	}
9187
+//	customData = append(customData, custom5)
9188
+//	custom6 := &CustomData{
9189
+//		MsgId: "H44022900158202103301718096755",
9190
+//		PsnNo: "44020000001102211860",
9191
+//		Info:  "2208",
9192
+//	}
9193
+//	customData = append(customData, custom6)
9194
+//	custom7 := &CustomData{
9195
+//		MsgId: "H44022900158202103301736551640",
9196
+//		PsnNo: "44020000001102687718",
9197
+//		Info:  "2208",
9198
+//	}
9199
+//
9200
+//	customData = append(customData, custom7)
9201
+//
9202
+//	custom8 := &CustomData{
9203
+//		MsgId: "H44022900158202103301743097676",
9204
+//		PsnNo: "44020000001102127785",
9205
+//		Info:  "2208",
9206
+//	}
9207
+//	customData = append(customData, custom8)
9208
+//	custom9 := &CustomData{
9209
+//		MsgId: "H44022900158202103301712304203",
9210
+//		PsnNo: "44020000001101518097",
9211
+//		Info:  "2208",
9212
+//	}
9213
+//	customData = append(customData, custom9)
9214
+//	custom10 := &CustomData{
9215
+//		MsgId: "H44022900158202103301738448785",
9216
+//		PsnNo: "44020000001100500813",
9217
+//		Info:  "2208",
9218
+//	}
9219
+//	customData = append(customData, custom10)
9220
+//
9221
+//	custom11 := &CustomData{
9222
+//		MsgId: "H44022900158202103301732455843",
9223
+//		PsnNo: "44020000001102690557",
9224
+//		Info:  "2208",
9225
+//	}
9226
+//
9227
+//	customData = append(customData, custom11)
9228
+//
9229
+//	custom12 := &CustomData{
9230
+//		MsgId: "H44022900158202103301745421708",
9231
+//		PsnNo: "44020000001102211928",
9232
+//		Info:  "2208",
9233
+//	}
9234
+//	customData = append(customData, custom12)
9235
+//
9236
+//	custom1212 := &CustomData{
9237
+//		MsgId: "H440229001582021033017351627",
9238
+//		PsnNo: "44020000001102481733",
9239
+//		Info:  "2208",
9240
+//	}
9241
+//	customData = append(customData, custom1212)
9242
+//
9243
+//	custom13 := &CustomData{
9244
+//		MsgId: "H44022900158202103301740327951",
9245
+//		PsnNo: "44020000001103174866",
9246
+//		Info:  "2208",
9247
+//	}
9248
+//	customData = append(customData, custom13)
9249
+//	custom14 := &CustomData{
9250
+//		MsgId: "H4402290015820210330174922668",
9251
+//		PsnNo: "44020000001102927272",
9252
+//		Info:  "2208",
9253
+//	}
9254
+//	customData = append(customData, custom14)
9255
+//	custom15 := &CustomData{
9256
+//		MsgId: "H44022900158202103301752362273",
9257
+//		PsnNo: "44020000001102942890",
9258
+//		Info:  "2208",
9259
+//	}
9260
+//	customData = append(customData, custom15)
9261
+//
9262
+//	custom16 := &CustomData{
9263
+//		MsgId: "H44022900158202103301751082917",
9264
+//		PsnNo: "44020000001101662162",
9265
+//		Info:  "2208",
9266
+//	}
9267
+//	customData = append(customData, custom16)
9268
+//
9269
+//	custom17 := &CustomData{
9270
+//		MsgId: "H44022900158202103301754147728",
9271
+//		PsnNo: "44020000000229014511",
9272
+//		Info:  "2208",
9273
+//	}
9274
+//	customData = append(customData, custom17)
9275
+//
9276
+//	adminUser := c.GetAdminUserInfo()
9277
+//	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
9278
+//
9279
+//	for _, item := range customData {
9280
+//		result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
9281
+//		fmt.Println(result)
9282
+//	}
9283
+//}
9217 9284
 
9218 9285
 func PathExists(path string) (bool, error) {
9219 9286
 	_, err := os.Stat(path)
@@ -9312,59 +9379,6 @@ func ReadFile(filePath string) []byte {
9312 9379
 	return fd
9313 9380
 }
9314 9381
 
9315
-func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
9316
-	newArr = make([]*models.HisOrderInfo, 0)
9317
-	for i := 0; i < len(arr); i++ {
9318
-		repeat := false
9319
-		for j := i + 1; j < len(arr); j++ {
9320
-			if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
9321
-				repeat = true
9322
-				break
9323
-			}
9324
-		}
9325
-		if !repeat {
9326
-			newArr = append(newArr, arr[i])
9327
-		}
9328
-	}
9329
-	return
9330
-}
9331
-
9332
-func saveRegisterLog(result string) {
9333
-
9334
-	org_id, _ := beego.AppConfig.Int64("org_id")
9335
-	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
9336
-	dir := miConfig.OrgName + "日志"
9337
-	utils.Mkdir(dir)
9338
-	month := time.Unix(1557042972, 0).Format("1")
9339
-	year := time.Now().Format("2006")
9340
-	month = time.Now().Format("01")
9341
-	day := time.Now().Format("02")
9342
-	file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
9343
-	file_name := file + ".txt"
9344
-	file_path := miConfig.OrgName + "日志" + "/" + file_name
9345
-	exist, _ := utils.PathExists(file_path)
9346
-	if exist { //存在
9347
-		fmt.Println("存在")
9348
-		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
9349
-		if err != nil {
9350
-			fmt.Println("read fail")
9351
-		}
9352
-		content := "\r\n" + result
9353
-		n, _ := f.Seek(0, 2)
9354
-		_, err = f.WriteAt([]byte(content), n)
9355
-
9356
-	} else { //不存在
9357
-		fmt.Println("文件不存在,创建文件")
9358
-		f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
9359
-		defer f.Close()
9360
-		if err != nil {
9361
-		} else {
9362
-			_, err = f.Write([]byte("记录日志"))
9363
-		}
9364
-	}
9365
-
9366
-}
9367
-
9368 9382
 func saveLog(result string, request string, infno string, desc string) {
9369 9383
 
9370 9384
 	org_id, _ := beego.AppConfig.Int64("org_id")

+ 27 - 0
models/yb_models.go View File

@@ -0,0 +1,27 @@
1
+package models
2
+
3
+type Result3260 struct {
4
+	ErrMsg      string `json:"err_msg"`
5
+	InfRefmsgid string `json:"inf_refmsgid"`
6
+	Infcode     int64  `json:"infcode"`
7
+	Output      struct {
8
+		Data []interface{} `json:"data"`
9
+	} `json:"output"`
10
+	RefmsgTime  string      `json:"refmsg_time"`
11
+	RespondTime string      `json:"respond_time"`
12
+	Signtype    interface{} `json:"signtype"`
13
+	WarnInfo    interface{} `json:"warn_info"`
14
+}
15
+
16
+type Result3261 struct {
17
+	Cainfo      interface{} `json:"cainfo"`
18
+	ErrMsg      string      `json:"err_msg"`
19
+	InfRefmsgid string      `json:"inf_refmsgid"`
20
+	Infcode     int64       `json:"infcode"`
21
+	Output      struct {
22
+	} `json:"output"`
23
+	RefmsgTime  string      `json:"refmsg_time"`
24
+	RespondTime string      `json:"respond_time"`
25
+	Signtype    interface{} `json:"signtype"`
26
+	WarnMsg     interface{} `json:"warn_msg"`
27
+}

+ 232 - 0
service/gdyb_service.go View File

@@ -3786,3 +3786,235 @@ func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code str
3786 3786
 	str := string(respBytes)
3787 3787
 	return str
3788 3788
 }
3789
+
3790
+func Gdyb3260(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string) (string, string) {
3791
+	//生成签名
3792
+	nonce := GetRandomString(32)
3793
+	timestamp := time.Now().Unix()
3794
+	signature := setSignature(timestamp, nonce, secret_key)
3795
+	//生成输入报文
3796
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
3797
+	input := make(map[string]interface{})
3798
+	inputData := make(map[string]interface{})
3799
+	inputMessage["infno"] = "3260" // 交易编码
3800
+
3801
+	inputData["trt_year"] = year   // 就诊凭证编号
3802
+	inputData["trt_month"] = month // 开始时间
3803
+	inputData["startrow"] = "100"  // 人员姓名
3804
+	input["data"] = inputData
3805
+	inputMessage["input"] = input //交易输入
3806
+	var inputLog string
3807
+	bytesData, err := json.Marshal(inputMessage)
3808
+	inputLog = string(bytesData)
3809
+	fmt.Println(string(bytesData))
3810
+	if err != nil {
3811
+		fmt.Println(err.Error())
3812
+		return err.Error(), ""
3813
+	}
3814
+	reader := bytes.NewReader(bytesData)
3815
+	gdyb_url := beego.AppConfig.String("gdyb_url")
3816
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
3817
+
3818
+	var url string
3819
+	if fixmedins_code == "H15049901371" {
3820
+		url = gdyb_url
3821
+	} else {
3822
+		url = gdyb_url + "3260"
3823
+	}
3824
+
3825
+	if insuplc_admdvs == "421300" {
3826
+		var json2 string
3827
+		cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
3828
+		out, err := cmd.Output()
3829
+		if err != nil {
3830
+			fmt.Println("error:", err.Error())
3831
+		}
3832
+		fmt.Println(string(out))
3833
+		return hex.EncodeToString(out), inputLog
3834
+	} else {
3835
+
3836
+		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
3837
+		request, err := http.NewRequest("POST", url, reader)
3838
+		if err != nil {
3839
+			fmt.Println(err.Error())
3840
+			return err.Error(), ""
3841
+		}
3842
+
3843
+		request.Header.Set("Content-Type", "application/json;charset=UTF-8")
3844
+		request.Header.Set("x-tif-paasid", gdyb_paasid)
3845
+		request.Header.Set("x-tif-signature", signature)
3846
+		request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
3847
+		request.Header.Set("x-tif-nonce", nonce)
3848
+
3849
+		client := http.Client{}
3850
+		resp, err := client.Do(request)
3851
+		if err != nil {
3852
+			fmt.Println(err.Error())
3853
+			return err.Error(), ""
3854
+		}
3855
+		respBytes, err := ioutil.ReadAll(resp.Body)
3856
+		if err != nil {
3857
+			fmt.Println(err.Error())
3858
+			return err.Error(), ""
3859
+		}
3860
+		fmt.Println(string(respBytes))
3861
+		str := string(respBytes)
3862
+		return str, inputLog
3863
+
3864
+	}
3865
+
3866
+}
3867
+func Gdyb3261(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string) (string, string) {
3868
+	//生成签名
3869
+	nonce := GetRandomString(32)
3870
+	timestamp := time.Now().Unix()
3871
+	signature := setSignature(timestamp, nonce, secret_key)
3872
+	//生成输入报文
3873
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
3874
+	input := make(map[string]interface{})
3875
+	inputData := make(map[string]interface{})
3876
+	inputMessage["infno"] = "3261" // 交易编码
3877
+	inputData["trt_year"] = ""     // 就诊凭证编号
3878
+	inputData["trt_month"] = ""    // 开始时间
3879
+	inputData["startrow"] = "100"  // 人员姓名
3880
+	input["data"] = inputData
3881
+	inputMessage["input"] = input //交易输入
3882
+	var inputLog string
3883
+	bytesData, err := json.Marshal(inputMessage)
3884
+	inputLog = string(bytesData)
3885
+	fmt.Println(string(bytesData))
3886
+	if err != nil {
3887
+		fmt.Println(err.Error())
3888
+		return err.Error(), ""
3889
+	}
3890
+	reader := bytes.NewReader(bytesData)
3891
+	gdyb_url := beego.AppConfig.String("gdyb_url")
3892
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
3893
+
3894
+	var url string
3895
+	if fixmedins_code == "H15049901371" {
3896
+		url = gdyb_url
3897
+	} else {
3898
+		url = gdyb_url + "3261"
3899
+	}
3900
+
3901
+	if insuplc_admdvs == "421300" {
3902
+		var json2 string
3903
+		cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
3904
+		out, err := cmd.Output()
3905
+		if err != nil {
3906
+			fmt.Println("error:", err.Error())
3907
+		}
3908
+		fmt.Println(string(out))
3909
+		return hex.EncodeToString(out), inputLog
3910
+	} else {
3911
+
3912
+		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
3913
+		request, err := http.NewRequest("POST", url, reader)
3914
+		if err != nil {
3915
+			fmt.Println(err.Error())
3916
+			return err.Error(), ""
3917
+		}
3918
+
3919
+		request.Header.Set("Content-Type", "application/json;charset=UTF-8")
3920
+		request.Header.Set("x-tif-paasid", gdyb_paasid)
3921
+		request.Header.Set("x-tif-signature", signature)
3922
+		request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
3923
+		request.Header.Set("x-tif-nonce", nonce)
3924
+
3925
+		client := http.Client{}
3926
+		resp, err := client.Do(request)
3927
+		if err != nil {
3928
+			fmt.Println(err.Error())
3929
+			return err.Error(), ""
3930
+		}
3931
+		respBytes, err := ioutil.ReadAll(resp.Body)
3932
+		if err != nil {
3933
+			fmt.Println(err.Error())
3934
+			return err.Error(), ""
3935
+		}
3936
+		fmt.Println(string(respBytes))
3937
+		str := string(respBytes)
3938
+		return str, inputLog
3939
+
3940
+	}
3941
+
3942
+}
3943
+func Gdyb3262(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, otransid string) (string, string) {
3944
+	//生成签名
3945
+	nonce := GetRandomString(32)
3946
+	timestamp := time.Now().Unix()
3947
+	signature := setSignature(timestamp, nonce, secret_key)
3948
+	//生成输入报文
3949
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
3950
+	input := make(map[string]interface{})
3951
+	inputData := make(map[string]interface{})
3952
+	inputMessage["infno"] = "3262" // 交易编码
3953
+
3954
+	inputData["trt_year"] = year     // 就诊凭证编号
3955
+	inputData["trt_month"] = ""      // 开始时间
3956
+	inputData["otransid"] = otransid // 开始时间
3957
+
3958
+	input["data"] = inputData
3959
+	inputMessage["input"] = input //交易输入
3960
+	var inputLog string
3961
+	bytesData, err := json.Marshal(inputMessage)
3962
+	inputLog = string(bytesData)
3963
+	fmt.Println(string(bytesData))
3964
+	if err != nil {
3965
+		fmt.Println(err.Error())
3966
+		return err.Error(), ""
3967
+	}
3968
+	reader := bytes.NewReader(bytesData)
3969
+	gdyb_url := beego.AppConfig.String("gdyb_url")
3970
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
3971
+
3972
+	var url string
3973
+	if fixmedins_code == "H15049901371" {
3974
+		url = gdyb_url
3975
+	} else {
3976
+		url = gdyb_url + "3261"
3977
+	}
3978
+
3979
+	if insuplc_admdvs == "421300" {
3980
+		var json2 string
3981
+		cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
3982
+		out, err := cmd.Output()
3983
+		if err != nil {
3984
+			fmt.Println("error:", err.Error())
3985
+		}
3986
+		fmt.Println(string(out))
3987
+		return hex.EncodeToString(out), inputLog
3988
+	} else {
3989
+
3990
+		//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
3991
+		request, err := http.NewRequest("POST", url, reader)
3992
+		if err != nil {
3993
+			fmt.Println(err.Error())
3994
+			return err.Error(), ""
3995
+		}
3996
+
3997
+		request.Header.Set("Content-Type", "application/json;charset=UTF-8")
3998
+		request.Header.Set("x-tif-paasid", gdyb_paasid)
3999
+		request.Header.Set("x-tif-signature", signature)
4000
+		request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
4001
+		request.Header.Set("x-tif-nonce", nonce)
4002
+
4003
+		client := http.Client{}
4004
+		resp, err := client.Do(request)
4005
+		if err != nil {
4006
+			fmt.Println(err.Error())
4007
+			return err.Error(), ""
4008
+		}
4009
+		respBytes, err := ioutil.ReadAll(resp.Body)
4010
+		if err != nil {
4011
+			fmt.Println(err.Error())
4012
+			return err.Error(), ""
4013
+		}
4014
+		fmt.Println(string(respBytes))
4015
+		str := string(respBytes)
4016
+		return str, inputLog
4017
+
4018
+	}
4019
+
4020
+}

+ 5 - 6
service/jsyb_service.go View File

@@ -201,12 +201,11 @@ func Jsyb2203(psnNo string, mdtrtId string, doctor string, department string, or
201 201
 		med_type = "11"
202 202
 	}
203 203
 
204
-	inputMessage["infno"] = "2203"     // 交易编码
205
-	inputData["mdtrt_id"] = mdtrtId    // 就诊 ID(来自2201接口返回)
206
-	inputData["psn_no"] = psnNo        // 人员编号 (来自1101接口返回)
207
-	inputData["med_type"] = med_type   // 医疗类别 16门诊特殊病
208
-	inputData["begntime"] = begin_time // 开始时间
209
-	//inputData["begntime"] =  // 开始时间
204
+	inputMessage["infno"] = "2203A"     // 交易编码
205
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
206
+	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
207
+	inputData["med_type"] = med_type    // 医疗类别 16门诊特殊病
208
+	inputData["begntime"] = begin_time  // 开始时间
210 209
 	inputData["main_cond_dscr"] = ""    // 主要病情描述
211 210
 	inputData["dise_codg"] = sick_code  // 病种编码
212 211
 	inputData["dise_name"] = sick_name  // 病种名称