Преглед изворни кода

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
 	doctor := c.GetString("doctor")
72
 	doctor := c.GetString("doctor")
73
 	fixmedins_code := c.GetString("fixmedins_code")
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
 	var dat map[string]interface{}
82
 	var dat map[string]interface{}
78
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
83
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
94
 	dept := c.GetString("dept")
99
 	dept := c.GetString("dept")
95
 	fixmedins_code := c.GetString("fixmedins_code")
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
 	var dat map[string]interface{}
112
 	var dat map[string]interface{}
100
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
113
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
113
 	iptOtpNo := c.GetString("ipt_otp_no")
126
 	iptOtpNo := c.GetString("ipt_otp_no")
114
 	org_name := c.GetString("org_name")
127
 	org_name := c.GetString("org_name")
115
 	doctor := c.GetString("doctor")
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
 	c.ServeSuccessJSON(map[string]interface{}{
135
 	c.ServeSuccessJSON(map[string]interface{}{
119
 		"pre": result,
136
 		"pre": result,
120
 	})
137
 	})
131
 	doctor_id, _ := c.GetInt64("doctor_id", 0)
148
 	doctor_id, _ := c.GetInt64("doctor_id", 0)
132
 	fixmedins_code := c.GetString("fixmedins_code")
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
 	var dat map[string]interface{}
157
 	var dat map[string]interface{}
136
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
158
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
137
 	} else {
159
 	} else {
179
 		return
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
 	var dat map[string]interface{}
207
 	var dat map[string]interface{}
185
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
208
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
199
 	org_name := c.GetString("org_name")
222
 	org_name := c.GetString("org_name")
200
 	doctor := c.GetString("doctor")
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
 	c.ServeSuccessJSON(map[string]interface{}{
232
 	c.ServeSuccessJSON(map[string]interface{}{
205
 		"pre": result,
233
 		"pre": result,
215
 	total := c.GetString("total")
243
 	total := c.GetString("total")
216
 	org_name := c.GetString("org_name")
244
 	org_name := c.GetString("org_name")
217
 	doctor := c.GetString("doctor")
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
 	var dat map[string]interface{}
249
 	var dat map[string]interface{}
221
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
250
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
222
 		fmt.Println(dat)
251
 		fmt.Println(dat)
238
 	org_name := c.GetString("org_name")
267
 	org_name := c.GetString("org_name")
239
 	doctor := c.GetString("doctor")
268
 	doctor := c.GetString("doctor")
240
 	fixmedins_code := c.GetString("fixmedins_code")
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
 	var dat map[string]interface{}
275
 	var dat map[string]interface{}
244
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
276
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
245
 		fmt.Println(dat)
277
 		fmt.Println(dat)
258
 	setlId := c.GetString("setl_id")
290
 	setlId := c.GetString("setl_id")
259
 	org_name := c.GetString("org_name")
291
 	org_name := c.GetString("org_name")
260
 	doctor := c.GetString("doctor")
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
 	c.ServeSuccessJSON(map[string]interface{}{
296
 	c.ServeSuccessJSON(map[string]interface{}{
264
 		"pre": result,
297
 		"pre": result,
265
 	})
298
 	})

+ 14 - 4
controllers/his_api_controller.go Прегледај датотеку

1300
 
1300
 
1301
 	if config.IsOpen == 1 {
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
 		resp, requestErr := http.Get(api)
1304
 		resp, requestErr := http.Get(api)
1305
 
1305
 
1306
 		if requestErr != nil {
1306
 		if requestErr != nil {
1366
 
1366
 
1367
 		department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
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
 		if count <= 0 {
1372
 		if count <= 0 {
1370
 			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1373
 			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1371
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1374
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1372
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
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
 			resp, requestErr := http.Get(api)
1377
 			resp, requestErr := http.Get(api)
1375
 			if requestErr != nil {
1378
 			if requestErr != nil {
1376
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1379
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1424
 			if err == nil {
1427
 			if err == nil {
1425
 				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
1428
 				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
1426
 					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
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
 				resp, requestErr := http.Get(api)
1432
 				resp, requestErr := http.Get(api)
1429
 				if requestErr != nil {
1433
 				if requestErr != nil {
1430
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1434
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1551
 
1555
 
1552
 	//org, _ := service.GetOrgById(adminUser.CurrentOrgId)
1556
 	//org, _ := service.GetOrgById(adminUser.CurrentOrgId)
1553
 	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
1557
 	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
1558
+	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1554
 
1559
 
1560
+	strconv.FormatInt(his.PatientId, 10)
1555
 	client := &http.Client{}
1561
 	client := &http.Client{}
1556
 	data := make(map[string]interface{})
1562
 	data := make(map[string]interface{})
1557
 	data["psn_no"] = his.PsnNo
1563
 	data["psn_no"] = his.PsnNo
1563
 	data["dept"] = patientPrescription.Departments
1569
 	data["dept"] = patientPrescription.Departments
1564
 
1570
 
1565
 	data["fixmedins_code"] = miConfig.Code
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
 	var ids []int64
1577
 	var ids []int64
1568
 	//var idsTwo []int64
1578
 	//var idsTwo []int64
1713
 				insutype := rf[0].Insutype
1723
 				insutype := rf[0].Insutype
1714
 				api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
1724
 				api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
1715
 					insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
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
 				resp, requestErr := http.Get(api)
1727
 				resp, requestErr := http.Get(api)
1718
 
1728
 
1719
 				if requestErr != nil {
1729
 				if requestErr != nil {

+ 14 - 11
models/his_models.go Прегледај датотеку

756
 }
756
 }
757
 
757
 
758
 type MedicalInsuranceOrgConfig struct {
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
 func (MedicalInsuranceOrgConfig) TableName() string {
775
 func (MedicalInsuranceOrgConfig) TableName() string {

+ 92 - 92
service/gdyb_service.go Прегледај датотеку

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
 	nonce := GetRandomString(32)
25
 	nonce := GetRandomString(32)
26
 	timestamp := time.Now().Unix()
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
 	input := make(map[string]interface{})
31
 	input := make(map[string]interface{})
32
 	inputData := make(map[string]interface{})
32
 	inputData := make(map[string]interface{})
33
 	inputMessage["infno"] = "1101"      // 交易编码
33
 	inputMessage["infno"] = "1101"      // 交易编码
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
 	nonce := GetRandomString(32)
84
 	nonce := GetRandomString(32)
85
 	timestamp := time.Now().Unix()
85
 	timestamp := time.Now().Unix()
86
-	signature := setSignature(timestamp, nonce)
86
+	signature := setSignature(timestamp, nonce, secret_key)
87
 	tempTime := time.Unix(timestamp, 0)
87
 	tempTime := time.Unix(timestamp, 0)
88
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
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
 	input := make(map[string]interface{})
92
 	input := make(map[string]interface{})
93
 	inputData := make(map[string]interface{})
93
 	inputData := make(map[string]interface{})
94
 	inputMessage["infno"] = "2201"        // 交易编码
94
 	inputMessage["infno"] = "2201"        // 交易编码
98
 	inputData["mdtrt_cert_type"] = "02"   // 就诊凭证类型
98
 	inputData["mdtrt_cert_type"] = "02"   // 就诊凭证类型
99
 	inputData["mdtrt_cert_no"] = certNo   // 就诊凭证编号
99
 	inputData["mdtrt_cert_no"] = certNo   // 就诊凭证编号
100
 	inputData["ipt_otp_no"] = ipt_otp_no  // 住院/门诊号
100
 	inputData["ipt_otp_no"] = ipt_otp_no  // 住院/门诊号
101
-	inputData["atddr_no"] = "1002"        // 医师编码
101
+	inputData["atddr_no"] = doctor_id     // 医师编码
102
 	inputData["dr_name"] = doctor         // 医师姓名
102
 	inputData["dr_name"] = doctor         // 医师姓名
103
-	inputData["dept_code"] = "3002"       // 科室编码
103
+	inputData["dept_code"] = dept_code    // 科室编码
104
 	inputData["dept_name"] = dept         // 科室名称
104
 	inputData["dept_name"] = dept         // 科室名称
105
 	inputData["caty"] = "A03.06"          // 科别
105
 	inputData["caty"] = "A03.06"          // 科别
106
 
106
 
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
 	nonce := GetRandomString(32)
150
 	nonce := GetRandomString(32)
151
 	timestamp := time.Now().Unix()
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
 	input := make(map[string]interface{})
156
 	input := make(map[string]interface{})
157
 	inputData := make(map[string]interface{})
157
 	inputData := make(map[string]interface{})
158
 	inputMessage["infno"] = "2202"       // 交易编码
158
 	inputMessage["infno"] = "2202"       // 交易编码
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
 	nonce := GetRandomString(32)
206
 	nonce := GetRandomString(32)
207
 	timestamp := time.Now().Unix()
207
 	timestamp := time.Now().Unix()
208
-	signature := setSignature(timestamp, nonce)
208
+	signature := setSignature(timestamp, nonce, secret_key)
209
 	tempTime := time.Unix(timestamp, 0)
209
 	tempTime := time.Unix(timestamp, 0)
210
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
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
 	input := make(map[string]interface{})
214
 	input := make(map[string]interface{})
215
 	inputData := make(map[string]interface{})
215
 	inputData := make(map[string]interface{})
216
 	diseinfo := make([]map[string]interface{}, 0)
216
 	diseinfo := make([]map[string]interface{}, 0)
229
 	diseinfo_sun := make(map[string]interface{})
229
 	diseinfo_sun := make(map[string]interface{})
230
 	diseinfo_sun["diag_type"] = "1"           // 诊断类别
230
 	diseinfo_sun["diag_type"] = "1"           // 诊断类别
231
 	diseinfo_sun["diag_srt_no"] = "1"         // 诊断排序号
231
 	diseinfo_sun["diag_srt_no"] = "1"         // 诊断排序号
232
-	diseinfo_sun["diag_code"] = "A04.902"     // 诊断代码
232
+	diseinfo_sun["diag_code"] = diag_code     // 诊断代码
233
 	diseinfo_sun["diag_name"] = diag          // 诊断名称
233
 	diseinfo_sun["diag_name"] = diag          // 诊断名称
234
 	diseinfo_sun["diag_dept"] = department    // 诊断科室
234
 	diseinfo_sun["diag_dept"] = department    // 诊断科室
235
 	diseinfo_sun["dise_dor_no"] = doctor_id   // 诊断医生编码
235
 	diseinfo_sun["dise_dor_no"] = doctor_id   // 诊断医生编码
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
 	nonce := GetRandomString(32)
339
 	nonce := GetRandomString(32)
340
 	timestamp := time.Now().Unix()
340
 	timestamp := time.Now().Unix()
341
-	signature := setSignature(timestamp, nonce)
341
+	signature := setSignature(timestamp, nonce, secret_key)
342
 	tempTime := time.Unix(timestamp, 0)
342
 	tempTime := time.Unix(timestamp, 0)
343
 	//timeFormat := tempTime.Format("20060102150405")
343
 	//timeFormat := tempTime.Format("20060102150405")
344
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
344
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
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
 	input := make(map[string]interface{})
402
 	input := make(map[string]interface{})
403
 	feedetail := make([]map[string]interface{}, 0)
403
 	feedetail := make([]map[string]interface{}, 0)
404
 	inputMessage["infno"] = "2204" // 交易编码
404
 	inputMessage["infno"] = "2204" // 交易编码
423
 		feedetailInfo["used_frqu_dscr"] = ""                         // 使用频次描述
423
 		feedetailInfo["used_frqu_dscr"] = ""                         // 使用频次描述
424
 		feedetailInfo["prd_days"] = "0"                              // 周期天数
424
 		feedetailInfo["prd_days"] = "0"                              // 周期天数
425
 		feedetailInfo["medc_way_dscr"] = ""                          // 用药途径描述
425
 		feedetailInfo["medc_way_dscr"] = ""                          // 用药途径描述
426
-		feedetailInfo["bilg_dept_codg"] = "3002"                     // 开单科室编码
426
+		feedetailInfo["bilg_dept_codg"] = dept_code                  // 开单科室编码
427
 		feedetailInfo["bilg_dept_name"] = dept                       // 开单科室名称
427
 		feedetailInfo["bilg_dept_name"] = dept                       // 开单科室名称
428
-		feedetailInfo["bilg_dr_codg"] = "1002"                       // 开单医生编码
428
+		feedetailInfo["bilg_dr_codg"] = doctor_id                    // 开单医生编码
429
 		feedetailInfo["bilg_dr_name"] = doctor                       // 开单医师姓名
429
 		feedetailInfo["bilg_dr_name"] = doctor                       // 开单医师姓名
430
 		feedetailInfo["acord_dept_codg"] = ""                        // 受单科室编码
430
 		feedetailInfo["acord_dept_codg"] = ""                        // 受单科室编码
431
 		feedetailInfo["acord_dept_name"] = ""                        // 受单科室名称
431
 		feedetailInfo["acord_dept_name"] = ""                        // 受单科室名称
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
 	nonce := GetRandomString(32)
489
 	nonce := GetRandomString(32)
490
 	timestamp := time.Now().Unix()
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
 	input := make(map[string]interface{})
495
 	input := make(map[string]interface{})
496
 	inputData := make(map[string]interface{})
496
 	inputData := make(map[string]interface{})
497
 	inputMessage["infno"] = "2205" // 交易编码
497
 	inputMessage["infno"] = "2205" // 交易编码
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
 	nonce := GetRandomString(32)
549
 	nonce := GetRandomString(32)
550
 	timestamp := time.Now().Unix()
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
 	input := make(map[string]interface{})
555
 	input := make(map[string]interface{})
556
 	inputData := make(map[string]interface{})
556
 	inputData := make(map[string]interface{})
557
 	inputMessage["infno"] = "2206" // 交易编码
557
 	inputMessage["infno"] = "2206" // 交易编码
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
 	nonce := GetRandomString(32)
613
 	nonce := GetRandomString(32)
614
 	timestamp := time.Now().Unix()
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
 	input := make(map[string]interface{})
619
 	input := make(map[string]interface{})
620
 	inputData := make(map[string]interface{})
620
 	inputData := make(map[string]interface{})
621
 	inputMessage["infno"] = "2207" // 交易编码
621
 	inputMessage["infno"] = "2207" // 交易编码
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
 	nonce := GetRandomString(32)
678
 	nonce := GetRandomString(32)
679
 	timestamp := time.Now().Unix()
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
 	input := make(map[string]interface{})
684
 	input := make(map[string]interface{})
685
 	inputData := make(map[string]interface{})
685
 	inputData := make(map[string]interface{})
686
 	inputMessage["infno"] = "2208" // 交易编码
686
 	inputMessage["infno"] = "2208" // 交易编码
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
 	hash := sha256.New()
929
 	hash := sha256.New()
930
 	//输入数据
930
 	//输入数据
931
 	hash.Write([]byte(str))
931
 	hash.Write([]byte(str))
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
 	tempTime := time.Unix(timestamp, 0)
955
 	tempTime := time.Unix(timestamp, 0)
956
 	timeFormat := tempTime.Format("20060102150405")
956
 	timeFormat := tempTime.Format("20060102150405")
962
 
962
 
963
 	inputMessage["infno"] = "1101"                                                              // 交易编码
963
 	inputMessage["infno"] = "1101"                                                              // 交易编码
964
 	inputMessage["msgid"] = fixmedins_code + timeFormat + strconv.FormatInt(int64(randNum), 10) // 发送方报文 ID
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
 	inputMessage["recer_sys_code"] = "01"                                                       // 接收方系统代码
967
 	inputMessage["recer_sys_code"] = "01"                                                       // 接收方系统代码
968
 	inputMessage["dev_no"] = ""                                                                 // 设备编号
968
 	inputMessage["dev_no"] = ""                                                                 // 设备编号
969
 	inputMessage["dev_safe_info"] = ""                                                          // 设备安全信息
969
 	inputMessage["dev_safe_info"] = ""                                                          // 设备安全信息
971
 	inputMessage["signtype"] = ""                                                               // 签名类型
971
 	inputMessage["signtype"] = ""                                                               // 签名类型
972
 	inputMessage["infver"] = "V1.1"                                                             // 接收方系统代码
972
 	inputMessage["infver"] = "V1.1"                                                             // 接收方系统代码
973
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
973
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
974
-	inputMessage["opter"] = "mockuser"                                                          // 经办人
974
+	inputMessage["opter"] = doctor                                                              // 经办人
975
 	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
975
 	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
976
 	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
976
 	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
977
 	inputMessage["fixmedins_code"] = fixmedins_code                                             // 定点医药机构编号
977
 	inputMessage["fixmedins_code"] = fixmedins_code                                             // 定点医药机构编号
980
 	return inputMessage
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
+//}