|
@@ -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
|
+}
|