Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

test_user před 2 roky
rodič
revize
57099bed5c

+ 2 - 3
conf/app.conf Zobrazit soubor

@@ -45,8 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10215
49
-
48
+org_id = 10088
50 49
 mobile_token_expiration_second = 86400
51 50
 httpdomain = https://api.xt.kuyicloud.com
52 51
 sso_domain = https://sso.kuyicloud.com
@@ -73,7 +72,7 @@ gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
73 72
 #深圳
74 73
 #gdyb_paasid = "sz_prd_yjyy"
75 74
 #肇庆
76
-gdyb_paasid = "zq_prd_yjyy"
75
+# gdyb_paasid = "zq_prd_yjyy"
77 76
 # gdyb_paasid = "sztest_hosp"
78 77
 #广州
79 78
 #gdyb_paasid = "gdyb_inf"

+ 44 - 1
controllers/hb/hbyb_controller.go Zobrazit soubor

@@ -27,10 +27,53 @@ func HbybRegistRouters() {
27 27
 	beego.Router("/hbyb/2208", &HBybController{}, "get:PostNine")
28 28
 	beego.Router("/hbyb/5203", &HBybController{}, "get:PostTen")
29 29
 	beego.Router("/hbyb/2001", &HBybController{}, "get:Post2001")
30
-
30
+	beego.Router("/hbyb/3202", &HBybController{}, "get:Post3202a")
31 31
 	beego.Router("/hbyb/4101", &HBybController{}, "post:Post4101")
32 32
 
33 33
 }
34
+func (c *HBybController) Post3202a() {
35
+	insutype := c.GetString("insutype")
36
+	clrType := c.GetString("clr_type")
37
+	setlOptins := c.GetString("setl_optins")
38
+	stmtBegndate := c.GetString("stmt_begndate")
39
+	stmtEnddate := c.GetString("stm_enddate")
40
+	fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
41
+	acctPay, _ := c.GetFloat("acct_pay", 0)
42
+	fixmedins_code := c.GetString("fixmedins_code")
43
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
44
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
45
+	secret_key := c.GetString("secret_key")
46
+	org_name := c.GetString("org_name")
47
+	doctor := c.GetString("doctor")
48
+
49
+	var baseParams models.BaseParams
50
+	baseParams.InsuplcAdmdvs = insuplc_admdvs
51
+	baseParams.MdtrtareaAdmvs = mdtrtarea_admvs
52
+	baseParams.SecretKey = secret_key
53
+	baseParams.OrgName = org_name
54
+	baseParams.Doctor = doctor
55
+	baseParams.FixmedinsCode = fixmedins_code
56
+	businessParams := models.BusinessParams{
57
+		Insutype:      insutype,
58
+		ClrType:       clrType,
59
+		SetlOptins:    setlOptins,
60
+		StmtBegndate:  stmtBegndate,
61
+		StmtEnddate:   stmtEnddate,
62
+		FundPaySumamt: fundPaySumamt,
63
+		AcctPay:       acctPay,
64
+	}
65
+	result := service.Hbyb3202a(baseParams, businessParams)
66
+	var dat map[string]interface{}
67
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
68
+		fmt.Println(dat)
69
+	} else {
70
+		fmt.Println(err)
71
+	}
72
+	c.ServeSuccessJSON(map[string]interface{}{
73
+		"pre": dat,
74
+	})
75
+}
76
+
34 77
 func (c *HBybController) Post4101() {
35 78
 	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
36 79
 	var respJSON map[string]interface{}

+ 478 - 7
controllers/sg/his_api_controller.go Zobrazit soubor

@@ -83,16 +83,18 @@ func HisManagerApiRegistRouters() {
83 83
 
84 84
 	beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
85 85
 
86
+	beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
87
+
86 88
 }
87 89
 
88 90
 type Result3101 struct {
89
-	Infcode     string      `json:"infcode"`
90
-	InfRefmsgid string      `json:"inf_refmsgid"`
91
-	RefmsgTime  string      `json:"refmsg_time"`
92
-	RespondTime string      `json:"respond_time"`
93
-	Enctype     string      `json:"enctype"`
94
-	Signtype    string      `json:"signtype"`
95
-	ErrMsg      interface{} `json:"err_msg"`
91
+	Infcode     string `json:"infcode"`
92
+	InfRefmsgid string `json:"inf_refmsgid"`
93
+	RefmsgTime  string `json:"refmsg_time"`
94
+	RespondTime string `json:"respond_time"`
95
+	Enctype     string `json:"enctype"`
96
+	Signtype    string `json:"signtype"`
97
+	ErrMsg      string `json:"err_msg"`
96 98
 	Output      struct {
97 99
 		Result []struct {
98 100
 			JudgeResultDetailDtos []struct {
@@ -145,6 +147,288 @@ func (c *HisApiController) Get9001() {
145 147
 	}
146 148
 
147 149
 }
150
+func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
151
+
152
+	adminUser := c.GetAdminUserInfo()
153
+	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
154
+	//his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
155
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
156
+	//record_time := c.GetString("record_time")
157
+	//trig_scen := c.GetString("trig_scen")
158
+
159
+	timeLayout := "2006-01-02"
160
+	loc, _ := time.LoadLocation("Local")
161
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
162
+	if err != nil {
163
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
164
+		return res
165
+	}
166
+	recordDateTime := theTime.Unix()
167
+
168
+	var patientPrescription models.HisPrescriptionInfo
169
+	//patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
170
+	//if patientPrescription.ID == 0 {
171
+	patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
172
+	//}
173
+	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
174
+	doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
175
+	//
176
+	diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
177
+
178
+	//prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
179
+
180
+	var pp models.PublicParams
181
+	pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
182
+	pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
183
+	pp.FixmedinsName = miConfig.OrgName
184
+	pp.FixmedinsCode = miConfig.Code
185
+
186
+	pp.RequestUrl = miConfig.Url
187
+	pp.Cainfo = miConfig.Cainfo
188
+	pp.SecretKey = miConfig.SecretKey
189
+	pp.AccessKey = miConfig.AccessKey
190
+	pp.OpterName = roles.UserName
191
+
192
+	var config []*models.HisXtDiagnoseConfig
193
+	for _, item := range diagnosis_ids {
194
+		id, _ := strconv.ParseInt(item, 10, 64)
195
+		diagnosisConfig, _ := service.FindDiagnoseById(id)
196
+		config = append(config, &diagnosisConfig)
197
+	}
198
+
199
+	var pd models.PatientDtos
200
+	pd.PatnID = his.PsnNo
201
+	pd.PatnName = his.Name
202
+	pd.Gend = his.Gend
203
+	pd.Brdy = his.Brdy
204
+	pd.Poolarea = his.InsuplcAdmdvs
205
+	pd.CurrMdtrtID = his.Number
206
+
207
+	var fed models.FsiEncounterDtos
208
+	fed.MdtrtID = his.Number
209
+	fed.MedinsID = miConfig.Code
210
+	fed.MedinsName = miConfig.OrgName
211
+	fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
212
+	fed.MedMdtrtType = "1"
213
+	fed.MedinsType = "1"
214
+	fed.MedinsLv = "11"
215
+	tm := time.Unix(his.RecordDate, 0)
216
+	s_tm := tm.Format("2006-01-02 15:04:05")
217
+	fed.AdmDate = s_tm
218
+	fed.DscgDate = s_tm
219
+	fed.DscgMainDiseCodg = config[0].CountryCode
220
+	fed.DscgMainDiseName = config[0].CountryContentName
221
+	//诊断信息
222
+	var fdds []*models.FsiDiagnoseDtos
223
+	for index, item := range config {
224
+		if index == 0 {
225
+			var fdd models.FsiDiagnoseDtos
226
+			fdd.DiseID = strconv.FormatInt(item.ID, 10)
227
+			fdd.InoutDiseType = "1"
228
+			fdd.MaindiseFlag = "1"
229
+			fdd.DiseDate = s_tm
230
+			fdd.DiasSrtNo = "1"
231
+			fdd.DiseName = item.CountryContentName
232
+			fdd.DiseCodg = item.CountryCode
233
+			fdds = append(fdds, &fdd)
234
+
235
+		} else {
236
+			var fdd models.FsiDiagnoseDtos
237
+			fdd.DiseID = strconv.FormatInt(item.ID, 10)
238
+			fdd.InoutDiseType = "1"
239
+			fdd.MaindiseFlag = "1"
240
+			fdd.DiseDate = s_tm
241
+			fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
242
+			fdd.DiseName = item.CountryContentName
243
+			fdd.DiseCodg = item.CountryCode
244
+			fdds = append(fdds, &fdd)
245
+		}
246
+	}
247
+	fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
248
+	fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
249
+	fed.AdmDeptName = department.Name
250
+	fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
251
+	fed.DscgDeptName = department.Name
252
+	fed.MedMdtrtType = "1"
253
+	fed.MedType = "11"
254
+	//if his.Insutype == "390" {
255
+	//	fed.MedType = "1402"
256
+	//} else {
257
+	//	fed.MedType = "9933"
258
+	//}
259
+	var orders []*models.FsiOrderDtos
260
+
261
+	if trig_scen == "2" {
262
+		//处方医嘱信息
263
+		for _, item := range prescriptions {
264
+			for _, subItem := range item.HisDoctorAdviceInfo {
265
+				var order models.FsiOrderDtos
266
+				order.RxID = strconv.FormatInt(item.ID, 10)
267
+				order.Rxno = strconv.FormatInt(item.ID, 10)
268
+				order.LongDrordFlag = "0"
269
+				order.HilistType = "1"
270
+				order.ChrgType = "1"
271
+				order.DrordBhvr = "-"
272
+				order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
273
+				order.HosplistName = subItem.BaseDrugLib.DrugName
274
+				order.HilistLv = "1"
275
+				order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
276
+				order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
277
+				order.HosplistName = subItem.BaseDrugLib.DrugName
278
+				order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
279
+				order.Pric = fmt.Sprintf("%.2f", subItem.Price)
280
+				order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
281
+				order.OwnpayAmt = ""
282
+				order.SelfpayAmt = ""
283
+				order.Spec = ""
284
+				order.SpecUnt = ""
285
+				order.DrordBegnDate = s_tm
286
+				order.DrordStopDate = ""
287
+				order.DrordDrCodg = "1"
288
+				order.DrordDeptName = department.Name
289
+				order.DrordDrCodg = "1"
290
+				order.DrordDrName = doctor_info.UserName
291
+				order.DrordDrProfttl = ""
292
+				order.CurrDrordFlag = "1"
293
+				orders = append(orders, &order)
294
+			}
295
+			for _, subItem := range item.HisPrescriptionProject {
296
+				if subItem.Type == 2 {
297
+					var order models.FsiOrderDtos
298
+					order.RxID = strconv.FormatInt(item.ID, 10)
299
+					order.Rxno = strconv.FormatInt(item.ID, 10)
300
+					order.LongDrordFlag = "0"
301
+					order.HilistType = "1"
302
+					order.ChrgType = "1"
303
+					order.DrordBhvr = "-"
304
+					order.HilistCode = subItem.HisProject.MedicalCode
305
+					order.HosplistName = subItem.HisProject.ProjectName
306
+					order.HilistLv = "1"
307
+					order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
308
+					order.HosplistCode = subItem.HisProject.MedicalCode
309
+					order.HosplistName = subItem.HisProject.ProjectName
310
+					order.Cnt = subItem.Count
311
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
312
+					order.Pric = fmt.Sprintf("%.2f", subItem.Price)
313
+					order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
314
+					order.OwnpayAmt = ""
315
+					order.SelfpayAmt = ""
316
+					order.Spec = ""
317
+					order.SpecUnt = ""
318
+					order.DrordBegnDate = s_tm
319
+					order.DrordStopDate = ""
320
+					order.DrordDrCodg = "1"
321
+					order.DrordDeptName = department.Name
322
+					order.DrordDrCodg = "1"
323
+					order.DrordDrName = doctor_info.UserName
324
+					order.DrordDrProfttl = ""
325
+					order.CurrDrordFlag = "1"
326
+					orders = append(orders, &order)
327
+
328
+				}
329
+				if subItem.Type == 3 {
330
+
331
+					var order models.FsiOrderDtos
332
+					order.RxID = strconv.FormatInt(item.ID, 10)
333
+					order.Rxno = strconv.FormatInt(item.ID, 10)
334
+					order.LongDrordFlag = "0"
335
+					order.HilistType = "1"
336
+					order.ChrgType = "1"
337
+					order.DrordBhvr = "-"
338
+					order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
339
+					order.HosplistName = subItem.GoodInfo.GoodName
340
+					order.HilistLv = "1"
341
+					order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
342
+					order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
343
+					order.HosplistName = subItem.GoodInfo.GoodName
344
+					order.Cnt = subItem.Count
345
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
346
+					order.Pric = fmt.Sprintf("%.2f", subItem.Price)
347
+					order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
348
+					order.OwnpayAmt = ""
349
+					order.SelfpayAmt = ""
350
+					order.Spec = ""
351
+					order.SpecUnt = ""
352
+					order.DrordBegnDate = s_tm
353
+					order.DrordStopDate = ""
354
+					order.DrordDrCodg = "1"
355
+					order.DrordDeptName = department.Name
356
+					order.DrordDrCodg = "1"
357
+					order.DrordDrName = doctor_info.UserName
358
+					order.DrordDrProfttl = ""
359
+					order.CurrDrordFlag = "1"
360
+					orders = append(orders, &order)
361
+
362
+				}
363
+			}
364
+		}
365
+		//处方医嘱信息
366
+	}
367
+	fed.MatnStas = "0"
368
+	fed.MedfeeSumamt = "0"
369
+	fed.OwnpayAmt = "0"
370
+	fed.SelfpayAmt = "0"
371
+	fed.AcctPayamt = "0"
372
+	fed.MaAmt = "0"
373
+	fed.HifpPayamt = "0"
374
+	fed.SetlTotlnum = "1"
375
+	fed.Insutype = his.Insutype
376
+	fed.ReimFlag = "0"
377
+	fed.OutSetlFlag = "0"
378
+
379
+	var fopd []*models.FsiOperationDtosData
380
+	data := make(map[string]interface{})
381
+	data["fed"] = fed
382
+	data["fdd"] = fdds
383
+	data["fod"] = orders
384
+	data["pd"] = pd
385
+	data["pp"] = pp
386
+	data["fopd"] = fopd
387
+	data["trig_scen"] = trig_scen
388
+	fmt.Println(data)
389
+	fmt.Println(fed)
390
+	fmt.Println(fdds)
391
+	fmt.Println(orders)
392
+	fmt.Println(pd)
393
+	fmt.Println(pp)
394
+	fmt.Println(fopd)
395
+
396
+	client := &http.Client{}
397
+	bytesData, _ := json.Marshal(data)
398
+	var req *http.Request
399
+
400
+	if miConfig.MdtrtareaAdmvs == "320921" {
401
+		req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
402
+	} else {
403
+		req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
404
+	}
405
+
406
+	resp, _ := client.Do(req)
407
+	defer resp.Body.Close()
408
+	body, ioErr := ioutil.ReadAll(resp.Body)
409
+	if ioErr != nil {
410
+		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
411
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
412
+		return res
413
+	}
414
+	var respJSON map[string]interface{}
415
+	if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
416
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
417
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
418
+		return res
419
+	}
420
+	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
421
+	result, _ := json.Marshal(respJSON)
422
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
423
+		utils.ErrorLog("解析失败:%v", err)
424
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
425
+		return res
426
+	}
427
+
428
+	return res
429
+
430
+}
431
+
148 432
 func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
149 433
 
150 434
 	adminUser := c.GetAdminUserInfo()
@@ -5566,6 +5850,31 @@ func (c *HisApiController) GetRegisterInfo() {
5566 5850
 					cert_no = bas[2]
5567 5851
 				}
5568 5852
 
5853
+				var hisPrescription []*models.HisPrescription
5854
+				res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
5855
+
5856
+				if res3101.Infcode == "0" && len(res3101.Output.Result) > 0 {
5857
+					for _, item := range res3101.Output.Result {
5858
+						if len(res3101.ErrMsg) == 0 {
5859
+							res3101.ErrMsg = item.VolaCont
5860
+						} else {
5861
+							res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
5862
+						}
5863
+					}
5864
+					c.ServeSuccessJSON(map[string]interface{}{
5865
+						"failed_code": -10,
5866
+						"msg":         res3101.ErrMsg,
5867
+					})
5868
+					return
5869
+
5870
+				} else if res3101.Infcode != "0" {
5871
+					c.ServeSuccessJSON(map[string]interface{}{
5872
+						"failed_code": -10,
5873
+						"msg":         res3101.ErrMsg,
5874
+					})
5875
+					return
5876
+				}
5877
+
5569 5878
 				var api string
5570 5879
 				if miConfig.MdtrtareaAdmvs == "320921" {
5571 5880
 
@@ -6622,6 +6931,22 @@ func (c *HisApiController) GetUploadInfo() {
6622 6931
 							}
6623 6932
 
6624 6933
 						} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
6934
+							result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
6935
+							if result3101.Infcode == "0" {
6936
+								if len(result3101.Output.Result) > 0 {
6937
+									var errMsgs []string
6938
+									for _, item := range result3101.Output.Result {
6939
+										errMsgs = append(errMsgs, item.VolaCont)
6940
+
6941
+									}
6942
+									c.ServeSuccessJSON(map[string]interface{}{
6943
+										"failed_code": -10,
6944
+										"msg":         errMsgs,
6945
+									})
6946
+									return
6947
+								}
6948
+							}
6949
+
6625 6950
 							psn_info, _ := service.GetPsnByPatientId(his.PatientId)
6626 6951
 							psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
6627 6952
 							bas := strings.Split(psn_info.CardInfo, "|")
@@ -7041,6 +7366,21 @@ func (c *HisApiController) GetUploadInfo() {
7041 7366
 				}
7042 7367
 
7043 7368
 			} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
7369
+				result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
7370
+				if result3101.Infcode == "0" {
7371
+					if len(result3101.Output.Result) > 0 {
7372
+						var errMsgs []string
7373
+						for _, item := range result3101.Output.Result {
7374
+							errMsgs = append(errMsgs, item.VolaCont)
7375
+
7376
+						}
7377
+						c.ServeSuccessJSON(map[string]interface{}{
7378
+							"failed_code": -10,
7379
+							"msg":         errMsgs,
7380
+						})
7381
+						return
7382
+					}
7383
+				}
7044 7384
 				psn_info, _ := service.GetPsnByPatientId(his.PatientId)
7045 7385
 				psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
7046 7386
 
@@ -8234,6 +8574,22 @@ func (c *HisApiController) GetPreUploadInfo() {
8234 8574
 				}
8235 8575
 
8236 8576
 			} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
8577
+				result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
8578
+				if result3101.Infcode == "0" {
8579
+					if len(result3101.Output.Result) > 0 {
8580
+						var errMsgs []string
8581
+						for _, item := range result3101.Output.Result {
8582
+							errMsgs = append(errMsgs, item.VolaCont)
8583
+
8584
+						}
8585
+						c.ServeSuccessJSON(map[string]interface{}{
8586
+							"failed_code": -10,
8587
+							"msg":         errMsgs,
8588
+						})
8589
+						return
8590
+					}
8591
+				}
8592
+
8237 8593
 				bytesData, _ := json.Marshal(data)
8238 8594
 				var req *http.Request
8239 8595
 				if miConfig.MdtrtareaAdmvs == "320921" {
@@ -8556,6 +8912,22 @@ func (c *HisApiController) GetPreUploadInfo() {
8556 8912
 						}
8557 8913
 
8558 8914
 					} else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
8915
+						result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
8916
+						if result3101.Infcode == "0" {
8917
+							if len(result3101.Output.Result) > 0 {
8918
+								var errMsgs []string
8919
+								for _, item := range result3101.Output.Result {
8920
+									errMsgs = append(errMsgs, item.VolaCont)
8921
+
8922
+								}
8923
+								c.ServeSuccessJSON(map[string]interface{}{
8924
+									"failed_code": -10,
8925
+									"msg":         errMsgs,
8926
+								})
8927
+								return
8928
+							}
8929
+						}
8930
+
8559 8931
 						psn_info, _ := service.GetPsnByPatientId(his.PatientId)
8560 8932
 						psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
8561 8933
 
@@ -12688,3 +13060,102 @@ func DeleteExtraSpace(s string) string {
12688 13060
 	}
12689 13061
 	return string(s2)
12690 13062
 }
13063
+
13064
+//对账
13065
+func (c *HisApiController) Post3202() {
13066
+	start_time := c.GetString("start_time")
13067
+	end_time := c.GetString("end_time")
13068
+	insutype := c.GetString("insutype")
13069
+	clr_type := c.GetString("clr_type")
13070
+	clr_org := c.GetString("clr_optins")
13071
+
13072
+	admin_user_id, _ := c.GetInt64("admin_user_id")
13073
+
13074
+	adminUser := c.GetAdminUserInfo()
13075
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
13076
+	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
13077
+	if len(clr_org) == 0 {
13078
+		clr_org = miConfig.MdtrtareaAdmvs
13079
+	}
13080
+	timeLayout := "2006-01-02"
13081
+	loc, _ := time.LoadLocation("Local")
13082
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
13083
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
13084
+	orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
13085
+	fixmedins_setl_cnt := int64(len(orders))
13086
+	var medfee_sumamt float64
13087
+	var acct_pay float64
13088
+	var fund_pay_sumamt float64
13089
+	for _, item := range orders {
13090
+		medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
13091
+		acct_pay = acct_pay + item.AcctPay
13092
+		fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
13093
+	}
13094
+	var user_name string
13095
+	role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
13096
+	if role.ID == 0 {
13097
+		user_name = "xxx"
13098
+	} else {
13099
+		user_name = role.UserName
13100
+	}
13101
+	var res ResultSix
13102
+	if config.IsOpen == 1 {
13103
+		if miConfig.MdtrtareaAdmvs == "421300" {
13104
+			api := "http://192.168.124.4:9532/" + "hbyb/3202?" +
13105
+				"insutype=" + insutype +
13106
+				"&clr_type=" + clr_type +
13107
+				"&setl_optins=" + clr_org +
13108
+				"&stmt_begndate=" + start_time +
13109
+				"&stm_enddate=" + end_time +
13110
+				"&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
13111
+				"&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
13112
+				"&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
13113
+				"&fixmedins_code=" + miConfig.Code +
13114
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
13115
+				"&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
13116
+				"&secret_key=" + miConfig.SecretKey +
13117
+				"&org_name=" + miConfig.OrgName +
13118
+				"&doctor=" + user_name
13119
+			resp, requestErr := http.Get(api)
13120
+			if requestErr != nil {
13121
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13122
+				return
13123
+			}
13124
+			body, ioErr := ioutil.ReadAll(resp.Body)
13125
+			if ioErr != nil {
13126
+				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
13127
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13128
+				return
13129
+			}
13130
+			var respJSON map[string]interface{}
13131
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
13132
+				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
13133
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13134
+				return
13135
+			}
13136
+
13137
+			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
13138
+			result, _ := json.Marshal(respJSON)
13139
+			fmt.Println("log")
13140
+			fmt.Println(string(result))
13141
+			if err := json.Unmarshal([]byte(result), &res); err != nil {
13142
+				utils.ErrorLog("解析失败:%v", err)
13143
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
13144
+				return
13145
+			}
13146
+
13147
+		}
13148
+
13149
+		if res.Infcode == 0 {
13150
+			c.ServeSuccessJSON(map[string]interface{}{
13151
+				"msg": "发起成功",
13152
+			})
13153
+		} else {
13154
+			c.ServeSuccessJSON(map[string]interface{}{
13155
+				"code": -10,
13156
+				"msg":  res.ErrMsg,
13157
+			})
13158
+
13159
+		}
13160
+	}
13161
+}

+ 40 - 36
main.go Zobrazit soubor

@@ -2,6 +2,10 @@ package main
2 2
 
3 3
 import (
4 4
 	"gdyb/service"
5
+	"github.com/qiniu/api.v7/auth/qbox"
6
+	"github.com/qiniu/api.v7/storage"
7
+
8
+	//"gdyb/service"
5 9
 
6 10
 	//"context"
7 11
 	"fmt"
@@ -832,42 +836,42 @@ func CreateLog(miConfig models.MedicalInsuranceOrgConfig) {
832 836
 
833 837
 }
834 838
 
835
-//func UploadLog(miConfig models.MedicalInsuranceOrgConfig) {
836
-//	//获取七牛云上的文件信息,不存在则表示没上传到七牛云,上传昨天日志信息
837
-//	nTime := time.Now()
838
-//	yesTime := nTime.AddDate(0, 0, -1)
839
-//	file_key := strconv.FormatInt(miConfig.UserOrgId, 10) + "_" + yesTime.Format("20060102") + "_log.txt"
840
-//	mac := qbox.NewMac(beego.AppConfig.String("qiniu_accesskey"), beego.AppConfig.String("qiniu_secretkey"))
841
-//	cfg := storage.Config{
842
-//		// 是否使用https域名进行资源管理
843
-//		UseHTTPS: true,
844
-//	}
845
-//	// 指定空间所在的区域,如果不指定将自动探测
846
-//	// 如果没有特殊需求,默认不需要指定
847
-//	//cfg.Zone=&storage.ZoneHuabei
848
-//	bucketManager := storage.NewBucketManager(mac, &cfg)
849
-//	bucket := beego.AppConfig.String("qiniu_bucket")
850
-//	key := file_key
851
-//	file, sErr := bucketManager.Stat(bucket, key)
852
-//	fmt.Println(file)
853
-//	fmt.Println(sErr)
854
-//	fmt.Println(miConfig.OrgName + "日志" + "/" + file_key)
855
-//
856
-//	if sErr != nil {
857
-//		fmt.Println("七牛云上文件不存在,上传到七牛云")
858
-//		//判断本地文件是否存在,存在则执行上传操作
859
-//		exist, _ := PathExists(miConfig.OrgName + "日志" + "/" + file_key)
860
-//		if exist {
861
-//			upload_qiniu(miConfig.OrgName+"日志"+"/"+file_key, file_key)
862
-//		} else {
863
-//			fmt.Println("本地文件不存在")
864
-//
865
-//		}
866
-//	} else {
867
-//		fmt.Println("七牛云文件存在")
868
-//	}
869
-//
870
-//}
839
+func UploadLog(miConfig models.MedicalInsuranceOrgConfig) {
840
+	//获取七牛云上的文件信息,不存在则表示没上传到七牛云,上传昨天日志信息
841
+	nTime := time.Now()
842
+	yesTime := nTime.AddDate(0, 0, -1)
843
+	file_key := strconv.FormatInt(miConfig.UserOrgId, 10) + "_" + yesTime.Format("20060102") + "_log.txt"
844
+	mac := qbox.NewMac(beego.AppConfig.String("qiniu_accesskey"), beego.AppConfig.String("qiniu_secretkey"))
845
+	cfg := storage.Config{
846
+		// 是否使用https域名进行资源管理
847
+		UseHTTPS: true,
848
+	}
849
+	// 指定空间所在的区域,如果不指定将自动探测
850
+	// 如果没有特殊需求,默认不需要指定
851
+	//cfg.Zone=&storage.ZoneHuabei
852
+	bucketManager := storage.NewBucketManager(mac, &cfg)
853
+	bucket := beego.AppConfig.String("qiniu_bucket")
854
+	key := file_key
855
+	file, sErr := bucketManager.Stat(bucket, key)
856
+	fmt.Println(file)
857
+	fmt.Println(sErr)
858
+	fmt.Println(miConfig.OrgName + "日志" + "/" + file_key)
859
+
860
+	if sErr != nil {
861
+		fmt.Println("七牛云上文件不存在,上传到七牛云")
862
+		//判断本地文件是否存在,存在则执行上传操作
863
+		exist, _ := PathExists(miConfig.OrgName + "日志" + "/" + file_key)
864
+		if exist {
865
+			//upload_qiniu(miConfig.OrgName+"日志"+"/"+file_key, file_key)
866
+		} else {
867
+			fmt.Println("本地文件不存在")
868
+
869
+		}
870
+	} else {
871
+		fmt.Println("七牛云文件存在")
872
+	}
873
+
874
+}
871 875
 func Mkdir(dir string) {
872 876
 	// 创建文件夹
873 877
 	exist, err := PathExists(dir)

+ 43 - 0
service/hbyb_service.go Zobrazit soubor

@@ -875,7 +875,50 @@ func Hbyb3201(baseParams models.BaseParams, businessParams models.BusinessParams
875 875
 	return str
876 876
 }
877 877
 
878
+func Hbyb3202a(baseParams models.BaseParams, businessParams models.BusinessParams) string {
879
+	fmt.Println("11222333-----")
880
+
881
+	fmt.Println(baseParams)
882
+	fmt.Println(businessParams)
883
+	// 生成签名
884
+	nonce := GetRandomString(32)
885
+	timestamp := time.Now().Unix()
886
+
887
+	// 生成输入报文
888
+	inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
889
+	input := make(map[string]interface{})
890
+	inputData := make(map[string]interface{})
891
+	inputMessage["infno"] = "3202a"                             // 交易编码
892
+	inputData["insutype"] = businessParams.Insutype             // 险种
893
+	inputData["clr_type"] = businessParams.ClrType              // 就诊 ID(来自2201接口返回)
894
+	inputData["setl_optins"] = baseParams.InsuplcAdmdvs         // 结算经办机构
895
+	inputData["stmt_begndate"] = businessParams.StmtBegndate    // 对帐开始时间
896
+	inputData["stmt_enddate"] = businessParams.StmtEnddate      //对帐结束时间
897
+	inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
898
+	inputData["acct_pay"] = businessParams.AcctPay              //个人账户支付金额
899
+
900
+	input["data"] = inputData
901
+	inputMessage["input"] = input //交易输入
902
+
903
+	bytesData, err := json.Marshal(inputMessage)
904
+	fmt.Println(string(bytesData))
905
+	if err != nil {
906
+		fmt.Println(err.Error())
907
+		return err.Error()
908
+	}
909
+	var json2 string
910
+	cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "3202a", string(bytesData), json2)
911
+	out, err := cmd.Output()
912
+	if err != nil {
913
+		fmt.Println("error:", err.Error())
914
+	}
915
+	fmt.Println(string(out))
916
+	return ConvertToString(string(out), "gbk", "utf-8")
917
+
918
+}
919
+
878 920
 //文件上传
921
+
879 922
 //文件上传
880 923
 func Hbyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
881 924
 

+ 12 - 0
service/his_service.go Zobrazit soubor

@@ -520,6 +520,11 @@ func FindLastPatientPrescriptionInfo(org_id int64, patient_id int64, record_date
520 520
 	return
521 521
 }
522 522
 
523
+func FindLastPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
524
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ?", org_id, record_date, patient_id).Last(&info).Error
525
+	return
526
+}
527
+
523 528
 func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
524 529
 	err = writeDb.Save(&info).Error
525 530
 	return
@@ -986,6 +991,13 @@ func GetOrderByTime(start_time int64, end_time int64, org_id int64, insutype str
986 991
 	return
987 992
 }
988 993
 
994
+func GetOrderByTimeFour(start_time int64, end_time int64, org_id int64, insutype string, clr_org string, clr_type string) (orders []*models.HisOrder, err error) {
995
+	db := readDb.Model(&models.HisOrder{})
996
+	db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time)  <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype)
997
+	err = db.Find(&orders).Error
998
+	return
999
+}
1000
+
989 1001
 func GetOrderByTimeThree(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (orders []*models.HisOrder, err error) {
990 1002
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1  AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype).Find(&orders).Error
991 1003
 	return