csx 4 years ago
parent
commit
f92d2e561e

+ 9 - 1
controllers/gdyb_controller.go View File

@@ -275,9 +275,17 @@ func (c *GdybController) PostSeven() {
275 275
 	total := c.GetString("total")
276 276
 	org_name := c.GetString("org_name")
277 277
 	doctor := c.GetString("doctor")
278
+	fixmedins_code := c.GetString("fixmedins_code")
279
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
280
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
278 281
 	secret_key := c.GetString("secret_key")
282
+	med_type := c.GetString("med_type")
283
+	id_card_type, _ := c.GetInt64("id_card_type")
284
+
285
+	//result := service.Gdyb2206(psnNo/**/, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
286
+
287
+	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type)
279 288
 
280
-	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
281 289
 	var dat map[string]interface{}
282 290
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
283 291
 		fmt.Println(dat)

+ 548 - 159
controllers/his_api_controller.go View File

@@ -40,6 +40,11 @@ func HisManagerApiRegistRouters() {
40 40
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
41 41
 	beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
42 42
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
43
+
44
+	//beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
45
+
46
+	beego.Router("/api/upload/get", &HisApiController{}, "get:Sel")
47
+
43 48
 	beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
44 49
 	beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
45 50
 	beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
@@ -153,173 +158,83 @@ func (c *HisApiController) Sscard() {
153 158
 	adminUser := c.GetAdminUserInfo()
154 159
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
155 160
 
156
-	r := CardInit()
157
-	if r == 0 {
158
-		switch id_card_type {
159
-		case 1:
160
-			basStr, err := GetBasBaseInfo()
161
-
162
-			if err != nil {
163
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
164
-				return
165
-
166
-			} else {
167
-				fmt.Println(basStr)
161
+	//r := CardInit()
162
+	//if r == 0 {
163
+	switch id_card_type {
164
+	case 1:
165
+		basStr, err := GetBasBaseInfo()
168 166
 
169
-				bas := strings.Split(basStr, "|")
167
+		if err != nil {
168
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
169
+			return
170 170
 
171
-				basNumber := bas[1]
171
+		} else {
172
+			fmt.Println(basStr)
172 173
 
173
-				//basNumber := bas[2]
174
-				card_sn := bas[3]
174
+			bas := strings.Split(basStr, "|")
175 175
 
176
-				appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
176
+			basNumber := bas[1]
177 177
 
178
-				api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
179
-				resp, requestErr := http.Get(api)
180
-				if requestErr != nil {
181
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
182
-					return
183
-				}
184
-				defer resp.Body.Close()
185
-				body, ioErr := ioutil.ReadAll(resp.Body)
186
-				if ioErr != nil {
187
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
188
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
189
-					return
190
-				}
191
-				var respJSON map[string]interface{}
178
+			//basNumber := bas[2]
179
+			card_sn := bas[3]
192 180
 
193
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
194
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
195
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
196
-					return
197
-				}
181
+			appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
198 182
 
199
-				userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
200
-				userJSONBytes, _ := json.Marshal(userJSON)
201
-				var res ResultTwo
202
-				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
203
-					utils.ErrorLog("解析失败:%v", err)
204
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
205
-					return
206
-				}
207
-				Iinfos, _ := json.Marshal(res.Output.Iinfo)
208
-				Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
209
-				infoStr := string(Iinfos)
210
-				idetinfoStr := string(Idetinfos)
211
-
212
-				if res.Infcode == 0 {
213
-					his := models.VMHisPatient{
214
-						Status:      1,
215
-						Ctime:       time.Now().Unix(),
216
-						Mtime:       time.Now().Unix(),
217
-						PsnNo:       res.Output.Baseinfo.PsnNo,
218
-						PsnCertType: res.Output.Baseinfo.PsnCertType,
219
-						Certno:      res.Output.Baseinfo.Certno,
220
-						PsnName:     res.Output.Baseinfo.PsnName,
221
-						Gend:        res.Output.Baseinfo.Gend,
222
-						Naty:        res.Output.Baseinfo.Naty,
223
-						Brdy:        res.Output.Baseinfo.Brdy,
224
-						Age:         res.Output.Baseinfo.Age,
225
-						Iinfo:       infoStr,
226
-						Idetinfo:    idetinfoStr,
227
-						UserOrgId:   adminUser.CurrentOrgId,
228
-						IsReturn:    1,
229
-						IdCardType:  id_card_type,
230
-					}
231
-
232
-					patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
233
-					if err == gorm.ErrRecordNotFound {
234
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
235
-						return
236
-
237
-					} else if err != nil {
238
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
239
-						return
240
-
241
-					} else {
242
-						c.ServeSuccessJSON(map[string]interface{}{
243
-							"patient": patient,
244
-							"his":     his,
245
-							"number":  basNumber,
246
-						})
247
-					}
248
-				} else {
249
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
250
-					return
251
-				}
183
+			api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
184
+			resp, requestErr := http.Get(api)
185
+			if requestErr != nil {
186
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
187
+				return
188
+			}
189
+			defer resp.Body.Close()
190
+			body, ioErr := ioutil.ReadAll(resp.Body)
191
+			if ioErr != nil {
192
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
193
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
194
+				return
195
+			}
196
+			var respJSON map[string]interface{}
252 197
 
198
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
199
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
200
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
201
+				return
253 202
 			}
254 203
 
255
-			break
256
-		case 2:
257
-			SFZStr, err := GetSFZBaseInfo()
258
-			if err != nil {
259
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
204
+			userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
205
+			userJSONBytes, _ := json.Marshal(userJSON)
206
+			var res ResultTwo
207
+			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
208
+				utils.ErrorLog("解析失败:%v", err)
209
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
260 210
 				return
211
+			}
212
+			Iinfos, _ := json.Marshal(res.Output.Iinfo)
213
+			Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
214
+			infoStr := string(Iinfos)
215
+			idetinfoStr := string(Idetinfos)
261 216
 
262
-			} else {
217
+			if res.Infcode == 0 {
218
+				his := models.VMHisPatient{
219
+					Status:      1,
220
+					Ctime:       time.Now().Unix(),
221
+					Mtime:       time.Now().Unix(),
222
+					PsnNo:       res.Output.Baseinfo.PsnNo,
223
+					PsnCertType: res.Output.Baseinfo.PsnCertType,
224
+					Certno:      res.Output.Baseinfo.Certno,
225
+					PsnName:     res.Output.Baseinfo.PsnName,
226
+					Gend:        res.Output.Baseinfo.Gend,
227
+					Naty:        res.Output.Baseinfo.Naty,
228
+					Brdy:        res.Output.Baseinfo.Brdy,
229
+					Age:         res.Output.Baseinfo.Age,
230
+					Iinfo:       infoStr,
231
+					Idetinfo:    idetinfoStr,
232
+					UserOrgId:   adminUser.CurrentOrgId,
233
+					IsReturn:    1,
234
+					IdCardType:  id_card_type,
235
+				}
263 236
 
264
-				id_card_str := strings.Split(SFZStr, "^")
265
-				id_card_number := id_card_str[0]
266
-				//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
267
-				//
268
-				//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
269
-				//resp, requestErr := http.Get(api)
270
-				//if requestErr != nil {
271
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
272
-				//	return
273
-				//}
274
-				//defer resp.Body.Close()
275
-				//body, ioErr := ioutil.ReadAll(resp.Body)
276
-				//if ioErr != nil {
277
-				//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
278
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
279
-				//	return
280
-				//}
281
-				//var respJSON map[string]interface{}
282
-				//
283
-				//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
284
-				//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
285
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
286
-				//	return
287
-				//}
288
-				//
289
-				//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
290
-				//userJSONBytes, _ := json.Marshal(userJSON)
291
-				//var res ResultTwo
292
-				//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
293
-				//	utils.ErrorLog("解析失败:%v", err)
294
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
295
-				//	return
296
-				//}
297
-				//Iinfos, _ := json.Marshal(res.Output.Iinfo)
298
-				//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
299
-				//infoStr := string(Iinfos)
300
-				//idetinfoStr := string(Idetinfos)
301
-				//
302
-				//if res.Infcode == 0 {
303
-				//	his := models.VMHisPatient{
304
-				//		Status:      1,
305
-				//		Ctime:       time.Now().Unix(),
306
-				//		Mtime:       time.Now().Unix(),
307
-				//		PsnNo:       res.Output.Baseinfo.PsnNo,
308
-				//		PsnCertType: res.Output.Baseinfo.PsnCertType,
309
-				//		Certno:      res.Output.Baseinfo.Certno,
310
-				//		PsnName:     res.Output.Baseinfo.PsnName,
311
-				//		Gend:        res.Output.Baseinfo.Gend,
312
-				//		Naty:        res.Output.Baseinfo.Naty,
313
-				//		Brdy:        res.Output.Baseinfo.Brdy,
314
-				//		Age:         res.Output.Baseinfo.Age,
315
-				//		Iinfo:       infoStr,
316
-				//		Idetinfo:    idetinfoStr,
317
-				//		UserOrgId:   adminUser.CurrentOrgId,
318
-				//		IsReturn:    1,
319
-				//		IdCardType:  id_card_type,
320
-				//	}
321
-
322
-				patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
237
+				patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
323 238
 				if err == gorm.ErrRecordNotFound {
324 239
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
325 240
 					return
@@ -331,18 +246,108 @@ func (c *HisApiController) Sscard() {
331 246
 				} else {
332 247
 					c.ServeSuccessJSON(map[string]interface{}{
333 248
 						"patient": patient,
334
-						"number":  id_card_number,
249
+						"his":     his,
250
+						"number":  basNumber,
335 251
 					})
336 252
 				}
253
+			} else {
254
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
255
+				return
337 256
 			}
338
-			break
339
-		case 3:
340 257
 
341
-			break
258
+		}
259
+
260
+		break
261
+	case 2:
262
+		SFZStr, err := GetSFZBaseInfo()
263
+		if err != nil {
264
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
265
+			return
266
+
267
+		} else {
268
+
269
+			id_card_str := strings.Split(SFZStr, "^")
270
+			id_card_number := id_card_str[0]
271
+			//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
272
+			//
273
+			//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
274
+			//resp, requestErr := http.Get(api)
275
+			//if requestErr != nil {
276
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
277
+			//	return
278
+			//}
279
+			//defer resp.Body.Close()
280
+			//body, ioErr := ioutil.ReadAll(resp.Body)
281
+			//if ioErr != nil {
282
+			//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
283
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
284
+			//	return
285
+			//}
286
+			//var respJSON map[string]interface{}
287
+			//
288
+			//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
289
+			//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
290
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
291
+			//	return
292
+			//}
293
+			//
294
+			//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
295
+			//userJSONBytes, _ := json.Marshal(userJSON)
296
+			//var res ResultTwo
297
+			//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
298
+			//	utils.ErrorLog("解析失败:%v", err)
299
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
300
+			//	return
301
+			//}
302
+			//Iinfos, _ := json.Marshal(res.Output.Iinfo)
303
+			//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
304
+			//infoStr := string(Iinfos)
305
+			//idetinfoStr := string(Idetinfos)
306
+			//
307
+			//if res.Infcode == 0 {
308
+			//	his := models.VMHisPatient{
309
+			//		Status:      1,
310
+			//		Ctime:       time.Now().Unix(),
311
+			//		Mtime:       time.Now().Unix(),
312
+			//		PsnNo:       res.Output.Baseinfo.PsnNo,
313
+			//		PsnCertType: res.Output.Baseinfo.PsnCertType,
314
+			//		Certno:      res.Output.Baseinfo.Certno,
315
+			//		PsnName:     res.Output.Baseinfo.PsnName,
316
+			//		Gend:        res.Output.Baseinfo.Gend,
317
+			//		Naty:        res.Output.Baseinfo.Naty,
318
+			//		Brdy:        res.Output.Baseinfo.Brdy,
319
+			//		Age:         res.Output.Baseinfo.Age,
320
+			//		Iinfo:       infoStr,
321
+			//		Idetinfo:    idetinfoStr,
322
+			//		UserOrgId:   adminUser.CurrentOrgId,
323
+			//		IsReturn:    1,
324
+			//		IdCardType:  id_card_type,
325
+			//	}
326
+
327
+			patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
328
+			if err == gorm.ErrRecordNotFound {
329
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
330
+				return
331
+
332
+			} else if err != nil {
333
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
334
+				return
342 335
 
336
+			} else {
337
+				c.ServeSuccessJSON(map[string]interface{}{
338
+					"patient": patient,
339
+					"number":  id_card_number,
340
+				})
341
+			}
343 342
 		}
343
+		break
344
+	case 3:
345
+
346
+		break
347
+
344 348
 	}
345 349
 }
350
+
346 351
 func StrPtr2(s string) uintptr {
347 352
 	return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
348 353
 }
@@ -1261,7 +1266,7 @@ func (c *HisApiController) GetUploadInfo() {
1261 1266
 
1262 1267
 				}
1263 1268
 
1264
-				api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
1269
+				api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
1265 1270
 					insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
1266 1271
 					"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
1267 1272
 					miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
@@ -1562,6 +1567,390 @@ func (c *HisApiController) GetUploadInfo() {
1562 1567
 	}
1563 1568
 }
1564 1569
 
1570
+//func (c *HisApiController) GetSettleInfo() {
1571
+//	id, _ := c.GetInt64("id")
1572
+//	record_time := c.GetString("record_time")
1573
+//	pay_way, _ := c.GetInt64("pay_way")
1574
+//	pay_price, _ := c.GetFloat("pay_price")
1575
+//	pay_card_no := c.GetString("pay_card_no")
1576
+//	discount_price, _ := c.GetFloat("discount_price")
1577
+//	preferential_price, _ := c.GetFloat("preferential_price")
1578
+//	reality_price, _ := c.GetFloat("reality_price")
1579
+//	found_price, _ := c.GetFloat("found_price")
1580
+//	medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
1581
+//	private_price, _ := c.GetFloat("private_price")
1582
+//	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
1583
+//	admin_user_id, _ := c.GetInt64("admin_user_id")
1584
+//	order_id, _ := c.GetInt64("order_id")
1585
+//
1586
+//	//fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
1587
+//	//overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
1588
+//	//preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
1589
+//	//inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
1590
+//
1591
+//	timeLayout := "2006-01-02"
1592
+//	loc, _ := time.LoadLocation("Local")
1593
+//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1594
+//	if err != nil {
1595
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1596
+//		return
1597
+//	}
1598
+//	recordDateTime := theTime.Unix()
1599
+//	adminUser := c.GetAdminUserInfo()
1600
+//
1601
+//	var prescriptions []*models.HisPrescription
1602
+//
1603
+//	data := make(map[string]interface{})
1604
+//	if settle_accounts_type == 1 { //日结
1605
+//		prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
1606
+//
1607
+//	} else { //月结
1608
+//		start_time_str := c.GetString("start_time")
1609
+//		end_time_str := c.GetString("end_time")
1610
+//		timeLayout := "2006-01-02"
1611
+//		loc, _ := time.LoadLocation("Local")
1612
+//		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
1613
+//		if err != nil {
1614
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1615
+//			return
1616
+//		}
1617
+//		recordStartTime := theStartTime.Unix()
1618
+//		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
1619
+//		if err != nil {
1620
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1621
+//			return
1622
+//		}
1623
+//		recordEndTime := theEndTime.Unix()
1624
+//		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
1625
+//
1626
+//	}
1627
+//
1628
+//	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1629
+//
1630
+//	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
1631
+//	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1632
+//	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
1633
+//	//department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1634
+//	order, err := service.GetHisOrderByID(order_id)
1635
+//
1636
+//	if err != nil {
1637
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
1638
+//		return
1639
+//	}
1640
+//
1641
+//	strconv.FormatInt(his.PatientId, 10)
1642
+//
1643
+//	var ids []int64
1644
+//	for _, item := range prescriptions {
1645
+//		ids = append(ids, item.ID)
1646
+//	}
1647
+//	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1648
+//	if config.IsOpen == 1 { //对接了医保,走医保流程
1649
+//		var total float64
1650
+//		for _, item := range prescriptions {
1651
+//			if item.Type == 1 { //药品
1652
+//				for _, subItem := range item.HisDoctorAdviceInfo {
1653
+//					total = total + (subItem.Price * subItem.PrescribingNumber)
1654
+//				}
1655
+//			}
1656
+//			if item.Type == 2 { //项目
1657
+//				for _, subItem := range item.HisPrescriptionProject {
1658
+//					total = total + (subItem.Price * float64(subItem.Count))
1659
+//				}
1660
+//			}
1661
+//		}
1662
+//
1663
+//		for _, item := range prescriptions {
1664
+//			for _, subItem := range item.HisAdditionalCharge {
1665
+//				total = total + (subItem.Price * float64(subItem.Count))
1666
+//			}
1667
+//		}
1668
+//
1669
+//		allTotal := fmt.Sprintf("%.2f", total)
1670
+//		var rf []*ResultFive
1671
+//		json.Unmarshal([]byte(his.Iinfo), &rf)
1672
+//		psn_no := his.PsnNo
1673
+//		mdtrt_id := his.Number
1674
+//		chrg_bchno := order.Number
1675
+//		cert_no := his.Certno
1676
+//		insutype := rf[0].Insutype
1677
+//
1678
+//		if his.IdCardType == 1 {
1679
+//			cert_no = his.MedicalInsuranceNumber
1680
+//
1681
+//		} else {
1682
+//			cert_no = his.Certno
1683
+//		}
1684
+//
1685
+//		api := "http://127.0.0.1:9532/" + "gdyb/eigth?cert_no=" + cert_no + "&insutype=" +
1686
+//			insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
1687
+//			"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
1688
+//			miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
1689
+//
1690
+//		resp, requestErr := http.Get(api)
1691
+//		if requestErr != nil {
1692
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1693
+//			return
1694
+//		}
1695
+//		defer resp.Body.Close()
1696
+//		body, ioErr := ioutil.ReadAll(resp.Body)
1697
+//		if ioErr != nil {
1698
+//			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
1699
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1700
+//			return
1701
+//		}
1702
+//		var respJSON map[string]interface{}
1703
+//		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
1704
+//			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1705
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1706
+//			return
1707
+//		}
1708
+//		fmt.Println(respJSON)
1709
+//		respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
1710
+//		userJSONBytes, _ := json.Marshal(respJSON)
1711
+//		var res ResultSeven
1712
+//		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1713
+//			utils.ErrorLog("解析失败:%v", err)
1714
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1715
+//			return
1716
+//		}
1717
+//		if res.Infcode == -1 {
1718
+//			errlog := &models.HisOrderError{
1719
+//				UserOrgId:  adminUser.CurrentOrgId,
1720
+//				Ctime:      time.Now().Unix(),
1721
+//				Mtime:      time.Now().Unix(),
1722
+//				Number:     chrg_bchno,
1723
+//				ErrMsg:     res.ErrMsg,
1724
+//				Status:     1,
1725
+//				PatientId:  id,
1726
+//				RecordTime: recordDateTime,
1727
+//				Stage:      6,
1728
+//			}
1729
+//			service.CreateErrMsgLog(errlog)
1730
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1731
+//			return
1732
+//		} else {
1733
+//			order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
1734
+//			order.OrderStatus = 2
1735
+//			order.MdtrtId = res.Output.Setlinfo.MdtrtID
1736
+//			order.SetlId = res.Output.Setlinfo.SetlID
1737
+//			order.PsnNo = res.Output.Setlinfo.PsnNo
1738
+//			order.PsnName = res.Output.Setlinfo.PsnName
1739
+//			order.PsnCertType = res.Output.Setlinfo.PsnCertType
1740
+//			order.Certno = res.Output.Setlinfo.Certno
1741
+//			order.Gend = res.Output.Setlinfo.Gend
1742
+//			order.Naty = res.Output.Setlinfo.Naty
1743
+//			order.Age = res.Output.Setlinfo.Age
1744
+//			order.Insutype = res.Output.Setlinfo.Insutype
1745
+//			order.PsnType = res.Output.Setlinfo.PsnType
1746
+//			order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
1747
+//			order.SetlTime = res.Output.Setlinfo.SetlTime
1748
+//			order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
1749
+//			order.MedType = res.Output.Setlinfo.MedType
1750
+//			order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
1751
+//			order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
1752
+//			order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
1753
+//			order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
1754
+//			order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
1755
+//			order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
1756
+//			order.HifpPay = res.Output.Setlinfo.HifpPay
1757
+//			order.CvlservPay = res.Output.Setlinfo.CvlservPay
1758
+//			order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
1759
+//			order.HifesPay = res.Output.Setlinfo.HifesPay
1760
+//			order.HifobPay = res.Output.Setlinfo.HifobPay
1761
+//			order.MafPay = res.Output.Setlinfo.MafPay
1762
+//			order.OthPay = res.Output.Setlinfo.OthPay
1763
+//			order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
1764
+//			order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
1765
+//			order.AcctPay = res.Output.Setlinfo.AcctPay
1766
+//			order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
1767
+//			order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
1768
+//			order.Balc = res.Output.Setlinfo.Balc
1769
+//			order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
1770
+//			order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
1771
+//			order.ClrOptins = res.Output.Setlinfo.ClrOptins
1772
+//			order.ClrWay = res.Output.Setlinfo.ClrWay
1773
+//			order.Creator = order.Creator
1774
+//			order.Modify = roles.ID
1775
+//			setlDetail, _ := json.Marshal(res.Output.Setldetail)
1776
+//			detailStr := string(setlDetail)
1777
+//			order.SetlDetail = detailStr
1778
+//			err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1779
+//			err = service.UpDateOrder(order)
1780
+//			if err == nil {
1781
+//				c.ServeSuccessJSON(map[string]interface{}{
1782
+//					"msg": "结算成功",
1783
+//				})
1784
+//			} else {
1785
+//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
1786
+//				return
1787
+//			}
1788
+//		}
1789
+//
1790
+//	} else {
1791
+//		var total float64
1792
+//		for _, item := range prescriptions {
1793
+//			if item.Type == 1 { //药品
1794
+//				for _, subItem := range item.HisDoctorAdviceInfo {
1795
+//					total = total + (subItem.Price * subItem.PrescribingNumber)
1796
+//				}
1797
+//			}
1798
+//			if item.Type == 2 { //项目
1799
+//				for _, subItem := range item.HisPrescriptionProject {
1800
+//					total = total + (subItem.Price * float64(subItem.Count))
1801
+//				}
1802
+//			}
1803
+//
1804
+//			for _, subItem := range item.HisAdditionalCharge {
1805
+//				total = total + (subItem.Price * float64(subItem.Count))
1806
+//			}
1807
+//		}
1808
+//
1809
+//		allTotal := fmt.Sprintf("%.2f", total)
1810
+//		totals, _ := strconv.ParseFloat(allTotal, 64)
1811
+//		order := &models.HisOrder{
1812
+//			UserOrgId:             adminUser.CurrentOrgId,
1813
+//			HisPatientId:          his.ID,
1814
+//			PatientId:             id,
1815
+//			SettleAccountsDate:    recordDateTime,
1816
+//			Ctime:                 time.Now().Unix(),
1817
+//			Mtime:                 time.Now().Unix(),
1818
+//			Status:                1,
1819
+//			OrderStatus:           2,
1820
+//			Number:                chrg_bchno,
1821
+//			MedfeeSumamt:          totals,
1822
+//			PayWay:                pay_way,
1823
+//			PayPrice:              pay_price,
1824
+//			PayCardNo:             pay_card_no,
1825
+//			DiscountPrice:         discount_price,
1826
+//			PreferentialPrice:     preferential_price,
1827
+//			RealityPrice:          reality_price,
1828
+//			FoundPrice:            found_price,
1829
+//			MedicalInsurancePrice: medical_insurance_price,
1830
+//			PrivatePrice:          private_price,
1831
+//		}
1832
+//		err = service.CreateOrder(order)
1833
+//		if err != nil {
1834
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
1835
+//			return
1836
+//		}
1837
+//
1838
+//		var customs []*Custom
1839
+//		for _, item := range prescriptions {
1840
+//
1841
+//			if item.Type == 1 { //药品
1842
+//				for _, subItem := range item.HisDoctorAdviceInfo {
1843
+//					cus := &Custom{
1844
+//						AdviceId:         subItem.ID,
1845
+//						ProjectId:        0,
1846
+//						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
1847
+//						Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
1848
+//						FeedetlSn:        subItem.FeedetlSn,
1849
+//						Price:            fmt.Sprintf("%.2f", subItem.Price),
1850
+//						MedListCodg:      subItem.MedListCodg,
1851
+//						Type:             1,
1852
+//					}
1853
+//					customs = append(customs, cus)
1854
+//				}
1855
+//			}
1856
+//
1857
+//			if item.Type == 2 { //项目
1858
+//				for _, subItem := range item.HisPrescriptionProject {
1859
+//
1860
+//					cus := &Custom{
1861
+//						AdviceId:         0,
1862
+//						ProjectId:        subItem.ID,
1863
+//						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
1864
+//						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
1865
+//						FeedetlSn:        subItem.FeedetlSn,
1866
+//						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
1867
+//						MedListCodg:      subItem.MedListCodg,
1868
+//						Type:             2,
1869
+//					}
1870
+//
1871
+//					customs = append(customs, cus)
1872
+//				}
1873
+//			}
1874
+//
1875
+//			for _, item := range item.HisAdditionalCharge {
1876
+//				cus := &Custom{
1877
+//					ItemId:           item.ID,
1878
+//					AdviceId:         0,
1879
+//					ProjectId:        0,
1880
+//					DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
1881
+//					Cut:              fmt.Sprintf("%.2f", float64(item.Count)),
1882
+//					FeedetlSn:        item.FeedetlSn,
1883
+//					Price:            fmt.Sprintf("%.2f", float64(item.Price)),
1884
+//					MedListCodg:      item.XtHisAddtionConfig.Code,
1885
+//					Type:             3,
1886
+//				}
1887
+//
1888
+//				customs = append(customs, cus)
1889
+//			}
1890
+//
1891
+//		}
1892
+//
1893
+//		for _, item := range customs {
1894
+//			var advice_id int64 = 0
1895
+//			var project_id int64 = 0
1896
+//			var item_id int64 = 0
1897
+//
1898
+//			var types int64 = 0
1899
+//
1900
+//			if item.Type == 1 {
1901
+//				advice_id = item.AdviceId
1902
+//				project_id = 0
1903
+//				item_id = 0
1904
+//			} else if item.Type == 2 {
1905
+//				advice_id = 0
1906
+//				item_id = 0
1907
+//
1908
+//				project_id = item.ProjectId
1909
+//			} else if item.Type == 3 {
1910
+//				advice_id = 0
1911
+//				item_id = item.ItemId
1912
+//				project_id = 0
1913
+//			}
1914
+//
1915
+//			detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
1916
+//			cut, _ := strconv.ParseFloat(item.Cut, 32)
1917
+//			pric, _ := strconv.ParseFloat(item.Price, 32)
1918
+//
1919
+//			info := &models.HisOrderInfo{
1920
+//				OrderNumber:      order.Number,
1921
+//				UploadDate:       time.Now().Unix(),
1922
+//				AdviceId:         advice_id,
1923
+//				DetItemFeeSumamt: detItemFeeSumamt,
1924
+//				Cnt:              cut,
1925
+//				Pric:             pric,
1926
+//				PatientId:        id,
1927
+//				Status:           1,
1928
+//				Mtime:            time.Now().Unix(),
1929
+//				Ctime:            time.Now().Unix(),
1930
+//				UserOrgId:        adminUser.CurrentOrgId,
1931
+//				HisPatientId:     his.ID,
1932
+//				OrderId:          order.ID,
1933
+//				ProjectId:        project_id,
1934
+//				Type:             types,
1935
+//				ItemId:           item_id,
1936
+//			}
1937
+//			service.CreateOrderInfo(info)
1938
+//		}
1939
+//		//err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1940
+//		err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1941
+//		err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
1942
+//		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1943
+//		if err == nil {
1944
+//			c.ServeSuccessJSON(map[string]interface{}{
1945
+//				"msg": "结算成功",
1946
+//			})
1947
+//		} else {
1948
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
1949
+//			return
1950
+//		}
1951
+//	}
1952
+//}
1953
+
1565 1954
 //退款
1566 1955
 func (c *HisApiController) Refund() {
1567 1956
 	order_id, _ := c.GetInt64("order_id")

+ 4 - 0
enums/error_code.go View File

@@ -236,6 +236,8 @@ const ( // ErrorCode
236 236
 	ErrorCodeNoPateintException = 20075
237 237
 
238 238
 	ErrorCodeHisFailedException = 20076
239
+
240
+	ErrorCodeHisOrderNoExistParamWrong = 30000
239 241
 )
240 242
 
241 243
 var ErrCodeMsgs = map[int]string{
@@ -455,6 +457,8 @@ var ErrCodeMsgs = map[int]string{
455 457
 	ErrorCodeNoPateintException: "读卡失败!请先在系统录入患者信息或检查患者身份证信息是否正确,再重新读卡",
456 458
 
457 459
 	ErrorCodeHisFailedException: "获取人员信息失败",
460
+
461
+	ErrorCodeHisOrderNoExistParamWrong: "订单不存在",
458 462
 }
459 463
 
460 464
 type SGJError struct {

+ 98 - 5
service/gdyb_service.go View File

@@ -633,21 +633,31 @@ func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, d
633 633
 }
634 634
 
635 635
 //  门诊预结算
636
-func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
636
+//func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
637
+func Gdyb2206(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, med_type string, id_card_type int64) string {
638
+
637 639
 	// 生成签名
638 640
 	nonce := GetRandomString(32)
639 641
 	timestamp := time.Now().Unix()
640 642
 	signature := setSignature(timestamp, nonce, secret_key)
641 643
 
642 644
 	// 生成输入报文
643
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", "", "")
645
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
646
+
644 647
 	input := make(map[string]interface{})
645 648
 	inputData := make(map[string]interface{})
646 649
 	inputMessage["infno"] = "2206" // 交易编码
647 650
 
648
-	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
649
-	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型,
650
-	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
651
+	inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
652
+
653
+	if id_card_type == 1 {
654
+		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
655
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
656
+	} else {
657
+		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
658
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
659
+	}
660
+
651 661
 	inputData["med_type"] = "11"        // 医疗类别 11 普通门诊  12 门诊挂号
652 662
 	inputData["medfee_sumamt"] = total  // 医疗费总额
653 663
 	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算
@@ -829,6 +839,89 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doct
829 839
 	return str
830 840
 }
831 841
 
842
+//确认订单
843
+func Gdyb6201(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, med_type string, id_card_type int64, order models.HisOrder) string {
844
+	// 生成签名
845
+	nonce := GetRandomString(32)
846
+	timestamp := time.Now().Unix()
847
+	signature := setSignature(timestamp, nonce, secret_key)
848
+
849
+	// 生成输入报文
850
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
851
+	input := make(map[string]interface{})
852
+	inputData := make(map[string]interface{})
853
+	inputMessage["infno"] = "6201" // 交易编码
854
+
855
+	inputData["mdtrt_id"] = order.MdtrtId
856
+	inputData["chrg_bchno"] = order.Number
857
+	inputData["psn_no"] = order.PsnNo
858
+	inputData["psn_name"] = order.PsnName
859
+	inputData["psn_cert_type"] = order.PsnCertType
860
+	inputData["certno"] = order.Certno
861
+	inputData["insutype"] = order.Insutype
862
+	inputData["med_type"] = order.MedType
863
+	inputData["medfee_sumamt"] = order.MedfeeSumamt
864
+	inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
865
+	inputData["overlmt_selfpay"] = order.OverlmtSelfPay
866
+	inputData["preselfpay_amt"] = order.PreselfpayAmt
867
+	inputData["inscp_scp_amt"] = order.InscpScpAmt
868
+	inputData["act_pay_dedc"] = order.ActPayDedc
869
+	inputData["hifp_pay"] = order.HifpPay
870
+	inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
871
+	inputData["cvlserv_pay"] = order.CvlservPay
872
+	inputData["hifes_pay"] = order.HifesPay
873
+	inputData["hifmi_pay"] = order.HifmiPay
874
+	inputData["hifob_pay"] = order.HifobPay
875
+	inputData["maf_pay"] = order.MafPay
876
+	inputData["oth_pay"] = order.OthPay
877
+	inputData["fund_pay_sumamt"] = order.FundPaySumamt
878
+	inputData["psn_part_amt"] = order.PsnPartAmt
879
+	inputData["acct_pay"] = order.AcctPay
880
+	inputData["psn_cash_pay"] = order.PsnCashPay
881
+	inputData["hosp_part_amt"] = order.HospPartAmt
882
+	inputData["acct_mulaid_pay"] = order.AcctMulaidPay
883
+
884
+	input["data"] = inputData
885
+	inputMessage["input"] = input //交易输入
886
+
887
+	bytesData, err := json.Marshal(inputMessage)
888
+	fmt.Println(string(bytesData))
889
+	if err != nil {
890
+		fmt.Println(err.Error())
891
+		return err.Error()
892
+	}
893
+	reader := bytes.NewReader(bytesData)
894
+	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
895
+
896
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
897
+	request, err := http.NewRequest("POST", url, reader)
898
+	if err != nil {
899
+		fmt.Println(err.Error())
900
+		return err.Error()
901
+	}
902
+
903
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
904
+	request.Header.Set("x-tif-paasid", "sg03_prd")
905
+	request.Header.Set("x-tif-signature", signature)
906
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
907
+	request.Header.Set("x-tif-nonce", nonce)
908
+
909
+	client := http.Client{}
910
+	resp, err := client.Do(request)
911
+	if err != nil {
912
+		fmt.Println(err.Error())
913
+		return err.Error()
914
+	}
915
+	respBytes, err := ioutil.ReadAll(resp.Body)
916
+	if err != nil {
917
+		fmt.Println(err.Error())
918
+		return err.Error()
919
+	}
920
+	str := string(respBytes)
921
+	fmt.Println(str)
922
+	return str
923
+}
924
+
832 925
 //  医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
833 926
 func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams) string {
834 927
 	fmt.Println("11222333-----")

+ 1 - 1
service/his_service.go View File

@@ -519,7 +519,7 @@ func UpDatePrescriptionNumber(user_org_id int64, ids []int64, number string) (er
519 519
 }
520 520
 
521 521
 func UpDatePrescriptionInfoNumber(user_org_id int64, id int64, number string, record_time int64) (err error) {
522
-	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date = ?", user_org_id, id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
522
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date = ?", user_org_id, id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 2, "mtime": time.Now().Unix()}).Error
523 523
 
524 524
 	return
525 525
 }