XMLWAN 4 лет назад
Родитель
Сommit
c6d1ceabd1

+ 17 - 9
controllers/dialysis_record_api_controller.go Просмотреть файл

@@ -438,15 +438,15 @@ func (this *DialysisRecordAPIController) EditMonitor() {
438 438
 			MonitoringNurse:           adminUserInfo.AdminUser.Id,
439 439
 			Conductivity:              monitorParam.Conductivity,
440 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 451
 		createErr := service.CreateMonitor(&monitor)
452 452
 		if createErr != nil {
@@ -870,6 +870,9 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
870 870
 		return
871 871
 	}
872 872
 
873
+	//获取最后一条透析处方数据
874
+	prescription, parseErr := service.GetLastDialysisPrescriptionByPatientId(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
875
+
873 876
 	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
874 877
 
875 878
 	var tempassessmentAfterDislysis models.AssessmentAfterDislysis
@@ -909,6 +912,11 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
909 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 920
 	if lastAssessmentAfterDislysis != nil {
913 921
 		tempassessmentAfterDislysis.BloodPressureType = lastAssessmentAfterDislysis.BloodPressureType
914 922
 

+ 6 - 5
controllers/doctors_api_controller.go Просмотреть файл

@@ -1,14 +1,14 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"XT_New/service"
5
-	"strconv"
6 4
 	"XT_New/enums"
7 5
 	"XT_New/models"
6
+	"XT_New/service"
8 7
 	"XT_New/utils"
9 8
 	"fmt"
10 9
 	"github.com/astaxie/beego"
11 10
 	"github.com/jinzhu/gorm"
11
+	"strconv"
12 12
 	"time"
13 13
 )
14 14
 
@@ -53,6 +53,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
53 53
 	orgID := adminUserInfo.CurrentOrgId
54 54
 
55 55
 	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id)
56
+	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix())
56 57
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
57 58
 	if err != nil {
58 59
 		c.ErrorLog("获取排班信息失败:%v", err)
@@ -65,9 +66,9 @@ func (c *DoctorsApiController) ScheduleAdvices() {
65 66
 			}
66 67
 		}
67 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 Просмотреть файл

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"fmt"
8 9
 )
9 10
 
10 11
 type DoctorAdviceAPIController struct {
@@ -38,6 +39,9 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
38 39
 	orgID := adminInfo.Org.Id
39 40
 
40 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 45
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
42 46
 	if err != nil {
43 47
 		this.ErrorLog("获取排班信息失败:%v", err)
@@ -50,9 +54,9 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
50 54
 			}
51 55
 		}
52 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 Просмотреть файл

@@ -860,6 +860,29 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
860 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 886
 func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
864 887
 	now := time.Now()
865 888
 	tx := writeDb.Begin()
@@ -1617,3 +1640,37 @@ func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his
1617 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
+}