瀏覽代碼

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 4 年之前
父節點
當前提交
c9294b38ff
共有 4 個文件被更改,包括 162 次插入116 次删除
  1. 42 9
      controllers/gdyb_controller.go
  2. 14 4
      controllers/his_api_controller.go
  3. 14 11
      models/his_models.go
  4. 92 92
      service/gdyb_service.go

+ 42 - 9
controllers/gdyb_controller.go 查看文件

@@ -72,7 +72,12 @@ func (c *GdybController) PostOne() {
72 72
 	doctor := c.GetString("doctor")
73 73
 	fixmedins_code := c.GetString("fixmedins_code")
74 74
 
75
-	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code)
75
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
76
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
77
+
78
+	secret_key := c.GetString("secret_key")
79
+
80
+	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
76 81
 
77 82
 	var dat map[string]interface{}
78 83
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -94,7 +99,15 @@ func (c *GdybController) PostTwo() {
94 99
 	dept := c.GetString("dept")
95 100
 	fixmedins_code := c.GetString("fixmedins_code")
96 101
 
97
-	result := service.Gdyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code)
102
+	dept_code := c.GetString("dept_code")
103
+	doctor_id := c.GetString("doctor_id")
104
+
105
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
106
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
107
+
108
+	secret_key := c.GetString("secret_key")
109
+
110
+	result := service.Gdyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key)
98 111
 
99 112
 	var dat map[string]interface{}
100 113
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -113,8 +126,12 @@ func (c *GdybController) PostThree() {
113 126
 	iptOtpNo := c.GetString("ipt_otp_no")
114 127
 	org_name := c.GetString("org_name")
115 128
 	doctor := c.GetString("doctor")
129
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
130
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
116 131
 
117
-	result := service.Gdyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor)
132
+	secret_key := c.GetString("secret_key")
133
+
134
+	result := service.Gdyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key)
118 135
 	c.ServeSuccessJSON(map[string]interface{}{
119 136
 		"pre": result,
120 137
 	})
@@ -131,7 +148,12 @@ func (c *GdybController) PostFour() {
131 148
 	doctor_id, _ := c.GetInt64("doctor_id", 0)
132 149
 	fixmedins_code := c.GetString("fixmedins_code")
133 150
 
134
-	result := service.Gdyb2203(psnNo, mdtrtId, doctor, department, diag, org_name, med_type, doctor_id, fixmedins_code)
151
+	diag_code := c.GetString("diag_code")
152
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
153
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
154
+	secret_key := c.GetString("secret_key")
155
+
156
+	result := service.Gdyb2203(psnNo, mdtrtId, doctor, department, diag, org_name, med_type, doctor_id, fixmedins_code, diag_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
135 157
 	var dat map[string]interface{}
136 158
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
137 159
 	} else {
@@ -179,7 +201,8 @@ func (c *GdybController) PostFive() {
179 201
 		return
180 202
 	}
181 203
 
182
-	result := service.Gdyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string), respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string))
204
+	result := service.Gdyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
205
+		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))
183 206
 
184 207
 	var dat map[string]interface{}
185 208
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -199,7 +222,12 @@ func (c *GdybController) PostSix() {
199 222
 	org_name := c.GetString("org_name")
200 223
 	doctor := c.GetString("doctor")
201 224
 
202
-	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor)
225
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
226
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
227
+
228
+	secret_key := c.GetString("secret_key")
229
+
230
+	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key)
203 231
 
204 232
 	c.ServeSuccessJSON(map[string]interface{}{
205 233
 		"pre": result,
@@ -215,8 +243,9 @@ func (c *GdybController) PostSeven() {
215 243
 	total := c.GetString("total")
216 244
 	org_name := c.GetString("org_name")
217 245
 	doctor := c.GetString("doctor")
246
+	secret_key := c.GetString("secret_key")
218 247
 
219
-	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor)
248
+	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
220 249
 	var dat map[string]interface{}
221 250
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
222 251
 		fmt.Println(dat)
@@ -238,8 +267,11 @@ func (c *GdybController) PostEight() {
238 267
 	org_name := c.GetString("org_name")
239 268
 	doctor := c.GetString("doctor")
240 269
 	fixmedins_code := c.GetString("fixmedins_code")
270
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
271
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
272
+	secret_key := c.GetString("secret_key")
241 273
 
242
-	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code)
274
+	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
243 275
 	var dat map[string]interface{}
244 276
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
245 277
 		fmt.Println(dat)
@@ -258,8 +290,9 @@ func (c *GdybController) PostNine() {
258 290
 	setlId := c.GetString("setl_id")
259 291
 	org_name := c.GetString("org_name")
260 292
 	doctor := c.GetString("doctor")
293
+	secret_key := c.GetString("secret_key")
261 294
 
262
-	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor)
295
+	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key)
263 296
 	c.ServeSuccessJSON(map[string]interface{}{
264 297
 		"pre": result,
265 298
 	})

+ 14 - 4
controllers/his_api_controller.go 查看文件

@@ -1300,7 +1300,7 @@ func (c *HisApiController) GetRegisterInfo() {
1300 1300
 
1301 1301
 	if config.IsOpen == 1 {
1302 1302
 
1303
-		api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code
1303
+		api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1304 1304
 		resp, requestErr := http.Get(api)
1305 1305
 
1306 1306
 		if requestErr != nil {
@@ -1366,11 +1366,14 @@ func (c *HisApiController) GetRegisterInfo() {
1366 1366
 
1367 1367
 		department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1368 1368
 
1369
+		//department_id := strconv.FormatInt(department.ID, 10)
1370
+		doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1371
+
1369 1372
 		if count <= 0 {
1370 1373
 			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1371 1374
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1372 1375
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1373
-				"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code
1376
+				"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1374 1377
 			resp, requestErr := http.Get(api)
1375 1378
 			if requestErr != nil {
1376 1379
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1424,7 +1427,8 @@ func (c *HisApiController) GetRegisterInfo() {
1424 1427
 			if err == nil {
1425 1428
 				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
1426 1429
 					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1427
-					"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code
1430
+					"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
1431
+					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1428 1432
 				resp, requestErr := http.Get(api)
1429 1433
 				if requestErr != nil {
1430 1434
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1551,7 +1555,9 @@ func (c *HisApiController) GetUploadInfo() {
1551 1555
 
1552 1556
 	//org, _ := service.GetOrgById(adminUser.CurrentOrgId)
1553 1557
 	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
1558
+	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1554 1559
 
1560
+	strconv.FormatInt(his.PatientId, 10)
1555 1561
 	client := &http.Client{}
1556 1562
 	data := make(map[string]interface{})
1557 1563
 	data["psn_no"] = his.PsnNo
@@ -1563,6 +1569,10 @@ func (c *HisApiController) GetUploadInfo() {
1563 1569
 	data["dept"] = patientPrescription.Departments
1564 1570
 
1565 1571
 	data["fixmedins_code"] = miConfig.Code
1572
+	data["dept_code"] = department.Number
1573
+	data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
1574
+	data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
1575
+	data["secret_key"] = miConfig.SecretKey
1566 1576
 
1567 1577
 	var ids []int64
1568 1578
 	//var idsTwo []int64
@@ -1713,7 +1723,7 @@ func (c *HisApiController) GetUploadInfo() {
1713 1723
 				insutype := rf[0].Insutype
1714 1724
 				api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
1715 1725
 					insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
1716
-					"&total=" + allTotal + "&org_name=" + org.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code
1726
+					"&total=" + allTotal + "&org_name=" + org.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1717 1727
 				resp, requestErr := http.Get(api)
1718 1728
 
1719 1729
 				if requestErr != nil {

+ 14 - 11
models/his_models.go 查看文件

@@ -756,17 +756,20 @@ func (HisOrderError) TableName() string {
756 756
 }
757 757
 
758 758
 type MedicalInsuranceOrgConfig struct {
759
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
760
-	Code          string `gorm:"column:code" json:"code" form:"code"`
761
-	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
762
-	Vpn           string `gorm:"column:vpn" json:"vpn" form:"vpn"`
763
-	EleCardId     string `gorm:"column:ele_card_id" json:"ele_card_id" form:"ele_card_id"`
764
-	EleCardKey    string `gorm:"column:ele_card_key" json:"ele_card_key" form:"ele_card_key"`
765
-	ChannelNumber string `gorm:"column:channel_number" json:"channel_number" form:"channel_number"`
766
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
767
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
768
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
769
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
759
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
760
+	Code           string `gorm:"column:code" json:"code" form:"code"`
761
+	OrgName        string `gorm:"column:org_name" json:"org_name" form:"org_name"`
762
+	Vpn            string `gorm:"column:vpn" json:"vpn" form:"vpn"`
763
+	EleCardId      string `gorm:"column:ele_card_id" json:"ele_card_id" form:"ele_card_id"`
764
+	EleCardKey     string `gorm:"column:ele_card_key" json:"ele_card_key" form:"ele_card_key"`
765
+	ChannelNumber  string `gorm:"column:channel_number" json:"channel_number" form:"channel_number"`
766
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
767
+	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
768
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
769
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
770
+	MdtrtareaAdmvs string `gorm:"column:mdtrtarea_admvs" json:"mdtrtarea_admvs" form:"mdtrtarea_admvs"`
771
+	InsuplcAdmdvs  string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
772
+	SecretKey      string `gorm:"column:secret_key" json:"secret_key" form:"secret_key"`
770 773
 }
771 774
 
772 775
 func (MedicalInsuranceOrgConfig) TableName() string {

+ 92 - 92
service/gdyb_service.go 查看文件

@@ -20,14 +20,14 @@ const (
20 20
 )
21 21
 
22 22
 // 人员基本信息
23
-func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string) string {
23
+func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
24 24
 	// 生成签名
25 25
 	nonce := GetRandomString(32)
26 26
 	timestamp := time.Now().Unix()
27
-	signature := setSignature(timestamp, nonce)
27
+	signature := setSignature(timestamp, nonce, secret_key)
28 28
 
29 29
 	// 生成输入报文
30
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code)
30
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
31 31
 	input := make(map[string]interface{})
32 32
 	inputData := make(map[string]interface{})
33 33
 	inputMessage["infno"] = "1101"      // 交易编码
@@ -79,16 +79,16 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
79 79
 }
80 80
 
81 81
 // 门诊挂号
82
-func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doctor string, ipt_otp_no string, dept string, fixmedins_code string) string {
82
+func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doctor string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
83 83
 	// 生成签名
84 84
 	nonce := GetRandomString(32)
85 85
 	timestamp := time.Now().Unix()
86
-	signature := setSignature(timestamp, nonce)
86
+	signature := setSignature(timestamp, nonce, secret_key)
87 87
 	tempTime := time.Unix(timestamp, 0)
88 88
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
89 89
 
90 90
 	// 生成输入报文
91
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code)
91
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
92 92
 	input := make(map[string]interface{})
93 93
 	inputData := make(map[string]interface{})
94 94
 	inputMessage["infno"] = "2201"        // 交易编码
@@ -98,9 +98,9 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doc
98 98
 	inputData["mdtrt_cert_type"] = "02"   // 就诊凭证类型
99 99
 	inputData["mdtrt_cert_no"] = certNo   // 就诊凭证编号
100 100
 	inputData["ipt_otp_no"] = ipt_otp_no  // 住院/门诊号
101
-	inputData["atddr_no"] = "1002"        // 医师编码
101
+	inputData["atddr_no"] = doctor_id     // 医师编码
102 102
 	inputData["dr_name"] = doctor         // 医师姓名
103
-	inputData["dept_code"] = "3002"       // 科室编码
103
+	inputData["dept_code"] = dept_code    // 科室编码
104 104
 	inputData["dept_name"] = dept         // 科室名称
105 105
 	inputData["caty"] = "A03.06"          // 科别
106 106
 
@@ -145,14 +145,14 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doc
145 145
 }
146 146
 
147 147
 // 门诊挂号撤销
148
-func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string) string {
148
+func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
149 149
 	// 生成签名
150 150
 	nonce := GetRandomString(32)
151 151
 	timestamp := time.Now().Unix()
152
-	signature := setSignature(timestamp, nonce)
152
+	signature := setSignature(timestamp, nonce, secret_key)
153 153
 
154 154
 	// 生成输入报文
155
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
155
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", insuplc_admdvs, mdtrtarea_admvs)
156 156
 	input := make(map[string]interface{})
157 157
 	inputData := make(map[string]interface{})
158 158
 	inputMessage["infno"] = "2202"       // 交易编码
@@ -201,16 +201,16 @@ func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string,
201 201
 }
202 202
 
203 203
 // 门诊就诊信息上传
204
-func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, diag string, org_name string, med_type string, doctor_id int64, fixmedins_code string) string {
204
+func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, diag string, org_name string, med_type string, doctor_id int64, fixmedins_code string, diag_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
205 205
 	// 生成签名
206 206
 	nonce := GetRandomString(32)
207 207
 	timestamp := time.Now().Unix()
208
-	signature := setSignature(timestamp, nonce)
208
+	signature := setSignature(timestamp, nonce, secret_key)
209 209
 	tempTime := time.Unix(timestamp, 0)
210 210
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
211 211
 
212 212
 	// 生成输入报文
213
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code)
213
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
214 214
 	input := make(map[string]interface{})
215 215
 	inputData := make(map[string]interface{})
216 216
 	diseinfo := make([]map[string]interface{}, 0)
@@ -229,7 +229,7 @@ func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, di
229 229
 	diseinfo_sun := make(map[string]interface{})
230 230
 	diseinfo_sun["diag_type"] = "1"           // 诊断类别
231 231
 	diseinfo_sun["diag_srt_no"] = "1"         // 诊断排序号
232
-	diseinfo_sun["diag_code"] = "A04.902"     // 诊断代码
232
+	diseinfo_sun["diag_code"] = diag_code     // 诊断代码
233 233
 	diseinfo_sun["diag_name"] = diag          // 诊断名称
234 234
 	diseinfo_sun["diag_dept"] = department    // 诊断科室
235 235
 	diseinfo_sun["dise_dor_no"] = doctor_id   // 诊断医生编码
@@ -334,11 +334,11 @@ type Result struct {
334 334
 }
335 335
 
336 336
 //  门诊费用明细信息上传
337
-func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string) string {
337
+func Gdyb2204(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) string {
338 338
 	// 生成签名
339 339
 	nonce := GetRandomString(32)
340 340
 	timestamp := time.Now().Unix()
341
-	signature := setSignature(timestamp, nonce)
341
+	signature := setSignature(timestamp, nonce, secret_key)
342 342
 	tempTime := time.Unix(timestamp, 0)
343 343
 	//timeFormat := tempTime.Format("20060102150405")
344 344
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
@@ -398,7 +398,7 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
398 398
 	}
399 399
 
400 400
 	// 生成输入报文
401
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code)
401
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
402 402
 	input := make(map[string]interface{})
403 403
 	feedetail := make([]map[string]interface{}, 0)
404 404
 	inputMessage["infno"] = "2204" // 交易编码
@@ -423,9 +423,9 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
423 423
 		feedetailInfo["used_frqu_dscr"] = ""                         // 使用频次描述
424 424
 		feedetailInfo["prd_days"] = "0"                              // 周期天数
425 425
 		feedetailInfo["medc_way_dscr"] = ""                          // 用药途径描述
426
-		feedetailInfo["bilg_dept_codg"] = "3002"                     // 开单科室编码
426
+		feedetailInfo["bilg_dept_codg"] = dept_code                  // 开单科室编码
427 427
 		feedetailInfo["bilg_dept_name"] = dept                       // 开单科室名称
428
-		feedetailInfo["bilg_dr_codg"] = "1002"                       // 开单医生编码
428
+		feedetailInfo["bilg_dr_codg"] = doctor_id                    // 开单医生编码
429 429
 		feedetailInfo["bilg_dr_name"] = doctor                       // 开单医师姓名
430 430
 		feedetailInfo["acord_dept_codg"] = ""                        // 受单科室编码
431 431
 		feedetailInfo["acord_dept_name"] = ""                        // 受单科室名称
@@ -484,14 +484,14 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
484 484
 }
485 485
 
486 486
 //  门诊费用明细信息撤销
487
-func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string) string {
487
+func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
488 488
 	// 生成签名
489 489
 	nonce := GetRandomString(32)
490 490
 	timestamp := time.Now().Unix()
491
-	signature := setSignature(timestamp, nonce)
491
+	signature := setSignature(timestamp, nonce, secret_key)
492 492
 
493 493
 	// 生成输入报文
494
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
494
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", insuplc_admdvs, mdtrtarea_admvs)
495 495
 	input := make(map[string]interface{})
496 496
 	inputData := make(map[string]interface{})
497 497
 	inputMessage["infno"] = "2205" // 交易编码
@@ -544,14 +544,14 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
544 544
 }
545 545
 
546 546
 //  门诊预结算
547
-func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string) string {
547
+func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
548 548
 	// 生成签名
549 549
 	nonce := GetRandomString(32)
550 550
 	timestamp := time.Now().Unix()
551
-	signature := setSignature(timestamp, nonce)
551
+	signature := setSignature(timestamp, nonce, secret_key)
552 552
 
553 553
 	// 生成输入报文
554
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
554
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", "", "")
555 555
 	input := make(map[string]interface{})
556 556
 	inputData := make(map[string]interface{})
557 557
 	inputMessage["infno"] = "2206" // 交易编码
@@ -608,14 +608,14 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
608 608
 }
609 609
 
610 610
 //  门诊结算
611
-func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string) string {
611
+func Gdyb2207(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) string {
612 612
 	// 生成签名
613 613
 	nonce := GetRandomString(32)
614 614
 	timestamp := time.Now().Unix()
615
-	signature := setSignature(timestamp, nonce)
615
+	signature := setSignature(timestamp, nonce, secret_key)
616 616
 
617 617
 	// 生成输入报文
618
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code)
618
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
619 619
 	input := make(map[string]interface{})
620 620
 	inputData := make(map[string]interface{})
621 621
 	inputMessage["infno"] = "2207" // 交易编码
@@ -673,14 +673,14 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
673 673
 }
674 674
 
675 675
 //  门诊结算撤销
676
-func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string) string {
676
+func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string) string {
677 677
 	// 生成签名
678 678
 	nonce := GetRandomString(32)
679 679
 	timestamp := time.Now().Unix()
680
-	signature := setSignature(timestamp, nonce)
680
+	signature := setSignature(timestamp, nonce, secret_key)
681 681
 
682 682
 	// 生成输入报文
683
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
683
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", "", "")
684 684
 	input := make(map[string]interface{})
685 685
 	inputData := make(map[string]interface{})
686 686
 	inputMessage["infno"] = "2208" // 交易编码
@@ -924,8 +924,8 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
924 924
 //}
925 925
 
926 926
 // 生成签名
927
-func setSignature(timestamp int64, nonce string) string {
928
-	str := strconv.FormatInt(timestamp, 10) + SceretKey + nonce + strconv.FormatInt(timestamp, 10)
927
+func setSignature(timestamp int64, nonce string, secret_key string) string {
928
+	str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
929 929
 	hash := sha256.New()
930 930
 	//输入数据
931 931
 	hash.Write([]byte(str))
@@ -950,7 +950,7 @@ func GetRandomString(l int) string {
950 950
 }
951 951
 
952 952
 // 生成基础报文
953
-func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string) map[string]interface{} {
953
+func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
954 954
 	// 生成签名
955 955
 	tempTime := time.Unix(timestamp, 0)
956 956
 	timeFormat := tempTime.Format("20060102150405")
@@ -962,8 +962,8 @@ func SetInputMessage(nonce string, timestamp int64, org_name string, doctor stri
962 962
 
963 963
 	inputMessage["infno"] = "1101"                                                              // 交易编码
964 964
 	inputMessage["msgid"] = fixmedins_code + timeFormat + strconv.FormatInt(int64(randNum), 10) // 发送方报文 ID
965
-	inputMessage["mdtrtarea_admvs"] = "440200"                                                  // 就医地医保区划
966
-	inputMessage["insuplc_admdvs"] = "440200"                                                   // 参保地医保区划
965
+	inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs                                           // 就医地医保区划
966
+	inputMessage["insuplc_admdvs"] = insuplc_admdvs                                             // 参保地医保区划
967 967
 	inputMessage["recer_sys_code"] = "01"                                                       // 接收方系统代码
968 968
 	inputMessage["dev_no"] = ""                                                                 // 设备编号
969 969
 	inputMessage["dev_safe_info"] = ""                                                          // 设备安全信息
@@ -971,7 +971,7 @@ func SetInputMessage(nonce string, timestamp int64, org_name string, doctor stri
971 971
 	inputMessage["signtype"] = ""                                                               // 签名类型
972 972
 	inputMessage["infver"] = "V1.1"                                                             // 接收方系统代码
973 973
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
974
-	inputMessage["opter"] = "mockuser"                                                          // 经办人
974
+	inputMessage["opter"] = doctor                                                              // 经办人
975 975
 	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
976 976
 	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
977 977
 	inputMessage["fixmedins_code"] = fixmedins_code                                             // 定点医药机构编号
@@ -980,57 +980,57 @@ func SetInputMessage(nonce string, timestamp int64, org_name string, doctor stri
980 980
 	return inputMessage
981 981
 }
982 982
 
983
-func Gdyb1201(psnNo string, org_name string, doctor string) string {
984
-	// 生成签名
985
-	nonce := GetRandomString(32)
986
-	timestamp := time.Now().Unix()
987
-	signature := setSignature(timestamp, nonce)
988
-
989
-	// 生成输入报文
990
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
991
-	input := make(map[string]interface{})
992
-	inputData := make(map[string]interface{})
993
-	inputMessage["infno"] = "1201"         // 交易编码
994
-	inputData["fixmedins_type"] = psnNo    // 人员编号 (来自1101接口返回)
995
-	inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
996
-	inputData["fixmedins_code"] = ""       // 人员编号 (来自1101接口返回)
997
-
998
-	input["medinsinfo"] = inputData
999
-	inputMessage["input"] = input //交易输入
1000
-
1001
-	bytesData, err := json.Marshal(inputMessage)
1002
-	fmt.Println(string(bytesData))
1003
-	if err != nil {
1004
-		fmt.Println(err.Error())
1005
-		return err.Error()
1006
-	}
1007
-	reader := bytes.NewReader(bytesData)
1008
-
1009
-	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
1010
-	request, err := http.NewRequest("POST", url, reader)
1011
-	if err != nil {
1012
-		fmt.Println(err.Error())
1013
-		return err.Error()
1014
-	}
1015
-
1016
-	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1017
-	request.Header.Set("x-tif-paasid", "test_hosp")
1018
-	request.Header.Set("x-tif-signature", signature)
1019
-	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1020
-	request.Header.Set("x-tif-nonce", nonce)
1021
-
1022
-	client := http.Client{}
1023
-	resp, err := client.Do(request)
1024
-	if err != nil {
1025
-		fmt.Println(err.Error())
1026
-		return err.Error()
1027
-	}
1028
-	respBytes, err := ioutil.ReadAll(resp.Body)
1029
-	if err != nil {
1030
-		fmt.Println(err.Error())
1031
-		return err.Error()
1032
-	}
1033
-	str := string(respBytes)
1034
-	fmt.Println(str)
1035
-	return str
1036
-}
983
+//func Gdyb1201(psnNo string, org_name string, doctor string) string {
984
+//	// 生成签名
985
+//	nonce := GetRandomString(32)
986
+//	timestamp := time.Now().Unix()
987
+//	signature := setSignature(timestamp, nonce)
988
+//
989
+//	// 生成输入报文
990
+//	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
991
+//	input := make(map[string]interface{})
992
+//	inputData := make(map[string]interface{})
993
+//	inputMessage["infno"] = "1201"         // 交易编码
994
+//	inputData["fixmedins_type"] = psnNo    // 人员编号 (来自1101接口返回)
995
+//	inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
996
+//	inputData["fixmedins_code"] = ""       // 人员编号 (来自1101接口返回)
997
+//
998
+//	input["medinsinfo"] = inputData
999
+//	inputMessage["input"] = input //交易输入
1000
+//
1001
+//	bytesData, err := json.Marshal(inputMessage)
1002
+//	fmt.Println(string(bytesData))
1003
+//	if err != nil {
1004
+//		fmt.Println(err.Error())
1005
+//		return err.Error()
1006
+//	}
1007
+//	reader := bytes.NewReader(bytesData)
1008
+//
1009
+//	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
1010
+//	request, err := http.NewRequest("POST", url, reader)
1011
+//	if err != nil {
1012
+//		fmt.Println(err.Error())
1013
+//		return err.Error()
1014
+//	}
1015
+//
1016
+//	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
1017
+//	request.Header.Set("x-tif-paasid", "test_hosp")
1018
+//	request.Header.Set("x-tif-signature", signature)
1019
+//	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
1020
+//	request.Header.Set("x-tif-nonce", nonce)
1021
+//
1022
+//	client := http.Client{}
1023
+//	resp, err := client.Do(request)
1024
+//	if err != nil {
1025
+//		fmt.Println(err.Error())
1026
+//		return err.Error()
1027
+//	}
1028
+//	respBytes, err := ioutil.ReadAll(resp.Body)
1029
+//	if err != nil {
1030
+//		fmt.Println(err.Error())
1031
+//		return err.Error()
1032
+//	}
1033
+//	str := string(respBytes)
1034
+//	fmt.Println(str)
1035
+//	return str
1036
+//}