Browse Source

Merge remote-tracking branch 'origin/master'

XMLWAN 4 years ago
parent
commit
07b28720b0

+ 9 - 6
conf/app.conf View File

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2 2
 httpport = 9532
3
-runmode = prod
3
+runmode = dev
4 4
 
5 5
 #
6 6
 copyrequestbody = true
@@ -44,14 +44,16 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 10028
47
+org_id = 9504
48 48
 mobile_token_expiration_second = 86400
49 49
 httpdomain = https://api.xt.kuyicloud.com
50 50
 sso_domain = https://sso.kuyicloud.com
51 51
 call_domain = https://hf.sgjyun.com
52 52
 front_end_domain = "https://xt.kuyicloud.com/#"
53
-url  = "http://192.168.1.228:17001/szsi-portal/transData"
54
-#url = "http://192.168.1.88:6666/szsi-portal/transData"
53
+#url  = "http://192.168.1.228:17001/szsi-portal/transData"
54
+url = "http://192.168.1.88:6666/szsi-portal/transData"
55
+gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
56
+gdyb_paasid = "sg03_prd"
55 57
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
56 58
 readmysqlport = 3306
57 59
 readmysqluser = syh
@@ -149,9 +151,10 @@ sso_domain = https://testsso.sgjyun.com
149 151
 call_domain = http://hf.szjkhd.com
150 152
 front_end_domain = "http://xt.test.sgjyun.com/#"
151 153
 
152
-org_id = 9538
154
+org_id = 4
153 155
 url  = "http://192.168.1.228:17001/szsi-portal/transData"
154
-
156
+gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/"
157
+gdyb_paasid = "test_hosp"
155 158
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
156 159
 readmysqlport = 3306
157 160
 readmysqluser = root

+ 95 - 79
controllers/base_api_controller.go View File

@@ -4,7 +4,6 @@ import (
4 4
 	"gdyb/enums"
5 5
 	"gdyb/models"
6 6
 	"github.com/astaxie/beego"
7
-
8 7
 	//"XT_New/models"
9 8
 
10 9
 	//"XT_New/models"
@@ -96,83 +95,65 @@ func (this *BaseAuthAPIController) Prepare() {
96 95
 		adminUserInfo.CurrentAppId = 8642
97 96
 		adminUserInfo.AdminUser = &userAdmin
98 97
 		this.SetSession("admin_user_info", &adminUserInfo)
99
-
100 98
 	}
101 99
 
102
-	//if this.Ctx.Request.Method != "GET" {
103
-	//	adminUserInfo := this.GetAdminUserInfo()
104
-	//
105
-	//	err := service.GetOrgSubscibeState(adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId])
106
-	//	if err != nil || adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId].State == 3 {
107
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
108
-	//		this.StopRun()
109
-	//	}
110
-	//}
111
-
112
-	//if this.Ctx.Request.Header.Get("Permission") == "1" {
113
-	//	isPermission := false
114
-	//
115
-	//	//adminUserInfo := this.GetAdminUserInfo()
116
-	//
117
-	//	//service.GetUserAllRole(adminUserInfo.CurrentOrgId)
118
-	//
119
-	//
120
-	//
100
+	//if this.Ctx.Request.Header.Get("Permission") == "5" { //医保相关权限
101
+	//	org_id, _ := beego.AppConfig.Int64("org_id")
102
+	//	org, _ := service.GetOrgById(org_id)
103
+	//	admin_user_id, _ := this.GetInt64("admin_user_id")
104
+	//	if admin_user_id != org.Creator { //超级管理员不受此限制
105
+	//		isPermission := false
106
+	//		//该机构下该用户有多少个
107
+	//		role, _ := service.GetUserAllRole(org_id, admin_user_id)
108
+	//		var roles []string
109
+	//		if len(role.RoleIds) <= 0 { //该用户没有设置角色
121 110
 	//
122
-	//	roles := []int64{1,2}		//模拟该用户有多少角色
123
-	//	var targetRole models.RolePurview
124
-	//	var userRolePurview []string
125
-	//
126
-	//	//用户角色1对应的权限
127
-	//	role1 := models.RolePurview{PurviewIds:"11,12,13"}
128
-	//
129
-	//	//用户角色2对应的权限
130
-	//	role2 := models.RolePurview{PurviewIds:"11,15,16"}
131
-	//
132
-	//
133
-	//	//模拟角色2
134
-	//	//判断该用户有多少个角色,合并最大角色权限
135
-	//	if len(roles) == 1{ //单个
136
-	//		targetRole = role1
137
-	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
138
-	//
139
-	//	}else{ //多个
140
-	//		targetRole = role1
141
-	//		targetRole.PurviewIds = targetRole.PurviewIds + "," + role2.PurviewIds
142
-	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
143
-	//	}
144
-	//
145
-	//	userRolePurview = RemoveRepeatedElement2(userRolePurview)
111
+	//		} else {
112
+	//			roles = strings.Split(role.RoleIds, ",")
113
+	//		}
114
+	//		fmt.Println(roles)
146 115
 	//
147
-	//	fmt.Println(userRolePurview)
148
-	//	//所有权限列表
149
-	//	allPermission := []models.Purview{{Id:10,Urlfor:"/m/api/dialysis/dialysisPrescription-/api/dialysis/prescription"},
150
-	//		{Id:11,Urlfor:"/m/api/dialysis/dialysisPrescription1-/api/dialysis/prescription1"},
151
-	//		{Id:12,Urlfor:"/m/api/dialysis/dialysisPrescription2-/api/dialysis/prescription2"},
152
-	//		{Id:13,Urlfor:"/m/api/dialysis/dialysisPrescription3-/api/dialysis/prescription3"},
153
-	//		{Id:14,Urlfor:"/m/api/dialysis/dialysisPrescription4-/api/dialysis/prescription4"},
154
-	//		{Id:15,Urlfor:"/m/api/dialysis/dialysisPrescription5-/api/dialysis/prescription5"},
155
-	//		{Id:16,Urlfor:"/m/api/dialysis/dialysisPrescription6-/api/dialysis/prescription6"}}
156
-	//	for _, item := range allPermission {
157
-	//		//判断当前路由是否在权限路由列表里面
158
-	//		if strings.Split(item.Urlfor, "-")[1] == strings.Split(this.Ctx.Request.RequestURI , "?")[0]{
159
-	//			fmt.Println(strings.Split(this.Ctx.Request.RequestURI , "?")[0])
116
+	//		//获取该用户下所有角色的权限总集
117
+	//		var userRolePurviews string
118
+	//		var userRolePurviewsArr []string
119
+	//		for _, item := range roles {
120
+	//			role_id, _ := strconv.ParseInt(item, 10, 64)
121
+	//			purviews, _ := service.GetRoleFuncPurviewIds(role_id)
122
+	//			if len(userRolePurviews) == 0 {
123
+	//				userRolePurviews = purviews
124
+	//			} else {
125
+	//				userRolePurviews = userRolePurviews + "," + purviews
126
+	//			}
127
+	//		}
128
+	//		//该用户所拥有角色的权限的总集
129
+	//		userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
130
+	//		fmt.Println(userRolePurviewsArr)
131
+	//		//系统所记录的权限列表
132
+	//		allPermission, _ := service.GetAllFunctionPurview()
160 133
 	//
134
+	//		for _, item := range allPermission {
161 135
 	//			//获取该角色的所有权限
162
-	//			for _, items := range userRolePurview{
136
+	//			for _, items := range userRolePurviewsArr {
163 137
 	//				id, _ := strconv.ParseInt(items, 10, 64)
164
-	//				if id == item.Id{
138
+	//				if id == item.ID {
165 139
 	//					isPermission = true
166 140
 	//				}
167 141
 	//			}
168
-	//			if !isPermission{
169
-	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreExist)
142
+	//			if !isPermission {
143
+	//				msg, _ := service.FindErrorMsgByStr(item.ID)
144
+	//				json := make(map[string]interface{})
145
+	//				json["msg"] = msg
146
+	//				json["code"] = 0
147
+	//				json["state"] = 0
148
+	//				this.Data["json"] = json
149
+	//				this.ServeJSON()
170 150
 	//				this.StopRun()
171 151
 	//			}
172
-	//		}
173 152
 	//
153
+	//		}
174 154
 	//	}
175 155
 	//}
156
+
176 157
 }
177 158
 
178 159
 type BaseServeAPIController struct {
@@ -182,16 +163,10 @@ type BaseServeAPIController struct {
182 163
 func (this *BaseServeAPIController) Prepare() {
183 164
 	this.BaseAPIController.Prepare()
184 165
 	if this.GetAdminUserInfo() == nil {
185
-		//org_id, _ := beego.AppConfig.Int64("org_id")
186 166
 		org_id, _ := beego.AppConfig.Int64("org_id")
187
-
188
-		//org_id, _ := this.GetInt64("org_id")
189 167
 		var userAdmin models.AdminUser
190 168
 		userAdmin.Id = 1448
191 169
 		userAdmin.Mobile = "13318599895"
192
-
193
-		//userAdmin.Id = 597
194
-		//userAdmin.Mobile = "19874122664"
195 170
 		userAdmin.IsSuperAdmin = false
196 171
 		userAdmin.Status = 1
197 172
 		userAdmin.CreateTime = 1530786071
@@ -213,21 +188,62 @@ func (this *BaseServeAPIController) Prepare() {
213 188
 		this.SetSession("admin_user_info", &adminUserInfo)
214 189
 	}
215 190
 
216
-	//if adminUserInfo.AppRole != nil {
217
-	//	if adminUserInfo.AppRole.Id > 0 {
218
-	//		app_role, _ := service.FindAppRoleById(adminUserInfo.AppRole.Id)
219
-	//		if app_role != nil {
220
-	//			if app_role.Status != 1 {
221
-	//				this.DelSession("mobile_admin_user_info")
222
-	//				this.Ctx.SetCookie("token_cookie", "")
223
-	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeForbidden)
191
+	//if this.Ctx.Request.Header.Get("Permission") == "5" { //医保相关权限
192
+	//	org_id, _ := beego.AppConfig.Int64("org_id")
193
+	//	org, _ := service.GetOrgById(org_id)
194
+	//	admin_user_id, _ := this.GetInt64("admin_user_id")
195
+	//	if admin_user_id != org.Creator { //超级管理员不受此限制
196
+	//		isPermission := false
197
+	//		//该机构下该用户有多少个
198
+	//		role, _ := service.GetUserAllRole(org_id, admin_user_id)
199
+	//		var roles []string
200
+	//		if len(role.RoleIds) <= 0 { //该用户没有设置角色
201
+	//
202
+	//		} else {
203
+	//			roles = strings.Split(role.RoleIds, ",")
204
+	//		}
205
+	//		fmt.Println(roles)
206
+	//
207
+	//		//获取该用户下所有角色的权限总集
208
+	//		var userRolePurviews string
209
+	//		var userRolePurviewsArr []string
210
+	//		for _, item := range roles {
211
+	//			role_id, _ := strconv.ParseInt(item, 10, 64)
212
+	//			purviews, _ := service.GetRoleFuncPurviewIds(role_id)
213
+	//			if len(userRolePurviews) == 0 {
214
+	//				userRolePurviews = purviews
215
+	//			} else {
216
+	//				userRolePurviews = userRolePurviews + "," + purviews
217
+	//			}
218
+	//		}
219
+	//		//该用户所拥有角色的权限的总集
220
+	//		userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
221
+	//		fmt.Println(userRolePurviewsArr)
222
+	//		//系统所记录的权限列表
223
+	//		allPermission, _ := service.GetAllFunctionPurview()
224
+	//
225
+	//		for _, item := range allPermission {
226
+	//			//获取该角色的所有权限
227
+	//			for _, items := range userRolePurviewsArr {
228
+	//				id, _ := strconv.ParseInt(items, 10, 64)
229
+	//				if id == item.ID {
230
+	//					isPermission = true
231
+	//				}
232
+	//			}
233
+	//			if !isPermission {
234
+	//				msg, _ := service.FindErrorMsgByStr(item.ID)
235
+	//				json := make(map[string]interface{})
236
+	//				json["msg"] = msg
237
+	//				json["code"] = 0
238
+	//				json["state"] = 0
239
+	//				this.Data["json"] = json
240
+	//				this.ServeJSON()
224 241
 	//				this.StopRun()
225 242
 	//			}
243
+	//
226 244
 	//		}
227 245
 	//	}
228
-	//
229 246
 	//}
230
-	//fmt.Println("222222222")
231 247
 
232 248
 }
233 249
 

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

@@ -79,7 +79,7 @@ func (c *GdybController) PostOne() {
79 79
 	id_card_type, _ := c.GetInt64("id_card_type")
80 80
 	card_sn := c.GetString("card_sn")
81 81
 
82
-	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, "44022919620927046X")
82
+	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn)
83 83
 
84 84
 	var dat map[string]interface{}
85 85
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {

+ 503 - 371
controllers/sg/his_api_controller.go View File

@@ -11,6 +11,7 @@ import (
11 11
 	"gdyb/service"
12 12
 	"gdyb/utils"
13 13
 	"github.com/astaxie/beego"
14
+	"github.com/axgle/mahonia"
14 15
 	"github.com/jinzhu/gorm"
15 16
 	"github.com/shopspring/decimal"
16 17
 	"io"
@@ -38,12 +39,12 @@ func HisManagerApiRegistRouters() {
38 39
 	beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
39 40
 	beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
40 41
 	beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
41
-	//beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
42
+	beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
42 43
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
43 44
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
44 45
 	beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
45 46
 	beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
46
-	beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
47
+	//beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
47 48
 	beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
48 49
 	//beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
49 50
 
@@ -56,7 +57,10 @@ func HisManagerApiRegistRouters() {
56 57
 	beego.Router("/api/310", &HisApiController{}, "get:Check310")
57 58
 	beego.Router("/api/390", &HisApiController{}, "get:Check390")
58 59
 
60
+	beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
61
+
59 62
 	//备案撤销相关接口
63
+
60 64
 	beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
61 65
 	beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
62 66
 	beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
@@ -240,256 +244,219 @@ func (c *HisApiController) GetHisPatientInfo() {
240 244
 	}
241 245
 }
242 246
 
243
-//func (c *HisApiController) Sscard() {
244
-//	id_card_type, _ := c.GetInt64("id_card_type")
245
-//	adminUser := c.GetAdminUserInfo()
246
-//	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
247
-//
248
-//	r := CardInit()
249
-//	fmt.Println(r)
250
-//	//if r == 0 {
251
-//	switch id_card_type {
252
-//	case 1:
253
-//		basStr, err := GetBasBaseInfo()
254
-//
255
-//		if err != nil {
256
-//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
257
-//			return
258
-//
259
-//		} else {
260
-//			fmt.Println(basStr)
261
-//
262
-//			bas := strings.Split(basStr, "|")
263
-//
264
-//			basNumber := bas[1]
265
-//
266
-//			//basNumber := bas[2]
267
-//			card_sn := bas[3]
268
-//
269
-//			appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
270
-//
271
-//			api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
272
-//			resp, requestErr := http.Get(api)
273
-//			if requestErr != nil {
274
-//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
275
-//				return
276
-//			}
277
-//			defer resp.Body.Close()
278
-//			body, ioErr := ioutil.ReadAll(resp.Body)
279
-//			if ioErr != nil {
280
-//				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
281
-//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
282
-//				return
283
-//			}
284
-//			var respJSON map[string]interface{}
285
-//
286
-//			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
287
-//				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
288
-//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
289
-//				return
290
-//			}
291
-//
292
-//			userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
293
-//			userJSONBytes, _ := json.Marshal(userJSON)
294
-//			var res ResultTwo
295
-//			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
296
-//				utils.ErrorLog("解析失败:%v", err)
297
-//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
298
-//				return
299
-//			}
300
-//			Iinfos, _ := json.Marshal(res.Output.Iinfo)
301
-//			Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
302
-//			infoStr := string(Iinfos)
303
-//			idetinfoStr := string(Idetinfos)
304
-//
305
-//			if res.Infcode == 0 {
306
-//				his := models.VMHisPatient{
307
-//					Status:      1,
308
-//					Ctime:       time.Now().Unix(),
309
-//					Mtime:       time.Now().Unix(),
310
-//					PsnNo:       res.Output.Baseinfo.PsnNo,
311
-//					PsnCertType: res.Output.Baseinfo.PsnCertType,
312
-//					Certno:      res.Output.Baseinfo.Certno,
313
-//					PsnName:     res.Output.Baseinfo.PsnName,
314
-//					Gend:        res.Output.Baseinfo.Gend,
315
-//					Naty:        res.Output.Baseinfo.Naty,
316
-//					Brdy:        res.Output.Baseinfo.Brdy,
317
-//					Age:         res.Output.Baseinfo.Age,
318
-//					Iinfo:       infoStr,
319
-//					Idetinfo:    idetinfoStr,
320
-//					UserOrgId:   adminUser.CurrentOrgId,
321
-//					IsReturn:    1,
322
-//					IdCardType:  id_card_type,
323
-//				}
324
-//
325
-//				patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
326
-//				if err == gorm.ErrRecordNotFound {
327
-//					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
328
-//					return
329
-//
330
-//				} else if err != nil {
331
-//					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
332
-//					return
333
-//
334
-//				} else {
335
-//					c.ServeSuccessJSON(map[string]interface{}{
336
-//						"patient": patient,
337
-//						"his":     his,
338
-//						"number":  basNumber,
339
-//					})
340
-//				}
341
-//			} else {
342
-//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
343
-//				return
344
-//			}
345
-//
346
-//		}
347
-//
348
-//		break
349
-//	case 2:
350
-//		////SFZStr, err := GetSFZBaseInfo()
351
-//		//if err != nil {
352
-//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
353
-//		//	return
354
-//		//
355
-//		//} else {
356
-//		//
357
-//		//	id_card_str := strings.Split(SFZStr, "^")
358
-//		//	id_card_number := id_card_str[0]
359
-//		//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
360
-//		//
361
-//		//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
362
-//		//resp, requestErr := http.Get(api)
363
-//		//if requestErr != nil {
364
-//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
365
-//		//	return
366
-//		//}
367
-//		//defer resp.Body.Close()
368
-//		//body, ioErr := ioutil.ReadAll(resp.Body)
369
-//		//if ioErr != nil {
370
-//		//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
371
-//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
372
-//		//	return
373
-//		//}
374
-//		//var respJSON map[string]interface{}
375
-//		//
376
-//		//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
377
-//		//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
378
-//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
379
-//		//	return
380
-//		//}
381
-//		//
382
-//		//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
383
-//		//userJSONBytes, _ := json.Marshal(userJSON)
384
-//		//var res ResultTwo
385
-//		//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
386
-//		//	utils.ErrorLog("解析失败:%v", err)
387
-//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
388
-//		//	return
389
-//		//}
390
-//		//Iinfos, _ := json.Marshal(res.Output.Iinfo)
391
-//		//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
392
-//		//infoStr := string(Iinfos)
393
-//		//idetinfoStr := string(Idetinfos)
394
-//		//
395
-//		//if res.Infcode == 0 {
396
-//		//	his := models.VMHisPatient{
397
-//		//		Status:      1,
398
-//		//		Ctime:       time.Now().Unix(),
399
-//		//		Mtime:       time.Now().Unix(),
400
-//		//		PsnNo:       res.Output.Baseinfo.PsnNo,
401
-//		//		PsnCertType: res.Output.Baseinfo.PsnCertType,
402
-//		//		Certno:      res.Output.Baseinfo.Certno,
403
-//		//		PsnName:     res.Output.Baseinfo.PsnName,
404
-//		//		Gend:        res.Output.Baseinfo.Gend,
405
-//		//		Naty:        res.Output.Baseinfo.Naty,
406
-//		//		Brdy:        res.Output.Baseinfo.Brdy,
407
-//		//		Age:         res.Output.Baseinfo.Age,
408
-//		//		Iinfo:       infoStr,
409
-//		//		Idetinfo:    idetinfoStr,
410
-//		//		UserOrgId:   adminUser.CurrentOrgId,
411
-//		//		IsReturn:    1,
412
-//		//		IdCardType:  id_card_type,
413
-//		//	}
414
-//
415
-//		//	patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
416
-//		//	if err == gorm.ErrRecordNotFound {
417
-//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
418
-//		//		return
419
-//		//
420
-//		//	} else if err != nil {
421
-//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
422
-//		//		return
423
-//		//
424
-//		//	} else {
425
-//		//		c.ServeSuccessJSON(map[string]interface{}{
426
-//		//			"patient": patient,
427
-//		//			"number":  id_card_number,
428
-//		//		})
429
-//		//	}
430
-//		//}
431
-//		break
432
-//	case 3:
433
-//
434
-//		break
435
-//
436
-//	}
437
-//}
247
+func (c *HisApiController) Sscard() {
248
+	//id_card_type, _ := c.GetInt64("id_card_type")
249
+	//adminUser := c.GetAdminUserInfo()
250
+	//miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
251
+	id_card_type := 1
252
+	r := CardInit()
253
+	fmt.Println(r)
254
+	//if r == 0 {
255
+	switch id_card_type {
256
+	case 1:
257
+		defer GetBasBaseInfo()
258
+
259
+		//if err != nil {
260
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
261
+		//	return
262
+		//
263
+		//} else {
264
+		//	fmt.Println(basStr)
265
+		//
266
+		//	bas := strings.Split(basStr, "|")
267
+		//
268
+		//	basNumber := bas[1]
269
+		//
270
+		//	//basNumber := bas[2]
271
+		//	card_sn := bas[3]
272
+		//
273
+		//	appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
274
+		//
275
+		//	api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
276
+		//	resp, requestErr := http.Get(api)
277
+		//	if requestErr != nil {
278
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
279
+		//		return
280
+		//	}
281
+		//	defer resp.Body.Close()
282
+		//	body, ioErr := ioutil.ReadAll(resp.Body)
283
+		//	if ioErr != nil {
284
+		//		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
285
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
286
+		//		return
287
+		//	}
288
+		//	var respJSON map[string]interface{}
289
+		//
290
+		//	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
291
+		//		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
292
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
293
+		//		return
294
+		//	}
295
+		//
296
+		//	userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
297
+		//	userJSONBytes, _ := json.Marshal(userJSON)
298
+		//	var res ResultTwo
299
+		//	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
300
+		//		utils.ErrorLog("解析失败:%v", err)
301
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
302
+		//		return
303
+		//	}
304
+		//	Iinfos, _ := json.Marshal(res.Output.Iinfo)
305
+		//	Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
306
+		//	infoStr := string(Iinfos)
307
+		//	idetinfoStr := string(Idetinfos)
308
+		//
309
+		//	if res.Infcode == 0 {
310
+		//		his := models.VMHisPatient{
311
+		//			Status:      1,
312
+		//			Ctime:       time.Now().Unix(),
313
+		//			Mtime:       time.Now().Unix(),
314
+		//			PsnNo:       res.Output.Baseinfo.PsnNo,
315
+		//			PsnCertType: res.Output.Baseinfo.PsnCertType,
316
+		//			Certno:      res.Output.Baseinfo.Certno,
317
+		//			PsnName:     res.Output.Baseinfo.PsnName,
318
+		//			Gend:        res.Output.Baseinfo.Gend,
319
+		//			Naty:        res.Output.Baseinfo.Naty,
320
+		//			Brdy:        res.Output.Baseinfo.Brdy,
321
+		//			Age:         res.Output.Baseinfo.Age,
322
+		//			Iinfo:       infoStr,
323
+		//			Idetinfo:    idetinfoStr,
324
+		//			UserOrgId:   adminUser.CurrentOrgId,
325
+		//			IsReturn:    1,
326
+		//			IdCardType:  id_card_type,
327
+		//		}
328
+		//
329
+		//		patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
330
+		//		if err == gorm.ErrRecordNotFound {
331
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
332
+		//			return
333
+		//
334
+		//		} else if err != nil {
335
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
336
+		//			return
337
+		//
338
+		//		} else {
339
+		//			c.ServeSuccessJSON(map[string]interface{}{
340
+		//				"patient": patient,
341
+		//				"his":     his,
342
+		//				"number":  basNumber,
343
+		//			})
344
+		//		}
345
+		//	} else {
346
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
347
+		//		return
348
+		//	}
349
+		//
350
+		//}
438 351
 
439
-//func GetBasBaseInfo() (jsonStr string, err error) {
440
-//
441
-//	handle, err := syscall.LoadLibrary("SSCard.dll")
442
-//	if err != nil {
443
-//		fmt.Printf("Error: %s\n", err)
444
-//		return "", err
445
-//	}
446
-//	defer syscall.FreeLibrary(handle)
447
-//	str := make([]byte, 256)
448
-//	str1 := make([]byte, 256)
449
-//	add, err := syscall.GetProcAddress(handle, "ReadCardBas")
450
-//	if err != nil {
451
-//		fmt.Printf("Error: %s\n", err)
452
-//		return "", err
453
-//	}
454
-//	ret, _, _ := syscall.Syscall(add, (uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
455
-//	if err != nil {
456
-//		fmt.Printf("Error: %s\n", err)
457
-//	}
458
-//	fmt.Println("> Add(4,5)的结果为:", ret)
459
-//	//return nil
460
-//
461
-//	//
462
-//	//handle := syscall.NewLazyDLL("SSCard.dll")
463
-//	//ReadCardBas := handle.NewProc("ReadCardBas")
464
-//	//
465
-//	//var str2 [1024]C.char
466
-//	//var str3 [1024]C.char
467
-//	//
468
-//	//
469
-//	//
470
-//	////sssssswwwww
471
-//	////a := 256
472
-//	//
473
-//	//r, _, _ := ReadCardBas.Call(&str2, 1024, &str3, 1024)
474
-//	//fmt.Println(r)
475
-//	////p := (*byte)(unsafe.Pointer(r))
476
-//	// define a slice to fill with the p string
477
-//	//data := make([]byte, 0)
478
-//
479
-//	// loop until find '\0'
480
-//	//if *p != 0 {
481
-//	//
482
-//	//	//data = append(data, *p)        // append 1 byte
483
-//	//	//r += unsafe.Sizeof(byte(0))    // move r to next byte
484
-//	//	//p = (*byte)(unsafe.Pointer(r)) // get the byte value
485
-//	//} else {
486
-//	//	return "", nil
487
-//	//
488
-//	//}
489
-//
490
-//	return "", nil
491
-//
492
-//}
352
+		break
353
+	case 2:
354
+		////SFZStr, err := GetSFZBaseInfo()
355
+		//if err != nil {
356
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
357
+		//	return
358
+		//
359
+		//} else {
360
+		//
361
+		//	id_card_str := strings.Split(SFZStr, "^")
362
+		//	id_card_number := id_card_str[0]
363
+		//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
364
+		//
365
+		//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
366
+		//resp, requestErr := http.Get(api)
367
+		//if requestErr != nil {
368
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
369
+		//	return
370
+		//}
371
+		//defer resp.Body.Close()
372
+		//body, ioErr := ioutil.ReadAll(resp.Body)
373
+		//if ioErr != nil {
374
+		//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
375
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
376
+		//	return
377
+		//}
378
+		//var respJSON map[string]interface{}
379
+		//
380
+		//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
381
+		//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
382
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
383
+		//	return
384
+		//}
385
+		//
386
+		//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
387
+		//userJSONBytes, _ := json.Marshal(userJSON)
388
+		//var res ResultTwo
389
+		//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
390
+		//	utils.ErrorLog("解析失败:%v", err)
391
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
392
+		//	return
393
+		//}
394
+		//Iinfos, _ := json.Marshal(res.Output.Iinfo)
395
+		//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
396
+		//infoStr := string(Iinfos)
397
+		//idetinfoStr := string(Idetinfos)
398
+		//
399
+		//if res.Infcode == 0 {
400
+		//	his := models.VMHisPatient{
401
+		//		Status:      1,
402
+		//		Ctime:       time.Now().Unix(),
403
+		//		Mtime:       time.Now().Unix(),
404
+		//		PsnNo:       res.Output.Baseinfo.PsnNo,
405
+		//		PsnCertType: res.Output.Baseinfo.PsnCertType,
406
+		//		Certno:      res.Output.Baseinfo.Certno,
407
+		//		PsnName:     res.Output.Baseinfo.PsnName,
408
+		//		Gend:        res.Output.Baseinfo.Gend,
409
+		//		Naty:        res.Output.Baseinfo.Naty,
410
+		//		Brdy:        res.Output.Baseinfo.Brdy,
411
+		//		Age:         res.Output.Baseinfo.Age,
412
+		//		Iinfo:       infoStr,
413
+		//		Idetinfo:    idetinfoStr,
414
+		//		UserOrgId:   adminUser.CurrentOrgId,
415
+		//		IsReturn:    1,
416
+		//		IdCardType:  id_card_type,
417
+		//	}
418
+
419
+		//	patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
420
+		//	if err == gorm.ErrRecordNotFound {
421
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
422
+		//		return
423
+		//
424
+		//	} else if err != nil {
425
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
426
+		//		return
427
+		//
428
+		//	} else {
429
+		//		c.ServeSuccessJSON(map[string]interface{}{
430
+		//			"patient": patient,
431
+		//			"number":  id_card_number,
432
+		//		})
433
+		//	}
434
+		//}
435
+		break
436
+	case 3:
437
+
438
+		break
439
+
440
+	}
441
+}
442
+
443
+func GetBasBaseInfo() (jsonStr string, err error) {
444
+
445
+	handle := syscall.NewLazyDLL("SSCard.dll")
446
+	add := handle.NewProc("ReadCardBas")
447
+	str := make([]byte, 1024)
448
+	str1 := make([]byte, 1024)
449
+	ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
450
+	fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
451
+
452
+	fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
453
+
454
+	fmt.Println("> Add(4,5)的结果为:", ret)
455
+	handle.Release()
456
+
457
+	return "", nil
458
+
459
+}
493 460
 
494 461
 //func GetSFZBaseInfo() (jsonStr string, err error) {
495 462
 //	//handle := syscall.MustLoadDLL("SSCard.dll")
@@ -515,16 +482,16 @@ func (c *HisApiController) GetHisPatientInfo() {
515 482
 //	return string(str), nil
516 483
 //}
517 484
 
518
-//func CardInit() int {
519
-//	DllTestDef := syscall.MustLoadDLL("SSCard.dll")
520
-//	add := DllTestDef.MustFindProc("Init")
521
-//	ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
522
-//	if err != nil {
523
-//		fmt.Println("SSCard的运算结果为:", ret)
524
-//	}
525
-//	result := int(ret)
526
-//	return result
527
-//}
485
+func CardInit() int {
486
+	DllTestDef := syscall.MustLoadDLL("SSCard.dll")
487
+	add := DllTestDef.MustFindProc("Init")
488
+	ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
489
+	if err != nil {
490
+		fmt.Println("SSCard的运算结果为:", ret)
491
+	}
492
+	result := int(ret)
493
+	return result
494
+}
528 495
 
529 496
 //func CardInit() int {
530 497
 //	ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
@@ -561,7 +528,7 @@ type ResultTwo struct {
561 528
 		} `json:"baseinfo"`
562 529
 		Idetinfo []interface{} `json:"idetinfo"`
563 530
 		Iinfo    []struct {
564
-			Balc                   int64       `json:"balc"`
531
+			Balc                   float64     `json:"balc"`
565 532
 			CvlservFlag            string      `json:"cvlserv_flag"`
566 533
 			EmpName                string      `json:"emp_name"`
567 534
 			InsuplcAdmdvs          string      `json:"insuplc_admdvs"`
@@ -3639,14 +3606,63 @@ func (c *HisApiController) GetUploadDiag() {
3639 3606
 
3640 3607
 }
3641 3608
 
3609
+type QueryResult struct {
3610
+	ID             int64
3611
+	Name           string
3612
+	Code           string
3613
+	List_type_code string
3614
+}
3615
+
3642 3616
 func (c *HisApiController) GetCheckCode() {
3643
-	name := c.GetString("name")
3644
-	codg := c.GetString("codg")
3645
-	list_type_code := c.GetString("list_type_code")
3646
-	admin_user_id, _ := c.GetInt64("admin_user_id")
3617
+	ids_str := c.GetString("ids")
3618
+	record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材  3.项目
3619
+
3620
+	ids_arr := strings.Split(ids_str, ",")
3621
+	var queryResult []QueryResult
3622
+	ids := make([]int64, 0)
3623
+	for _, item := range ids_arr {
3624
+		id, _ := strconv.ParseInt(item, 10, 64)
3625
+		ids = append(ids, id)
3626
+	}
3627
+	if record_type == 1 {
3628
+		drugs, _ := service.GetBatchDrugList(ids)
3629
+		for _, item := range drugs {
3630
+			result := QueryResult{
3631
+				ID:             item.ID,
3632
+				Name:           item.DrugName,
3633
+				Code:           item.MedicalInsuranceNumber,
3634
+				List_type_code: item.MedicalInsuranceNumber,
3635
+			}
3636
+			queryResult = append(queryResult, result)
3637
+		}
3647 3638
 
3648
-	adminUser := c.GetAdminUserInfo()
3639
+	} else if record_type == 2 {
3640
+		goods, _ := service.GetBatchGoodInformationList(ids)
3641
+
3642
+		for _, item := range goods {
3643
+			result := QueryResult{
3644
+				ID:             item.ID,
3645
+				Name:           item.GoodName,
3646
+				Code:           item.MedicalInsuranceNumber,
3647
+				List_type_code: item.MedicalInsuranceNumber,
3648
+			}
3649
+			queryResult = append(queryResult, result)
3650
+		}
3651
+	} else if record_type == 3 {
3652
+		projects, _ := service.GetBathchMyPorjecgList(ids)
3653
+		for _, item := range projects {
3654
+			result := QueryResult{
3655
+				ID:             item.ID,
3656
+				Name:           item.ProjectName,
3657
+				Code:           item.MedicalCode,
3658
+				List_type_code: item.MedicalCode,
3659
+			}
3660
+			queryResult = append(queryResult, result)
3661
+		}
3662
+	}
3649 3663
 
3664
+	admin_user_id, _ := c.GetInt64("admin_user_id")
3665
+	adminUser := c.GetAdminUserInfo()
3650 3666
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
3651 3667
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
3652 3668
 
@@ -3668,22 +3684,91 @@ func (c *HisApiController) GetCheckCode() {
3668 3684
 	}
3669 3685
 
3670 3686
 	if config.IsOpen == 1 {
3671
-		result := service.Gdyb3301(baseParams, name, codg, list_type_code, "", "")
3672
-		var dat map[string]interface{}
3673
-		if err := json.Unmarshal([]byte(result), &dat); err == nil {
3674
-			fmt.Println(dat)
3675
-		} else {
3676
-			fmt.Println(err)
3677
-		}
3687
+		for _, item := range queryResult {
3688
+			result := service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "")
3689
+			var dat map[string]interface{}
3690
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
3691
+				fmt.Println(dat)
3692
+			} else {
3693
+				fmt.Println(err)
3694
+			}
3678 3695
 
3679
-	}
3696
+			userJSONBytes, _ := json.Marshal(dat)
3697
+			var res ResultSix
3698
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3699
+				utils.ErrorLog("解析失败:%v", err)
3700
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3701
+				return
3702
+			}
3703
+			if res.Infcode == 0 {
3704
+				if record_type == 1 {
3705
+					service.UpdateBaseDrugById(item.ID)
3706
+				} else if record_type == 2 {
3707
+					service.UpdateGoodInformaitonByDetail(item.ID)
3708
+				} else if record_type == 3 {
3709
+					service.UpdateProjectById(item.ID)
3710
+				}
3711
+				c.ServeSuccessJSON(map[string]interface{}{
3712
+					"failed_code": 0,
3713
+					"msg":         "目录对照成功",
3714
+				})
3715
+			} else {
3716
+				c.ServeSuccessJSON(map[string]interface{}{
3717
+					"failed_code": -10,
3718
+					"msg":         res.ErrMsg,
3719
+				})
3680 3720
 
3721
+			}
3722
+		}
3723
+	}
3681 3724
 }
3682 3725
 func (c *HisApiController) UnCheckCode() {
3683
-	name := c.GetString("name")
3684
-	codg := c.GetString("codg")
3685
-	list_type_code := c.GetString("list_type_code")
3726
+	ids_str := c.GetString("ids")
3727
+	record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材  3.项目
3686 3728
 	admin_user_id, _ := c.GetInt64("admin_user_id")
3729
+	ids_arr := strings.Split(ids_str, ",")
3730
+	var queryResult []QueryResult
3731
+	ids := make([]int64, 0)
3732
+	for _, item := range ids_arr {
3733
+		id, _ := strconv.ParseInt(item, 10, 64)
3734
+		ids = append(ids, id)
3735
+	}
3736
+	if record_type == 1 {
3737
+		drugs, _ := service.GetBatchDrugList(ids)
3738
+		for _, item := range drugs {
3739
+			result := QueryResult{
3740
+				ID:             item.ID,
3741
+				Name:           item.DrugName,
3742
+				Code:           item.MedicalInsuranceNumber,
3743
+				List_type_code: item.MedicalInsuranceNumber,
3744
+			}
3745
+			queryResult = append(queryResult, result)
3746
+		}
3747
+
3748
+	} else if record_type == 2 {
3749
+		goods, _ := service.GetBatchGoodInformationList(ids)
3750
+
3751
+		for _, item := range goods {
3752
+			result := QueryResult{
3753
+				ID:             item.ID,
3754
+				Name:           item.GoodName,
3755
+				Code:           item.MedicalInsuranceNumber,
3756
+				List_type_code: item.MedicalInsuranceNumber,
3757
+			}
3758
+			queryResult = append(queryResult, result)
3759
+		}
3760
+	} else if record_type == 3 {
3761
+		projects, _ := service.GetBathchMyPorjecgList(ids)
3762
+		for _, item := range projects {
3763
+			result := QueryResult{
3764
+				ID:             item.ID,
3765
+				Name:           item.ProjectName,
3766
+				Code:           item.MedicalCode,
3767
+				List_type_code: item.MedicalCode,
3768
+			}
3769
+			queryResult = append(queryResult, result)
3770
+		}
3771
+	}
3687 3772
 
3688 3773
 	adminUser := c.GetAdminUserInfo()
3689 3774
 
@@ -3708,7 +3793,62 @@ func (c *HisApiController) UnCheckCode() {
3708 3793
 	}
3709 3794
 
3710 3795
 	if config.IsOpen == 1 {
3711
-		result := service.Gdyb3302(baseParams, name, codg, list_type_code)
3796
+		for _, item := range queryResult {
3797
+
3798
+			result := service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
3799
+			var dat2 map[string]interface{}
3800
+			if err := json.Unmarshal([]byte(result), &dat2); err == nil {
3801
+				fmt.Println(dat2)
3802
+			} else {
3803
+				fmt.Println(err)
3804
+			}
3805
+
3806
+			userJSONBytes, _ := json.Marshal(dat2)
3807
+			var res ResultSix
3808
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3809
+				utils.ErrorLog("解析失败:%v", err)
3810
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3811
+				return
3812
+			}
3813
+			if res.Infcode == 0 {
3814
+				if record_type == 1 {
3815
+					service.UpdateDrugByIdDetail(item.ID)
3816
+				} else if record_type == 2 {
3817
+					service.UpdateGoodInfoById(item.ID)
3818
+
3819
+				} else if record_type == 3 {
3820
+					service.UpdateMyProjectById(item.ID)
3821
+				}
3822
+				c.ServeSuccessJSON(map[string]interface{}{
3823
+					"failed_code": 0,
3824
+					"msg":         "撤销目录对照成功",
3825
+				})
3826
+			} else {
3827
+				c.ServeSuccessJSON(map[string]interface{}{
3828
+					"failed_code": -10,
3829
+					"msg":         res.ErrMsg,
3830
+				})
3831
+			}
3832
+		}
3833
+	}
3834
+}
3835
+func (c *HisApiController) GetPatientInfo() {
3836
+	id_card_no := c.GetString("id_card_no")
3837
+	admin_user_id, _ := c.GetInt64("admin_user_id")
3838
+
3839
+	patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
3840
+
3841
+	if patient.ID == 0 {
3842
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
3843
+		return
3844
+	}
3845
+
3846
+	role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
3847
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
3848
+	config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
3849
+	if config.IsOpen == 1 {
3850
+
3851
+		result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
3712 3852
 		var dat map[string]interface{}
3713 3853
 		if err := json.Unmarshal([]byte(result), &dat); err == nil {
3714 3854
 			fmt.Println(dat)
@@ -3716,8 +3856,27 @@ func (c *HisApiController) UnCheckCode() {
3716 3856
 			fmt.Println(err)
3717 3857
 		}
3718 3858
 
3719
-	}
3859
+		userJSONBytes, _ := json.Marshal(dat)
3860
+		var res ResultTwo
3861
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3862
+			utils.ErrorLog("解析失败:%v", err)
3863
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3864
+			return
3865
+		}
3720 3866
 
3867
+		if res.Infcode == -1 {
3868
+			c.ServeSuccessJSON(map[string]interface{}{
3869
+				"failed_code": -10,
3870
+				"msg":         res.ErrMsg,
3871
+			})
3872
+		} else {
3873
+			c.ServeSuccessJSON(map[string]interface{}{
3874
+				"failed_code": 0,
3875
+				"info":        res,
3876
+			})
3877
+		}
3878
+
3879
+	}
3721 3880
 }
3722 3881
 func (c *HisApiController) PsnPutOnRecord() {
3723 3882
 	record_type, _ := c.GetInt64("type")
@@ -3878,106 +4037,63 @@ func (c *HisApiController) PsnUnPutOnRecord() {
3878 4037
 
3879 4038
 }
3880 4039
 func (c *HisApiController) PsnPutNCDSOnRecord() {
3881
-	record_type, _ := c.GetInt64("type")
3882 4040
 	patient_id, _ := c.GetInt64("patient_id")
3883
-	admin_user_id, _ := c.GetInt64("admin_user_id")
4041
+	insutype := c.GetString("insutype")
4042
+	psn_no := c.GetString("psn_no")
4043
+	doctor_id, _ := c.GetInt64("doctor_id")
4044
+	sick_id, _ := c.GetInt64("sick_id")
4045
+	department_id, _ := c.GetInt64("department_id")
3884 4046
 	adminUser := c.GetAdminUserInfo()
3885
-	var patients []*models.Patients
3886
-	if record_type == 1 { //全部备案
3887
-		patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
3888
-		patients = append(patients, patient...)
3889
-	} else { //单个备案
3890
-		patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
3891
-		patients = append(patients, patient)
3892
-	}
4047
+	patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
3893 4048
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
3894 4049
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
3895
-	var user_name string
3896
-	role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
3897
-	if role.ID == 0 {
3898
-		user_name = "xxx"
3899
-	} else {
3900
-		user_name = role.UserName
3901
-	}
3902
-
4050
+	sick, _ := service.FindSickById(sick_id)
4051
+	//role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
4052
+	doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
3903 4053
 	if config.IsOpen == 1 {
3904
-		for _, item := range patients {
3905
-			api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
3906
-			resp, requestErr := http.Get(api)
3907
-			if requestErr != nil {
3908
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3909
-				return
3910
-			}
3911
-			defer resp.Body.Close()
3912
-			body, ioErr := ioutil.ReadAll(resp.Body)
3913
-			if ioErr != nil {
3914
-				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
3915
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3916
-				return
3917
-			}
3918
-			var respJSON map[string]interface{}
3919
-
3920
-			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
3921
-				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
3922
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3923
-				return
3924
-			}
3925
-
3926
-			userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
3927
-			userJSONBytes, _ := json.Marshal(userJSON)
3928
-			var res ResultTwo
3929
-			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
3930
-				utils.ErrorLog("解析失败:%v", err)
3931
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3932
-				return
3933
-			}
3934
-
3935
-			if res.Infcode == 0 {
3936
-				result := service.Gdyb2503(res.Output.Baseinfo.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, user_name, miConfig.Code, strconv.FormatInt(admin_user_id, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "慢性肾功能不全(血透治疗)", "M07803")
3937
-				var dat map[string]interface{}
3938
-				if err := json.Unmarshal([]byte(result), &dat); err == nil {
3939
-					fmt.Println(dat)
3940
-				} else {
3941
-					fmt.Println(err)
3942
-				}
3943
-
3944
-				userJSONBytes, _ := json.Marshal(dat)
3945
-
3946
-				var res2 ResultThirteen
3947
-				if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
3948
-					utils.ErrorLog("解析失败:%v", err)
3949
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3950
-					return
3951
-				}
3952
-
3953
-				//patient, _ := service.GetPatientByIDCard(item.IdCardNo, adminUser.CurrentOrgId)
3954
-
3955
-				if res2.Infcode == 0 {
3956
-					psnResult := &models.GdybPsnNcdsRecord{
3957
-						UserOrgId:     adminUser.CurrentOrgId,
3958
-						PatientId:     item.ID,
3959
-						PsnNo:         res.Output.Baseinfo.PsnNo,
3960
-						Ctime:         time.Now().Unix(),
3961
-						Mtime:         time.Now().Unix(),
3962
-						Status:        1,
3963
-						IsCancel:      1,
3964
-						TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
3965
-					}
3966
-					service.CreatePsnNCDSRecord(psnResult)
3967
-
3968
-				} else {
3969
-					c.ServeSuccessJSON(map[string]interface{}{
3970
-						"failed_code": -10,
3971
-						"msg":         res2.ErrMsg,
3972
-					})
3973
-					return
3974
-				}
4054
+		result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.CountryCode)
4055
+		var dat map[string]interface{}
4056
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
4057
+			fmt.Println(dat)
4058
+		} else {
4059
+			fmt.Println(err)
4060
+		}
4061
+		userJSONBytes, _ := json.Marshal(dat)
4062
+		var res2 ResultThirteen
4063
+		if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
4064
+			utils.ErrorLog("解析失败:%v", err)
4065
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4066
+			return
4067
+		}
4068
+		if res2.Infcode == 0 {
4069
+			psnResult := &models.GdybPsnNcdsRecord{
4070
+				UserOrgId:     adminUser.CurrentOrgId,
4071
+				PatientId:     patient.ID,
4072
+				PsnNo:         psn_no,
4073
+				DoctorId:      doctor.ID,
4074
+				DepartmentId:  department_id,
4075
+				SickType:      sick_id,
4076
+				Insutype:      insutype,
4077
+				Ctime:         time.Now().Unix(),
4078
+				Mtime:         time.Now().Unix(),
4079
+				Status:        1,
4080
+				IsCancel:      1,
4081
+				TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
3975 4082
 			}
4083
+			service.CreatePsnNCDSRecord(psnResult)
4084
+			c.ServeSuccessJSON(map[string]interface{}{
4085
+				"failed_code": 0,
4086
+				"msg":         "备案成功",
4087
+			})
3976 4088
 
4089
+		} else {
4090
+			c.ServeSuccessJSON(map[string]interface{}{
4091
+				"failed_code": -10,
4092
+				"msg":         res2.ErrMsg,
4093
+			})
4094
+			return
3977 4095
 		}
3978
-
3979 4096
 	}
3980
-
3981 4097
 }
3982 4098
 func (c *HisApiController) PsnPutUnNCDSOnRecord() {
3983 4099
 	id, _ := c.GetInt64("id")
@@ -4142,3 +4258,19 @@ func RemoveRepeatedCode(arr []string) (newArr []string) {
4142 4258
 	}
4143 4259
 	return
4144 4260
 }
4261
+
4262
+type Charset string
4263
+
4264
+const (
4265
+	UTF8    = Charset("UTF-8")
4266
+	GB18030 = Charset("GB18030")
4267
+)
4268
+
4269
+func ConvertToString(src string, srcCode string, tagCode string) string {
4270
+	srcCoder := mahonia.NewDecoder(srcCode)
4271
+	srcResult := srcCoder.ConvertString(src)
4272
+	tagCoder := mahonia.NewDecoder(tagCode)
4273
+	_, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
4274
+	result := string(cdata)
4275
+	return result
4276
+}

+ 395 - 400
controllers/sz/sz_his_api_controller.go View File

@@ -328,21 +328,14 @@ type SZHisApiController struct {
328 328
 func SZHisManagerApiRegistRouters() {
329 329
 	//挂号
330 330
 	beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
331
-	//上传明细,预结算
332
-	//beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
333
-
334 331
 	//结算
335 332
 	beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
336
-
337 333
 	//退费
338 334
 	beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
339
-
340 335
 	beego.Router("/sz/api/readcard", &SZHisApiController{}, "get:ReadCard")
341
-
342 336
 	beego.Router("sz/api/refundnumber/get", &SZHisApiController{}, "get:RefundNumber")
343 337
 
344 338
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
345
-
346 339
 	//查询交易
347 340
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
348 341
 	//beego.Router("/sz/api/detail/upload", &SZHisApiController{}, "get:GetUploadDetail")
@@ -1233,399 +1226,399 @@ func (c *SZHisApiController) GetRegisterInfo() {
1233 1226
 }
1234 1227
 
1235 1228
 //func (c *SZHisApiController) GetInfo() {
1236
-func (c *SZHisApiController) GetRegisterInfo() {
1237
-	adminInfo := c.GetAdminUserInfo()
1238
-	admin_user_id, _ := c.GetInt64("admin_user_id")
1239
-	patient_id, _ := c.GetInt64("id")
1240
-	record_time := c.GetString("record_time")
1241
-	settlementValue, _ := c.GetInt64("settlement_value")
1242
-	medical_insurance_card := c.GetString("medical_insurance_card")
1243
-	name := c.GetString("name")
1244
-	id_card_type, _ := c.GetInt64("id_card_type")
1245
-	certificates, _ := c.GetInt64("certificates")
1246
-	medical_care, _ := c.GetInt64("medical_care")
1247
-	birthday := c.GetString("birthday")
1248
-	id_card := c.GetString("id_card")
1249
-	register_type, _ := c.GetInt64("register")
1250
-	doctor, _ := c.GetInt64("doctor")
1251
-	department, _ := c.GetInt64("department")
1252
-	gender, _ := c.GetInt64("sex")
1253
-	registration_fee, _ := c.GetFloat("registration_fee")
1254
-	medical_expenses, _ := c.GetFloat("medical_expenses")
1255
-	social_type, _ := c.GetInt64("social_type")
1256
-
1257
-	is_yidi, _ := c.GetInt64("is_yidi")
1258
-
1259
-	timeLayout := "2006-01-02"
1260
-	loc, _ := time.LoadLocation("Local")
1261
-	birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
1262
-	birthUnix := birthdays.Unix()
1263
-
1264
-	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1265
-	if err != nil {
1266
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1267
-		return
1268
-	}
1269
-
1270
-	var patient service.Patients
1271
-	if patient_id == 0 {
1272
-		patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
1273
-	} else {
1274
-		patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
1275
-	}
1276
-
1277
-	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
1278
-	if patient.ID == 0 {
1279
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1280
-		return
1281
-	}
1282
-	if len(patient.IdCardNo) == 0 {
1283
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
1284
-		return
1285
-	}
1286
-
1287
-	adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
1288
-	his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
1289
-
1290
-	var custom_code string
1291
-	var custom_project_name string
1292
-	var allPrice float64
1293
-
1294
-	switch register_type {
1295
-	case 1:
1296
-		custom_code = "110100002"
1297
-		custom_project_name = "普通门诊"
1298
-		allPrice = 10
1299
-		break
1300
-	case 3:
1301
-		custom_code = "110200002-2"
1302
-		custom_project_name = "主任医师"
1303
-		allPrice = 10
1304
-
1305
-		break
1306
-	case 2:
1307
-		custom_code = "110200002-3"
1308
-		custom_project_name = "副主任医师"
1309
-		allPrice = 10
1310
-
1311
-		break
1312
-	case 4:
1313
-		custom_code = "0"
1314
-		custom_project_name = "免受诊金"
1315
-		allPrice = 0
1316
-		break
1317
-	case 5:
1318
-		custom_code = "110200002-1"
1319
-		custom_project_name = "专家"
1320
-		allPrice = 10
1321
-
1322
-		break
1323
-	}
1324
-
1325
-	if his.ID == 0 {
1326
-
1327
-		var doctor_name string
1328
-		var doctor_code string
1329
-		if adminRole.ID == 0 {
1330
-
1331
-			doctor_name = ""
1332
-			doctor_code = "1001"
1333
-			doctor_name = ""
1334
-			doctor_code = ""
1335
-
1336
-		} else {
1337
-			doctor_name = adminRole.UserName
1338
-			doctor_code = strconv.FormatInt(admin_user_id, 10)
1339
-
1340
-		}
1341
-		month := time.Unix(1557042972, 0).Format("1")
1342
-		year := time.Now().Format("2006")
1343
-		month = time.Now().Format("01")
1344
-		day := time.Now().Format("02")
1345
-
1346
-		//流水号
1347
-		//
1348
-		number := miConfig.Code + year + month + day +
1349
-			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
1350
-		mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
1351
-			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
1352
-		//1.判断读卡类型
1353
-		//2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
1354
-		yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
1355
-		fmt.Println(yiliao_number)
1356
-		fmt.Println(id_card_number)
1357
-		fmt.Println(verifyCode)
1358
-		fmt.Println(version_code)
1359
-		fmt.Println(ret4)
1360
-
1361
-		dept_code := "0305"
1362
-		is_yidi = 1
1363
-		tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
1364
-		//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
1365
-		if tempPatient.ID == patient_id {
1366
-			if ret4 == 0 { //本地卡流程
1367
-				if is_yidi == 1 {
1368
-					//本地就医流程
1369
-					//挂号
1370
-					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
1371
-					var dat map[string]interface{}
1372
-					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1373
-						fmt.Println(dat)
1374
-					} else {
1375
-						fmt.Println(err)
1376
-					}
1377
-					userJSONBytes, _ := json.Marshal(dat)
1378
-					var res ResultOne
1379
-					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1380
-						utils.ErrorLog("解析失败:%v", err)
1381
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1382
-						return
1383
-					}
1384
-					if res.Transreturncode == "00000000" {
1385
-						his := models.VMHisPatient{
1386
-							Name:                   name,
1387
-							Gender:                 gender,
1388
-							Birthday:               birthUnix,
1389
-							MedicalTreatmentType:   medical_care,
1390
-							IdType:                 certificates,
1391
-							IdCardNo:               id_card,
1392
-							BalanceAccountsType:    settlementValue,
1393
-							SocialType:             social_type,
1394
-							MedicalInsuranceNumber: medical_insurance_card,
1395
-							RegisterType:           register_type,
1396
-							RegisterCost:           registration_fee,
1397
-							TreatmentCost:          medical_expenses,
1398
-							Status:                 1,
1399
-							Ctime:                  time.Now().Unix(),
1400
-							Mtime:                  time.Now().Unix(),
1401
-							Iinfo:                  resp_result,
1402
-							PatientId:              patient.ID,
1403
-							RecordDate:             theTime.Unix(),
1404
-							UserOrgId:              adminInfo.CurrentOrgId,
1405
-							AdminUserId:            admin_user_id,
1406
-							IsReturn:               1,
1407
-							IdCardType:             id_card_type,
1408
-							Doctor:                 doctor,
1409
-							Departments:            department,
1410
-							YiliaoNumber:           yiliao_number,
1411
-							MzNumber:               number,
1412
-							Number:                 mz_number,
1413
-						}
1414
-						service.CreateHisPatientTwo(&his)
1415
-						c.ServeSuccessJSON(map[string]interface{}{
1416
-							"msg": "挂号成功",
1417
-						})
1418
-					} else {
1419
-						c.ServeSuccessJSON(map[string]interface{}{
1420
-							"failed_code": -10,
1421
-							"msg":         res.Transreturnmessage,
1422
-						})
1423
-						return
1424
-					}
1425
-
1426
-				} else {
1427
-					//异地就医流程
1428
-					//异地走鉴权流程
1429
-					//authResult := CardAuth(number)
1430
-					//fmt.Println(authResult)
1431
-
1432
-					//tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
1433
-					//if tempPatient.ID == patient_id {
1434
-					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
1435
-					var dat map[string]interface{}
1436
-					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1437
-						fmt.Println(dat)
1438
-					} else {
1439
-						fmt.Println(err)
1440
-					}
1441
-
1442
-					userJSONBytes, _ := json.Marshal(dat)
1443
-
1444
-					var res ResultOne
1445
-					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1446
-						utils.ErrorLog("解析失败:%v", err)
1447
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1448
-						return
1449
-					}
1450
-					if res.Transreturncode == "00000000" {
1451
-						his := models.VMHisPatient{
1452
-							Name:                   name,
1453
-							Gender:                 gender,
1454
-							Birthday:               birthUnix,
1455
-							MedicalTreatmentType:   medical_care,
1456
-							IdType:                 certificates,
1457
-							IdCardNo:               id_card,
1458
-							BalanceAccountsType:    settlementValue,
1459
-							SocialType:             social_type,
1460
-							MedicalInsuranceNumber: medical_insurance_card,
1461
-							RegisterType:           register_type,
1462
-							RegisterCost:           registration_fee,
1463
-							TreatmentCost:          medical_expenses,
1464
-							Status:                 1,
1465
-							Ctime:                  time.Now().Unix(),
1466
-							Mtime:                  time.Now().Unix(),
1467
-							Iinfo:                  resp_result,
1468
-							PatientId:              patient.ID,
1469
-							RecordDate:             theTime.Unix(),
1470
-							UserOrgId:              adminInfo.CurrentOrgId,
1471
-							AdminUserId:            admin_user_id,
1472
-							IsReturn:               1,
1473
-							IdCardType:             id_card_type,
1474
-							Doctor:                 doctor,
1475
-							Departments:            department,
1476
-							YiliaoNumber:           yiliao_number,
1477
-							MzNumber:               number,
1478
-							Number:                 mz_number,
1479
-						}
1480
-						service.CreateHisPatientTwo(&his)
1481
-						c.ServeSuccessJSON(map[string]interface{}{
1482
-							"msg": "挂号成功",
1483
-						})
1484
-					} else {
1485
-						c.ServeSuccessJSON(map[string]interface{}{
1486
-							"failed_code": -10,
1487
-							"msg":         res.Transreturnmessage,
1488
-						})
1489
-						return
1490
-					}
1491
-
1492
-				}
1493
-
1494
-			} else { //异地卡流程
1495
-				//readCardBasResult := ReadCardBasHSM(number)
1496
-				//fmt.Println(readCardBasResult)
1497
-				//是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
1498
-				if is_yidi == 1 { //1本地就医
1499
-					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
1500
-					var dat map[string]interface{}
1501
-					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1502
-						fmt.Println(dat)
1503
-					} else {
1504
-						fmt.Println(err)
1505
-					}
1506
-
1507
-					userJSONBytes, _ := json.Marshal(dat)
1508
-
1509
-					var res ResultOne
1510
-					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1511
-						utils.ErrorLog("解析失败:%v", err)
1512
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1513
-						return
1514
-					}
1515
-					if res.Transreturncode == "00000000" {
1516
-						his := models.VMHisPatient{
1517
-							Name:                   name,
1518
-							Gender:                 gender,
1519
-							Birthday:               birthUnix,
1520
-							MedicalTreatmentType:   medical_care,
1521
-							IdType:                 certificates,
1522
-							IdCardNo:               id_card,
1523
-							BalanceAccountsType:    settlementValue,
1524
-							SocialType:             social_type,
1525
-							MedicalInsuranceNumber: medical_insurance_card,
1526
-							RegisterType:           register_type,
1527
-							RegisterCost:           registration_fee,
1528
-							TreatmentCost:          medical_expenses,
1529
-							Status:                 1,
1530
-							Ctime:                  time.Now().Unix(),
1531
-							Mtime:                  time.Now().Unix(),
1532
-							Iinfo:                  resp_result,
1533
-							PatientId:              patient.ID,
1534
-							RecordDate:             theTime.Unix(),
1535
-							UserOrgId:              adminInfo.CurrentOrgId,
1536
-							AdminUserId:            admin_user_id,
1537
-							IsReturn:               1,
1538
-							IdCardType:             id_card_type,
1539
-							Doctor:                 doctor,
1540
-							Departments:            department,
1541
-							YiliaoNumber:           yiliao_number,
1542
-							MzNumber:               number,
1543
-							Number:                 mz_number,
1544
-						}
1545
-						service.CreateHisPatientTwo(&his)
1546
-						c.ServeSuccessJSON(map[string]interface{}{
1547
-							"msg": "挂号成功",
1548
-						})
1549
-					} else {
1550
-						c.ServeSuccessJSON(map[string]interface{}{
1551
-							"failed_code": -10,
1552
-							"msg":         res.Transreturnmessage,
1553
-						})
1554
-						return
1555
-					}
1556
-
1557
-				} else { //异地就医需要走鉴权流程
1558
-					//authResult := CardAuth(number)
1559
-					//fmt.Println(authResult)
1560
-					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
1561
-					var dat map[string]interface{}
1562
-					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1563
-						fmt.Println(dat)
1564
-					} else {
1565
-						fmt.Println(err)
1566
-					}
1567
-
1568
-					userJSONBytes, _ := json.Marshal(dat)
1569
-
1570
-					var res ResultOne
1571
-					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1572
-						utils.ErrorLog("解析失败:%v", err)
1573
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1574
-						return
1575
-					}
1576
-					if res.Transreturncode == "00000000" {
1577
-						his := models.VMHisPatient{
1578
-							Name:                   name,
1579
-							Gender:                 gender,
1580
-							Birthday:               birthUnix,
1581
-							MedicalTreatmentType:   medical_care,
1582
-							IdType:                 certificates,
1583
-							IdCardNo:               id_card,
1584
-							BalanceAccountsType:    settlementValue,
1585
-							SocialType:             social_type,
1586
-							MedicalInsuranceNumber: medical_insurance_card,
1587
-							RegisterType:           register_type,
1588
-							RegisterCost:           registration_fee,
1589
-							TreatmentCost:          medical_expenses,
1590
-							Status:                 1,
1591
-							Ctime:                  time.Now().Unix(),
1592
-							Mtime:                  time.Now().Unix(),
1593
-							Iinfo:                  resp_result,
1594
-							PatientId:              patient.ID,
1595
-							RecordDate:             theTime.Unix(),
1596
-							UserOrgId:              adminInfo.CurrentOrgId,
1597
-							AdminUserId:            admin_user_id,
1598
-							IsReturn:               1,
1599
-							IdCardType:             id_card_type,
1600
-							Doctor:                 doctor,
1601
-							Departments:            department,
1602
-							YiliaoNumber:           yiliao_number,
1603
-							MzNumber:               number,
1604
-							Number:                 mz_number,
1605
-						}
1606
-						service.CreateHisPatientTwo(&his)
1607
-						c.ServeSuccessJSON(map[string]interface{}{
1608
-							"msg": "挂号成功",
1609
-						})
1610
-					} else {
1611
-						c.ServeSuccessJSON(map[string]interface{}{
1612
-							"failed_code": -10,
1613
-							"msg":         res.Transreturnmessage,
1614
-						})
1615
-						return
1616
-					}
1617
-
1618
-				}
1619
-			}
1620
-		} else {
1621
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
1622
-			return
1623
-		}
1624
-	} else {
1625
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1626
-		return
1627
-	}
1628
-}
1229
+//func (c *SZHisApiController) GetRegisterInfo() {
1230
+//	adminInfo := c.GetAdminUserInfo()
1231
+//	admin_user_id, _ := c.GetInt64("admin_user_id")
1232
+//	patient_id, _ := c.GetInt64("id")
1233
+//	record_time := c.GetString("record_time")
1234
+//	settlementValue, _ := c.GetInt64("settlement_value")
1235
+//	medical_insurance_card := c.GetString("medical_insurance_card")
1236
+//	name := c.GetString("name")
1237
+//	id_card_type, _ := c.GetInt64("id_card_type")
1238
+//	certificates, _ := c.GetInt64("certificates")
1239
+//	medical_care, _ := c.GetInt64("medical_care")
1240
+//	birthday := c.GetString("birthday")
1241
+//	id_card := c.GetString("id_card")
1242
+//	register_type, _ := c.GetInt64("register")
1243
+//	doctor, _ := c.GetInt64("doctor")
1244
+//	department, _ := c.GetInt64("department")
1245
+//	gender, _ := c.GetInt64("sex")
1246
+//	registration_fee, _ := c.GetFloat("registration_fee")
1247
+//	medical_expenses, _ := c.GetFloat("medical_expenses")
1248
+//	social_type, _ := c.GetInt64("social_type")
1249
+//
1250
+//	is_yidi, _ := c.GetInt64("is_yidi")
1251
+//
1252
+//	timeLayout := "2006-01-02"
1253
+//	loc, _ := time.LoadLocation("Local")
1254
+//	birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
1255
+//	birthUnix := birthdays.Unix()
1256
+//
1257
+//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1258
+//	if err != nil {
1259
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1260
+//		return
1261
+//	}
1262
+//
1263
+//	var patient service.Patients
1264
+//	if patient_id == 0 {
1265
+//		patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
1266
+//	} else {
1267
+//		patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
1268
+//	}
1269
+//
1270
+//	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
1271
+//	if patient.ID == 0 {
1272
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1273
+//		return
1274
+//	}
1275
+//	if len(patient.IdCardNo) == 0 {
1276
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
1277
+//		return
1278
+//	}
1279
+//
1280
+//	adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
1281
+//	his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
1282
+//
1283
+//	var custom_code string
1284
+//	var custom_project_name string
1285
+//	var allPrice float64
1286
+//
1287
+//	switch register_type {
1288
+//	case 1:
1289
+//		custom_code = "110100002"
1290
+//		custom_project_name = "普通门诊"
1291
+//		allPrice = 10
1292
+//		break
1293
+//	case 3:
1294
+//		custom_code = "110200002-2"
1295
+//		custom_project_name = "主任医师"
1296
+//		allPrice = 10
1297
+//
1298
+//		break
1299
+//	case 2:
1300
+//		custom_code = "110200002-3"
1301
+//		custom_project_name = "副主任医师"
1302
+//		allPrice = 10
1303
+//
1304
+//		break
1305
+//	case 4:
1306
+//		custom_code = "0"
1307
+//		custom_project_name = "免受诊金"
1308
+//		allPrice = 0
1309
+//		break
1310
+//	case 5:
1311
+//		custom_code = "110200002-1"
1312
+//		custom_project_name = "专家"
1313
+//		allPrice = 10
1314
+//
1315
+//		break
1316
+//	}
1317
+//
1318
+//	if his.ID == 0 {
1319
+//
1320
+//		var doctor_name string
1321
+//		var doctor_code string
1322
+//		if adminRole.ID == 0 {
1323
+//
1324
+//			doctor_name = ""
1325
+//			doctor_code = "1001"
1326
+//			doctor_name = ""
1327
+//			doctor_code = ""
1328
+//
1329
+//		} else {
1330
+//			doctor_name = adminRole.UserName
1331
+//			doctor_code = strconv.FormatInt(admin_user_id, 10)
1332
+//
1333
+//		}
1334
+//		month := time.Unix(1557042972, 0).Format("1")
1335
+//		year := time.Now().Format("2006")
1336
+//		month = time.Now().Format("01")
1337
+//		day := time.Now().Format("02")
1338
+//
1339
+//		//流水号
1340
+//		//
1341
+//		number := miConfig.Code + year + month + day +
1342
+//			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
1343
+//		mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
1344
+//			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
1345
+//		//1.判断读卡类型
1346
+//		//2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
1347
+//		yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
1348
+//		fmt.Println(yiliao_number)
1349
+//		fmt.Println(id_card_number)
1350
+//		fmt.Println(verifyCode)
1351
+//		fmt.Println(version_code)
1352
+//		fmt.Println(ret4)
1353
+//
1354
+//		dept_code := "0305"
1355
+//		is_yidi = 1
1356
+//		tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
1357
+//		//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
1358
+//		if tempPatient.ID == patient_id {
1359
+//			if ret4 == 0 { //本地卡流程
1360
+//				if is_yidi == 1 {
1361
+//					//本地就医流程
1362
+//					//挂号
1363
+//					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
1364
+//					var dat map[string]interface{}
1365
+//					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1366
+//						fmt.Println(dat)
1367
+//					} else {
1368
+//						fmt.Println(err)
1369
+//					}
1370
+//					userJSONBytes, _ := json.Marshal(dat)
1371
+//					var res ResultOne
1372
+//					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1373
+//						utils.ErrorLog("解析失败:%v", err)
1374
+//						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1375
+//						return
1376
+//					}
1377
+//					if res.Transreturncode == "00000000" {
1378
+//						his := models.VMHisPatient{
1379
+//							Name:                   name,
1380
+//							Gender:                 gender,
1381
+//							Birthday:               birthUnix,
1382
+//							MedicalTreatmentType:   medical_care,
1383
+//							IdType:                 certificates,
1384
+//							IdCardNo:               id_card,
1385
+//							BalanceAccountsType:    settlementValue,
1386
+//							SocialType:             social_type,
1387
+//							MedicalInsuranceNumber: medical_insurance_card,
1388
+//							RegisterType:           register_type,
1389
+//							RegisterCost:           registration_fee,
1390
+//							TreatmentCost:          medical_expenses,
1391
+//							Status:                 1,
1392
+//							Ctime:                  time.Now().Unix(),
1393
+//							Mtime:                  time.Now().Unix(),
1394
+//							Iinfo:                  resp_result,
1395
+//							PatientId:              patient.ID,
1396
+//							RecordDate:             theTime.Unix(),
1397
+//							UserOrgId:              adminInfo.CurrentOrgId,
1398
+//							AdminUserId:            admin_user_id,
1399
+//							IsReturn:               1,
1400
+//							IdCardType:             id_card_type,
1401
+//							Doctor:                 doctor,
1402
+//							Departments:            department,
1403
+//							YiliaoNumber:           yiliao_number,
1404
+//							MzNumber:               number,
1405
+//							Number:                 mz_number,
1406
+//						}
1407
+//						service.CreateHisPatientTwo(&his)
1408
+//						c.ServeSuccessJSON(map[string]interface{}{
1409
+//							"msg": "挂号成功",
1410
+//						})
1411
+//					} else {
1412
+//						c.ServeSuccessJSON(map[string]interface{}{
1413
+//							"failed_code": -10,
1414
+//							"msg":         res.Transreturnmessage,
1415
+//						})
1416
+//						return
1417
+//					}
1418
+//
1419
+//				} else {
1420
+//					//异地就医流程
1421
+//					//异地走鉴权流程
1422
+//					//authResult := CardAuth(number)
1423
+//					//fmt.Println(authResult)
1424
+//
1425
+//					//tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
1426
+//					//if tempPatient.ID == patient_id {
1427
+//					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
1428
+//					var dat map[string]interface{}
1429
+//					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1430
+//						fmt.Println(dat)
1431
+//					} else {
1432
+//						fmt.Println(err)
1433
+//					}
1434
+//
1435
+//					userJSONBytes, _ := json.Marshal(dat)
1436
+//
1437
+//					var res ResultOne
1438
+//					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1439
+//						utils.ErrorLog("解析失败:%v", err)
1440
+//						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1441
+//						return
1442
+//					}
1443
+//					if res.Transreturncode == "00000000" {
1444
+//						his := models.VMHisPatient{
1445
+//							Name:                   name,
1446
+//							Gender:                 gender,
1447
+//							Birthday:               birthUnix,
1448
+//							MedicalTreatmentType:   medical_care,
1449
+//							IdType:                 certificates,
1450
+//							IdCardNo:               id_card,
1451
+//							BalanceAccountsType:    settlementValue,
1452
+//							SocialType:             social_type,
1453
+//							MedicalInsuranceNumber: medical_insurance_card,
1454
+//							RegisterType:           register_type,
1455
+//							RegisterCost:           registration_fee,
1456
+//							TreatmentCost:          medical_expenses,
1457
+//							Status:                 1,
1458
+//							Ctime:                  time.Now().Unix(),
1459
+//							Mtime:                  time.Now().Unix(),
1460
+//							Iinfo:                  resp_result,
1461
+//							PatientId:              patient.ID,
1462
+//							RecordDate:             theTime.Unix(),
1463
+//							UserOrgId:              adminInfo.CurrentOrgId,
1464
+//							AdminUserId:            admin_user_id,
1465
+//							IsReturn:               1,
1466
+//							IdCardType:             id_card_type,
1467
+//							Doctor:                 doctor,
1468
+//							Departments:            department,
1469
+//							YiliaoNumber:           yiliao_number,
1470
+//							MzNumber:               number,
1471
+//							Number:                 mz_number,
1472
+//						}
1473
+//						service.CreateHisPatientTwo(&his)
1474
+//						c.ServeSuccessJSON(map[string]interface{}{
1475
+//							"msg": "挂号成功",
1476
+//						})
1477
+//					} else {
1478
+//						c.ServeSuccessJSON(map[string]interface{}{
1479
+//							"failed_code": -10,
1480
+//							"msg":         res.Transreturnmessage,
1481
+//						})
1482
+//						return
1483
+//					}
1484
+//
1485
+//				}
1486
+//
1487
+//			} else { //异地卡流程
1488
+//				//readCardBasResult := ReadCardBasHSM(number)
1489
+//				//fmt.Println(readCardBasResult)
1490
+//				//是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
1491
+//				if is_yidi == 1 { //1本地就医
1492
+//					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
1493
+//					var dat map[string]interface{}
1494
+//					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1495
+//						fmt.Println(dat)
1496
+//					} else {
1497
+//						fmt.Println(err)
1498
+//					}
1499
+//
1500
+//					userJSONBytes, _ := json.Marshal(dat)
1501
+//
1502
+//					var res ResultOne
1503
+//					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1504
+//						utils.ErrorLog("解析失败:%v", err)
1505
+//						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1506
+//						return
1507
+//					}
1508
+//					if res.Transreturncode == "00000000" {
1509
+//						his := models.VMHisPatient{
1510
+//							Name:                   name,
1511
+//							Gender:                 gender,
1512
+//							Birthday:               birthUnix,
1513
+//							MedicalTreatmentType:   medical_care,
1514
+//							IdType:                 certificates,
1515
+//							IdCardNo:               id_card,
1516
+//							BalanceAccountsType:    settlementValue,
1517
+//							SocialType:             social_type,
1518
+//							MedicalInsuranceNumber: medical_insurance_card,
1519
+//							RegisterType:           register_type,
1520
+//							RegisterCost:           registration_fee,
1521
+//							TreatmentCost:          medical_expenses,
1522
+//							Status:                 1,
1523
+//							Ctime:                  time.Now().Unix(),
1524
+//							Mtime:                  time.Now().Unix(),
1525
+//							Iinfo:                  resp_result,
1526
+//							PatientId:              patient.ID,
1527
+//							RecordDate:             theTime.Unix(),
1528
+//							UserOrgId:              adminInfo.CurrentOrgId,
1529
+//							AdminUserId:            admin_user_id,
1530
+//							IsReturn:               1,
1531
+//							IdCardType:             id_card_type,
1532
+//							Doctor:                 doctor,
1533
+//							Departments:            department,
1534
+//							YiliaoNumber:           yiliao_number,
1535
+//							MzNumber:               number,
1536
+//							Number:                 mz_number,
1537
+//						}
1538
+//						service.CreateHisPatientTwo(&his)
1539
+//						c.ServeSuccessJSON(map[string]interface{}{
1540
+//							"msg": "挂号成功",
1541
+//						})
1542
+//					} else {
1543
+//						c.ServeSuccessJSON(map[string]interface{}{
1544
+//							"failed_code": -10,
1545
+//							"msg":         res.Transreturnmessage,
1546
+//						})
1547
+//						return
1548
+//					}
1549
+//
1550
+//				} else { //异地就医需要走鉴权流程
1551
+//					//authResult := CardAuth(number)
1552
+//					//fmt.Println(authResult)
1553
+//					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
1554
+//					var dat map[string]interface{}
1555
+//					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1556
+//						fmt.Println(dat)
1557
+//					} else {
1558
+//						fmt.Println(err)
1559
+//					}
1560
+//
1561
+//					userJSONBytes, _ := json.Marshal(dat)
1562
+//
1563
+//					var res ResultOne
1564
+//					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1565
+//						utils.ErrorLog("解析失败:%v", err)
1566
+//						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1567
+//						return
1568
+//					}
1569
+//					if res.Transreturncode == "00000000" {
1570
+//						his := models.VMHisPatient{
1571
+//							Name:                   name,
1572
+//							Gender:                 gender,
1573
+//							Birthday:               birthUnix,
1574
+//							MedicalTreatmentType:   medical_care,
1575
+//							IdType:                 certificates,
1576
+//							IdCardNo:               id_card,
1577
+//							BalanceAccountsType:    settlementValue,
1578
+//							SocialType:             social_type,
1579
+//							MedicalInsuranceNumber: medical_insurance_card,
1580
+//							RegisterType:           register_type,
1581
+//							RegisterCost:           registration_fee,
1582
+//							TreatmentCost:          medical_expenses,
1583
+//							Status:                 1,
1584
+//							Ctime:                  time.Now().Unix(),
1585
+//							Mtime:                  time.Now().Unix(),
1586
+//							Iinfo:                  resp_result,
1587
+//							PatientId:              patient.ID,
1588
+//							RecordDate:             theTime.Unix(),
1589
+//							UserOrgId:              adminInfo.CurrentOrgId,
1590
+//							AdminUserId:            admin_user_id,
1591
+//							IsReturn:               1,
1592
+//							IdCardType:             id_card_type,
1593
+//							Doctor:                 doctor,
1594
+//							Departments:            department,
1595
+//							YiliaoNumber:           yiliao_number,
1596
+//							MzNumber:               number,
1597
+//							Number:                 mz_number,
1598
+//						}
1599
+//						service.CreateHisPatientTwo(&his)
1600
+//						c.ServeSuccessJSON(map[string]interface{}{
1601
+//							"msg": "挂号成功",
1602
+//						})
1603
+//					} else {
1604
+//						c.ServeSuccessJSON(map[string]interface{}{
1605
+//							"failed_code": -10,
1606
+//							"msg":         res.Transreturnmessage,
1607
+//						})
1608
+//						return
1609
+//					}
1610
+//
1611
+//				}
1612
+//			}
1613
+//		} else {
1614
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
1615
+//			return
1616
+//		}
1617
+//	} else {
1618
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1619
+//		return
1620
+//	}
1621
+//}
1629 1622
 
1630 1623
 //func (c *SZHisApiController) GetRegisterInfo() {
1631 1624
 //	adminInfo := c.GetAdminUserInfo()
@@ -2470,6 +2463,8 @@ func (c *SZHisApiController) GetSettleInfo() {
2470 2463
 			}
2471 2464
 		}
2472 2465
 
2466
+		total, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
2467
+
2473 2468
 		yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
2474 2469
 
2475 2470
 		if ret4 == 0 {

+ 10 - 0
models/gdyb_models.go View File

@@ -10,6 +10,11 @@ type GdybPsnRecord struct {
10 10
 	Status        int64  `gorm:"column:status" json:"status" form:"status"`
11 11
 	IsCancel      int64  `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
12 12
 	TrtDclaDetlSn string `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
13
+	DoctorId      int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
14
+	DepartmentId  int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
15
+	Insutype      string `gorm:"column:insutype" json:"insutype" form:"insutype"`
16
+	SickType      int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
17
+	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
13 18
 }
14 19
 
15 20
 func (GdybPsnRecord) TableName() string {
@@ -26,6 +31,11 @@ type GdybPsnNcdsRecord struct {
26 31
 	Status        int64  `gorm:"column:status" json:"status" form:"status"`
27 32
 	IsCancel      int64  `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
28 33
 	TrtDclaDetlSn string `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
34
+	DoctorId      int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
35
+	DepartmentId  int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
36
+	Insutype      string `gorm:"column:insutype" json:"insutype" form:"insutype"`
37
+	SickType      int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
38
+	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
29 39
 }
30 40
 
31 41
 func (GdybPsnNcdsRecord) TableName() string {

+ 246 - 66
service/gdyb_service.go View File

@@ -7,6 +7,7 @@ import (
7 7
 	"encoding/json"
8 8
 	"fmt"
9 9
 	"gdyb/models"
10
+	"github.com/astaxie/beego"
10 11
 	"io"
11 12
 	"io/ioutil"
12 13
 	"math/rand"
@@ -50,7 +51,11 @@ func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code stri
50 51
 		return err.Error()
51 52
 	}
52 53
 	reader := bytes.NewReader(bytesData)
53
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
54
+	gdyb_url := beego.AppConfig.String("gdyb_url")
55
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
56
+	url := gdyb_url + "1201"
57
+
58
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
54 59
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
55 60
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
56 61
 	request, err := http.NewRequest("POST", url, reader)
@@ -60,7 +65,7 @@ func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code stri
60 65
 	}
61 66
 
62 67
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
63
-	request.Header.Set("x-tif-paasid", "sg03_prd")
68
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
64 69
 	request.Header.Set("x-tif-signature", signature)
65 70
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
66 71
 	request.Header.Set("x-tif-nonce", nonce)
@@ -82,13 +87,12 @@ func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code stri
82 87
 }
83 88
 
84 89
 // 人员基本信息
85
-func Gdyb1101(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, id_card_no string) string {
86
-	// 生成签名
90
+func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string) string {
91
+	//生成签名
87 92
 	nonce := GetRandomString(32)
88 93
 	timestamp := time.Now().Unix()
89 94
 	signature := setSignature(timestamp, nonce, secret_key)
90
-
91
-	// 生成输入报文
95
+	//生成输入报文
92 96
 	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
93 97
 	input := make(map[string]interface{})
94 98
 	inputData := make(map[string]interface{})
@@ -97,10 +101,7 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
97 101
 	if id_card_type == 1 {
98 102
 		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
99 103
 		inputData["card_sn"] = card_sn      // 卡识别码
100
-		inputData["certno"] = id_card_no    // 证件号码
101
-		//inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
102
-		//inputData["card_sn"] = ""           // 卡识别码
103
-		//inputData["certno"] = certNo        // 证件号码
104
+		inputData["certno"] = certNo        // 证件号码
104 105
 	} else {
105 106
 		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
106 107
 		inputData["card_sn"] = ""           // 卡识别码
@@ -120,7 +121,72 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
120 121
 		return err.Error()
121 122
 	}
122 123
 	reader := bytes.NewReader(bytesData)
123
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
124
+	gdyb_url := beego.AppConfig.String("gdyb_url")
125
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
126
+
127
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
128
+	url := gdyb_url + "1101"
129
+
130
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
131
+	request, err := http.NewRequest("POST", url, reader)
132
+	if err != nil {
133
+		fmt.Println(err.Error())
134
+		return err.Error()
135
+	}
136
+
137
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
138
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
139
+	request.Header.Set("x-tif-signature", signature)
140
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
141
+	request.Header.Set("x-tif-nonce", nonce)
142
+
143
+	client := http.Client{}
144
+	resp, err := client.Do(request)
145
+	if err != nil {
146
+		fmt.Println(err.Error())
147
+		return err.Error()
148
+	}
149
+	respBytes, err := ioutil.ReadAll(resp.Body)
150
+	if err != nil {
151
+		fmt.Println(err.Error())
152
+		return err.Error()
153
+	}
154
+	fmt.Println(string(respBytes))
155
+	str := string(respBytes)
156
+	return str
157
+}
158
+
159
+func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
160
+	//生成签名
161
+	nonce := GetRandomString(32)
162
+	timestamp := time.Now().Unix()
163
+	signature := setSignature(timestamp, nonce, secret_key)
164
+	//生成输入报文
165
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
166
+	input := make(map[string]interface{})
167
+	inputData := make(map[string]interface{})
168
+	inputMessage["infno"] = "1101"      // 交易编码
169
+	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
170
+	inputData["card_sn"] = ""           // 卡识别码
171
+	inputData["certno"] = certNo        // 证件号码
172
+	inputData["psn_cert_type"] = "1"    // 人员证件类型
173
+	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
174
+	inputData["begntime"] = ""          // 开始时间
175
+	inputData["psn_name"] = ""          // 人员姓名
176
+	input["data"] = inputData
177
+	inputMessage["input"] = input //交易输入
178
+
179
+	bytesData, err := json.Marshal(inputMessage)
180
+	fmt.Println(string(bytesData))
181
+	if err != nil {
182
+		fmt.Println(err.Error())
183
+		return err.Error()
184
+	}
185
+	reader := bytes.NewReader(bytesData)
186
+	gdyb_url := beego.AppConfig.String("gdyb_url")
187
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
188
+	url := gdyb_url + "1101"
189
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
124 190
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
125 191
 
126 192
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
@@ -131,7 +197,7 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
131 197
 	}
132 198
 
133 199
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
134
-	request.Header.Set("x-tif-paasid", "sg03_prd")
200
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
135 201
 	request.Header.Set("x-tif-signature", signature)
136 202
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
137 203
 	request.Header.Set("x-tif-nonce", nonce)
@@ -195,9 +261,12 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doc
195 261
 		return err.Error()
196 262
 	}
197 263
 	reader := bytes.NewReader(bytesData)
198
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
264
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
199 265
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
200 266
 
267
+	gdyb_url := beego.AppConfig.String("gdyb_url")
268
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
269
+	url := gdyb_url + "2201"
201 270
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
202 271
 	request, err := http.NewRequest("POST", url, reader)
203 272
 	if err != nil {
@@ -206,7 +275,7 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doc
206 275
 	}
207 276
 
208 277
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
209
-	request.Header.Set("x-tif-paasid", "sg03_prd")
278
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
210 279
 	request.Header.Set("x-tif-signature", signature)
211 280
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
212 281
 	request.Header.Set("x-tif-nonce", nonce)
@@ -254,7 +323,10 @@ func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string,
254 323
 	}
255 324
 	reader := bytes.NewReader(bytesData)
256 325
 
257
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
326
+	gdyb_url := beego.AppConfig.String("gdyb_url")
327
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
328
+	url := gdyb_url + "2202"
329
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
258 330
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
259 331
 
260 332
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
@@ -266,7 +338,7 @@ func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string,
266 338
 
267 339
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
268 340
 	//request.Header.Set("x-tif-paasid", "test_hosp")
269
-	request.Header.Set("x-tif-paasid", "sg03_prd")
341
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
270 342
 
271 343
 	request.Header.Set("x-tif-signature", signature)
272 344
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
@@ -338,7 +410,11 @@ func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, di
338 410
 	}
339 411
 	reader := bytes.NewReader(bytesData)
340 412
 
341
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
413
+	gdyb_url := beego.AppConfig.String("gdyb_url")
414
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
415
+	url := gdyb_url + "2203"
416
+
417
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
342 418
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
343 419
 
344 420
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
@@ -349,7 +425,7 @@ func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, di
349 425
 	}
350 426
 
351 427
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
352
-	request.Header.Set("x-tif-paasid", "sg03_prd")
428
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
353 429
 	request.Header.Set("x-tif-signature", signature)
354 430
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
355 431
 	request.Header.Set("x-tif-nonce", nonce)
@@ -423,7 +499,11 @@ func Gdyb2203A(psnNo string, mdtrtId string, doctor string, department string, d
423 499
 	}
424 500
 	reader := bytes.NewReader(bytesData)
425 501
 
426
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
502
+	gdyb_url := beego.AppConfig.String("gdyb_url")
503
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
504
+	url := gdyb_url + "2203A"
505
+
506
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
427 507
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
428 508
 
429 509
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
@@ -434,7 +514,7 @@ func Gdyb2203A(psnNo string, mdtrtId string, doctor string, department string, d
434 514
 	}
435 515
 
436 516
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
437
-	request.Header.Set("x-tif-paasid", "sg03_prd")
517
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
438 518
 	request.Header.Set("x-tif-signature", signature)
439 519
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
440 520
 	request.Header.Set("x-tif-nonce", nonce)
@@ -628,7 +708,14 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
628 708
 		return ""
629 709
 	}
630 710
 	reader := bytes.NewReader(bytesData)
631
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
711
+
712
+	gdyb_url := beego.AppConfig.String("gdyb_url")
713
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
714
+
715
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
716
+	url := gdyb_url + "2204"
717
+
718
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
632 719
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
633 720
 
634 721
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
@@ -639,7 +726,7 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
639 726
 	}
640 727
 
641 728
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
642
-	request.Header.Set("x-tif-paasid", "sg03_prd")
729
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
643 730
 	request.Header.Set("x-tif-signature", signature)
644 731
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
645 732
 	request.Header.Set("x-tif-nonce", nonce)
@@ -688,7 +775,13 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
688 775
 		return err.Error()
689 776
 	}
690 777
 	reader := bytes.NewReader(bytesData)
691
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
778
+	gdyb_url := beego.AppConfig.String("gdyb_url")
779
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
780
+
781
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
782
+	url := gdyb_url + "2205"
783
+
784
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
692 785
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
693 786
 
694 787
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
@@ -702,7 +795,7 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
702 795
 	}
703 796
 
704 797
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
705
-	request.Header.Set("x-tif-paasid", "sg03_prd")
798
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
706 799
 	request.Header.Set("x-tif-signature", signature)
707 800
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
708 801
 	request.Header.Set("x-tif-nonce", nonce)
@@ -768,7 +861,13 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
768 861
 	}
769 862
 	reader := bytes.NewReader(bytesData)
770 863
 
771
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
864
+	gdyb_url := beego.AppConfig.String("gdyb_url")
865
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
866
+
867
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
868
+	url := gdyb_url + "2206"
869
+
870
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
772 871
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
773 872
 
774 873
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
@@ -779,7 +878,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
779 878
 	}
780 879
 
781 880
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
782
-	request.Header.Set("x-tif-paasid", "sg03_prd")
881
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
783 882
 	request.Header.Set("x-tif-signature", signature)
784 883
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
785 884
 	request.Header.Set("x-tif-nonce", nonce)
@@ -847,7 +946,13 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
847 946
 		return err.Error()
848 947
 	}
849 948
 	reader := bytes.NewReader(bytesData)
850
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
949
+	gdyb_url := beego.AppConfig.String("gdyb_url")
950
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
951
+
952
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
953
+	url := gdyb_url + "2207"
954
+
955
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
851 956
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
852 957
 
853 958
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
@@ -858,7 +963,7 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
858 963
 	}
859 964
 
860 965
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
861
-	request.Header.Set("x-tif-paasid", "sg03_prd")
966
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
862 967
 	request.Header.Set("x-tif-signature", signature)
863 968
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
864 969
 	request.Header.Set("x-tif-nonce", nonce)
@@ -906,7 +1011,13 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
906 1011
 		return err.Error()
907 1012
 	}
908 1013
 	reader := bytes.NewReader(bytesData)
909
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
1014
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1015
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1016
+
1017
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1018
+	url := gdyb_url + "2208"
1019
+
1020
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
910 1021
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
911 1022
 
912 1023
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
@@ -917,7 +1028,7 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
917 1028
 	}
918 1029
 
919 1030
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
920
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1031
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
921 1032
 	request.Header.Set("x-tif-signature", signature)
922 1033
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
923 1034
 	request.Header.Set("x-tif-nonce", nonce)
@@ -990,7 +1101,12 @@ func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_adm
990 1101
 		return err.Error()
991 1102
 	}
992 1103
 	reader := bytes.NewReader(bytesData)
993
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
1104
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1105
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1106
+
1107
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1108
+	url := gdyb_url + "6201"
1109
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
994 1110
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
995 1111
 
996 1112
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
@@ -1001,7 +1117,7 @@ func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_adm
1001 1117
 	}
1002 1118
 
1003 1119
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1004
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1120
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1005 1121
 	request.Header.Set("x-tif-signature", signature)
1006 1122
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1007 1123
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1058,7 +1174,12 @@ func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams
1058 1174
 		return err.Error()
1059 1175
 	}
1060 1176
 	reader := bytes.NewReader(bytesData)
1061
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
1177
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1178
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1179
+
1180
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1181
+	url := gdyb_url + "3201"
1182
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
1062 1183
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
1063 1184
 
1064 1185
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
@@ -1069,7 +1190,7 @@ func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams
1069 1190
 	}
1070 1191
 
1071 1192
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1072
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1193
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1073 1194
 	request.Header.Set("x-tif-signature", signature)
1074 1195
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1075 1196
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1127,9 +1248,14 @@ func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte)
1127 1248
 		return err.Error()
1128 1249
 	}
1129 1250
 	reader := bytes.NewReader(bytesData)
1130
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
1251
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
1131 1252
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
1132 1253
 
1254
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1255
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1256
+
1257
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1258
+	url := gdyb_url + "9101"
1133 1259
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
1134 1260
 	request, err := http.NewRequest("POST", url, reader)
1135 1261
 	if err != nil {
@@ -1138,7 +1264,7 @@ func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte)
1138 1264
 	}
1139 1265
 
1140 1266
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1141
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1267
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1142 1268
 	request.Header.Set("x-tif-signature", signature)
1143 1269
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1144 1270
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1182,7 +1308,12 @@ func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no strin
1182 1308
 		return err.Error()
1183 1309
 	}
1184 1310
 	reader := bytes.NewReader(bytesData)
1185
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
1311
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1312
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1313
+
1314
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1315
+	url := gdyb_url + "9102"
1316
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
1186 1317
 
1187 1318
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
1188 1319
 
@@ -1194,7 +1325,7 @@ func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no strin
1194 1325
 	}
1195 1326
 
1196 1327
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1197
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1328
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1198 1329
 	request.Header.Set("x-tif-signature", signature)
1199 1330
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1200 1331
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1244,7 +1375,12 @@ func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams
1244 1375
 		return err.Error()
1245 1376
 	}
1246 1377
 	reader := bytes.NewReader(bytesData)
1247
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
1378
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1379
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1380
+
1381
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1382
+	url := gdyb_url + "3202"
1383
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
1248 1384
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
1249 1385
 
1250 1386
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
@@ -1254,7 +1390,7 @@ func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams
1254 1390
 		return err.Error()
1255 1391
 	}
1256 1392
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1257
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1393
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1258 1394
 	request.Header.Set("x-tif-signature", signature)
1259 1395
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1260 1396
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1297,7 +1433,12 @@ func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams
1297 1433
 		return err.Error()
1298 1434
 	}
1299 1435
 	reader := bytes.NewReader(bytesData)
1300
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
1436
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1437
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1438
+
1439
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1440
+	url := gdyb_url + "5203"
1441
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
1301 1442
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
1302 1443
 
1303 1444
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
@@ -1307,7 +1448,7 @@ func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams
1307 1448
 		return err.Error()
1308 1449
 	}
1309 1450
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1310
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1451
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1311 1452
 	request.Header.Set("x-tif-signature", signature)
1312 1453
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1313 1454
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1351,16 +1492,21 @@ func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_
1351 1492
 		return err.Error()
1352 1493
 	}
1353 1494
 	reader := bytes.NewReader(bytesData)
1354
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
1495
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
1355 1496
 
1356
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
1497
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1498
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1499
+
1500
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1501
+	url := gdyb_url + "2001"
1502
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
1357 1503
 	request, err := http.NewRequest("POST", url, reader)
1358 1504
 	if err != nil {
1359 1505
 		fmt.Println(err.Error())
1360 1506
 		return err.Error()
1361 1507
 	}
1362 1508
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1363
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1509
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1364 1510
 	request.Header.Set("x-tif-signature", signature)
1365 1511
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1366 1512
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1416,16 +1562,21 @@ func Gdyb3301(baseParams *models.BaseParams, name string, codg string, list_type
1416 1562
 		return err.Error()
1417 1563
 	}
1418 1564
 	reader := bytes.NewReader(bytesData)
1419
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
1420
-
1421
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
1565
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
1566
+	//
1567
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
1568
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1569
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1570
+
1571
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1572
+	url := gdyb_url + "3301"
1422 1573
 	request, err := http.NewRequest("POST", url, reader)
1423 1574
 	if err != nil {
1424 1575
 		fmt.Println(err.Error())
1425 1576
 		return err.Error()
1426 1577
 	}
1427 1578
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1428
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1579
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1429 1580
 	request.Header.Set("x-tif-signature", signature)
1430 1581
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1431 1582
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1471,16 +1622,21 @@ func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type
1471 1622
 		return err.Error()
1472 1623
 	}
1473 1624
 	reader := bytes.NewReader(bytesData)
1474
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
1625
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
1475 1626
 
1476
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
1627
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
1628
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1629
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1630
+
1631
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1632
+	url := gdyb_url + "3302"
1477 1633
 	request, err := http.NewRequest("POST", url, reader)
1478 1634
 	if err != nil {
1479 1635
 		fmt.Println(err.Error())
1480 1636
 		return err.Error()
1481 1637
 	}
1482 1638
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1483
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1639
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1484 1640
 	request.Header.Set("x-tif-signature", signature)
1485 1641
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1486 1642
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1534,14 +1690,20 @@ func Gdyb2505(psnNo string, doctor string, org_name string, fixmedins_code strin
1534 1690
 		return err.Error()
1535 1691
 	}
1536 1692
 	reader := bytes.NewReader(bytesData)
1537
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
1693
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
1694
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
1695
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1696
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1697
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1698
+	url := gdyb_url + "2505"
1699
+
1538 1700
 	request, err := http.NewRequest("POST", url, reader)
1539 1701
 	if err != nil {
1540 1702
 		fmt.Println(err.Error())
1541 1703
 		return err.Error()
1542 1704
 	}
1543 1705
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1544
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1706
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1545 1707
 	request.Header.Set("x-tif-signature", signature)
1546 1708
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1547 1709
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1583,8 +1745,13 @@ func Gdyb2506(psnNo string, doctor string, org_name string, fixmedins_code strin
1583 1745
 	}
1584 1746
 	reader := bytes.NewReader(bytesData)
1585 1747
 
1586
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
1587
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
1748
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
1749
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
1750
+
1751
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1752
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1753
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1754
+	url := gdyb_url + "2506"
1588 1755
 
1589 1756
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
1590 1757
 	request, err := http.NewRequest("POST", url, reader)
@@ -1594,7 +1761,7 @@ func Gdyb2506(psnNo string, doctor string, org_name string, fixmedins_code strin
1594 1761
 	}
1595 1762
 
1596 1763
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1597
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1764
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1598 1765
 	request.Header.Set("x-tif-signature", signature)
1599 1766
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1600 1767
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1642,7 +1809,7 @@ func Gdyb2503(psnNo string, insutype string, org_name string, doctor string, fix
1642 1809
 	inputData["begndate"] = timeFormatTwo          // 医师编码
1643 1810
 	inputData["tel"] = ""                          // 医师编码
1644 1811
 	inputData["addr"] = ""                         // 医师编码
1645
-	inputData["enddate"] = ""                      // 医师编码
1812
+	inputData["enddate"] = "2099-12-31"            // 医师编码
1646 1813
 
1647 1814
 	input["data"] = inputData
1648 1815
 	inputMessage["input"] = input //交易输入
@@ -1653,7 +1820,13 @@ func Gdyb2503(psnNo string, insutype string, org_name string, doctor string, fix
1653 1820
 		return err.Error()
1654 1821
 	}
1655 1822
 	reader := bytes.NewReader(bytesData)
1656
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
1823
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
1824
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
1825
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1826
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1827
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1828
+	url := gdyb_url + "2503"
1829
+
1657 1830
 	request, err := http.NewRequest("POST", url, reader)
1658 1831
 	if err != nil {
1659 1832
 		fmt.Println(err.Error())
@@ -1661,7 +1834,7 @@ func Gdyb2503(psnNo string, insutype string, org_name string, doctor string, fix
1661 1834
 	}
1662 1835
 
1663 1836
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1664
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1837
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1665 1838
 	request.Header.Set("x-tif-signature", signature)
1666 1839
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1667 1840
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1703,14 +1876,19 @@ func Gdyb2504(psnNo string, org_name string, doctor string, fixmedins_code strin
1703 1876
 		return err.Error()
1704 1877
 	}
1705 1878
 	reader := bytes.NewReader(bytesData)
1706
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
1879
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
1880
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
1881
+	gdyb_url := beego.AppConfig.String("gdyb_url")
1882
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
1883
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
1884
+	url := gdyb_url + "2504"
1707 1885
 	request, err := http.NewRequest("POST", url, reader)
1708 1886
 	if err != nil {
1709 1887
 		fmt.Println(err.Error())
1710 1888
 		return err.Error()
1711 1889
 	}
1712 1890
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1713
-	request.Header.Set("x-tif-paasid", "sg03_prd")
1891
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1714 1892
 	request.Header.Set("x-tif-signature", signature)
1715 1893
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1716 1894
 	request.Header.Set("x-tif-nonce", nonce)
@@ -1836,7 +2014,11 @@ func Gdyb5301(psnNo string, insutype string, org_name string, doctor string, fix
1836 2014
 		return err.Error()
1837 2015
 	}
1838 2016
 	reader := bytes.NewReader(bytesData)
1839
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
2017
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
2018
+	gdyb_url := beego.AppConfig.String("gdyb_url")
2019
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
2020
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
2021
+	url := gdyb_url + "5301"
1840 2022
 	request, err := http.NewRequest("POST", url, reader)
1841 2023
 	if err != nil {
1842 2024
 		fmt.Println(err.Error())
@@ -1844,7 +2026,7 @@ func Gdyb5301(psnNo string, insutype string, org_name string, doctor string, fix
1844 2026
 	}
1845 2027
 
1846 2028
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1847
-	request.Header.Set("x-tif-paasid", "test_hosp")
2029
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
1848 2030
 	request.Header.Set("x-tif-signature", signature)
1849 2031
 	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1850 2032
 	request.Header.Set("x-tif-nonce", nonce)
@@ -2095,8 +2277,6 @@ func SetInputMessage(nonce string, timestamp int64, org_name string, doctor stri
2095 2277
 
2096 2278
 	// 生成输入报文
2097 2279
 	inputMessage := make(map[string]interface{})
2098
-
2099
-	inputMessage["infno"] = "1101"                                                              // 交易编码
2100 2280
 	inputMessage["msgid"] = fixmedins_code + timeFormat + strconv.FormatInt(int64(randNum), 10) // 发送方报文 ID
2101 2281
 	inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs                                           // 就医地医保区划
2102 2282
 	inputMessage["insuplc_admdvs"] = insuplc_admdvs                                             // 参保地医保区划

+ 23 - 5
service/sz_his_service.go View File

@@ -762,7 +762,7 @@ func SetSZDrugMessage(doctor string, doctor_code string, fixmedins_code string)
762 762
 	inputMessage["transReturnCode"] = ""                                           //
763 763
 	inputMessage["transReturnMessage"] = ""                                        //
764 764
 	inputMessage["transTime"] = year + month + day + hour + min + sec + ":" + msec //
765
-	inputMessage["transVersion"] = "V0.3"                                          //   //
765
+	inputMessage["transVersion"] = "V0.2"                                          //   //
766 766
 	inputMessage["transChannel"] = "10"                                            //
767 767
 
768 768
 	return inputMessage
@@ -955,10 +955,28 @@ func SzybYS001(doctor string, doctor_code string, fixmedins_code string, doc *mo
955 955
 	feedetail := make([]map[string]interface{}, 0)
956 956
 
957 957
 	feedetailInfo := make(map[string]interface{})
958
-	feedetailInfo["aac003"] = doc.UserName                                //医护人员姓名
959
-	feedetailInfo["bka633"] = "1"                                         //医护人员类别
960
-	feedetailInfo["aac004"] = doc.Sex                                     //性别
961
-	feedetailInfo["aac058"] = doc.CardType                                //证件类型
958
+	feedetailInfo["aac003"] = doc.UserName //医护人员姓名
959
+	feedetailInfo["bka633"] = "1"          //医护人员类别
960
+	feedetailInfo["aac004"] = doc.Sex      //性别
961
+
962
+	switch doc.CardType {
963
+
964
+	}
965
+
966
+	if doc.CardType == "1" {
967
+		feedetailInfo["aac058"] = "01"
968
+	} else if doc.CardType == "2" {
969
+		feedetailInfo["aac058"] = "02"
970
+	} else if doc.CardType == "4" {
971
+		feedetailInfo["aac058"] = "04"
972
+	} else if doc.CardType == "6" {
973
+		feedetailInfo["aac058"] = "06"
974
+	} else if doc.CardType == "8" {
975
+		feedetailInfo["aac058"] = "08"
976
+	} else if doc.CardType == "90" {
977
+		feedetailInfo["aac058"] = "90"
978
+	}
979
+
962 980
 	feedetailInfo["aac147"] = doc.IdCard                                  //证件号码
963 981
 	feedetailInfo["aae005"] = doc.Phone                                   //联系电话
964 982
 	feedetailInfo["bkc322"] = doc.WorkMajorName                           //现从事专业名称

+ 44 - 0
service/user_service.go View File

@@ -164,3 +164,47 @@ func GetAllHisDoctor(orgid int64) (appRole []*models.App_Role, err error) {
164 164
 	err = UserReadDB().Where("org_id = ?  AND status = 1 AND  (user_type = ? OR user_type = ?) ", orgid, 2, 1).Find(&appRole).Error
165 165
 	return appRole, err
166 166
 }
167
+
168
+func GetOrgById(orgID int64) (*models.Org, error) {
169
+	var org models.Org
170
+	err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
171
+	if err != nil {
172
+		if err == gorm.ErrRecordNotFound {
173
+			return nil, nil
174
+		} else {
175
+			return nil, err
176
+		}
177
+	}
178
+	return &org, nil
179
+}
180
+
181
+func GetUserAllRole(org_id int64, admin_user_id int64) (role models.App_Role, err error) {
182
+	err = readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
183
+	return
184
+}
185
+
186
+func GetAllFunctionPurview() (purview []models.SgjUserOperatePurview, err error) {
187
+	err = readUserDb.Model(&models.SgjUserOperatePurview{}).Where("status = 1 ").Order("number asc").Find(&purview).Error
188
+	return
189
+}
190
+
191
+func GetRoleFuncPurviewIds(roleID int64) (string, error) {
192
+	var rolePurview models.SgjUserRoleFuncPurview
193
+	err := readUserDb.Where("role_id = ?", roleID).First(&rolePurview).Error
194
+	if err != nil {
195
+		if err == gorm.ErrRecordNotFound {
196
+			return "", nil
197
+		} else {
198
+			return "", err
199
+		}
200
+	}
201
+	return rolePurview.PurviewIds, nil
202
+}
203
+
204
+func FindErrorMsgByStr(id int64) (string, error) {
205
+	var purview models.SgjUserOperatePurview
206
+	var err error
207
+	err = readUserDb.Model(&models.SgjUserOperatePurview{}).Where("id = ?", id).First(&purview).Error
208
+	return purview.ErrorMsg, err
209
+
210
+}