Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
8c705b39c2

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3 3
 runmode = dev
4 4
 #dev/prod
5 5
 

+ 27 - 2
controllers/dialysis_api_controller.go View File

@@ -90,7 +90,9 @@ func DialysisApiRegistRouters() {
90 90
 
91 91
 	beego.Router("/api/patient/getdialysisparametergoodlist", &DialysisApiController{}, "Get:GetDialysisParameterGoodList")
92 92
 
93
-	beego.Router("/api/patinet/savehisdialysis", &DialysisApiController{}, "Get:SaveHisDialysis")
93
+	beego.Router("/api/patient/savehisdialysis", &DialysisApiController{}, "Get:SaveHisDialysis")
94
+
95
+	beego.Router("/api/patient/gethisdialysisgoodcount", &DialysisApiController{}, "Get:GetHisDialysisGoodCount")
94 96
 }
95 97
 
96 98
 func (c *DialysisApiController) GetQueueCall() {
@@ -4276,9 +4278,11 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4276 4278
 
4277 4279
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4278 4280
 	_, config := service.FindXTHisRecordByOrgId(orgId)
4281
+
4279 4282
 	goodType, _ := service.GetAllGoodType(orgId)
4280
-	if config.IsOpen == 0 {
4283
+	if config.IsOpen != 1 {
4281 4284
 		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4285
+		fmt.Println("list2232323223332323232", list)
4282 4286
 		if err == nil {
4283 4287
 			this.ServeSuccessJSON(map[string]interface{}{
4284 4288
 				"list":     list,
@@ -4583,3 +4587,24 @@ func (this *DialysisApiController) SaveHisDialysis() {
4583 4587
 	this.ServeSuccessJSON(returnData)
4584 4588
 	return
4585 4589
 }
4590
+
4591
+func (this *DialysisApiController) GetHisDialysisGoodCount() {
4592
+
4593
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4594
+
4595
+	schedule_type, _ := this.GetInt64("schedule_type")
4596
+
4597
+	partion_type, _ := this.GetInt64("partion_type")
4598
+
4599
+	start_time := this.GetString("selected_date")
4600
+	timeLayout := "2006-01-02"
4601
+	loc, _ := time.LoadLocation("Local")
4602
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4603
+
4604
+	list, _ := service.GetHisDialysisGoodCount(orgId, schedule_type, partion_type, startTime.Unix())
4605
+
4606
+	this.ServeSuccessJSON(map[string]interface{}{
4607
+		"list": list,
4608
+	})
4609
+	return
4610
+}

+ 4 - 1
controllers/dialysis_record_api_controller.go View File

@@ -1163,6 +1163,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1163 1163
 	internal_fistula := this.GetString("internal_fistula")
1164 1164
 	catheter := this.GetString("catheter")
1165 1165
 	cruor := this.GetString("cruor")
1166
+	mission := this.GetString("mission")
1166 1167
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 {
1167 1168
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1168 1169
 		return
@@ -1457,7 +1458,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1457 1458
 	}()
1458 1459
 
1459 1460
 	//执行下机
1460
-	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor)
1461
+	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
1461 1462
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1462 1463
 	redis := service.RedisClient()
1463 1464
 	defer redis.Close()
@@ -1736,6 +1737,7 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
1736 1737
 	internal_fistula := c.GetString("internal_fistula")
1737 1738
 	catheter := c.GetString("catheter")
1738 1739
 	cruor := c.GetString("cruor")
1740
+	mission := c.GetString("mission")
1739 1741
 	if record_id <= 0 || nurseID <= 0 {
1740 1742
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1741 1743
 		return
@@ -1782,6 +1784,7 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
1782 1784
 		BloodAccessInternalFistula: internal_fistula,
1783 1785
 		Catheter:                   catheter,
1784 1786
 		Cruor:                      cruor,
1787
+		Mission:                    mission,
1785 1788
 	}
1786 1789
 
1787 1790
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)

+ 9 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -574,6 +574,8 @@ func (this *DialysisAPIController) DialysisRecord() {
574 574
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
575 575
 	}
576 576
 	fmt.Println("doctorAdvices23344334344433434334343434wode", doctorAdvices)
577
+
578
+	lastOrder, _ := service.GetLastDilysisOrder(adminInfo.Org.Id, patientID, date.Unix())
577 579
 	returnData := map[string]interface{}{
578 580
 		"patient":                        patient,
579 581
 		"schedual":                       schedual,
@@ -606,6 +608,7 @@ func (this *DialysisAPIController) DialysisRecord() {
606 608
 		"team_projects":                  team_projects,
607 609
 		"is_advice_open":                 is_advice_open,
608 610
 		"prescription_open":              prescriptionConfig.IsOpen,
611
+		"lastOrder":                      lastOrder,
609 612
 	}
610 613
 	this.ServeSuccessJSON(returnData)
611 614
 }
@@ -1683,6 +1686,7 @@ func (c *DialysisAPIController) Finish() {
1683 1686
 	internal_fistula := c.GetString("blood_access_internal_fistula")
1684 1687
 	catheter := c.GetString("catheter")
1685 1688
 	cruor := c.GetString("cruor")
1689
+	mission := c.GetString("mission")
1686 1690
 	if id <= 0 || nurseID <= 0 {
1687 1691
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1688 1692
 		return
@@ -1994,7 +1998,7 @@ func (c *DialysisAPIController) Finish() {
1994 1998
 		return
1995 1999
 	}
1996 2000
 	if dialysisOrder.Stage == 1 {
1997
-		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor)
2001
+		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
1998 2002
 
1999 2003
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2000 2004
 		redis := service.RedisClient()
@@ -2090,7 +2094,7 @@ func (this *DialysisAPIController) StartDialysis() {
2090 2094
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
2091 2095
 	blood_access_id, _ := this.GetInt64("blood_access_id")
2092 2096
 	zone_id, _ := this.GetInt64("zone_id")
2093
-
2097
+	elecsign := this.GetString("url")
2094 2098
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
2095 2099
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2096 2100
 		return
@@ -2279,6 +2283,7 @@ func (this *DialysisAPIController) StartDialysis() {
2279 2283
 		DialysisIrrigation:     dialysis_irrigation,
2280 2284
 		DialysisDialyszers:     dialysis_dialyszers,
2281 2285
 		BloodAccessId:          blood_access_id,
2286
+		Url:                    elecsign,
2282 2287
 	}
2283 2288
 	//查询该床位是否有人用了
2284 2289
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
@@ -3278,6 +3283,7 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
3278 3283
 	blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
3279 3284
 	catheter := c.GetString("catheter")
3280 3285
 	cruor := c.GetString("cruor")
3286
+	mission := c.GetString("mission")
3281 3287
 	if record_id <= 0 || nurseID <= 0 {
3282 3288
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3283 3289
 		return
@@ -3324,6 +3330,7 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
3324 3330
 		BloodAccessInternalFistula: blood_access_internal_fistula,
3325 3331
 		Catheter:                   catheter,
3326 3332
 		Cruor:                      cruor,
3333
+		Mission:                    mission,
3327 3334
 	}
3328 3335
 
3329 3336
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)

+ 1 - 0
models/dialysis.go View File

@@ -842,6 +842,7 @@ type DialysisOrder struct {
842 842
 	DialysisDialyszers         string        `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
843 843
 	DialysisIrrigation         string        `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
844 844
 	BloodAccessId              int64         `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
845
+	Mission                    string        `gorm:"column:mission" json:"mission" form:"mission"`
845 846
 }
846 847
 
847 848
 func (DialysisOrder) TableName() string {

+ 97 - 16
models/schedule_models.go View File

@@ -351,24 +351,105 @@ func (NewMSchedualPatientVMList) TableName() string {
351 351
 }
352 352
 
353 353
 type VmBloodScheduleTwo struct {
354
-	ID                          int64                       `gorm:"column:id" json:"id" form:"id"`
355
-	UserOrgId                   int64                       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
356
-	PartitionId                 int64                       `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
357
-	BedId                       int64                       `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
358
-	PatientId                   int64                       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
359
-	ScheduleDate                int64                       `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
360
-	ScheduleType                int64                       `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
361
-	ScheduleWeek                int64                       `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
362
-	ModeId                      int64                       `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
363
-	Status                      int64                       `gorm:"column:status" json:"status" form:"status"`
364
-	CreatedTime                 int64                       `gorm:"column:created_time" json:"created_time" form:"created_time"`
365
-	UpdatedTime                 int64                       `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
366
-	IsExport                    int64                       `gorm:"column:is_export" json:"is_export" form:"is_export"`
367
-	DeviceNumber                *NewMDeviceNumberVM         `gorm:"ForeignKey:BedId" json:"device_number"`
368
-	SchedualPatient             *NewMSchedualPatientVMList  `gorm:"ForeignKey:PatientId" json:"patient"`
369
-	HisPrescriptionInfoTemplate HisPrescriptionInfoTemplate `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
354
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
355
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
356
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
357
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
358
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
359
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
360
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
361
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
362
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
363
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
364
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
365
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
366
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
367
+	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
368
+	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
369
+	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
370 370
 }
371 371
 
372 372
 func (VmBloodScheduleTwo) TableName() string {
373 373
 	return "xt_schedule"
374 374
 }
375
+
376
+type HisPrescriptionTemplateSix struct {
377
+	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
378
+	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
379
+	PatientId                      int64                             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
380
+	Type                           int64                             `gorm:"column:type" json:"type" form:"type"`
381
+	Status                         int64                             `gorm:"column:status" json:"status" form:"status"`
382
+	Ctime                          int64                             `gorm:"column:ctime" json:"ctime" form:"ctime"`
383
+	Mtime                          int64                             `gorm:"column:mtime" json:"mtime" form:"mtime"`
384
+	Name                           string                            `gorm:"column:name" json:"name" form:"name"`
385
+	Mode                           int64                             `gorm:"column:mode" json:"mode" form:"mode"`
386
+	HisPrescriptionInfoTemplateSix []*HisPrescriptionInfoTemplateSix `gorm:"ForeignKey:PTemplateId;AssociationForeignKey:ID" json:"his_prescription_info"`
387
+}
388
+
389
+func (HisPrescriptionTemplateSix) TableName() string {
390
+	return "his_prescription_template"
391
+}
392
+
393
+type HisPrescriptionInfoTemplateSix struct {
394
+	ID                                  int64                                  `gorm:"column:id" json:"id" form:"id"`
395
+	UserOrgId                           int64                                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
396
+	RecordDate                          int64                                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
397
+	PatientId                           int64                                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
398
+	Status                              int64                                  `gorm:"column:status" json:"status" form:"status"`
399
+	Ctime                               int64                                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
400
+	Mtime                               int64                                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
401
+	Type                                int64                                  `gorm:"column:type" json:"type" form:"type"`
402
+	Creator                             int64                                  `gorm:"column:creator" json:"creator" form:"creator"`
403
+	Modifier                            int64                                  `gorm:"column:modifier" json:"modifier" form:"modifier"`
404
+	PType                               int64                                  `gorm:"column:p_type" json:"p_type" form:"p_type"`
405
+	PTemplateId                         int64                                  `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
406
+	HisPrescriptionProjectTemplateSeven []*HisPrescriptionProjectTemplateSeven `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
407
+	MedType                             string                                 `gorm:"column:med_type" json:"med_type" form:"med_type"`
408
+}
409
+
410
+func (HisPrescriptionInfoTemplateSix) TableName() string {
411
+	return "his_prescription_info_template"
412
+}
413
+
414
+type HisPrescriptionProjectTemplateSeven struct {
415
+	ID                 int64         `gorm:"column:id" json:"id" form:"id"`
416
+	ProjectId          int64         `gorm:"column:project_id" json:"project_id" form:"project_id"`
417
+	Price              float64       `gorm:"column:price" json:"price" form:"price"`
418
+	UserOrgId          int64         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
419
+	Status             int64         `gorm:"column:status" json:"status" form:"status"`
420
+	Ctime              int64         `gorm:"column:ctime" json:"ctime" form:"ctime"`
421
+	Mtime              int64         `gorm:"column:mtime" json:"mtime" form:"mtime"`
422
+	PatientId          int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
423
+	HisPatientId       int64         `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
424
+	RecordDate         int64         `gorm:"column:record_date" json:"record_date" form:"record_date"`
425
+	Count              string        `gorm:"column:count" json:"count" form:"count"`
426
+	FeedetlSn          string        `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
427
+	MedListCodg        string        `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
428
+	SingleDose         string        `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
429
+	DeliveryWay        string        `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
430
+	ExecutionFrequency string        `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
431
+	Day                string        `gorm:"column:day" json:"day" form:"day"`
432
+	Remark             string        `gorm:"column:remark" json:"remark" form:"remark"`
433
+	Unit               string        `gorm:"column:unit" json:"unit" form:"unit"`
434
+	Type               int64         `gorm:"column:type" json:"type" form:"type"`
435
+	PrescriptionId     int64         `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
436
+	GoodInfo           GoodInfoNight `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
437
+	FrequencyType      int64         `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
438
+	DayCount           int64         `gorm:"column:day_count" json:"day_count" form:"day_count"`
439
+	WeekDay            string        `gorm:"column:week_day" json:"week_day" form:"week_day"`
440
+}
441
+
442
+func (HisPrescriptionProjectTemplateSeven) TableName() string {
443
+	return "his_prescription_project_template"
444
+}
445
+
446
+type GoodInfoNight struct {
447
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
448
+	GoodName          string `gorm:"column:good_name" json:"good_name" form:"good_name"`
449
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
450
+	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
451
+}
452
+
453
+func (GoodInfoNight) TableName() string {
454
+	return "xt_good_information"
455
+}

+ 2 - 2
service/dialysis_service.go View File

@@ -553,8 +553,8 @@ func CreateDialysisRecord(id int64, orgId int64, record *models.DialysisOrder) e
553 553
 	return nil
554 554
 }
555 555
 
556
-func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64, puncture_point_haematoma int64, internal_fistula string, catheter string, cruor string) error {
557
-	err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id, "puncture_point_haematoma": puncture_point_haematoma, "blood_access_internal_fistula": internal_fistula, "catheter": catheter, "cruor": cruor}).Error
556
+func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64, puncture_point_haematoma int64, internal_fistula string, catheter string, cruor string, mission string) error {
557
+	err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id, "puncture_point_haematoma": puncture_point_haematoma, "blood_access_internal_fistula": internal_fistula, "catheter": catheter, "cruor": cruor, "mission": mission}).Error
558 558
 	return err
559 559
 
560 560
 }

+ 41 - 6
service/dialysis_solution_service.go View File

@@ -294,9 +294,11 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
294 294
 		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
295 295
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
296 296
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
297
-			Preload("HisPrescriptionInfoTemplate", func(db *gorm.DB) *gorm.DB {
298
-				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
299
-					return db.Where("user_org_id = ? and status = 1 and type =3 ", orgID).Preload("GoodInfo", "org_id = ? and status = 1", orgID)
297
+			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
298
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
299
+					return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
300
+						return db.Where("user_org_id = ? and status = 1 and type = 3", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
301
+					})
300 302
 				})
301 303
 			})
302 304
 		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
@@ -306,12 +308,45 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
306 308
 			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
307 309
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
308 310
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
309
-			Preload("HisPrescriptionInfoTemplate", func(db *gorm.DB) *gorm.DB {
310
-				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
311
-					return db.Where("user_org_id = ? and status = 1 and type =3 ", orgID).Preload("GoodInfo", "org_id = ? and status = 1", orgID)
311
+			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
312
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
313
+					return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
314
+						return db.Where("user_org_id = ? and status = 1 and type = 3", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
315
+					})
312 316
 				})
313 317
 			}).Find(&schedule).Error
314 318
 	}
315 319
 
316 320
 	return schedule, total, err
317 321
 }
322
+
323
+func GetHisDialysisGoodCount(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleTwo, err error) {
324
+
325
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
326
+	if scheduleDate > 0 {
327
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
328
+	}
329
+	if schedule_type > 0 {
330
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
331
+	}
332
+	if partition_id > 0 {
333
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
334
+	}
335
+	if orgID > 0 {
336
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
337
+	}
338
+
339
+	err = db.
340
+		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
341
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
342
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
343
+		Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
344
+			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
345
+				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
346
+					return db.Where("user_org_id = ? and status = 1 and type = 3", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
347
+				})
348
+			})
349
+		}).Find(&schedule).Error
350
+
351
+	return schedule, err
352
+}

+ 10 - 1
service/mobile_dialysis_service.go View File

@@ -2033,7 +2033,7 @@ func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2033 2033
 func ModifyFinishDialysisOrder(order *models.DialysisOrder) error {
2034 2034
 	tx := writeDb.Begin()
2035 2035
 	updateTime := time.Now().Unix()
2036
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"finish_nurse": order.FinishNurse, "updated_time": updateTime, "end_time": order.EndTime, "finish_modifier": order.FinishModifier, "puncture_point_haematoma": order.PuncturePointHaematoma, "blood_access_internal_fistula": order.BloodAccessInternalFistula, "catheter": order.Catheter, "cruor": order.Cruor}).Error
2036
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"finish_nurse": order.FinishNurse, "updated_time": updateTime, "end_time": order.EndTime, "finish_modifier": order.FinishModifier, "puncture_point_haematoma": order.PuncturePointHaematoma, "blood_access_internal_fistula": order.BloodAccessInternalFistula, "catheter": order.Catheter, "cruor": order.Cruor, "mission": order.Mission}).Error
2037 2037
 	if err != nil {
2038 2038
 		tx.Rollback()
2039 2039
 		return err
@@ -4109,3 +4109,12 @@ func GetGoodWarehouseOutInfo(orgId int64, patient_id int64, sys_record_time int6
4109 4109
 	err = readDb.Where("org_id = ? and patient_id = ? and sys_record_time = ? and status = 1", orgId, patient_id, sys_record_time).Find(&outifno).Error
4110 4110
 	return outifno, err
4111 4111
 }
4112
+
4113
+func GetLastDilysisOrder(orgid int64, patient_id int64, dialysis_date int64) (models.DialysisOrder, error) {
4114
+
4115
+	order := models.DialysisOrder{}
4116
+
4117
+	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date < ? and status= 1", orgid, patient_id, dialysis_date).Last(&order).Error
4118
+
4119
+	return order, err
4120
+}