|
@@ -742,6 +742,28 @@ func (MScheduleDoctorAdviceVM) TableName() string {
|
742
|
742
|
return "xt_schedule"
|
743
|
743
|
}
|
744
|
744
|
|
|
745
|
+type MScheduleDoctorAdviceVMOne struct {
|
|
746
|
+ ID int64 `gorm:"column:id" json:"id"`
|
|
747
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
|
748
|
+ PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
|
749
|
+ BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
|
750
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
|
751
|
+ ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
|
752
|
+ ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
|
753
|
+ ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
|
754
|
+ Status int64 `gorm:"column:status" json:"status"`
|
|
755
|
+ DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
|
|
756
|
+ SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
757
|
+ DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
|
758
|
+ DoctorAdvices []*MDoctorAdviceVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
|
759
|
+ Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
|
760
|
+
|
|
761
|
+}
|
|
762
|
+
|
|
763
|
+func (MScheduleDoctorAdviceVMOne) TableName() string {
|
|
764
|
+ return "xt_schedule"
|
|
765
|
+}
|
|
766
|
+
|
745
|
767
|
type MDoctorAdviceVM struct {
|
746
|
768
|
ID int64 `gorm:"column:id" json:"id"`
|
747
|
769
|
UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
|
@@ -887,6 +909,101 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
|
887
|
909
|
return vms, err
|
888
|
910
|
}
|
889
|
911
|
|
|
912
|
+func MobileGetScheduleDoctorAdvicesTwo(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string) ([]*MScheduleDoctorAdviceVMOne, error) {
|
|
913
|
+ var vms []*MScheduleDoctorAdviceVMOne
|
|
914
|
+ adviceWhere := ""
|
|
915
|
+ adviceCondition := []interface{}{}
|
|
916
|
+ if adviceType == 0 {
|
|
917
|
+ if patientType == 0 {
|
|
918
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
|
919
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
920
|
+
|
|
921
|
+ } else if patientType == 1 {
|
|
922
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
|
923
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
924
|
+
|
|
925
|
+ } else if patientType == 2 {
|
|
926
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
|
927
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
928
|
+ }
|
|
929
|
+
|
|
930
|
+ } else if adviceType == 1 {
|
|
931
|
+ if patientType == 0 {
|
|
932
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
|
933
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
934
|
+
|
|
935
|
+ } else if patientType == 1 {
|
|
936
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
|
937
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
938
|
+
|
|
939
|
+ } else if patientType == 2 {
|
|
940
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
|
941
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
942
|
+
|
|
943
|
+ }
|
|
944
|
+
|
|
945
|
+ } else if adviceType == 3 {
|
|
946
|
+ if patientType == 0 {
|
|
947
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
|
948
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
949
|
+
|
|
950
|
+ } else if patientType == 1 {
|
|
951
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
|
952
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
953
|
+ } else if patientType == 2 {
|
|
954
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
|
955
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
956
|
+ }
|
|
957
|
+
|
|
958
|
+ } else if adviceType == 2 && len(deliverWay) > 0 {
|
|
959
|
+ if patientType == 0 {
|
|
960
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
|
961
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
962
|
+
|
|
963
|
+ } else if patientType == 1 {
|
|
964
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
|
965
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
966
|
+ } else if patientType == 2 {
|
|
967
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
|
968
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
969
|
+ }
|
|
970
|
+
|
|
971
|
+ } else if adviceType == 2 && len(deliverWay) <= 0 {
|
|
972
|
+
|
|
973
|
+ if patientType == 0 {
|
|
974
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
|
975
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
976
|
+
|
|
977
|
+ } else if patientType == 1 {
|
|
978
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND (advice_doctor = ? or execution_staff = ?)"
|
|
979
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, adminUserId)
|
|
980
|
+ } else if patientType == 2 {
|
|
981
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
|
982
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
983
|
+ }
|
|
984
|
+
|
|
985
|
+ }
|
|
986
|
+
|
|
987
|
+ db := readDb.
|
|
988
|
+ Table("xt_schedule").
|
|
989
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
990
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
991
|
+ return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
992
|
+ }).
|
|
993
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
994
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
995
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
996
|
+
|
|
997
|
+ Preload("DoctorAdvices", adviceCondition...).
|
|
998
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
999
|
+ if scheduleDate != 0 {
|
|
1000
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1001
|
+ }
|
|
1002
|
+
|
|
1003
|
+ err := db.Find(&vms).Error
|
|
1004
|
+ return vms, err
|
|
1005
|
+}
|
|
1006
|
+
|
890
|
1007
|
func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleDoctorAdviceVM, error) {
|
891
|
1008
|
|
892
|
1009
|
var vms []*HisMScheduleDoctorAdviceVM
|
|
@@ -969,6 +1086,88 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
|
969
|
1086
|
return vms, err
|
970
|
1087
|
}
|
971
|
1088
|
|
|
1089
|
+func GetHisDoctorAdvicesTwo(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleDoctorAdviceVMOne, error) {
|
|
1090
|
+
|
|
1091
|
+ var vms []*HisMScheduleDoctorAdviceVMOne
|
|
1092
|
+ if len(deliverWay) > 0 {
|
|
1093
|
+ if patientType == 0 {
|
|
1094
|
+ db := readDb.
|
|
1095
|
+ Table("xt_schedule").
|
|
1096
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
|
1097
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1098
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1099
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1100
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1101
|
+ return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1102
|
+ }).
|
|
1103
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1104
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1105
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1106
|
+ if scheduleDate != 0 {
|
|
1107
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1108
|
+ }
|
|
1109
|
+ err = db.Find(&vms).Error
|
|
1110
|
+ }
|
|
1111
|
+ if patientType > 0 {
|
|
1112
|
+ db := readDb.
|
|
1113
|
+ Table("xt_schedule").
|
|
1114
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1115
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1116
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
|
|
1117
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1118
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1119
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1120
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1121
|
+ return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1122
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
1123
|
+ if scheduleDate != 0 {
|
|
1124
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1125
|
+ }
|
|
1126
|
+ err = db.Find(&vms).Error
|
|
1127
|
+ }
|
|
1128
|
+
|
|
1129
|
+ } else {
|
|
1130
|
+ if patientType == 0 {
|
|
1131
|
+ db := readDb.
|
|
1132
|
+ Table("xt_schedule").
|
|
1133
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
|
|
1134
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1135
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1136
|
+ return db.Where("status = 1 AND user_org_id = ? and dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1137
|
+ }).
|
|
1138
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1139
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1140
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1141
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1142
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1143
|
+ if scheduleDate != 0 {
|
|
1144
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1145
|
+ }
|
|
1146
|
+ err = db.Find(&vms).Error
|
|
1147
|
+ }
|
|
1148
|
+ if patientType > 0 {
|
|
1149
|
+ db := readDb.
|
|
1150
|
+ Table("xt_schedule").
|
|
1151
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1152
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
|
|
1153
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1154
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1155
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1156
|
+ return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1157
|
+ }).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1158
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1159
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1160
|
+ if scheduleDate != 0 {
|
|
1161
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1162
|
+ }
|
|
1163
|
+ err = db.Find(&vms).Error
|
|
1164
|
+ }
|
|
1165
|
+
|
|
1166
|
+ }
|
|
1167
|
+
|
|
1168
|
+ return vms, err
|
|
1169
|
+}
|
|
1170
|
+
|
972
|
1171
|
func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
|
973
|
1172
|
var vms []*HisMScheduleProjectVM
|
974
|
1173
|
if patientType == 0 {
|
|
@@ -1848,6 +2047,28 @@ func (HisMScheduleDoctorAdviceVM) TableName() string {
|
1848
|
2047
|
return "xt_schedule"
|
1849
|
2048
|
}
|
1850
|
2049
|
|
|
2050
|
+type HisMScheduleDoctorAdviceVMOne struct {
|
|
2051
|
+ ID int64 `gorm:"column:id" json:"id"`
|
|
2052
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
|
2053
|
+ PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
|
2054
|
+ BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
|
2055
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
|
2056
|
+ ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
|
2057
|
+ ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
|
2058
|
+ ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
|
2059
|
+ Status int64 `gorm:"column:status" json:"status"`
|
|
2060
|
+ DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
|
|
2061
|
+ SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
2062
|
+ DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
|
2063
|
+ Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
|
2064
|
+ HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
|
2065
|
+ HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
|
|
2066
|
+}
|
|
2067
|
+
|
|
2068
|
+func (HisMScheduleDoctorAdviceVMOne) TableName() string {
|
|
2069
|
+ return "xt_schedule"
|
|
2070
|
+}
|
|
2071
|
+
|
1851
|
2072
|
type HisMScheduleProjectVM struct {
|
1852
|
2073
|
ID int64 `gorm:"column:id" json:"id"`
|
1853
|
2074
|
UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|