|
@@ -902,6 +902,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
|
902
|
902
|
Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
903
|
903
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
904
|
904
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
|
905
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
905
|
906
|
Where("status = 1 AND user_org_id = ?", orgID)
|
906
|
907
|
if scheduleDate != 0 {
|
907
|
908
|
db = db.Where("schedule_date = ?", scheduleDate)
|
|
@@ -919,6 +920,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
|
919
|
920
|
Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
920
|
921
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
921
|
922
|
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).
|
|
923
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
922
|
924
|
Where("status = 1 AND user_org_id = ?", orgID)
|
923
|
925
|
if scheduleDate != 0 {
|
924
|
926
|
db = db.Where("schedule_date = ?", scheduleDate)
|
|
@@ -938,6 +940,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
|
938
|
940
|
Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
939
|
941
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
940
|
942
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
|
|
943
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
941
|
944
|
Where("status = 1 AND user_org_id = ?", orgID)
|
942
|
945
|
if scheduleDate != 0 {
|
943
|
946
|
db = db.Where("schedule_date = ?", scheduleDate)
|
|
@@ -956,6 +959,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
|
956
|
959
|
Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
957
|
960
|
Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
958
|
961
|
Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
|
|
962
|
+ Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
959
|
963
|
Where("status = 1 AND user_org_id = ?", orgID)
|
960
|
964
|
if scheduleDate != 0 {
|
961
|
965
|
db = db.Where("schedule_date = ?", scheduleDate)
|
|
@@ -968,6 +972,52 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
|
968
|
972
|
return vms, err
|
969
|
973
|
}
|
970
|
974
|
|
|
975
|
+func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
|
|
976
|
+ var vms []*HisMScheduleProjectVM
|
|
977
|
+ if patientType == 0 {
|
|
978
|
+ db := readDb.
|
|
979
|
+ Table("xt_schedule").
|
|
980
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
981
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
982
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
983
|
+ }).
|
|
984
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
985
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
986
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
987
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
988
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
989
|
+ }).
|
|
990
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
991
|
+ if scheduleDate != 0 {
|
|
992
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
993
|
+ }
|
|
994
|
+ err = db.Find(&vms).Error
|
|
995
|
+ }
|
|
996
|
+
|
|
997
|
+ if patientType > 0 {
|
|
998
|
+ db := readDb.
|
|
999
|
+ Table("xt_schedule").
|
|
1000
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1001
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1002
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1003
|
+ }).
|
|
1004
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1005
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1006
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1007
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
|
|
1008
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
1009
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
1010
|
+ }).
|
|
1011
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1012
|
+ if scheduleDate != 0 {
|
|
1013
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1014
|
+ }
|
|
1015
|
+ err = db.Find(&vms).Error
|
|
1016
|
+ }
|
|
1017
|
+
|
|
1018
|
+ return vms, err
|
|
1019
|
+}
|
|
1020
|
+
|
971
|
1021
|
func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
|
972
|
1022
|
now := time.Now()
|
973
|
1023
|
tx := writeDb.Begin()
|
|
@@ -1775,26 +1825,48 @@ func GetLastDialysisPrescriptionByPatientId(orgid int64, patientid int64, record
|
1775
|
1825
|
}
|
1776
|
1826
|
|
1777
|
1827
|
type HisMScheduleDoctorAdviceVM struct {
|
1778
|
|
- ID int64 `gorm:"column:id" json:"id"`
|
1779
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
1780
|
|
- PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
1781
|
|
- BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
1782
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
1783
|
|
- ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
1784
|
|
- ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
1785
|
|
- ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
1786
|
|
- Status int64 `gorm:"column:status" json:"status"`
|
1787
|
|
- DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
|
1788
|
|
- SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
1789
|
|
- DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
1790
|
|
- Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
1791
|
|
- HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
|
1828
|
+ ID int64 `gorm:"column:id" json:"id"`
|
|
1829
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
|
1830
|
+ PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
|
1831
|
+ BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
|
1832
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
|
1833
|
+ ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
|
1834
|
+ ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
|
1835
|
+ ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
|
1836
|
+ Status int64 `gorm:"column:status" json:"status"`
|
|
1837
|
+ DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
|
|
1838
|
+ SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
1839
|
+ DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
|
1840
|
+ Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
|
1841
|
+ HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
|
1842
|
+ HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
|
1792
|
1843
|
}
|
1793
|
1844
|
|
1794
|
1845
|
func (HisMScheduleDoctorAdviceVM) TableName() string {
|
1795
|
1846
|
return "xt_schedule"
|
1796
|
1847
|
}
|
1797
|
1848
|
|
|
1849
|
+type HisMScheduleProjectVM struct {
|
|
1850
|
+ ID int64 `gorm:"column:id" json:"id"`
|
|
1851
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id"`
|
|
1852
|
+ PartitionId int64 `gorm:"column:partition_id" json:"partition_id"`
|
|
1853
|
+ BedId int64 `gorm:"column:bed_id" json:"bed_id"`
|
|
1854
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id"`
|
|
1855
|
+ ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
|
|
1856
|
+ ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
|
|
1857
|
+ ModeId int64 `gorm:"column:mode_id" json:"mode_id"`
|
|
1858
|
+ Status int64 `gorm:"column:status" json:"status"`
|
|
1859
|
+ DialysisOrder *MDialysisOrderVM `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
|
|
1860
|
+ SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
1861
|
+ DeviceNumber *MDeviceNumberVM `gorm:"ForeignKey:BedId" json:"device_number"`
|
|
1862
|
+ Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
|
1863
|
+ HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
|
|
1864
|
+}
|
|
1865
|
+
|
|
1866
|
+func (HisMScheduleProjectVM) TableName() string {
|
|
1867
|
+ return "xt_schedule"
|
|
1868
|
+}
|
|
1869
|
+
|
1798
|
1870
|
func GetHisDoctorConfig(orgid int64) (models.XtHisConfig, error) {
|
1799
|
1871
|
config := models.XtHisConfig{}
|
1800
|
1872
|
err := XTReadDB().Model(&config).Where("user_org_id = ? and status =1", orgid).Find(&config).Error
|
|
@@ -2121,3 +2193,48 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
|
2121
|
2193
|
|
2122
|
2194
|
return
|
2123
|
2195
|
}
|
|
2196
|
+
|
|
2197
|
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
|
|
2198
|
+ var vms []*HisMScheduleProjectVM
|
|
2199
|
+ if patientType == 0 {
|
|
2200
|
+ db := readDb.
|
|
2201
|
+ Table("xt_schedule").
|
|
2202
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2203
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2204
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2205
|
+ }).
|
|
2206
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2207
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2208
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2209
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2210
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2211
|
+ }).Where("status = 1 AND user_org_id = ?", orgID)
|
|
2212
|
+ if scheduleDate != 0 {
|
|
2213
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2214
|
+ }
|
|
2215
|
+ err = db.Find(&vms).Error
|
|
2216
|
+ }
|
|
2217
|
+
|
|
2218
|
+ if patientType > 0 {
|
|
2219
|
+ db := readDb.
|
|
2220
|
+ Table("xt_schedule").
|
|
2221
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
2222
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
2223
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
2224
|
+ }).
|
|
2225
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
2226
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
2227
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
2228
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
|
|
2229
|
+ Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
2230
|
+ return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
|
|
2231
|
+ }).
|
|
2232
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
2233
|
+ if scheduleDate != 0 {
|
|
2234
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
2235
|
+ }
|
|
2236
|
+ err = db.Find(&vms).Error
|
|
2237
|
+ }
|
|
2238
|
+
|
|
2239
|
+ return vms, err
|
|
2240
|
+}
|