Pārlūkot izejas kodu

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

csx 3 gadus atpakaļ
vecāks
revīzija
4398cf85a5

+ 45 - 0
controllers/sg/gdyb_controller.go Parādīt failu

29
 	beego.Router("/gdyb/eleven", &GdybController{}, "get:PostEleven")
29
 	beego.Router("/gdyb/eleven", &GdybController{}, "get:PostEleven")
30
 	beego.Router("/gdyb/twelve", &GdybController{}, "get:PostTwelve")
30
 	beego.Router("/gdyb/twelve", &GdybController{}, "get:PostTwelve")
31
 
31
 
32
+	beego.Router("/gdyb/zh/five", &GdybController{}, "post:PostZHFive")
33
+
32
 }
34
 }
33
 
35
 
34
 type Result struct {
36
 type Result struct {
509
 		"pre": dat,
511
 		"pre": dat,
510
 	})
512
 	})
511
 }
513
 }
514
+
515
+func (c *GdybController) PostZHFive() {
516
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
517
+	var respJSON map[string]interface{}
518
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
519
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
520
+		return
521
+	}
522
+	userJSONBytes, _ := json.Marshal(respJSON["pre"])
523
+	var hp []*models.HisPrescription
524
+	if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
525
+		utils.ErrorLog("解析失败:%v", err)
526
+		return
527
+	}
528
+	fmt.Println(respJSON["psn_no"].(string))
529
+	fmt.Println(respJSON["mdtrt_id"].(string))
530
+
531
+	fmt.Println(respJSON["chrg_bchno"].(string))
532
+	fmt.Println(respJSON["org_name"].(string))
533
+	fmt.Println(respJSON["doctor"].(string))
534
+	fmt.Println(respJSON["dept"].(string))
535
+
536
+	fmt.Println(respJSON["fixmedins_code"].(string))
537
+	fmt.Println(respJSON["dept_code"].(string))
538
+	fmt.Println(respJSON["doctor_id"].(string))
539
+
540
+	fmt.Println(respJSON["insuplc_admdvs"].(string))
541
+	fmt.Println(respJSON["mdtrtarea_admvs"].(string))
542
+	fmt.Println(respJSON["secret_key"].(string))
543
+
544
+	result := service.ZHGdyb2301(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
545
+		respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string), respJSON["med_type"].(string))
546
+
547
+	var dat map[string]interface{}
548
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
549
+		fmt.Println(dat)
550
+	} else {
551
+		fmt.Println(err)
552
+	}
553
+	c.ServeSuccessJSON(map[string]interface{}{
554
+		"pre": dat,
555
+	})
556
+}

+ 2 - 0
controllers/sg/his_api_controller.go Parādīt failu

73
 
73
 
74
 	beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
74
 	beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
75
 
75
 
76
+	//beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
77
+
76
 }
78
 }
77
 
79
 
78
 type CustomFundPay struct {
80
 type CustomFundPay struct {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1360 - 0
controllers/zh/zh_his_api_controller.go


+ 12 - 0
enums/error_code.go Parādīt failu

249
 	ErrorCodeParamSickTypeWrong = 30006
249
 	ErrorCodeParamSickTypeWrong = 30006
250
 
250
 
251
 	ErrorPsnRecordNoExistWrong = 30007
251
 	ErrorPsnRecordNoExistWrong = 30007
252
+
253
+	ErrorCodeInHospitalNoExistDataException = 30008
254
+
255
+	ErrorCodeHospitalNoExistDataException = 30009
256
+
257
+	ErrorCodeHospitalExistDataException = 300010
252
 )
258
 )
253
 
259
 
254
 var ErrCodeMsgs = map[int]string{
260
 var ErrCodeMsgs = map[int]string{
480
 	ErrorCodeParamSickTypeWrong: "医生所开处方的疾病类型不能为空",
486
 	ErrorCodeParamSickTypeWrong: "医生所开处方的疾病类型不能为空",
481
 
487
 
482
 	ErrorPsnRecordNoExistWrong: "人员备案信息不存在",
488
 	ErrorPsnRecordNoExistWrong: "人员备案信息不存在",
489
+
490
+	ErrorCodeInHospitalNoExistDataException: "入院记录不存在",
491
+
492
+	ErrorCodeHospitalNoExistDataException: "请先办理出院才能进行结算",
493
+
494
+	ErrorCodeHospitalExistDataException: "该患者已经入院,请选办理出院结算后再进行办理入院操作",
483
 }
495
 }
484
 
496
 
485
 type SGJError struct {
497
 type SGJError struct {

+ 46 - 0
models/zh_his_models.go Parādīt failu

1
+package models
2
+
3
+type HisHospitalCheckRecord struct {
4
+	ID                   int64  `gorm:"column:id" json:"id" form:"id"`
5
+	Name                 string `gorm:"column:name" json:"name" form:"name"`
6
+	MedicalTreatmentType int64  `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
7
+	RecordDate           int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
8
+	IdCardNo             string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
9
+	AdminUserId          int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
10
+	Departments          int64  `gorm:"column:departments" json:"departments" form:"departments"`
11
+	UserOrgId            int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
12
+	Status               int64  `gorm:"column:status" json:"status" form:"status"`
13
+	Ctime                int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
14
+	Mtime                int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
15
+	PatientId            int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
16
+	Number               string `gorm:"column:number" json:"number" form:"number"`
17
+	Doctor               int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
18
+	PsnNo                string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
19
+	PsnCertType          string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
20
+	Certno               string `gorm:"column:certno" json:"certno" form:"certno"`
21
+	PsnName              string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
22
+	Gend                 string `gorm:"column:gend" json:"gend" form:"gend"`
23
+	Naty                 string `gorm:"column:naty" json:"naty" form:"naty"`
24
+	MedType              int64  `gorm:"column:med_type" json:"med_type" form:"med_type"`
25
+	Brdy                 string `gorm:"column:brdy" json:"brdy" form:"brdy"`
26
+	Iinfo                string `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
27
+	Idetinfo             string `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
28
+	IptOtpNo             string `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
29
+	AdmBed               int64  `gorm:"column:adm_bed" json:"adm_bed" form:"adm_bed"`
30
+	IdCardType           int64  `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
31
+	Diagnosis            string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
32
+	SickType             int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
33
+	MdtrtCertType        string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
34
+	InHosptialTime       string `gorm:"column:in_hosptial_time" json:"in_hosptial_time" form:"in_hosptial_time"`
35
+	OutHosptialTime      string `gorm:"column:out_hosptial_time" json:"out_hosptial_time" form:"out_hosptial_time"`
36
+	InHospitalStatus     int64  `gorm:"column:in_hospital_status" json:"in_hospital_status" form:"in_hospital_status"`
37
+	Certificates         int64  `gorm:"column:certificates" json:"certificates" form:"certificates"`
38
+	InsutypeType         string `gorm:"column:insutype_type" json:"insutype_type" form:"insutype_type"`
39
+	OutHospitalStatus    int64  `gorm:"column:out_hospital_status" json:"out_hospital_status" form:"out_hospital_status"`
40
+	OutWay               int64  `gorm:"column:out_way" json:"out_way" form:"out_way"`
41
+	Phone                string `gorm:"column:phone" json:"phone" form:"phone"`
42
+}
43
+
44
+func (HisHospitalCheckRecord) TableName() string {
45
+	return "his_hospital_check_record"
46
+}

+ 4 - 3
routers/router.go Parādīt failu

1
 package routers
1
 package routers
2
 
2
 
3
 import (
3
 import (
4
-	"gdyb/controllers/sg"
5
 	//"gdyb/controllers/sz"
4
 	//"gdyb/controllers/sz"
6
 
5
 
6
+	"gdyb/controllers/zh"
7
 	//"gdyb/controllers/sz"
7
 	//"gdyb/controllers/sz"
8
 	//"gdyb/controllers/sz"
8
 	//"gdyb/controllers/sz"
9
 	//admin_api "XT_New/controllers/admin_api_controllers"
9
 	//admin_api "XT_New/controllers/admin_api_controllers"
22
 		AllowCredentials: true,
22
 		AllowCredentials: true,
23
 	}))
23
 	}))
24
 
24
 
25
-	sg.HisManagerApiRegistRouters()
26
-	sg.GdybRegistRouters()
25
+	//sg.HisManagerApiRegistRouters()
26
+	//sg.GdybRegistRouters()
27
 	//sz.SZHisManagerApiRegistRouters()
27
 	//sz.SZHisManagerApiRegistRouters()
28
+	zh.ZHHisManagerApiRegistRouters()
28
 
29
 
29
 }
30
 }

+ 11 - 0
service/his_service.go Parādīt failu

944
 	return dealer, err
944
 	return dealer, err
945
 }
945
 }
946
 
946
 
947
+func FindDiagnoseByIds(ids []string) ([]*models.HisXtDiagnoseConfig, error) {
948
+	dealer := []*models.HisXtDiagnoseConfig{}
949
+	err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id IN (?) AND status = 1", ids).Find(&dealer).Error
950
+	return dealer, err
951
+}
952
+
947
 func FindSickById(id int64) (*models.OutpatientServiceSick, error) {
953
 func FindSickById(id int64) (*models.OutpatientServiceSick, error) {
948
 	outPatient := &models.OutpatientServiceSick{}
954
 	outPatient := &models.OutpatientServiceSick{}
949
 	err := readDb.Model(&models.OutpatientServiceSick{}).Where("id = ? AND status = 1", id).First(&outPatient).Error
955
 	err := readDb.Model(&models.OutpatientServiceSick{}).Where("id = ? AND status = 1", id).First(&outPatient).Error
1178
 	err = writeDb.Create(&result).Error
1184
 	err = writeDb.Create(&result).Error
1179
 	return
1185
 	return
1180
 }
1186
 }
1187
+
1188
+func GetDeviceNumberByID(bed_id int64, org_id int64) (device_number models.DeviceNumber, err error) {
1189
+	err = readDb.Model(&models.DeviceNumber{}).Where("id = ? AND org_id = ?", bed_id, org_id).First(&device_number).Error
1190
+	return
1191
+}

+ 930 - 0
service/zh_his_service.go Parādīt failu

1
+package service
2
+
3
+import (
4
+	"bytes"
5
+	"encoding/json"
6
+	"fmt"
7
+	"gdyb/models"
8
+	"github.com/astaxie/beego"
9
+	"io/ioutil"
10
+	"net/http"
11
+	"strconv"
12
+	"time"
13
+	_ "unsafe"
14
+)
15
+
16
+// 人员基本信息
17
+func ZHGdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) string {
18
+	//生成签名
19
+	nonce := GetRandomString(32)
20
+	timestamp := time.Now().Unix()
21
+	signature := setSignature(timestamp, nonce, secret_key)
22
+	//生成输入报文
23
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
24
+	input := make(map[string]interface{})
25
+	inputData := make(map[string]interface{})
26
+	inputMessage["infno"] = "1101" // 交易编码
27
+
28
+	if certificates == 3 {
29
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
30
+		inputData["certno"] = certNo        // 证件号码
31
+		inputData["psn_cert_type"] = "99"   // 人员证件类型
32
+
33
+	} else {
34
+		if id_card_type == 1 {
35
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
36
+			inputData["card_sn"] = card_sn      // 卡识别码
37
+			inputData["certno"] = certNo        // 证件号码
38
+			inputData["psn_cert_type"] = "1"    // 人员证件类型
39
+
40
+		} else {
41
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
42
+			inputData["card_sn"] = ""           // 卡识别码
43
+			inputData["certno"] = certNo        // 证件号码
44
+			inputData["psn_cert_type"] = "1"    // 人员证件类型
45
+		}
46
+	}
47
+
48
+	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
49
+	inputData["begntime"] = ""          // 开始时间
50
+	inputData["psn_name"] = ""          // 人员姓名
51
+	input["data"] = inputData
52
+	inputMessage["input"] = input //交易输入
53
+
54
+	bytesData, err := json.Marshal(inputMessage)
55
+	fmt.Println(string(bytesData))
56
+	if err != nil {
57
+		fmt.Println(err.Error())
58
+		return err.Error()
59
+	}
60
+	reader := bytes.NewReader(bytesData)
61
+	gdyb_url := beego.AppConfig.String("gdyb_url")
62
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
63
+
64
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
65
+	url := gdyb_url + "1101"
66
+
67
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
68
+	request, err := http.NewRequest("POST", url, reader)
69
+	if err != nil {
70
+		fmt.Println(err.Error())
71
+		return err.Error()
72
+	}
73
+
74
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
75
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
76
+	request.Header.Set("x-tif-signature", signature)
77
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
78
+	request.Header.Set("x-tif-nonce", nonce)
79
+
80
+	client := http.Client{}
81
+	resp, err := client.Do(request)
82
+	if err != nil {
83
+		fmt.Println(err.Error())
84
+		return err.Error()
85
+	}
86
+	respBytes, err := ioutil.ReadAll(resp.Body)
87
+	if err != nil {
88
+		fmt.Println(err.Error())
89
+		return err.Error()
90
+	}
91
+	fmt.Println(string(respBytes))
92
+	str := string(respBytes)
93
+	return str
94
+}
95
+
96
+type DiseinfoStruct struct {
97
+	PsnNo        string
98
+	DiagType     string
99
+	MaindiagFlag string
100
+	DiagSrtNo    string
101
+	DiagCode     string
102
+	DiagName     string
103
+	DiagDept     string
104
+	DiseDorNo    string
105
+	DiseDorName  string
106
+	DiagTime     string
107
+}
108
+type Struct2401 struct {
109
+	PsnNo            string
110
+	Insutype         string
111
+	MdtrtCertType    string
112
+	MdtrtCertNo      string
113
+	MedType          string
114
+	IptNo            string
115
+	AtddrNo          string
116
+	ChfpdrName       string
117
+	AdmDiagDscr      string
118
+	AdmDeptCodg      string
119
+	AdmDeptName      string
120
+	AdmBed           string
121
+	DscgMaindiagCode string
122
+	DscgMaindiagName string
123
+	Diseinfo         []DiseinfoStruct
124
+	Begntime         string
125
+	DiseCodg         string
126
+	DiseName         string
127
+}
128
+
129
+// 住院登记
130
+func ZHGdyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) string {
131
+	// 生成签名
132
+	nonce := GetRandomString(32)
133
+	timestamp := time.Now().Unix()
134
+	signature := setSignature(timestamp, nonce, secret_key)
135
+	//tempTime := time.Unix(timestamp, 0)
136
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
137
+
138
+	// 生成输入报文
139
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
140
+	input := make(map[string]interface{})
141
+	inputData := make(map[string]interface{})
142
+	inputMessage["infno"] = "2201"              // 交易编码
143
+	inputData["psn_no"] = struct2401.PsnNo      // 人员编号 (来自1101接口返回)
144
+	inputData["insutype"] = struct2401.Insutype // 险种类型(来自1101接口返回)
145
+	inputData["tel"] = ""
146
+	inputData["coner_name"] = ""
147
+	inputData["begntime"] = struct2401.Begntime         // 开始时间
148
+	inputData["mdtrt_cert_type"] = "02"                 // 就诊凭证类型
149
+	inputData["mdtrt_cert_no"] = struct2401.MdtrtCertNo // 就诊凭证编号
150
+	inputData["med_type"] = struct2401.MedType          // 就诊凭证编号
151
+	inputData["ipt_no"] = struct2401.IptNo              // 住院/门诊号
152
+	inputData["medrcdno"] = ""
153
+	inputData["atddr_no"] = struct2401.AtddrNo
154
+	inputData["chfpdr_name"] = struct2401.ChfpdrName
155
+	inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
156
+	inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
157
+	inputData["adm_dept_name"] = struct2401.AdmDeptName
158
+	inputData["adm_bed"] = struct2401.AdmBed
159
+	inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
160
+	inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
161
+	inputData["main_cond_dscr"] = ""
162
+	inputData["dise_codg"] = ""
163
+	inputData["dise_name"] = ""
164
+	inputData["oprn_oprt_code"] = ""
165
+	inputData["oprn_oprt_name"] = ""
166
+	inputData["fpsc_no"] = ""
167
+	inputData["matn_type"] = ""
168
+	inputData["birctrl_type"] = ""
169
+	inputData["latechb_flag"] = ""
170
+	inputData["geso_val"] = ""
171
+	inputData["fetts"] = ""
172
+	inputData["fetus_cnt"] = ""
173
+	inputData["pret_flag"] = ""
174
+	inputData["birctrl_matn_date"] = ""
175
+	inputData["dise_type_code"] = ""
176
+
177
+	inputDataArr := make([]map[string]interface{}, 0)
178
+	for _, item := range struct2401.Diseinfo {
179
+		inputDataTwo := make(map[string]interface{})
180
+		inputDataTwo["psn_no"] = item.PsnNo
181
+		inputDataTwo["diag_type"] = item.DiagType
182
+		inputDataTwo["maindiag_flag"] = item.MaindiagFlag
183
+		inputDataTwo["diag_srt_no"] = item.DiagSrtNo
184
+		inputDataTwo["diag_code"] = item.DiagCode
185
+		inputDataTwo["diag_name"] = item.DiagName
186
+		inputDataTwo["adm_cond"] = ""
187
+		inputDataTwo["diag_dept"] = item.DiagDept
188
+		inputDataTwo["dise_dor_no"] = item.DiseDorNo
189
+		inputDataTwo["dise_dor_name"] = item.DiseDorName
190
+		inputDataTwo["diag_time"] = item.DiagTime
191
+		inputDataArr = append(inputDataArr, inputDataTwo)
192
+	}
193
+	input["mdtrtinfo"] = inputData
194
+	input["diseinfo"] = inputDataArr
195
+	inputMessage["input"] = input //交易输入
196
+
197
+	bytesData, err := json.Marshal(inputMessage)
198
+	fmt.Println(string(bytesData))
199
+	if err != nil {
200
+		fmt.Println(err.Error())
201
+		return err.Error()
202
+	}
203
+	reader := bytes.NewReader(bytesData)
204
+	gdyb_url := beego.AppConfig.String("gdyb_url")
205
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
206
+	url := gdyb_url + "2401"
207
+	request, err := http.NewRequest("POST", url, reader)
208
+	if err != nil {
209
+		fmt.Println(err.Error())
210
+		return err.Error()
211
+	}
212
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
213
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
214
+	request.Header.Set("x-tif-signature", signature)
215
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
216
+	request.Header.Set("x-tif-nonce", nonce)
217
+
218
+	client := http.Client{}
219
+	resp, err := client.Do(request)
220
+	if err != nil {
221
+		fmt.Println(err.Error())
222
+		return err.Error()
223
+	}
224
+	respBytes, err := ioutil.ReadAll(resp.Body)
225
+	if err != nil {
226
+		fmt.Println(err.Error())
227
+		return err.Error()
228
+	}
229
+	str := string(respBytes)
230
+	fmt.Println(str)
231
+	return str
232
+}
233
+
234
+//住院撤销
235
+func ZHGdyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) string {
236
+	// 生成签名
237
+	nonce := GetRandomString(32)
238
+	timestamp := time.Now().Unix()
239
+	signature := setSignature(timestamp, nonce, secret_key)
240
+
241
+	// 生成输入报文
242
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
243
+	input := make(map[string]interface{})
244
+	inputData := make(map[string]interface{})
245
+	inputMessage["infno"] = "2404"   // 交易编码
246
+	inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
247
+	inputData["psn_no"] = psn_no     // 人员编号 (来自1101接口返回)
248
+	input["data"] = inputData
249
+	inputMessage["input"] = input //交易输入
250
+	bytesData, err := json.Marshal(inputMessage)
251
+	fmt.Println(string(bytesData))
252
+	if err != nil {
253
+		fmt.Println(err.Error())
254
+		return err.Error()
255
+	}
256
+	reader := bytes.NewReader(bytesData)
257
+	gdyb_url := beego.AppConfig.String("gdyb_url")
258
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
259
+	url := gdyb_url + "2404"
260
+	request, err := http.NewRequest("POST", url, reader)
261
+	if err != nil {
262
+		fmt.Println(err.Error())
263
+		return err.Error()
264
+	}
265
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
266
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
267
+	request.Header.Set("x-tif-signature", signature)
268
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
269
+	request.Header.Set("x-tif-nonce", nonce)
270
+
271
+	client := http.Client{}
272
+	resp, err := client.Do(request)
273
+	if err != nil {
274
+		fmt.Println(err.Error())
275
+		return err.Error()
276
+	}
277
+	respBytes, err := ioutil.ReadAll(resp.Body)
278
+	if err != nil {
279
+		fmt.Println(err.Error())
280
+		return err.Error()
281
+	}
282
+	str := string(respBytes)
283
+	fmt.Println(str)
284
+	return str
285
+}
286
+
287
+//出院撤销
288
+func ZHGdyb2405(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) string {
289
+	// 生成签名
290
+	nonce := GetRandomString(32)
291
+	timestamp := time.Now().Unix()
292
+	signature := setSignature(timestamp, nonce, secret_key)
293
+
294
+	// 生成输入报文
295
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
296
+	input := make(map[string]interface{})
297
+	inputData := make(map[string]interface{})
298
+	inputMessage["infno"] = "2405"   // 交易编码
299
+	inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
300
+	inputData["psn_no"] = psn_no     // 人员编号 (来自1101接口返回)
301
+	input["data"] = inputData
302
+	inputMessage["input"] = input //交易输入
303
+	bytesData, err := json.Marshal(inputMessage)
304
+	fmt.Println(string(bytesData))
305
+	if err != nil {
306
+		fmt.Println(err.Error())
307
+		return err.Error()
308
+	}
309
+	reader := bytes.NewReader(bytesData)
310
+	gdyb_url := beego.AppConfig.String("gdyb_url")
311
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
312
+	url := gdyb_url + "2405"
313
+	request, err := http.NewRequest("POST", url, reader)
314
+	if err != nil {
315
+		fmt.Println(err.Error())
316
+		return err.Error()
317
+	}
318
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
319
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
320
+	request.Header.Set("x-tif-signature", signature)
321
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
322
+	request.Header.Set("x-tif-nonce", nonce)
323
+
324
+	client := http.Client{}
325
+	resp, err := client.Do(request)
326
+	if err != nil {
327
+		fmt.Println(err.Error())
328
+		return err.Error()
329
+	}
330
+	respBytes, err := ioutil.ReadAll(resp.Body)
331
+	if err != nil {
332
+		fmt.Println(err.Error())
333
+		return err.Error()
334
+	}
335
+	str := string(respBytes)
336
+	fmt.Println(str)
337
+	return str
338
+}
339
+
340
+type Diseinfo2402Struct struct {
341
+	MdtrtId      string
342
+	PsnNo        string
343
+	DiagType     string
344
+	MaindiagFlag string
345
+	DiagSrtNo    string
346
+	DiagCode     string
347
+	DiagName     string
348
+	DiagDept     string
349
+	DiseDorNo    string
350
+	DiseDorName  string
351
+	DiagTime     string
352
+}
353
+type Struct2402 struct {
354
+	MdtrtId      string
355
+	PsnNo        string
356
+	Insutype     string
357
+	Endtime      string
358
+	DscgDeptCodg string
359
+	DscgDeptName string
360
+	DscgWay      string
361
+	Diseinfo     []Diseinfo2402Struct
362
+}
363
+
364
+// 出院
365
+func ZHGdyb2402(struct2402 Struct2402, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
366
+
367
+	// 生成签名
368
+	nonce := GetRandomString(32)
369
+	timestamp := time.Now().Unix()
370
+	signature := setSignature(timestamp, nonce, secret_key)
371
+	//tempTime := time.Unix(timestamp, 0)
372
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
373
+
374
+	// 生成输入报文
375
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
376
+	input := make(map[string]interface{})
377
+	inputData := make(map[string]interface{})
378
+	inputMessage["infno"] = "2402"              // 交易编码
379
+	inputData["mdtrt_id"] = struct2402.MdtrtId  // 人员编号 (来自1101接口返回)
380
+	inputData["psn_no"] = struct2402.PsnNo      // 人员编号 (来自1101接口返回)
381
+	inputData["insutype"] = struct2402.Insutype // 险种类型(来自1101接口返回)
382
+	inputData["endtime"] = struct2402.Endtime   // 结束时间
383
+	inputData["dise_codg"] = ""                 // 就诊凭证类型
384
+
385
+	inputData["dise_name"] = ""      // 就诊凭证类型
386
+	inputData["oprn_oprt_code"] = "" // 就诊凭证类型
387
+	inputData["oprn_oprt_name"] = "" // 就诊凭证类型
388
+	inputData["fpsc_no"] = ""        // 就诊凭证类型
389
+
390
+	inputData["matn_type"] = ""    // 就诊凭证类型
391
+	inputData["birctrl_type"] = "" // 就诊凭证类型
392
+	inputData["latechb_flag"] = "" // 就诊凭证类型
393
+	inputData["geso_val"] = ""
394
+	inputData["fetts"] = ""
395
+	inputData["fetus_cnt"] = ""
396
+	inputData["pret_flag"] = ""
397
+	inputData["birctrl_matn_date"] = ""
398
+	inputData["cop_flag"] = ""
399
+
400
+	inputData["dscg_dept_codg"] = struct2402.DscgDeptCodg
401
+	inputData["dscg_dept_name"] = struct2402.DscgDeptName
402
+	inputData["dscg_bed"] = ""
403
+	inputData["dscg_way"] = struct2402.DscgWay
404
+	inputData["die_date"] = ""
405
+
406
+	inputDataArr := make([]map[string]interface{}, 0)
407
+	for _, item := range struct2402.Diseinfo {
408
+		inputDataTwo := make(map[string]interface{})
409
+		inputDataTwo["psn_no"] = item.PsnNo
410
+		inputDataTwo["diag_type"] = item.DiagType
411
+		inputDataTwo["maindiag_flag"] = item.MaindiagFlag
412
+		inputDataTwo["diag_srt_no"] = item.DiagSrtNo
413
+		inputDataTwo["diag_code"] = item.DiagCode
414
+		inputDataTwo["diag_name"] = item.DiagName
415
+		inputDataTwo["adm_cond"] = ""
416
+		inputDataTwo["diag_dept"] = item.DiagDept
417
+		inputDataTwo["dise_dor_no"] = item.DiseDorNo
418
+		inputDataTwo["dise_dor_name"] = item.DiseDorName
419
+		inputDataTwo["diag_time"] = item.DiagTime
420
+		inputDataArr = append(inputDataArr, inputDataTwo)
421
+	}
422
+
423
+	input["mdtrtinfo"] = inputData
424
+	input["diseinfo"] = inputDataArr
425
+
426
+	inputMessage["input"] = input //交易输入
427
+
428
+	bytesData, err := json.Marshal(inputMessage)
429
+	fmt.Println(string(bytesData))
430
+	if err != nil {
431
+		fmt.Println(err.Error())
432
+		return err.Error()
433
+	}
434
+	reader := bytes.NewReader(bytesData)
435
+
436
+	gdyb_url := beego.AppConfig.String("gdyb_url")
437
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
438
+	url := gdyb_url + "2402"
439
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
440
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
441
+
442
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
443
+	request, err := http.NewRequest("POST", url, reader)
444
+	if err != nil {
445
+		fmt.Println(err.Error())
446
+		return err.Error()
447
+	}
448
+
449
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
450
+	//request.Header.Set("x-tif-paasid", "test_hosp")
451
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
452
+
453
+	request.Header.Set("x-tif-signature", signature)
454
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
455
+	request.Header.Set("x-tif-nonce", nonce)
456
+
457
+	client := http.Client{}
458
+	resp, err := client.Do(request)
459
+	if err != nil {
460
+		fmt.Println(err.Error())
461
+		return err.Error()
462
+	}
463
+	respBytes, err := ioutil.ReadAll(resp.Body)
464
+	if err != nil {
465
+		fmt.Println(err.Error())
466
+		return err.Error()
467
+	}
468
+	str := string(respBytes)
469
+	fmt.Println(str)
470
+	return str
471
+}
472
+
473
+type ZHCustom struct {
474
+	DetItemFeeSumamt string
475
+	Cut              string
476
+	FeedetlSn        string
477
+	Price            string
478
+	MedListCodg      string
479
+	LmtUsedFlag      int64
480
+	HospApprFlag     int64
481
+}
482
+type ZHRequestResult struct {
483
+	Output      Output `json:"output" form:"output"`
484
+	Infcode     int64  `gorm:"column:infcode" json:"infcode" form:"infcode"`
485
+	WarnMsg     string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
486
+	Cainfo      string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
487
+	ErrMsg      string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
488
+	RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
489
+	InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
490
+}
491
+type ZHOutput struct {
492
+	Result Result `json:"result" form:"result"`
493
+}
494
+type ZHResult struct {
495
+	BasMednFlag      string  `json:"bas_medn_flag" form:"bas_medn_flag"`
496
+	MedChrgitmType   string  `json:"med_chrgitm_type" form:"med_chrgitm_type"`
497
+	DetItemFeeSumamt int64   `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
498
+	HiNegoDrugFlag   string  `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
499
+	FulamtOwnpayAmt  float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
500
+
501
+	FeedtlSn       int64   `json:"feedtl_sn" form:"feedtl_sn"`
502
+	UploadDate     int64   `json:"upload_date" form:"upload_date"`
503
+	AdviceId       int64   `json:"advice_id" form:"advice_id"`
504
+	Cnt            int64   `json:"cnt" form:"cnt"`
505
+	Pric           float64 `json:"pric" form:"pric"`
506
+	PatientId      int64   `json:"patient_id" form:"patient_id"`
507
+	PricUplmtAmt   float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
508
+	SelfpayProp    float64 `json:"selfpay_prop" form:"selfpay_prop"`
509
+	OverlmtAmt     float64 `json:"overlmt_amt" form:"overlmt_amt"`
510
+	PreselfpayAmt  float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
511
+	Status         int64   `json:"status" form:"status"`
512
+	Memo           string  `json:"memo" form:"memo"`
513
+	FeedetlSn      string  `json:"feedetl_sn" form:"feedetl_sn"`
514
+	Mtime          int64   `json:"mtime" form:"mtime"`
515
+	InscpScpAmt    float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
516
+	DrtReimFlag    string  `json:"drt_reim_flag" form:"drt_reim_flag"`
517
+	Ctime          int64   `json:"ctime" form:"ctime"`
518
+	ListSpItemFlag string  `json:"list_sp_item_flag" form:"list_sp_item_flag"`
519
+	ChldMedcFlag   string  `json:"chld_medc_flag" form:"chld_medc_flag"`
520
+	LmtUsedFlag    string  `json:"lmt_used_flag" form:"lmt_used_flag"`
521
+	ChrgitmLv      string  `json:"chrgitm_lv" form:"chrgitm_lv"`
522
+	UserOrgId      int64   `json:"user_org_id" form:"user_org_id"`
523
+	HisPatientId   int64   `json:"his_patient_id" form:"his_patient_id"`
524
+	OrderId        int64   `json:"order_id" form:"order_id"`
525
+}
526
+
527
+//  住院费用明细信息上传
528
+func ZHGdyb2301(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string) string {
529
+	// 生成签名
530
+	nonce := GetRandomString(32)
531
+	timestamp := time.Now().Unix()
532
+	signature := setSignature(timestamp, nonce, secret_key)
533
+	tempTime := time.Unix(timestamp, 0)
534
+	//timeFormat := tempTime.Format("20060102150405")
535
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
536
+	//chrgBchno := rand.Intn(100000) + 10000
537
+
538
+	var customs []*Custom
539
+
540
+	for _, item := range hisPrescription {
541
+		if item.Type == 1 { //药品
542
+			for _, subItem := range item.HisDoctorAdviceInfo {
543
+				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
544
+					//var randNum int
545
+					//randNum = rand.Intn(10000) + 1000
546
+					cus := &Custom{
547
+						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
548
+						Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
549
+						FeedetlSn:        subItem.FeedetlSn,
550
+						Price:            fmt.Sprintf("%.2f", subItem.Price),
551
+						MedListCodg:      subItem.BaseDrugLib.MedicalInsuranceNumber,
552
+						HospApprFlag:     subItem.BaseDrugLib.HospApprFlag,
553
+					}
554
+
555
+					customs = append(customs, cus)
556
+				}
557
+			}
558
+		}
559
+
560
+		if item.Type == 2 { //项目
561
+			for _, subItem := range item.HisPrescriptionProject {
562
+				//var randNum int
563
+				//randNum = rand.Intn(10000) + 1000
564
+				if len(subItem.HisProject.MedicalCode) > 0 {
565
+
566
+					cus := &Custom{
567
+						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
568
+						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
569
+						FeedetlSn:        subItem.FeedetlSn,
570
+						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
571
+						MedListCodg:      subItem.HisProject.MedicalCode,
572
+						HospApprFlag:     -1,
573
+					}
574
+					customs = append(customs, cus)
575
+				}
576
+			}
577
+		}
578
+
579
+		for _, subItem := range item.HisAdditionalCharge {
580
+			if len(subItem.XtHisAddtionConfig.Code) > 0 {
581
+				cus := &Custom{
582
+					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
583
+					Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
584
+					FeedetlSn:        subItem.FeedetlSn,
585
+					Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
586
+					MedListCodg:      subItem.XtHisAddtionConfig.Code,
587
+					HospApprFlag:     -1,
588
+				}
589
+				customs = append(customs, cus)
590
+			}
591
+		}
592
+	}
593
+
594
+	// 生成输入报文
595
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
596
+	input := make(map[string]interface{})
597
+	feedetail := make([]map[string]interface{}, 0)
598
+	inputMessage["infno"] = "2301" // 交易编码
599
+
600
+	//chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
601
+	for _, item := range customs {
602
+		feedetailInfo := make(map[string]interface{})
603
+		feedetailInfo["feedetl_sn"] = item.FeedetlSn
604
+		feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
605
+		feedetailInfo["psn_no"] = psnNo     // 人员编号 (来自1101接口返回)
606
+		feedetailInfo["med_type"] = med_type
607
+		feedetailInfo["fee_ocur_time"] = timeFormatOne               // 费用发生时间
608
+		feedetailInfo["med_list_codg"] = item.MedListCodg            // 医疗目录编码
609
+		feedetailInfo["medins_list_codg"] = fixmedins_code           // 医药机构目录编码
610
+		feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
611
+		feedetailInfo["cnt"] = item.Cut                              // 数量
612
+		feedetailInfo["pric"] = item.Price                           // 单价
613
+		feedetailInfo["bilg_dept_codg"] = dept_code                  // 开单科室编码
614
+		feedetailInfo["bilg_dept_name"] = dept                       // 开单科室名称
615
+		feedetailInfo["bilg_dr_codg"] = doctor_id                    // 开单医生编码
616
+		feedetailInfo["bilg_dr_name"] = doctor
617
+		feedetailInfo["acord_dept_codg"] = ""    // 受单科室编码
618
+		feedetailInfo["acord_dept_name"] = ""    // 受单科室名称
619
+		feedetailInfo["orders_dr_code"] = ""     // 受单医生编码
620
+		feedetailInfo["orders_dr_name"] = ""     // 受单医生姓名
621
+		feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
622
+		feedetailInfo["dise_codg"] = ""          // 病种编码
623
+		feedetailInfo["rxno"] = ""               // 处方号
624
+		feedetailInfo["rx_circ_flag"] = "0"      // 外购处方标志
625
+		feedetailInfo["sin_dos_dscr"] = ""       // 单次剂量描述
626
+		feedetailInfo["used_frqu_dscr"] = ""     // 使用频次描述
627
+		feedetailInfo["prd_days"] = "0"          // 周期天数
628
+		feedetailInfo["medc_way_dscr"] = ""      // 用药途径描述
629
+		// 开单医师姓名
630
+
631
+		if item.HospApprFlag != -1 {
632
+			if item.HospApprFlag == 1 {
633
+				feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
634
+			} else if item.HospApprFlag == 2 {
635
+				feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
636
+			} else if item.HospApprFlag == 3 {
637
+				feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
638
+			} else {
639
+				feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
640
+			}
641
+		} else {
642
+			feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
643
+		}
644
+
645
+		feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
646
+		feedetailInfo["etip_flag"] = ""        // 外检标志
647
+		feedetailInfo["etip_hosp_code"] = ""   // 外检医院编码
648
+		feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
649
+		feedetailInfo["matn_fee_flag"] = ""    // 生育费用标志
650
+		feedetail = append(feedetail, feedetailInfo)
651
+	}
652
+	input["feedetail"] = feedetail
653
+	inputMessage["input"] = input //交易输入
654
+
655
+	bytesData, err := json.Marshal(inputMessage)
656
+	fmt.Println("----------")
657
+	fmt.Println(string(bytesData))
658
+	fmt.Println("----------")
659
+
660
+	if err != nil {
661
+		fmt.Println(err.Error())
662
+		return ""
663
+	}
664
+	reader := bytes.NewReader(bytesData)
665
+
666
+	gdyb_url := beego.AppConfig.String("gdyb_url")
667
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
668
+	url := gdyb_url + "2301"
669
+	request, err := http.NewRequest("POST", url, reader)
670
+	if err != nil {
671
+		fmt.Println(err.Error())
672
+		return ""
673
+	}
674
+
675
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
676
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
677
+	request.Header.Set("x-tif-signature", signature)
678
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
679
+	request.Header.Set("x-tif-nonce", nonce)
680
+
681
+	client := http.Client{}
682
+	resp, err := client.Do(request)
683
+	if err != nil {
684
+		fmt.Println(err.Error())
685
+		return ""
686
+	}
687
+	respBytes, err := ioutil.ReadAll(resp.Body)
688
+	if err != nil {
689
+		fmt.Println(err.Error())
690
+		return ""
691
+	}
692
+	return string(respBytes)
693
+
694
+}
695
+
696
+//  住院费用明细信息撤销
697
+func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
698
+	// 生成签名
699
+	nonce := GetRandomString(32)
700
+	timestamp := time.Now().Unix()
701
+	signature := setSignature(timestamp, nonce, secret_key)
702
+
703
+	// 生成输入报文
704
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
705
+	input := make(map[string]interface{})
706
+	inputData := make(map[string]interface{})
707
+	inputMessage["infno"] = "2302" // 交易编码
708
+
709
+	inputData["mdtrt_id"] = mdtrtId  // 就诊 ID
710
+	inputData["feedetl_sn"] = "0000" //
711
+	inputData["psn_no"] = psnNo      // 人员编号
712
+
713
+	input["data"] = inputData
714
+	inputMessage["input"] = input //交易输入
715
+
716
+	bytesData, err := json.Marshal(inputMessage)
717
+	fmt.Println(string(bytesData))
718
+	if err != nil {
719
+		fmt.Println(err.Error())
720
+		return err.Error()
721
+	}
722
+	reader := bytes.NewReader(bytesData)
723
+	gdyb_url := beego.AppConfig.String("gdyb_url")
724
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
725
+
726
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
727
+	url := gdyb_url + "2302"
728
+
729
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
730
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
731
+
732
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
733
+	request, err := http.NewRequest("POST", url, reader)
734
+	fmt.Println(err)
735
+
736
+	fmt.Println(request)
737
+	if err != nil {
738
+		fmt.Println(err.Error())
739
+		return err.Error()
740
+	}
741
+
742
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
743
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
744
+	request.Header.Set("x-tif-signature", signature)
745
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
746
+	request.Header.Set("x-tif-nonce", nonce)
747
+
748
+	client := http.Client{}
749
+	resp, err := client.Do(request)
750
+	if err != nil {
751
+		fmt.Println(err.Error())
752
+		return err.Error()
753
+	}
754
+	respBytes, err := ioutil.ReadAll(resp.Body)
755
+	if err != nil {
756
+		fmt.Println(err.Error())
757
+		return err.Error()
758
+	}
759
+	str := string(respBytes)
760
+	fmt.Println(str)
761
+	return str
762
+}
763
+
764
+//  住院结算
765
+func ZHGdyb2304(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
766
+	// 生成签名
767
+	nonce := GetRandomString(32)
768
+	timestamp := time.Now().Unix()
769
+	signature := setSignature(timestamp, nonce, secret_key)
770
+
771
+	// 生成输入报文
772
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
773
+	input := make(map[string]interface{})
774
+	inputData := make(map[string]interface{})
775
+	inputMessage["infno"] = "2304" // 交易编码
776
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
777
+	if certificates == 3 {
778
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
779
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
780
+	} else {
781
+		if id_card_type == 1 {
782
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
783
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
784
+		} else {
785
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
786
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
787
+		}
788
+	}
789
+
790
+	inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
791
+	inputData["medfee_sumamt"] = total         // 医疗费总额
792
+	inputData["psn_setlway"] = "01"            // 个人结算方式 01 按项目结 02 按定额结算
793
+	inputData["mdtrt_id"] = mdtrtId            // 就诊 ID(来自2201接口返回)
794
+	inputData["chrg_bchno"] = chrgBchno        // 收费批次号(来自2204生成的)
795
+	inputData["acct_used_flag"] = "1"          // 个人账户使用标志 0否 1是
796
+	inputData["insutype"] = insutype           // 险种类型
797
+	inputData["invono"] = ""                   // 发票号
798
+
799
+	inputData["mid_setl_flag"] = "" // 中途结算标志
800
+
801
+	inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
802
+	inputData["overlmt_selfpay"] = overlmt_selfpay     //
803
+	inputData["preselfpay_amt"] = preselfpay_amt       //
804
+	inputData["inscp_scp_amt"] = inscp_scp_amt         //
805
+
806
+	input["data"] = inputData
807
+	inputMessage["input"] = input //交易输入
808
+
809
+	bytesData, err := json.Marshal(inputMessage)
810
+	fmt.Println(string(bytesData))
811
+	if err != nil {
812
+		fmt.Println(err.Error())
813
+		return err.Error(), ""
814
+	}
815
+	reader := bytes.NewReader(bytesData)
816
+	gdyb_url := beego.AppConfig.String("gdyb_url")
817
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
818
+
819
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
820
+	url := gdyb_url + "2304"
821
+
822
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
823
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
824
+
825
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
826
+	request, err := http.NewRequest("POST", url, reader)
827
+	if err != nil {
828
+		fmt.Println(err.Error())
829
+		return err.Error(), ""
830
+	}
831
+
832
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
833
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
834
+	request.Header.Set("x-tif-signature", signature)
835
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
836
+	request.Header.Set("x-tif-nonce", nonce)
837
+
838
+	client := http.Client{}
839
+	resp, err := client.Do(request)
840
+	if err != nil {
841
+		fmt.Println(err.Error())
842
+		return err.Error(), ""
843
+	}
844
+	respBytes, err := ioutil.ReadAll(resp.Body)
845
+	if err != nil {
846
+		fmt.Println(err.Error())
847
+		return err.Error(), ""
848
+	}
849
+	str := string(respBytes)
850
+	fmt.Println(str)
851
+	mjson, _ := json.Marshal(inputMessage)
852
+	str2 := string(mjson)
853
+
854
+	return str, str2
855
+}
856
+
857
+//  住院结算撤销
858
+func Gdyb2305(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
859
+	// 生成签名
860
+	nonce := GetRandomString(32)
861
+	timestamp := time.Now().Unix()
862
+	signature := setSignature(timestamp, nonce, secret_key)
863
+
864
+	// 生成输入报文
865
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
866
+	input := make(map[string]interface{})
867
+	inputData := make(map[string]interface{})
868
+	inputMessage["infno"] = "2305" // 交易编码
869
+
870
+	inputData["psn_no"] = psnNo     // 人员编号 (来自1101接口返回)
871
+	inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
872
+	inputData["setl_id"] = setlId   // 结算 ID
873
+
874
+	input["data"] = inputData
875
+	inputMessage["input"] = input //交易输入
876
+
877
+	bytesData, err := json.Marshal(inputMessage)
878
+	fmt.Println(string(bytesData))
879
+	if err != nil {
880
+		fmt.Println(err.Error())
881
+		return err.Error(), ""
882
+	}
883
+	reader := bytes.NewReader(bytesData)
884
+	gdyb_url := beego.AppConfig.String("gdyb_url")
885
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
886
+	url := gdyb_url + "2305"
887
+	request, err := http.NewRequest("POST", url, reader)
888
+	if err != nil {
889
+		fmt.Println(err.Error())
890
+		return err.Error(), ""
891
+	}
892
+
893
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
894
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
895
+	request.Header.Set("x-tif-signature", signature)
896
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
897
+	request.Header.Set("x-tif-nonce", nonce)
898
+
899
+	client := http.Client{}
900
+	resp, err := client.Do(request)
901
+	if err != nil {
902
+		fmt.Println(err.Error())
903
+		return err.Error(), ""
904
+	}
905
+	respBytes, err := ioutil.ReadAll(resp.Body)
906
+	if err != nil {
907
+		fmt.Println(err.Error())
908
+		return err.Error(), ""
909
+	}
910
+	str := string(respBytes)
911
+	fmt.Println(str)
912
+	mjson, _ := json.Marshal(inputMessage)
913
+	str2 := string(mjson)
914
+	return str, str2
915
+}
916
+
917
+func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
918
+	err = writeDb.Save(&record).Error
919
+	return
920
+}
921
+
922
+func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err error) {
923
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
924
+	return
925
+}
926
+
927
+func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
928
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 AND user_org_id = ?", id, user_org_id).Last(&record).Error
929
+	return
930
+}