Bladeren bron

医保对接

csx 3 jaren geleden
bovenliggende
commit
576ba6a0dd

+ 94 - 41
controllers/coordinate_controller.go Bestand weergeven

10
 	"github.com/astaxie/beego"
10
 	"github.com/astaxie/beego"
11
 	"io/ioutil"
11
 	"io/ioutil"
12
 	"math/rand"
12
 	"math/rand"
13
+	"os"
13
 	"strconv"
14
 	"strconv"
14
 	"strings"
15
 	"strings"
15
 	"time"
16
 	"time"
28
 type ResultSettle struct {
29
 type ResultSettle struct {
29
 	ResultCode string `json:"resultCode"`
30
 	ResultCode string `json:"resultCode"`
30
 	ResultDesc string `json:"resultDesc"`
31
 	ResultDesc string `json:"resultDesc"`
31
-	DocId      string `json:"docId"`
32
-	Amount     string `json:"amount"`
33
 }
32
 }
34
 
33
 
35
 type ResultCancelSettle struct {
34
 type ResultCancelSettle struct {
73
 	beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
72
 	beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
74
 	//坐标挂号
73
 	//坐标挂号
75
 	beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
74
 	beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
76
-	//beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
77
 	//坐标记账
75
 	//坐标记账
78
 	beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
76
 	beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
79
 	//坐标撤销记账
77
 	//坐标撤销记账
170
 	record_date := c.GetString("record_date")
168
 	record_date := c.GetString("record_date")
171
 	admin_user_id, _ := c.GetInt64("admin_user_id")
169
 	admin_user_id, _ := c.GetInt64("admin_user_id")
172
 	org_id, _ := c.GetInt64("org_id")
170
 	org_id, _ := c.GetInt64("org_id")
173
-	org_id = 4
174
 	patient, _ := service.GetPatientByID(org_id, patient_id)
171
 	patient, _ := service.GetPatientByID(org_id, patient_id)
172
+	org, _ := service.GetOrgById(org_id)
175
 
173
 
176
 	timeLayout := "2006-01-02"
174
 	timeLayout := "2006-01-02"
177
 	loc, _ := time.LoadLocation("Local")
175
 	loc, _ := time.LoadLocation("Local")
180
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
181
 		return
179
 		return
182
 	}
180
 	}
181
+	if len(patient.ZbPatientId) == 0 {
182
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnNoEmpty)
183
+		return
184
+	}
185
+
183
 	recordDateTime := theTime.Unix()
186
 	recordDateTime := theTime.Unix()
184
 	patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
187
 	patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
185
 	if patientPrescription.ID == 0 {
188
 	if patientPrescription.ID == 0 {
186
 		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
189
 		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
187
 	}
190
 	}
188
-	//department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
189
 	doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
191
 	doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
190
-
191
-	//admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
192
-
192
+	admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
193
 	reg := models.Reg{
193
 	reg := models.Reg{
194
 		DeptId:      "0112",
194
 		DeptId:      "0112",
195
 		PatientId:   patient.ZbPatientId,
195
 		PatientId:   patient.ZbPatientId,
196
 		PatientName: patient.Name,
196
 		PatientName: patient.Name,
197
 		DoctorId:    doctor_info.DoctorNumber,
197
 		DoctorId:    doctor_info.DoctorNumber,
198
 		RegDate:     strings.Split(diagnosis_time, " ")[0],
198
 		RegDate:     strings.Split(diagnosis_time, " ")[0],
199
-		RegFee:      "8",
200
-		TreatFee:    "10",
201
-		OperatorId:  "测试",
199
+		RegFee:      "0",
200
+		TreatFee:    "0",
201
+		OperatorId:  admin_user_info.UserName,
202
 		IdCardNo:    patient.IdCardNo,
202
 		IdCardNo:    patient.IdCardNo,
203
 	}
203
 	}
204
 
204
 
205
 	result, request_log := service.SaveReg(reg)
205
 	result, request_log := service.SaveReg(reg)
206
 	fmt.Println(result)
206
 	fmt.Println(result)
207
 	fmt.Println(request_log)
207
 	fmt.Println(request_log)
208
-
208
+	saveLog(result, request_log, "登记", "登记", org.OrgName)
209
 	var res ResultReg
209
 	var res ResultReg
210
-	//if err := json.Unmarshal([]byte(result), &res); err != nil {
211
-	//	utils.ErrorLog("解析失败:%v", err)
212
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
213
-	//	return
214
-	//}
215
-	res.ResultCode = "0"
216
-	res.InfoSeq = "122333"
210
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
211
+		utils.ErrorLog("解析失败:%v", err)
212
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
213
+		return
214
+	}
217
 	if res.ResultCode == "0" {
215
 	if res.ResultCode == "0" {
218
 		timestamp := time.Now().Unix()
216
 		timestamp := time.Now().Unix()
219
 		tempTime := time.Unix(timestamp, 0)
217
 		tempTime := time.Unix(timestamp, 0)
262
 			"his_info": his,
260
 			"his_info": his,
263
 		})
261
 		})
264
 	} else {
262
 	} else {
265
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
266
-		return
263
+
264
+		c.ServeSuccessJSON(map[string]interface{}{
265
+			"failed_code": -10,
266
+			"msg":         res.ResultDesc,
267
+		})
268
+
267
 	}
269
 	}
268
 }
270
 }
269
 
271
 
287
 	sick_type, _ := c.GetInt64("sick_type")
289
 	sick_type, _ := c.GetInt64("sick_type")
288
 	reg_type, _ := c.GetInt64("p_type")
290
 	reg_type, _ := c.GetInt64("p_type")
289
 	org_id, _ := c.GetInt64("org_id")
291
 	org_id, _ := c.GetInt64("org_id")
290
-	org_id = 4
292
+	org, _ := service.GetOrgById(org_id)
293
+
291
 	his, _ := service.GetHisPatientByIdThree(his_patient_id)
294
 	his, _ := service.GetHisPatientByIdThree(his_patient_id)
292
 
295
 
293
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
296
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
433
 		}
436
 		}
434
 	}
437
 	}
435
 	result, request_log := service.OpKeepAccounts(his.Number, customs)
438
 	result, request_log := service.OpKeepAccounts(his.Number, customs)
436
-
437
-	fmt.Println(result)
438
-	fmt.Println(request_log)
439
+	saveLog(result, request_log, "记账", "记账", org.OrgName)
439
 
440
 
440
 	var res ResultSettle
441
 	var res ResultSettle
441
-	res.ResultCode = "0"
442
-	res.DocId = "708275799870021632"
443
-	res.Amount = "1088.00"
444
-	//if err := json.Unmarshal([]byte(result), &res); err != nil {
445
-	//	utils.ErrorLog("解析失败:%v", err)
446
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
447
-	//	return
448
-	//}
442
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
443
+		utils.ErrorLog("解析失败:%v", err)
444
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
445
+		return
446
+	}
449
 	if res.ResultCode == "0" {
447
 	if res.ResultCode == "0" {
450
-		//allTotal := fmt.Sprintf("%.4f", total)
451
-		totals, _ := strconv.ParseFloat(res.Amount, 64)
448
+
449
+		//totals, _ := strconv.ParseFloat(total, 64)
452
 		order := &models.HisOrder{
450
 		order := &models.HisOrder{
453
 			PsnNo:              his.PsnNo,
451
 			PsnNo:              his.PsnNo,
454
 			UserOrgId:          org_id,
452
 			UserOrgId:          org_id,
461
 			OrderStatus:        1,
459
 			OrderStatus:        1,
462
 			MdtrtId:            his.Number,
460
 			MdtrtId:            his.Number,
463
 			Number:             chrg_bchno,
461
 			Number:             chrg_bchno,
464
-			SetlId:             res.DocId,
465
-			MedfeeSumamt:       totals,
462
+			SetlId:             "",
463
+			MedfeeSumamt:       total,
466
 			MedType:            strconv.Itoa(int(reg_type)),
464
 			MedType:            strconv.Itoa(int(reg_type)),
467
 			SettleEndTime:      end_time,
465
 			SettleEndTime:      end_time,
468
 			SettleStartTime:    start_time,
466
 			SettleStartTime:    start_time,
536
 				"msg": "记账成功",
534
 				"msg": "记账成功",
537
 			})
535
 			})
538
 		}
536
 		}
537
+	} else {
538
+		c.ServeSuccessJSON(map[string]interface{}{
539
+			"failed_code": -10,
540
+			"msg":         res.ResultDesc,
541
+		})
539
 	}
542
 	}
540
 
543
 
541
 }
544
 }
544
 	order_id, _ := c.GetInt64("order_id")
547
 	order_id, _ := c.GetInt64("order_id")
545
 	admin_user_id, _ := c.GetInt64("admin_user_id")
548
 	admin_user_id, _ := c.GetInt64("admin_user_id")
546
 	org_id, _ := c.GetInt64("org_id")
549
 	org_id, _ := c.GetInt64("org_id")
547
-	org_id = 4
550
+	org, _ := service.GetOrgById(org_id)
551
+
548
 	order, _ := service.GetHisOrderByID(order_id)
552
 	order, _ := service.GetHisOrderByID(order_id)
549
 	if order.ID == 0 {
553
 	if order.ID == 0 {
550
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
554
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
553
 
557
 
554
 	role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
558
 	role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
555
 	result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
559
 	result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
556
-
560
+	saveLog(result, request_log, "撤销记账", "撤销记账", org.OrgName)
557
 	var res RefundDetail
561
 	var res RefundDetail
558
 	if err := json.Unmarshal([]byte(result), &res); err != nil {
562
 	if err := json.Unmarshal([]byte(result), &res); err != nil {
559
 		utils.ErrorLog("解析失败:%v", err)
563
 		utils.ErrorLog("解析失败:%v", err)
573
 	if len(res.Result) == flag {
577
 	if len(res.Result) == flag {
574
 		isSuccess = true
578
 		isSuccess = true
575
 	}
579
 	}
580
+	var errMsg string
581
+	for _, item := range res.Result {
582
+		errMsg = errMsg + "\n" + item.ResultMsg
583
+	}
576
 
584
 
577
 	if isSuccess {
585
 	if isSuccess {
578
 		err := service.UpdataOrderStatus(order_id, order.Number, org_id)
586
 		err := service.UpdataOrderStatus(order_id, order.Number, org_id)
585
 			return
593
 			return
586
 		}
594
 		}
587
 	} else {
595
 	} else {
588
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
589
-		return
596
+		c.ServeSuccessJSON(map[string]interface{}{
597
+			"failed_code": -10,
598
+			"msg":         errMsg,
599
+		})
600
+
590
 	}
601
 	}
591
 }
602
 }
592
 
603
 
638
 	UTF8    = Charset("UTF-8")
649
 	UTF8    = Charset("UTF-8")
639
 	GB18030 = Charset("GB18030")
650
 	GB18030 = Charset("GB18030")
640
 )
651
 )
652
+
653
+func saveLog(result string, request string, infno string, desc string, org_name string) {
654
+
655
+	//org_id, _ := beego.AppConfig.Int64("org_id")
656
+	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
657
+	dir := org_name + "日志"
658
+	utils.Mkdir(dir)
659
+	month := time.Unix(1557042972, 0).Format("1")
660
+	year := time.Now().Format("2006")
661
+	month = time.Now().Format("01")
662
+	day := time.Now().Format("02")
663
+	hour := time.Now().Format("15")
664
+	min := time.Now().Format("04")
665
+	sec := time.Now().Format("05")
666
+
667
+	result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
668
+
669
+	file := org_name + "_" + year + month + day + "_log"
670
+	file_name := file + ".txt"
671
+	file_path := org_name + "日志" + "/" + file_name
672
+	exist, _ := utils.PathExists(file_path)
673
+	if exist { //存在
674
+		fmt.Println("存在")
675
+		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
676
+		if err != nil {
677
+			fmt.Println("read fail")
678
+		}
679
+		content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
680
+		n, _ := f.Seek(0, 2)
681
+		_, err = f.WriteAt([]byte(content), n)
682
+
683
+	} else { //不存在
684
+		fmt.Println("文件不存在,创建文件")
685
+		f, err := os.Create(org_name + "日志" + "/" + file_name)
686
+		defer f.Close()
687
+		if err != nil {
688
+		} else {
689
+			_, err = f.Write([]byte("记录日志"))
690
+		}
691
+	}
692
+
693
+}

+ 24 - 71
controllers/his_api_controller.go Bestand weergeven

4547
 	reg_type, _ := c.GetInt64("p_type")
4547
 	reg_type, _ := c.GetInt64("p_type")
4548
 	order_id, _ := c.GetInt64("order_id")
4548
 	order_id, _ := c.GetInt64("order_id")
4549
 
4549
 
4550
-	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
4551
-	tmp_decimal := c.GetString("tmp_decimal")
4552
-	var decimal float64 //本次使用的押金
4553
-	var errmsg error
4554
-	tx := service.XTWriteDB().Begin() //开了事务
4555
-	//只检测扣费函数SpendDeposit有没有返回错误,如果有则回滚所有以TX结尾的方法(去掉TX即为原先的方法)
4556
-	defer func() {
4557
-		if errmsg != nil {
4558
-			utils.ErrorLog("事务失败,原因为: %v", errmsg.Error())
4559
-			tx.Rollback()
4560
-		} else {
4561
-			tx.Commit()
4562
-		}
4563
-	}()
4564
-	if dec_way == "true" && tmp_decimal == "0" && tmp_decimal == "" {
4565
-		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
4566
-		return
4567
-	}
4568
-	if len(tmp_decimal) > 0 {
4569
-		if tmp_decimal[0] == 45 {
4570
-			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
4571
-			return
4572
-		}
4573
-	}
4574
-	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
4575
-	if errs != nil {
4576
-		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
4577
-		return
4578
-	}
4579
-	decimal = tt
4580
-
4581
-	his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)
4550
+	his, _ := service.GetHisPatientByIdThree(his_patient_id)
4582
 
4551
 
4583
-	tempOrder, _ := service.GetHisOrderByIDTX(order_id, tx)
4552
+	tempOrder, _ := service.GetHisOrderByID(order_id)
4584
 
4553
 
4585
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
4554
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
4586
 	if err != nil {
4555
 	if err != nil {
4601
 
4570
 
4602
 			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
4571
 			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
4603
 
4572
 
4604
-				prescriptions, _ = service.GetPrescriptionByIdsTX(ids_arr, adminUser.CurrentOrgId, tx)
4573
+				prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
4605
 			} else {
4574
 			} else {
4606
-				prescriptions, _ = service.GetSettleHisPrescriptionTX(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
4575
+				prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
4607
 			}
4576
 			}
4608
 		} else { //月结
4577
 		} else { //月结
4609
 
4578
 
4625
 			}
4594
 			}
4626
 			recordEndTime := theEndTime.Unix()
4595
 			recordEndTime := theEndTime.Unix()
4627
 			end_time = recordEndTime
4596
 			end_time = recordEndTime
4628
-			prescriptions, _ = service.GetMonthHisPrescriptionTX(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type, tx)
4597
+			prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
4629
 		}
4598
 		}
4599
+
4630
 		timestamp := time.Now().Unix()
4600
 		timestamp := time.Now().Unix()
4631
 		tempTime := time.Unix(timestamp, 0)
4601
 		tempTime := time.Unix(timestamp, 0)
4632
 		timeFormat := tempTime.Format("20060102150405")
4602
 		timeFormat := tempTime.Format("20060102150405")
4668
 
4638
 
4669
 		allTotal := fmt.Sprintf("%.4f", total)
4639
 		allTotal := fmt.Sprintf("%.4f", total)
4670
 		totals, _ := strconv.ParseFloat(allTotal, 64)
4640
 		totals, _ := strconv.ParseFloat(allTotal, 64)
4671
-		order := &models.HisOrder{ //
4641
+		order := &models.HisOrder{
4672
 			UserOrgId:             adminUser.CurrentOrgId,
4642
 			UserOrgId:             adminUser.CurrentOrgId,
4673
 			HisPatientId:          his.ID,
4643
 			HisPatientId:          his.ID,
4674
 			PatientId:             id,
4644
 			PatientId:             id,
4698
 			Diagnosis:             diagnosis_id,
4668
 			Diagnosis:             diagnosis_id,
4699
 			PType:                 2,
4669
 			PType:                 2,
4700
 			SetlTime:              tm.Format("2006-01-02 15:04:05"),
4670
 			SetlTime:              tm.Format("2006-01-02 15:04:05"),
4701
-			Decimal:               decimal,
4702
 		}
4671
 		}
4703
-		err = service.CreateOrderTX(order, tx)
4672
+		err = service.CreateOrder(order)
4704
 		if err != nil {
4673
 		if err != nil {
4705
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4674
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4706
 			return
4675
 			return
4796
 				Type:             types,
4765
 				Type:             types,
4797
 				ItemId:           item_id,
4766
 				ItemId:           item_id,
4798
 			}
4767
 			}
4799
-			service.CreateOrderInfoTX(info, tx)
4768
+			service.CreateOrderInfo(info)
4800
 		}
4769
 		}
4801
 		his.Diagnosis = diagnosis_id
4770
 		his.Diagnosis = diagnosis_id
4802
 		his.SickType = sick_type
4771
 		his.SickType = sick_type
4803
 		his.RegisterType = reg_type
4772
 		his.RegisterType = reg_type
4804
 		his.MedicalTreatmentType = reg_type
4773
 		his.MedicalTreatmentType = reg_type
4805
-		service.UpdataHisPateintTX(&his, tx)
4806
-		err = service.UpDatePrescriptionNumberTX(adminUser.CurrentOrgId, ids, chrg_bchno, tx)
4807
-		err = service.UpDateHisPrescriptionInfoNumberTX(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id, tx)
4808
-		err = service.UpdataOrderStatusTwoTX(chrg_bchno, adminUser.CurrentOrgId, tx)
4809
-		//判断是否使用了押金
4810
-		if dec_way == "true" {
4811
-
4812
-			tmpstring := strconv.FormatInt(order.ID, 10)
4813
-			//扣押金
4814
-			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
4815
-			if errmsg != nil {
4816
-				c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
4817
-				//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4818
-				return
4819
-			}
4820
-		}
4774
+		service.UpdataHisPateint(&his)
4775
+		err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
4776
+		err = service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id)
4777
+		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
4821
 		if err == nil {
4778
 		if err == nil {
4822
 			c.ServeSuccessJSON(map[string]interface{}{
4779
 			c.ServeSuccessJSON(map[string]interface{}{
4823
 				"msg": "结算成功",
4780
 				"msg": "结算成功",
4862
 	order_id, _ := c.GetInt64("order_id")
4819
 	order_id, _ := c.GetInt64("order_id")
4863
 	order, _ := service.GetHisOrderByID(order_id)
4820
 	order, _ := service.GetHisOrderByID(order_id)
4864
 	adminUser := c.GetAdminUserInfo()
4821
 	adminUser := c.GetAdminUserInfo()
4865
-	orgid := c.GetAdminUserInfo().CurrentOrgId
4866
 	err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
4822
 	err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
4867
-	if err != nil {
4868
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4869
-		return
4870
-	}
4871
-	tmp := strconv.FormatInt(order.ID, 10)
4872
-	err = service.MoneyIncrease(orgid, order.HisPatientId, tmp, order.Decimal)
4873
-	if err != nil {
4823
+	if err == nil {
4824
+		c.ServeSuccessJSON(map[string]interface{}{
4825
+			"msg": "退费成功",
4826
+		})
4827
+	} else {
4874
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4828
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4875
 		return
4829
 		return
4876
 	}
4830
 	}
4877
-	c.ServeSuccessJSON(map[string]interface{}{
4878
-		"msg": "退费成功",
4879
-	})
4880
 }
4831
 }
4881
 
4832
 
4882
 func (c *HisApiController) RefundNumber() {
4833
 func (c *HisApiController) RefundNumber() {
5257
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
5208
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
5258
 		return
5209
 		return
5259
 	}
5210
 	}
5211
+	record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
5260
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5212
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5261
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5213
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5262
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5214
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5263
 	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5215
 	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5264
 	c.ServeSuccessJSON(map[string]interface{}{
5216
 	c.ServeSuccessJSON(map[string]interface{}{
5265
-		"order":      order,
5266
-		"order_info": order_info,
5267
-		"patient":    patient,
5268
-		"admin_info": adminInfo,
5217
+		"order":           order,
5218
+		"order_info":      order_info,
5219
+		"patient":         patient,
5220
+		"admin_info":      adminInfo,
5221
+		"hospital_record": record,
5269
 	})
5222
 	})
5270
 	return
5223
 	return
5271
 
5224
 

+ 5 - 0
controllers/his_project_api_controller.go Bestand weergeven

1240
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1240
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1241
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1241
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1242
 
1242
 
1243
+	//psn_info, _ := service.GetPsnInfo(patient_id)
1244
+
1245
+	psn_info, _ := service.GetPsnByPatientId(patient_id)
1246
+
1243
 	eles, _ := service.GetNewAdminUserES(adminUserInfo.CurrentOrgId)
1247
 	eles, _ := service.GetNewAdminUserES(adminUserInfo.CurrentOrgId)
1244
 
1248
 
1245
 	if err != nil {
1249
 	if err != nil {
1254
 		"hisHospitalRecord": hisHospitalRecord,
1258
 		"hisHospitalRecord": hisHospitalRecord,
1255
 		"info":              prescriptionInfo,
1259
 		"info":              prescriptionInfo,
1256
 		"eles":              eles,
1260
 		"eles":              eles,
1261
+		"psn_info":          psn_info,
1257
 	})
1262
 	})
1258
 }
1263
 }
1259
 
1264
 

+ 4 - 0
enums/error_code.go Bestand weergeven

245
 	ErrorCodeHospitalExistDataException = 300010
245
 	ErrorCodeHospitalExistDataException = 300010
246
 
246
 
247
 	ErrorCodeRecordFailedException = 300011
247
 	ErrorCodeRecordFailedException = 300011
248
+
249
+	ErrorPsnNoEmpty = 310000
248
 )
250
 )
249
 
251
 
250
 var ErrCodeMsgs = map[int]string{
252
 var ErrCodeMsgs = map[int]string{
480
 	ErrorCodeRecordFailedException: "记录不存在",
482
 	ErrorCodeRecordFailedException: "记录不存在",
481
 
483
 
482
 	ErrorCodeStockExced: "请先出库,执行失败",
484
 	ErrorCodeStockExced: "请先出库,执行失败",
485
+
486
+	ErrorPsnNoEmpty: "人员编码不能为空",
483
 }
487
 }
484
 
488
 
485
 type SGJError struct {
489
 type SGJError struct {

+ 5 - 0
service/his_hospital_service.go Bestand weergeven

548
 	return
548
 	return
549
 
549
 
550
 }
550
 }
551
+
552
+func GetPsnByPatientId(patient_id int64) (psn models.HisPsn, err error) {
553
+	err = readDb.Model(&models.HisPsn{}).Where("patient_id = ?", patient_id).Last(&psn).Error
554
+	return
555
+}

+ 1 - 1
service/his_project_service.go Bestand weergeven

755
 }
755
 }
756
 
756
 
757
 func GetLastHisPatient(patient_id int64, org_id int64) (his models.HisPatient, err error) {
757
 func GetLastHisPatient(patient_id int64, org_id int64) (his models.HisPatient, err error) {
758
-	err = XTReadDB().Model(&models.HisPatient{}).Where("user_org_id = ? AND patient_id = ? and status = 1 AND patient_info <> ''", org_id, patient_id).First(&his).Error
758
+	err = XTReadDB().Model(&models.HisPatient{}).Where("user_org_id = ? AND patient_id = ? and status = 1 and patient_info <> ''", org_id, patient_id).First(&his).Error
759
 	return
759
 	return
760
 }
760
 }
761
 
761
 

+ 32 - 0
utils/log.go Bestand weergeven

2
 
2
 
3
 import (
3
 import (
4
 	"fmt"
4
 	"fmt"
5
+	"os"
5
 	"time"
6
 	"time"
6
 )
7
 )
7
 
8
 
64
 func formatLog(prefix string) string {
65
 func formatLog(prefix string) string {
65
 	return time.Now().Format("[2006/01/02 15:04:05]") + " " + prefix + " "
66
 	return time.Now().Format("[2006/01/02 15:04:05]") + " " + prefix + " "
66
 }
67
 }
68
+
69
+func Mkdir(dir string) {
70
+	// 创建文件夹
71
+	exist, err := PathExists(dir)
72
+	if err != nil {
73
+		fmt.Println(err.Error())
74
+	} else {
75
+		if exist {
76
+			fmt.Println(dir + "文件夹已存在!")
77
+		} else {
78
+			// 文件夹名称,权限
79
+			err := os.Mkdir(dir, os.ModePerm)
80
+			if err != nil {
81
+				fmt.Println(dir+"文件夹创建失败:", err.Error())
82
+			} else {
83
+				fmt.Println(dir + "文件夹创建成功!")
84
+			}
85
+		}
86
+	}
87
+}
88
+
89
+func PathExists(path string) (bool, error) {
90
+	_, err := os.Stat(path)
91
+	if err == nil {
92
+		return true, nil
93
+	}
94
+	if os.IsNotExist(err) {
95
+		return false, nil
96
+	}
97
+	return false, err
98
+}

+ 20 - 0
utils/time_helper.go Bestand weergeven

4
 	"time"
4
 	"time"
5
 )
5
 )
6
 
6
 
7
+const ntpEpochOffset = 2208988800
8
+
9
+type packet struct {
10
+	Settings       uint8
11
+	Stratum        uint8
12
+	Poll           int8
13
+	Precision      int8
14
+	RootDelay      uint32
15
+	RootDispersion uint32
16
+	ReferenceID    uint32
17
+	RefTimeSec     uint32
18
+	RefTimeFrac    uint32
19
+	OrigTimeSec    uint32
20
+	OrigTimeFrac   uint32
21
+	RxTimeSec      uint32
22
+	RxTimeFrac     uint32
23
+	TxTimeSec      uint32
24
+	TxTimeFrac     uint32
25
+}
26
+
7
 // day 当天凌晨0点
27
 // day 当天凌晨0点
8
 func ZeroHourTimeOfDay(day time.Time) time.Time {
28
 func ZeroHourTimeOfDay(day time.Time) time.Time {
9
 	dayStr := day.Format("2006-01-02")
29
 	dayStr := day.Format("2006-01-02")