浏览代码

耗材参数

XMLWAN 4 年前
父节点
当前提交
0b2064030e
共有 3 个文件被更改,包括 60 次插入1 次删除
  1. 31 0
      controllers/his_project_api_controller.go
  2. 1 0
      models/his_models.go
  3. 28 1
      service/his_project_service.go

+ 31 - 0
controllers/his_project_api_controller.go 查看文件

76
 	beego.Router("/api/hispatient/getchargeprinttemplate", &HisProjectApiController{}, "Get:GetChargePrintTemplate")
76
 	beego.Router("/api/hispatient/getchargeprinttemplate", &HisProjectApiController{}, "Get:GetChargePrintTemplate")
77
 	beego.Router("/api/hispatient/getallhispatient", &HisProjectApiController{}, "Get:GetAllHisPatient")
77
 	beego.Router("/api/hispatient/getallhispatient", &HisProjectApiController{}, "Get:GetAllHisPatient")
78
 	beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
78
 	beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
79
+	beego.Router("/api/hispatient/gettodayschedulepatient", &HisProjectApiController{}, "Get:GetTodaySchedulePatient")
79
 }
80
 }
80
 
81
 
81
 func (this *HisProjectApiController) SaveProject() {
82
 func (this *HisProjectApiController) SaveProject() {
802
 			IsReturn:               1,
803
 			IsReturn:               1,
803
 		}
804
 		}
804
 		err := service.CreateHisPatient(&patient)
805
 		err := service.CreateHisPatient(&patient)
806
+		lastPatient, err := service.GetLastPatient(orgId)
807
+		timeStr := time.Now().Format("2006-01-02")
808
+		timeArr := strings.Split(timeStr, "-")
809
+		var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
810
+		fmt.Println("str--------", str)
811
+		hisPatient := models.HisPatient{
812
+			Number: str,
813
+		}
814
+		err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
815
+		fmt.Println("errr", err)
805
 		if err != nil {
816
 		if err != nil {
806
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
817
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
807
 			return
818
 			return
1305
 	adminUserInfo := this.GetAdminUserInfo()
1316
 	adminUserInfo := this.GetAdminUserInfo()
1306
 	chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
1317
 	chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
1307
 	prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
1318
 	prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
1319
+	patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient_id)
1308
 	if err != nil {
1320
 	if err != nil {
1309
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1321
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1310
 		return
1322
 		return
1312
 	this.ServeSuccessJSON(map[string]interface{}{
1324
 	this.ServeSuccessJSON(map[string]interface{}{
1313
 		"list":         chargePrint,
1325
 		"list":         chargePrint,
1314
 		"prescription": prescription,
1326
 		"prescription": prescription,
1327
+		"patient":      patient,
1328
+	})
1329
+}
1330
+
1331
+func (this *HisProjectApiController) GetTodaySchedulePatient() {
1332
+
1333
+	adminUserInfo := this.GetAdminUserInfo()
1334
+	orgId := adminUserInfo.CurrentOrgId
1335
+	recordDateStr := time.Now().Format("2006-01-02")
1336
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1337
+	scheduleDate := recordDate.Unix()
1338
+
1339
+	patient, err := service.GetTodaySchedulePatient(orgId, scheduleDate)
1340
+	if err != nil {
1341
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1342
+		return
1343
+	}
1344
+	this.ServeSuccessJSON(map[string]interface{}{
1345
+		"patient": patient,
1315
 	})
1346
 	})
1316
 }
1347
 }

+ 1 - 0
models/his_models.go 查看文件

101
 	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
101
 	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
102
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
102
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
103
 	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
103
 	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
104
+	Number                 string  `gorm:"column:number" json:"number" form:"number"`
104
 }
105
 }
105
 
106
 
106
 func (HisPatient) TableName() string {
107
 func (HisPatient) TableName() string {

+ 28 - 1
service/his_project_service.go 查看文件

533
 
533
 
534
 	err = readDb.Model(&HisOrder{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND settle_accounts_date=?", user_org_id, patient_id, record).
534
 	err = readDb.Model(&HisOrder{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND settle_accounts_date=?", user_org_id, patient_id, record).
535
 		Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
535
 		Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
536
-		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
537
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
536
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
538
 		Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
537
 		Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
539
 		Order("ctime desc").
538
 		Order("ctime desc").
541
 	return
540
 	return
542
 
541
 
543
 }
542
 }
543
+
544
+func GetLastPatient(orgid int64) (models.HisPatient, error) {
545
+
546
+	patient := models.HisPatient{}
547
+	err := XTReadDB().Model(&patient).Where("user_org_id = ? and status = 1", orgid).Last(&patient).Error
548
+	return patient, err
549
+}
550
+
551
+func UpdateHisPatient(id int64, patient models.HisPatient) error {
552
+
553
+	err := XTWriteDB().Model(&patient).Where("id = ? and status = 1", id).Update(map[string]interface{}{"number": patient.Number}).Error
554
+	return err
555
+}
556
+
557
+func GetTodaySchedulePatient(orgid int64, scheduledata int64) (schedule []*models.Schedules, err error) {
558
+
559
+	schedules := models.Schedules{}
560
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
561
+	if orgid > 0 {
562
+		db = db.Where("x.user_org_id = ?", orgid)
563
+	}
564
+	if scheduledata > 0 {
565
+		db = db.Where("x.schedule_date = ?", scheduledata)
566
+	}
567
+
568
+	err = db.Select("x.id,x.patient_id,x.schedule_date,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Scan(&schedules).Error
569
+	return schedule, err
570
+}