소스 검색

Merge branch '20211122' of http://git.shengws.com/csx/XT_New into 20211122

XMLWAN 3 년 전
부모
커밋
b1d2d87be9

+ 94 - 41
controllers/coordinate_controller.go 파일 보기

@@ -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 - 14
controllers/his_api_controller.go 파일 보기

@@ -548,7 +548,7 @@ func (c *HisApiController) GetHisPatientList() {
548 548
 	recordDateTime := theTime.Unix()
549 549
 	adminInfo := c.GetAdminUserInfo()
550 550
 	//patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
551
-	patients, _ := service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime)
551
+	patients, _ := service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
552 552
 	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
553 553
 	//获取当前用户的信息
554 554
 	adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
@@ -4602,9 +4602,9 @@ func (c *HisApiController) GetUploadInfo() {
4602 4602
 
4603 4603
 			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
4604 4604
 
4605
-				prescriptions, _ = service.GetPrescriptionByIdsTX(ids_arr, adminUser.CurrentOrgId, tx)
4605
+				prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
4606 4606
 			} else {
4607
-				prescriptions, _ = service.GetSettleHisPrescriptionTX(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
4607
+				prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
4608 4608
 			}
4609 4609
 		} else { //月结
4610 4610
 
@@ -4626,8 +4626,9 @@ func (c *HisApiController) GetUploadInfo() {
4626 4626
 			}
4627 4627
 			recordEndTime := theEndTime.Unix()
4628 4628
 			end_time = recordEndTime
4629
-			prescriptions, _ = service.GetMonthHisPrescriptionTX(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type, tx)
4629
+			prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
4630 4630
 		}
4631
+
4631 4632
 		timestamp := time.Now().Unix()
4632 4633
 		tempTime := time.Unix(timestamp, 0)
4633 4634
 		timeFormat := tempTime.Format("20060102150405")
@@ -4669,7 +4670,7 @@ func (c *HisApiController) GetUploadInfo() {
4669 4670
 
4670 4671
 		allTotal := fmt.Sprintf("%.4f", total)
4671 4672
 		totals, _ := strconv.ParseFloat(allTotal, 64)
4672
-		order := &models.HisOrder{ //
4673
+		order := &models.HisOrder{
4673 4674
 			UserOrgId:             adminUser.CurrentOrgId,
4674 4675
 			HisPatientId:          his.ID,
4675 4676
 			PatientId:             id,
@@ -4699,9 +4700,8 @@ func (c *HisApiController) GetUploadInfo() {
4699 4700
 			Diagnosis:             diagnosis_id,
4700 4701
 			PType:                 2,
4701 4702
 			SetlTime:              tm.Format("2006-01-02 15:04:05"),
4702
-			Decimal:               decimal,
4703 4703
 		}
4704
-		err = service.CreateOrderTX(order, tx)
4704
+		err = service.CreateOrder(order)
4705 4705
 		if err != nil {
4706 4706
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4707 4707
 			return
@@ -5261,15 +5261,17 @@ func (c *HisApiController) GetAllOrderDetail() {
5261 5261
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
5262 5262
 		return
5263 5263
 	}
5264
+	record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
5264 5265
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5265 5266
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5266 5267
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5267 5268
 	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5268 5269
 	c.ServeSuccessJSON(map[string]interface{}{
5269
-		"order":      order,
5270
-		"order_info": order_info,
5271
-		"patient":    patient,
5272
-		"admin_info": adminInfo,
5270
+		"order":           order,
5271
+		"order_info":      order_info,
5272
+		"patient":         patient,
5273
+		"admin_info":      adminInfo,
5274
+		"hospital_record": record,
5273 5275
 	})
5274 5276
 	return
5275 5277
 
@@ -6147,9 +6149,17 @@ func (c *HisApiController) GetFaPiaoData() {
6147 6149
 				chineseTraditionalMedicineCostSelfTotal = chineseTraditionalMedicineCostTotal
6148 6150
 			}
6149 6151
 
6150
-			if item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
6151
-				otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
6152
-				otherCostSelfTotal = otherCostTotal
6152
+			if c.GetAdminUserInfo().CurrentOrgId == 10106 {
6153
+				if item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
6154
+					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
6155
+					otherCostSelfTotal = otherCostTotal
6156
+				}
6157
+			} else {
6158
+				if item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
6159
+					otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
6160
+					otherCostSelfTotal = otherCostTotal
6161
+				}
6162
+
6153 6163
 			}
6154 6164
 
6155 6165
 		}

+ 5 - 0
controllers/his_project_api_controller.go 파일 보기

@@ -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 파일 보기

@@ -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 {

+ 23 - 0
models/his_hospital_models.go 파일 보기

@@ -77,6 +77,7 @@ type HisHospitalCheckRecord struct {
77 77
 	Phone                string           `gorm:"column:phone" json:"phone" form:"phone"`
78 78
 	HisHospitalOrder     HisHospitalOrder `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"order"`
79 79
 	BalanceAccountsType  int64            `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
80
+	InsuplcAdmdvs        string           `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
80 81
 }
81 82
 
82 83
 func (HisHospitalCheckRecord) TableName() string {
@@ -212,3 +213,25 @@ type HisHospitalOrderInfo struct {
212 213
 func (HisHospitalOrderInfo) TableName() string {
213 214
 	return "his_order_info"
214 215
 }
216
+
217
+type HisPsn struct {
218
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
219
+	PsnNo        string  `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
220
+	Age          float64 `gorm:"column:age" json:"age" form:"age"`
221
+	PatientId    int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
222
+	Certno       string  `gorm:"column:certno" json:"certno" form:"certno"`
223
+	Brdy         string  `gorm:"column:brdy" json:"brdy" form:"brdy"`
224
+	Gend         string  `gorm:"column:gend" json:"gend" form:"gend"`
225
+	Naty         string  `gorm:"column:naty" json:"naty" form:"naty"`
226
+	PsnCertType  string  `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
227
+	PsnName      string  `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
228
+	Idetinfo     string  `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
229
+	Insuinfo     string  `gorm:"column:insuinfo" json:"insuinfo" form:"insuinfo"`
230
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
231
+	CardInfo     string  `gorm:"column:card_info" json:"card_info" form:"card_info"`
232
+	VerifyNumber string  `gorm:"column:verify_number" json:"verify_number" form:"verify_number"`
233
+}
234
+
235
+func (HisPsn) TableName() string {
236
+	return "his_psn"
237
+}

+ 5 - 0
service/his_hospital_service.go 파일 보기

@@ -552,3 +552,8 @@ func UpdataHospitalOrderStatusTwo(number string, user_org_id int64) (err error)
552 552
 	return
553 553
 
554 554
 }
555
+
556
+func GetPsnByPatientId(patient_id int64) (psn models.HisPsn, err error) {
557
+	err = readDb.Model(&models.HisPsn{}).Where("patient_id = ?", patient_id).Last(&psn).Error
558
+	return
559
+}

+ 1 - 1
service/his_project_service.go 파일 보기

@@ -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
 

+ 6 - 4
service/his_service.go 파일 보기

@@ -260,9 +260,12 @@ func (HisPrescriptionTwo) TableName() string {
260 260
 	return "his_prescription"
261 261
 }
262 262
 
263
-func GetNewHisPatientList(org_id int64, record_date int64) (patients []*PatientTwo, err error) {
263
+func GetNewHisPatientList(org_id int64, record_date int64, sch_type int64) (patients []*PatientTwo, err error) {
264 264
 	db := readDb.Model(&PatientTwo{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
265 265
 		Joins("join his_patient as hp ON hp.patient_id = xt_patients.id AND hp.record_date = ? AND hp.status = 1 AND hp.user_org_id = ?", record_date, org_id)
266
+	if sch_type > 0 {
267
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND schedule_type = ?", record_date, org_id, sch_type)
268
+	}
266 269
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
267 270
 		return db.Preload("HisPrescriptionTwo", "status = 1 AND user_org_id = ?  AND record_date = ?", org_id, record_date).Where("user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
268 271
 	})
@@ -1208,10 +1211,9 @@ func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
1208 1211
 
1209 1212
 func UpdataHospitalOrderStatus(id int64, number string, user_org_id int64, log string, result string) (err error) {
1210 1213
 	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "refund_request_log": log, "refund_log": result, "status": 0}).Error
1211
-	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
1212
-	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
1214
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 4, "mtime": time.Now().Unix()}).Error
1215
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 4, "mtime": time.Now().Unix()}).Error
1213 1216
 	return
1214
-
1215 1217
 }
1216 1218
 
1217 1219
 func UpdataOrderInfoStatus(id int64, number string, user_org_id int64) {

+ 32 - 0
utils/log.go 파일 보기

@@ -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 파일 보기

@@ -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")