Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
c6d1ceabd1

+ 17 - 9
controllers/dialysis_record_api_controller.go View File

438
 			MonitoringNurse:           adminUserInfo.AdminUser.Id,
438
 			MonitoringNurse:           adminUserInfo.AdminUser.Id,
439
 			Conductivity:              monitorParam.Conductivity,
439
 			Conductivity:              monitorParam.Conductivity,
440
 			DisplacementFlowQuantity:  monitorParam.DisplacementFlowQuantity,
440
 			DisplacementFlowQuantity:  monitorParam.DisplacementFlowQuantity,
441
-			Status:                1,
442
-			CreatedTime:           time.Now().Unix(),
443
-			UpdatedTime:           time.Now().Unix(),
444
-			BloodOxygenSaturation: monitorParam.BloodOxygenSaturation,
445
-			Creator:               adminUserInfo.AdminUser.Id,
446
-			Heparin:               monitorParam.Heparin,
447
-			DialysateFlow:         monitorParam.DialysateFlow,
448
-			Urr:                   monitorParam.Urr,
449
-			BloodSugar:            monitorParam.BloodSugar,
441
+			Status:                    1,
442
+			CreatedTime:               time.Now().Unix(),
443
+			UpdatedTime:               time.Now().Unix(),
444
+			BloodOxygenSaturation:     monitorParam.BloodOxygenSaturation,
445
+			Creator:                   adminUserInfo.AdminUser.Id,
446
+			Heparin:                   monitorParam.Heparin,
447
+			DialysateFlow:             monitorParam.DialysateFlow,
448
+			Urr:                       monitorParam.Urr,
449
+			BloodSugar:                monitorParam.BloodSugar,
450
 		}
450
 		}
451
 		createErr := service.CreateMonitor(&monitor)
451
 		createErr := service.CreateMonitor(&monitor)
452
 		if createErr != nil {
452
 		if createErr != nil {
870
 		return
870
 		return
871
 	}
871
 	}
872
 
872
 
873
+	//获取最后一条透析处方数据
874
+	prescription, parseErr := service.GetLastDialysisPrescriptionByPatientId(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
875
+
873
 	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
876
 	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
874
 
877
 
875
 	var tempassessmentAfterDislysis models.AssessmentAfterDislysis
878
 	var tempassessmentAfterDislysis models.AssessmentAfterDislysis
909
 		tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
912
 		tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
910
 	}
913
 	}
911
 
914
 
915
+	if prescription.ID > 0 && adminUserInfo.CurrentOrgId == 9583 {
916
+
917
+		tempassessmentAfterDislysis.ActualUltrafiltration = prescription.TargetUltrafiltration
918
+	}
919
+
912
 	if lastAssessmentAfterDislysis != nil {
920
 	if lastAssessmentAfterDislysis != nil {
913
 		tempassessmentAfterDislysis.BloodPressureType = lastAssessmentAfterDislysis.BloodPressureType
921
 		tempassessmentAfterDislysis.BloodPressureType = lastAssessmentAfterDislysis.BloodPressureType
914
 
922
 

+ 6 - 5
controllers/doctors_api_controller.go View File

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/service"
5
-	"strconv"
6
 	"XT_New/enums"
4
 	"XT_New/enums"
7
 	"XT_New/models"
5
 	"XT_New/models"
6
+	"XT_New/service"
8
 	"XT_New/utils"
7
 	"XT_New/utils"
9
 	"fmt"
8
 	"fmt"
10
 	"github.com/astaxie/beego"
9
 	"github.com/astaxie/beego"
11
 	"github.com/jinzhu/gorm"
10
 	"github.com/jinzhu/gorm"
11
+	"strconv"
12
 	"time"
12
 	"time"
13
 )
13
 )
14
 
14
 
53
 	orgID := adminUserInfo.CurrentOrgId
53
 	orgID := adminUserInfo.CurrentOrgId
54
 
54
 
55
 	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id)
55
 	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id)
56
+	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix())
56
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
57
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
57
 	if err != nil {
58
 	if err != nil {
58
 		c.ErrorLog("获取排班信息失败:%v", err)
59
 		c.ErrorLog("获取排班信息失败:%v", err)
65
 			}
66
 			}
66
 		}
67
 		}
67
 		c.ServeSuccessJSON(map[string]interface{}{
68
 		c.ServeSuccessJSON(map[string]interface{}{
68
-			"scheduals": filtedScheduals,
69
-
70
-			"adminUser": adminUser,
69
+			"scheduals":  filtedScheduals,
70
+			"adminUser":  adminUser,
71
+			"hisAdvices": hisAdvices,
71
 		})
72
 		})
72
 	}
73
 	}
73
 }
74
 }

+ 7 - 3
controllers/mobile_api_controllers/doctor_advice_api_controller.go View File

5
 	"XT_New/models"
5
 	"XT_New/models"
6
 	"XT_New/service"
6
 	"XT_New/service"
7
 	"XT_New/utils"
7
 	"XT_New/utils"
8
+	"fmt"
8
 )
9
 )
9
 
10
 
10
 type DoctorAdviceAPIController struct {
11
 type DoctorAdviceAPIController struct {
38
 	orgID := adminInfo.Org.Id
39
 	orgID := adminInfo.Org.Id
39
 
40
 
40
 	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id)
41
 	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id)
42
+	//获取his医嘱数据
43
+	fmt.Println("date.un222222", date.Unix())
44
+	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix())
41
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
45
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
42
 	if err != nil {
46
 	if err != nil {
43
 		this.ErrorLog("获取排班信息失败:%v", err)
47
 		this.ErrorLog("获取排班信息失败:%v", err)
50
 			}
54
 			}
51
 		}
55
 		}
52
 		this.ServeSuccessJSON(map[string]interface{}{
56
 		this.ServeSuccessJSON(map[string]interface{}{
53
-			"scheduals": filtedScheduals,
54
-
55
-			"adminUser": adminUser,
57
+			"scheduals":  filtedScheduals,
58
+			"adminUser":  adminUser,
59
+			"hisAdvices": hisAdvices,
56
 		})
60
 		})
57
 	}
61
 	}
58
 }
62
 }

+ 57 - 0
service/mobile_dialysis_service.go View File

860
 	return vms, err
860
 	return vms, err
861
 }
861
 }
862
 
862
 
863
+func GetHisDoctorAdvices(orgID int64, scheduleDate int64) ([]*HisMScheduleDoctorAdviceVM, error) {
864
+
865
+	var vms []*HisMScheduleDoctorAdviceVM
866
+
867
+	db := readDb.
868
+		Table("xt_schedule").
869
+		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
870
+		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
871
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
872
+		}).
873
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
874
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
875
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
876
+		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
877
+		Where("status = 1 AND user_org_id = ?", orgID)
878
+	if scheduleDate != 0 {
879
+		db = db.Where("schedule_date = ?", scheduleDate)
880
+	}
881
+
882
+	err := db.Find(&vms).Error
883
+	return vms, err
884
+}
885
+
863
 func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
886
 func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
864
 	now := time.Now()
887
 	now := time.Now()
865
 	tx := writeDb.Begin()
888
 	tx := writeDb.Begin()
1617
 	return
1640
 	return
1618
 
1641
 
1619
 }
1642
 }
1643
+
1644
+func GetLastDialysisPrescriptionByPatientId(orgid int64, patientid int64, recorddate int64) (*models.DialysisPrescription, error) {
1645
+
1646
+	prescription := models.DialysisPrescription{}
1647
+	err := readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patientid, recorddate).Find(&prescription).Error
1648
+	if err == gorm.ErrRecordNotFound {
1649
+		return nil, err
1650
+	}
1651
+	if err != nil {
1652
+		return nil, err
1653
+	}
1654
+	return &prescription, nil
1655
+}
1656
+
1657
+type HisMScheduleDoctorAdviceVM struct {
1658
+	ID                  int64                            `gorm:"column:id" json:"id"`
1659
+	UserOrgId           int64                            `gorm:"column:user_org_id" json:"user_org_id"`
1660
+	PartitionId         int64                            `gorm:"column:partition_id" json:"partition_id"`
1661
+	BedId               int64                            `gorm:"column:bed_id" json:"bed_id"`
1662
+	PatientId           int64                            `gorm:"column:patient_id" json:"patient_id"`
1663
+	ScheduleDate        int64                            `gorm:"column:schedule_date" json:"schedule_date"`
1664
+	ScheduleType        int64                            `gorm:"column:schedule_type" json:"schedule_type"`
1665
+	ModeId              int64                            `gorm:"column:mode_id" json:"mode_id"`
1666
+	Status              int64                            `gorm:"column:status" json:"status"`
1667
+	DialysisOrder       *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
1668
+	SchedualPatient     *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1669
+	DeviceNumber        *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
1670
+	Prescription        *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1671
+	HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
1672
+}
1673
+
1674
+func (HisMScheduleDoctorAdviceVM) TableName() string {
1675
+	return "xt_schedule"
1676
+}