Browse Source

医保对接

csx 2 years ago
parent
commit
576ba6a0dd

+ 94 - 41
controllers/coordinate_controller.go View File

@@ -10,6 +10,7 @@ import (
10 10
 	"github.com/astaxie/beego"
11 11
 	"io/ioutil"
12 12
 	"math/rand"
13
+	"os"
13 14
 	"strconv"
14 15
 	"strings"
15 16
 	"time"
@@ -28,8 +29,6 @@ type ResultReg struct {
28 29
 type ResultSettle struct {
29 30
 	ResultCode string `json:"resultCode"`
30 31
 	ResultDesc string `json:"resultDesc"`
31
-	DocId      string `json:"docId"`
32
-	Amount     string `json:"amount"`
33 32
 }
34 33
 
35 34
 type ResultCancelSettle struct {
@@ -73,7 +72,6 @@ func CoordinateRcegistRouters() {
73 72
 	beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
74 73
 	//坐标挂号
75 74
 	beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
76
-	//beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
77 75
 	//坐标记账
78 76
 	beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
79 77
 	//坐标撤销记账
@@ -170,8 +168,8 @@ func (c *CoordinateController) Register() {
170 168
 	record_date := c.GetString("record_date")
171 169
 	admin_user_id, _ := c.GetInt64("admin_user_id")
172 170
 	org_id, _ := c.GetInt64("org_id")
173
-	org_id = 4
174 171
 	patient, _ := service.GetPatientByID(org_id, patient_id)
172
+	org, _ := service.GetOrgById(org_id)
175 173
 
176 174
 	timeLayout := "2006-01-02"
177 175
 	loc, _ := time.LoadLocation("Local")
@@ -180,40 +178,40 @@ func (c *CoordinateController) Register() {
180 178
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
181 179
 		return
182 180
 	}
181
+	if len(patient.ZbPatientId) == 0 {
182
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnNoEmpty)
183
+		return
184
+	}
185
+
183 186
 	recordDateTime := theTime.Unix()
184 187
 	patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
185 188
 	if patientPrescription.ID == 0 {
186 189
 		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
187 190
 	}
188
-	//department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
189 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 193
 	reg := models.Reg{
194 194
 		DeptId:      "0112",
195 195
 		PatientId:   patient.ZbPatientId,
196 196
 		PatientName: patient.Name,
197 197
 		DoctorId:    doctor_info.DoctorNumber,
198 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 202
 		IdCardNo:    patient.IdCardNo,
203 203
 	}
204 204
 
205 205
 	result, request_log := service.SaveReg(reg)
206 206
 	fmt.Println(result)
207 207
 	fmt.Println(request_log)
208
-
208
+	saveLog(result, request_log, "登记", "登记", org.OrgName)
209 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 215
 	if res.ResultCode == "0" {
218 216
 		timestamp := time.Now().Unix()
219 217
 		tempTime := time.Unix(timestamp, 0)
@@ -262,8 +260,12 @@ func (c *CoordinateController) Register() {
262 260
 			"his_info": his,
263 261
 		})
264 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,7 +289,8 @@ func (c *CoordinateController) OpKeepAccounts() {
287 289
 	sick_type, _ := c.GetInt64("sick_type")
288 290
 	reg_type, _ := c.GetInt64("p_type")
289 291
 	org_id, _ := c.GetInt64("org_id")
290
-	org_id = 4
292
+	org, _ := service.GetOrgById(org_id)
293
+
291 294
 	his, _ := service.GetHisPatientByIdThree(his_patient_id)
292 295
 
293 296
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
@@ -433,22 +436,17 @@ func (c *CoordinateController) OpKeepAccounts() {
433 436
 		}
434 437
 	}
435 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 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 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 450
 		order := &models.HisOrder{
453 451
 			PsnNo:              his.PsnNo,
454 452
 			UserOrgId:          org_id,
@@ -461,8 +459,8 @@ func (c *CoordinateController) OpKeepAccounts() {
461 459
 			OrderStatus:        1,
462 460
 			MdtrtId:            his.Number,
463 461
 			Number:             chrg_bchno,
464
-			SetlId:             res.DocId,
465
-			MedfeeSumamt:       totals,
462
+			SetlId:             "",
463
+			MedfeeSumamt:       total,
466 464
 			MedType:            strconv.Itoa(int(reg_type)),
467 465
 			SettleEndTime:      end_time,
468 466
 			SettleStartTime:    start_time,
@@ -536,6 +534,11 @@ func (c *CoordinateController) OpKeepAccounts() {
536 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,7 +547,8 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
544 547
 	order_id, _ := c.GetInt64("order_id")
545 548
 	admin_user_id, _ := c.GetInt64("admin_user_id")
546 549
 	org_id, _ := c.GetInt64("org_id")
547
-	org_id = 4
550
+	org, _ := service.GetOrgById(org_id)
551
+
548 552
 	order, _ := service.GetHisOrderByID(order_id)
549 553
 	if order.ID == 0 {
550 554
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
@@ -553,7 +557,7 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
553 557
 
554 558
 	role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
555 559
 	result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
556
-
560
+	saveLog(result, request_log, "撤销记账", "撤销记账", org.OrgName)
557 561
 	var res RefundDetail
558 562
 	if err := json.Unmarshal([]byte(result), &res); err != nil {
559 563
 		utils.ErrorLog("解析失败:%v", err)
@@ -573,6 +577,10 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
573 577
 	if len(res.Result) == flag {
574 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 585
 	if isSuccess {
578 586
 		err := service.UpdataOrderStatus(order_id, order.Number, org_id)
@@ -585,8 +593,11 @@ func (c *CoordinateController) OpCancelKeepAccounts() {
585 593
 			return
586 594
 		}
587 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,3 +649,45 @@ const (
638 649
 	UTF8    = Charset("UTF-8")
639 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 View File

@@ -4547,40 +4547,9 @@ func (c *HisApiController) GetUploadInfo() {
4547 4547
 	reg_type, _ := c.GetInt64("p_type")
4548 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 4554
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
4586 4555
 	if err != nil {
@@ -4601,9 +4570,9 @@ func (c *HisApiController) GetUploadInfo() {
4601 4570
 
4602 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 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 4577
 		} else { //月结
4609 4578
 
@@ -4625,8 +4594,9 @@ func (c *HisApiController) GetUploadInfo() {
4625 4594
 			}
4626 4595
 			recordEndTime := theEndTime.Unix()
4627 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 4600
 		timestamp := time.Now().Unix()
4631 4601
 		tempTime := time.Unix(timestamp, 0)
4632 4602
 		timeFormat := tempTime.Format("20060102150405")
@@ -4668,7 +4638,7 @@ func (c *HisApiController) GetUploadInfo() {
4668 4638
 
4669 4639
 		allTotal := fmt.Sprintf("%.4f", total)
4670 4640
 		totals, _ := strconv.ParseFloat(allTotal, 64)
4671
-		order := &models.HisOrder{ //
4641
+		order := &models.HisOrder{
4672 4642
 			UserOrgId:             adminUser.CurrentOrgId,
4673 4643
 			HisPatientId:          his.ID,
4674 4644
 			PatientId:             id,
@@ -4698,9 +4668,8 @@ func (c *HisApiController) GetUploadInfo() {
4698 4668
 			Diagnosis:             diagnosis_id,
4699 4669
 			PType:                 2,
4700 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 4673
 		if err != nil {
4705 4674
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4706 4675
 			return
@@ -4796,28 +4765,16 @@ func (c *HisApiController) GetUploadInfo() {
4796 4765
 				Type:             types,
4797 4766
 				ItemId:           item_id,
4798 4767
 			}
4799
-			service.CreateOrderInfoTX(info, tx)
4768
+			service.CreateOrderInfo(info)
4800 4769
 		}
4801 4770
 		his.Diagnosis = diagnosis_id
4802 4771
 		his.SickType = sick_type
4803 4772
 		his.RegisterType = reg_type
4804 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 4778
 		if err == nil {
4822 4779
 			c.ServeSuccessJSON(map[string]interface{}{
4823 4780
 				"msg": "结算成功",
@@ -4862,21 +4819,15 @@ func (c *HisApiController) Refund() {
4862 4819
 	order_id, _ := c.GetInt64("order_id")
4863 4820
 	order, _ := service.GetHisOrderByID(order_id)
4864 4821
 	adminUser := c.GetAdminUserInfo()
4865
-	orgid := c.GetAdminUserInfo().CurrentOrgId
4866 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 4828
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4875 4829
 		return
4876 4830
 	}
4877
-	c.ServeSuccessJSON(map[string]interface{}{
4878
-		"msg": "退费成功",
4879
-	})
4880 4831
 }
4881 4832
 
4882 4833
 func (c *HisApiController) RefundNumber() {
@@ -5257,15 +5208,17 @@ func (c *HisApiController) GetAllOrderDetail() {
5257 5208
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
5258 5209
 		return
5259 5210
 	}
5211
+	record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
5260 5212
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5261 5213
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5262 5214
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5263 5215
 	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5264 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 5223
 	return
5271 5224
 

+ 5 - 0
controllers/his_project_api_controller.go View File

@@ -1240,6 +1240,10 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1240 1240
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1241 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 1247
 	eles, _ := service.GetNewAdminUserES(adminUserInfo.CurrentOrgId)
1244 1248
 
1245 1249
 	if err != nil {
@@ -1254,6 +1258,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1254 1258
 		"hisHospitalRecord": hisHospitalRecord,
1255 1259
 		"info":              prescriptionInfo,
1256 1260
 		"eles":              eles,
1261
+		"psn_info":          psn_info,
1257 1262
 	})
1258 1263
 }
1259 1264
 

+ 4 - 0
enums/error_code.go View File

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

+ 5 - 0
service/his_hospital_service.go View File

@@ -548,3 +548,8 @@ func UpdataHospitalOrderStatusTwo(number string, user_org_id int64) (err error)
548 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 View File

@@ -755,7 +755,7 @@ func GetHisPatientByIdThreeTX(id int64, tx *gorm.DB) (models.HisPatient, error)
755 755
 }
756 756
 
757 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 759
 	return
760 760
 }
761 761
 

+ 32 - 0
utils/log.go View File

@@ -2,6 +2,7 @@ package utils
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"os"
5 6
 	"time"
6 7
 )
7 8
 
@@ -64,3 +65,34 @@ func magenta(s string) string {
64 65
 func formatLog(prefix string) string {
65 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 View File

@@ -4,6 +4,26 @@ import (
4 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 27
 // day 当天凌晨0点
8 28
 func ZeroHourTimeOfDay(day time.Time) time.Time {
9 29
 	dayStr := day.Format("2006-01-02")