Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
67c35c68b2

+ 2 - 2
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3 3
 runmode = dev
4 4
 
5 5
 #
@@ -7,7 +7,7 @@ copyrequestbody = true
7 7
 sessionon = true
8 8
 #sessiongcmaxlifetime = 64800
9 9
 
10
-tokencookiemaxlifetime = 64800
10
+tokencookiemaxlifetime = 604800
11 11
 enablexsrf = false
12 12
 xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
13 13
 xsrfexpire = 3600

+ 53 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/models"
7 7
 	"XT_New/service"
8 8
 	"fmt"
9
+	"github.com/jinzhu/gorm"
9 10
 	"strings"
10 11
 	"time"
11 12
 )
@@ -288,7 +289,8 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
288 289
 	}
289 290
 	if is_open == 1 {
290 291
 		//获取空床位的排班数据
291
-		list, err := service.GetPatientScheduleByBed(startTime, zoneid, classtype, orgid)
292
+		list, err := service.GetPatientScheduleByBed(startTime, zoneid, orgid)
293
+
292 294
 		if err != nil {
293 295
 			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
294 296
 			return
@@ -365,3 +367,53 @@ func (this *StaffScheduleApiController) UpdatePatientScheduleById() {
365 367
 		"msg": "切换成功",
366 368
 	})
367 369
 }
370
+
371
+func (this *StaffScheduleApiController) UpdateBloodSchedule() {
372
+	timeLayout := "2006-01-02"
373
+	loc, _ := time.LoadLocation("Local")
374
+	id, _ := this.GetInt64("id")
375
+	patient_id, _ := this.GetInt64("patient_id")
376
+	mode_id, _ := this.GetInt64("mode_id")
377
+	schedule_type, _ := this.GetInt64("schedule_type")
378
+	start_time := this.GetString("start_time")
379
+	dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
380
+	var startTime int64
381
+	if len(start_time) > 0 {
382
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
383
+		if err != nil {
384
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
385
+			return
386
+		}
387
+		startTime = theTime.Unix()
388
+	}
389
+
390
+	//更改排班
391
+	schedule := models.XtSchedule{
392
+		ScheduleType: schedule_type,
393
+		ModeId:       mode_id,
394
+	}
395
+
396
+	service.UpdatedSchedule(schedule, id)
397
+
398
+	//更改透析模式
399
+	_, errcode := service.GetDialyisSolution(patient_id, startTime)
400
+	if errcode == gorm.ErrRecordNotFound {
401
+		orgId := this.GetAdminUserInfo().CurrentOrgId
402
+		prescription := models.DialysisPrescription{
403
+			DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus,
404
+			DialysisDialyszers:         dialyzer_perfusion_apparatus,
405
+			PatientId:                  patient_id,
406
+			UserOrgId:                  orgId,
407
+			Status:                     1,
408
+			RecordDate:                 startTime,
409
+			CreatedTime:                time.Now().Unix(),
410
+		}
411
+		service.CreateDialysisPrescription(prescription)
412
+	} else if errcode == nil {
413
+		prescription := models.DialysisPrescription{
414
+			DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus,
415
+			DialysisDialyszers:         dialyzer_perfusion_apparatus,
416
+		}
417
+		service.UpdateDialysisPrescriptionOne(prescription, patient_id, startTime)
418
+	}
419
+}

+ 1 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go View File

@@ -20,4 +20,5 @@ func StaffScheduleApiControllersRegisterRouters() {
20 20
 	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
21 21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22 22
 	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
23
+	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
23 24
 }

+ 49 - 22
models/device_models.go View File

@@ -1056,26 +1056,53 @@ type VmXtSchedule struct {
1056 1056
 }
1057 1057
 
1058 1058
 type PatientDeviceNumber struct {
1059
-	ID            int64         `gorm:"column:id" json:"id"`
1060
-	OrgID         int64         `gorm:"column:org_id" json:"-"`
1061
-	Number        string        `gorm:"column:number" json:"number"`
1062
-	GroupID       int64         `gorm:"column:group_id" json:"group_id"`
1063
-	ZoneID        int64         `gorm:"column:zone_id" json:"zone_id"`
1064
-	CreateTime    int64         `gorm:"column:ctime" json:"-"`
1065
-	ModifyTime    int64         `gorm:"column:mtime" json:"-"`
1066
-	Sort          int64         `gorm:"column:sort" json:"sort" form:"sort"`
1067
-	PartitionId   int64         `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1068
-	BedId         int64         `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1069
-	PatientId     int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1070
-	ScheduleDate  int64         `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1071
-	ScheduleType  int64         `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1072
-	ScheduleWeek  int64         `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1073
-	ModeId        int64         `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1074
-	Name          string        `gorm:"column:name" json:"name"`
1075
-	Patient       Patients      `json:"patient"  gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
1076
-	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
1077
-	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
1078
-	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
1079
-	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
1080
-	Schedule      Schedule      `json:"schedule"  gorm:"foreignkey:BedId;AssociationForeignKey:ID;"`
1059
+	ID       int64           `gorm:"column:id" json:"id" form:"id"`
1060
+	OrgId    int64           `gorm:"column:org_id" json:"org_id" form:"org_id"`
1061
+	Number   string          `gorm:"column:number" json:"number" form:"number"`
1062
+	GroupId  int64           `gorm:"column:group_id" json:"group_id" form:"group_id"`
1063
+	ZoneId   int64           `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1064
+	Status   int64           `gorm:"column:status" json:"status" form:"status"`
1065
+	Ctime    int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
1066
+	Mtime    int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
1067
+	Sort     int64           `gorm:"column:sort" json:"sort" form:"sort"`
1068
+	Schedule []*BlodSchedule `json:"schedule" gorm:"foreignkey:BedId;AssociationForeignKey:ID;"`
1069
+}
1070
+
1071
+func (PatientDeviceNumber) TableName() string {
1072
+
1073
+	return "xt_device_number"
1074
+}
1075
+
1076
+type PatientDialysisOrder struct {
1077
+	ID                     int64  `gorm:"column:id" json:"id" form:"id"`
1078
+	DialysisDate           int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
1079
+	UserOrgId              int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1080
+	PatientId              int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1081
+	PrescriptionId         int64  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1082
+	Stage                  int64  `gorm:"column:stage" json:"stage" form:"stage"`
1083
+	Remark                 string `gorm:"column:remark" json:"remark" form:"remark"`
1084
+	BedId                  int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1085
+	StartNurse             int64  `gorm:"column:start_nurse" json:"start_nurse" form:"start_nurse"`
1086
+	FinishNurse            int64  `gorm:"column:finish_nurse" json:"finish_nurse" form:"finish_nurse"`
1087
+	Status                 int64  `gorm:"column:status" json:"status" form:"status"`
1088
+	CreatedTime            int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
1089
+	UpdatedTime            int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1090
+	PunctureNurse          int64  `gorm:"column:puncture_nurse" json:"puncture_nurse" form:"puncture_nurse"`
1091
+	Creator                int64  `gorm:"column:creator" json:"creator" form:"creator"`
1092
+	Modifier               int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
1093
+	FinishCreator          int64  `gorm:"column:finish_creator" json:"finish_creator" form:"finish_creator"`
1094
+	FinishModifier         int64  `gorm:"column:finish_modifier" json:"finish_modifier" form:"finish_modifier"`
1095
+	SchedualType           int64  `gorm:"column:schedual_type" json:"schedual_type" form:"schedual_type"`
1096
+	StartTime              int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
1097
+	EndTime                int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
1098
+	WashpipeNurse          int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
1099
+	ChangeNurse            int64  `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
1100
+	DifficultPunctureNurse int64  `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
1101
+	NewFistulaNurse        int64  `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
1102
+	ZoneId                 int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1103
+}
1104
+
1105
+func (PatientDialysisOrder) TableName() string {
1106
+
1107
+	return "xt_dialysis_order"
1081 1108
 }

+ 62 - 6
models/schedule_models.go View File

@@ -44,12 +44,12 @@ type Schedule struct {
44 44
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
45 45
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
46 46
 
47
-	Patient       string        `gorm:"-" json:"patient" form:"patient"`
48
-	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
49
-	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
50
-	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
51
-	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
52
-
47
+	Patient                   string               `gorm:"-" json:"patient" form:"patient"`
48
+	DeviceZone                DeviceZone           `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
49
+	DeviceNumber              DeviceNumber         `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
50
+	TreatmentMode             TreatmentMode        `json:"mode" gorm:"foreignkey:ModeId"`
51
+	DialysisOrder             DialysisOrder        `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
52
+	DialysisPrescription      DialysisPrescription `json:"order" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId;"`
53 53
 	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
54 54
 }
55 55
 
@@ -233,3 +233,59 @@ type WeekScheduleSix struct {
233 233
 func (WeekScheduleSix) TableName() string {
234 234
 	return "xt_schedule"
235 235
 }
236
+
237
+type BlodSchedule struct {
238
+	ID                        int64                     `gorm:"column:id" json:"id" form:"id"`
239
+	UserOrgId                 int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
240
+	PartitionId               int64                     `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
241
+	BedId                     int64                     `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
242
+	PatientId                 int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
243
+	ScheduleDate              int64                     `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
244
+	ScheduleType              int64                     `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
245
+	ScheduleWeek              int64                     `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
246
+	ModeId                    int64                     `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
247
+	Status                    int64                     `gorm:"column:status" json:"status" form:"status"`
248
+	VmBloodPatients           VmBloodPatients           `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
249
+	BloodDialysisOrder        BloodPatientDialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
250
+	BloodDialysisPrescription BloodDialysisPrescription `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId;"`
251
+}
252
+
253
+func (BlodSchedule) TableName() string {
254
+	return "xt_schedule"
255
+}
256
+
257
+type BloodPatientDialysisOrder struct {
258
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
259
+	DialysisDate int64 `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
260
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
261
+	Stage        int64 `gorm:"column:stage" json:"stage" form:"stage"`
262
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
263
+}
264
+
265
+func (BloodPatientDialysisOrder) TableName() string {
266
+	return "xt_dialysis_order"
267
+}
268
+
269
+type BloodPatientDialysisPrescription struct {
270
+	ID                         int64  `gorm:"column:id" json:"id" form:"id"`
271
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
272
+	MachineType                string `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
273
+	ModeId                     int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
274
+	DialysisDialyszers         string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
275
+	DialysisIrrigation         string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
276
+	DialyzerPerfusionApparatus string `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
277
+}
278
+
279
+func (BloodPatientDialysisPrescription) TableName() string {
280
+	return "xt_dialysis_prescription"
281
+}
282
+
283
+type VmBloodPatients struct {
284
+	ID    int64  `gorm:"column:id" json:"id" form:"id"`
285
+	BedId int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
286
+	Name  string `gorm:"column:name" json:"name" form:"name"`
287
+}
288
+
289
+func (VmBloodPatients) TableName() string {
290
+	return "xt_patients"
291
+}

+ 55 - 9
service/doctor_schedule_service.go View File

@@ -598,26 +598,38 @@ func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int
598 598
 	return schedule, err
599 599
 }
600 600
 
601
-func GetPatientScheduleByBed(startime int64, zoneid int64, classtype int64, orgid int64) (list []*models.PatientDeviceNumber, err error) {
601
+func GetPatientScheduleByBed(schedule_date int64, zoneid int64, orgid int64) (list []*models.PatientDeviceNumber, err error) {
602 602
 
603 603
 	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
604
-	table := XTReadDB().Table("xt_schedule as s").Where("s.status = 1")
605
-	p := XTReadDB().Table("xt_patients as p").Where("p.status = 1")
606
-	fmt.Println(table, p)
607 604
 	if zoneid > 0 {
608
-		db = db.Where("s.zone_id = ?", zoneid)
605
+		db = db.Where("x.zone_id = ?", zoneid)
609 606
 	}
610 607
 	if orgid > 0 {
611 608
 		db = db.Where("x.org_id = ?", orgid)
612 609
 	}
613
-	if classtype > 0 {
614
-		db = db.Where("s.schedule_type = ?", classtype)
615
-	}
610
+	err = db.Select("x.id,x.number,x.sort,x.group_id,x.zone_id,x.sort").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
611
+		return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ?", orgid, schedule_date).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1").Preload("BloodDialysisPrescription", "status = 1")
612
+	}).Find(&list).Error
616 613
 
617
-	err = db.Select("x.id,x.number,x.group_id,x.zone_id,x.sort,s.partition_id,s.bed_id,s.patient_id,s.schedule_date,s.schedule_type,s.schedule_week,s.mode_id").Joins("left join xt_schedule as s on s.bed_id = x.id").Where("s.schedule_date = ?", startime).Scan(&list).Error
618 614
 	return list, err
619 615
 }
620 616
 
617
+func GetPatientDialysisOrderDate(shcedule_date int64, class_type int64, orgid int64) (schedule []*models.Schedule, err error) {
618
+
619
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
620
+	if shcedule_date > 0 {
621
+		db = db.Where("x.schedule_date = ?", shcedule_date)
622
+	}
623
+	if class_type > 0 {
624
+		db = db.Where("x.schedule_type = ?", class_type)
625
+	}
626
+	if orgid > 0 {
627
+		db = db.Where("x.user_org_id = ?", orgid)
628
+	}
629
+	err = db.Select("x.id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id").Preload("DialysisOrder", "status = 1").Preload("DialysisPrescription", "status = 1").Find(&schedule).Error
630
+	return schedule, err
631
+}
632
+
621 633
 func DeleteSchedule(id int64) error {
622 634
 
623 635
 	schedule := models.XtSchedule{}
@@ -655,3 +667,37 @@ func UpdateStaffScheduleOne(nextid int64, schedule models.WeekSchedule) error {
655 667
 	err := XTWriteDB().Model(&schedule).Where("id = ?", nextid).Updates(map[string]interface{}{"patient_id": schedule.PatientId, "mode_id": schedule.ModeId}).Error
656 668
 	return err
657 669
 }
670
+
671
+func UpdatedSchedule(schedule models.XtSchedule, id int64) error {
672
+
673
+	xtSchedule := models.XtSchedule{}
674
+	err := XTWriteDB().Model(&xtSchedule).Where("id = ? and status =1", id).Updates(map[string]interface{}{"schedule_type": schedule.ScheduleType, "mode_id": schedule.ModeId}).Error
675
+	return err
676
+}
677
+
678
+func GetDialyisSolution(patientid int64, recorddate int64) (*models.DialysisPrescription, error) {
679
+
680
+	prescription := models.DialysisPrescription{}
681
+
682
+	err := XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and status = 1", patientid, recorddate).Find(&prescription).Error
683
+	if err == gorm.ErrRecordNotFound {
684
+		return nil, err
685
+	}
686
+	if err != nil {
687
+		return nil, err
688
+	}
689
+	return &prescription, nil
690
+}
691
+
692
+func CreateDialysisPrescription(prescription models.DialysisPrescription) error {
693
+
694
+	err := XTReadDB().Create(&prescription).Error
695
+
696
+	return err
697
+}
698
+
699
+func UpdateDialysisPrescriptionOne(prescription models.DialysisPrescription, patientid int64, recordate int64) error {
700
+
701
+	err := XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and status = 1", patientid, recordate).Updates(map[string]interface{}{"dialyzers": prescription.Dialyzer, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus}).Error
702
+	return err
703
+}

+ 1 - 3
service/user_service.go View File

@@ -138,9 +138,7 @@ func GetLastData(orgid int64) (models.SgjPatientDryweight, error) {
138 138
 }
139 139
 
140 140
 func UpdateDialysisPrescription(patientid int64, orgid int64, dryweight float64, prescription models.PredialysisEvaluation) error {
141
-	fmt.Println("patientid", patientid)
142
-	fmt.Println("orgid", orgid)
143
-	fmt.Println("dryweight", dryweight)
141
+
144 142
 	err := XTWriteDB().Model(&prescription).Where("patient_id = ? AND user_org_id = ?", patientid, orgid).Update(map[string]interface{}{"dry_weight": dryweight, "mtime": time.Now().Unix()}).Last(&prescription).Error
145 143
 	fmt.Println("错误是设么", err)
146 144
 	return err