28169 пре 10 месеци
родитељ
комит
04fb5087aa

+ 20 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Прегледај датотеку

@@ -7781,12 +7781,24 @@ func (c *DialysisAPIController) GetDialysisGoods() {
7781 7781
 		if patient_id != 0 {
7782 7782
 			for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
7783 7783
 				goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.Org.Id, date.Unix())
7784
+
7784 7785
 				lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.Org.Id, date.Unix())
7786
+
7785 7787
 				//获取患者总的出库数据
7786 7788
 				item.LastAutomaticReduceDetail = goodUser
7787 7789
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
7788 7790
 				item.Project = project
7791
+
7792
+				for _, it := range item.AutomaticReduceDetail {
7793
+					var total int64
7794
+					auto, _ := service.GetPatientAutoMatic(it.PatientId, adminUser.Org.Id, date.Unix(), it.GoodId)
7795
+					for _, its := range auto {
7796
+						total += its.Count
7797
+					}
7798
+					it.Count = total
7799
+				}
7789 7800
 			}
7801
+
7790 7802
 		}
7791 7803
 		c.ServeSuccessJSON(map[string]interface{}{
7792 7804
 			"dialysis_goods":   dialysisGoods,
@@ -7813,6 +7825,14 @@ func (c *DialysisAPIController) GetDialysisGoods() {
7813 7825
 				item.Project = project
7814 7826
 				item.LastAutomaticReduceDetail = goodUser
7815 7827
 				item.LastDialysisBeforePrepare = lastGoodUserDetial
7828
+				for _, it := range item.AutomaticReduceDetail {
7829
+					var total int64
7830
+					auto, _ := service.GetPatientAutoMatic(it.PatientId, adminUser.Org.Id, date.Unix(), it.GoodId)
7831
+					for _, its := range auto {
7832
+						total += its.Count
7833
+					}
7834
+					it.Count = total
7835
+				}
7816 7836
 			}
7817 7837
 		}
7818 7838
 		if err == nil {

+ 34 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Прегледај датотеку

@@ -2990,4 +2990,38 @@ func (this *NewDialysisApiController) GetNextInspectionDetail() {
2990 2990
 
2991 2991
 func (this *NewDialysisApiController) GetInspectionGroup() {
2992 2992
 
2993
+	patient_id, _ := this.GetInt64("patient_id")
2994
+
2995
+	org_id := this.GetMobileAdminUserInfo().Org.Id
2996
+
2997
+	inspection, _ := service.GetInspectionGroup(patient_id, org_id)
2998
+
2999
+	if len(inspection) > 0 {
3000
+		for _, item := range inspection {
3001
+			inspecList, _ := service.GetInspectionByProjectId(item.PatientId, org_id, item.ProjectId)
3002
+			item.Count = int64(len(inspecList))
3003
+		}
3004
+	}
3005
+
3006
+	this.ServeSuccessJSON(map[string]interface{}{
3007
+		"inspection": inspection,
3008
+	})
3009
+}
3010
+
3011
+func (this *NewDialysisApiController) GetInspectionByProject() {
3012
+
3013
+	patient_id, _ := this.GetInt64("patient_id")
3014
+
3015
+	project_id, _ := this.GetInt64("project_id")
3016
+
3017
+	org_id := this.GetMobileAdminUserInfo().Org.Id
3018
+
3019
+	inspection, _ := service.GetInspectionByProject(patient_id, project_id, org_id)
3020
+
3021
+	patients, _ := service.GetPatientByIDOne(org_id, patient_id)
3022
+
3023
+	this.ServeSuccessJSON(map[string]interface{}{
3024
+		"inspection": inspection,
3025
+		"patients":   patients,
3026
+	})
2993 3027
 }

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Прегледај датотеку

@@ -190,4 +190,6 @@ func NewMobileAPIControllersRegisterRouters() {
190 190
 
191 191
 	beego.Router("/m/api/patient/getinspectiongroup", &NewDialysisApiController{}, "Get:GetInspectionGroup")
192 192
 
193
+	beego.Router("/m/api/patient/getinspectionbyprojectid", &NewDialysisApiController{}, "Get:GetInspectionByProject")
194
+
193 195
 }

+ 12 - 0
models/patient_models.go Прегледај датотеку

@@ -2737,3 +2737,15 @@ func (XtAgePatients) TableName() string {
2737 2737
 
2738 2738
 	return "xt_patients"
2739 2739
 }
2740
+
2741
+type NewInspection struct {
2742
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
2743
+	PatientId       int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2744
+	OrgId           int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
2745
+	ProjectId       int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
2746
+	ProjectName     string `gorm:"column:project_name" json:"project_name" form:"project_name"`
2747
+	InspectDate     int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
2748
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
2749
+	Count           int64
2750
+	LastInspectData int64
2751
+}

+ 43 - 1
service/inspection_service.go Прегледај датотеку

@@ -1,11 +1,12 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"XT_New/models"
5 4
 	"errors"
6 5
 	"fmt"
7 6
 	"strings"
8 7
 	"time"
8
+
9
+	"XT_New/models"
9 10
 )
10 11
 
11 12
 func GetInspectionReference(orgId int64, inspect_type int64) (reference []*models.InspectionReference, err error) {
@@ -351,3 +352,44 @@ func GetInsepctionConfigurationList(orgid int64) (standard []*models.QualityCont
351 352
 		Joins("left join xt_inspection_reference as s on s.item_id = x.inspection_minor and s.project_id = x.inspection_major").Where("s.org_id = ? and s.status = 1", orgid).Scan(&standard).Error
352 353
 	return standard, err
353 354
 }
355
+
356
+func GetInspectionGroup(patient_id int64, org_id int64) (inspection []*models.NewInspection, err error) {
357
+
358
+	db := XTReadDB().Table("xt_inspection").Where("status =1")
359
+
360
+	if patient_id > 0 {
361
+		db = db.Where("patient_id = ?", patient_id)
362
+	}
363
+	if org_id > 0 {
364
+		db = db.Where("org_id = ?", org_id)
365
+	}
366
+
367
+	err = db.Order("inspect_date desc").Group("project_id").Scan(&inspection).Error
368
+	return inspection, err
369
+}
370
+
371
+func GetInspectionByProjectId(patient_id int64, org_id int64, project_id int64) (inspection []*models.NewInspection, err error) {
372
+
373
+	db := XTReadDB().Table("xt_inspection").Where("status =1")
374
+
375
+	if patient_id > 0 {
376
+		db = db.Where("patient_id = ?", patient_id)
377
+	}
378
+	if org_id > 0 {
379
+		db = db.Where("org_id = ?", org_id)
380
+	}
381
+	if project_id > 0 {
382
+		db = db.Where("project_id = ?", project_id)
383
+	}
384
+
385
+	err = db.Order("inspect_date desc").Group("inspect_date").Scan(&inspection).Error
386
+	return inspection, err
387
+
388
+}
389
+
390
+func GetInspectionByProject(patient_id int64, project_id int64, org_id int64) (inspection []*models.XtInspection, err error) {
391
+
392
+	err = XTReadDB().Where("patient_id = ? and project_id = ? and org_id = ? and status=1", patient_id, project_id, org_id).Order("id desc").Find(&inspection).Error
393
+
394
+	return inspection, err
395
+}

+ 7 - 0
service/mobile_dialysis_service.go Прегледај датотеку

@@ -3058,6 +3058,13 @@ func GetLastDialysisBeforePrepare(patient_id int64, orgID int64, record_time int
3058 3058
 	return
3059 3059
 }
3060 3060
 
3061
+func GetPatientAutoMatic(patient_id int64, orgID int64, record_time int64, good_id int64) (auto []*models.AutomaticReduceDetail, err error) {
3062
+
3063
+	err = XTReadDB().Where("patient_id = ? and org_id = ? and record_time = ? and good_id =? and status=1", patient_id, orgID, record_time, good_id).Find(&auto).Error
3064
+
3065
+	return auto, err
3066
+}
3067
+
3061 3068
 func GetAllWarehouseOutSumList(patient_id int64, orgID int64, record_time int64) (info []*models.WarehouseOutInfoSeven, err error) {
3062 3069
 
3063 3070
 	err = XTReadDB().Where("patient_id = ? and org_id = ? and sys_record_time = ? and status = 1", patient_id, orgID, record_time).Find(&info).Error