|
@@ -794,9 +794,6 @@ func (MDoctorAdviceVM) TableName() string {
|
794
|
794
|
func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string) ([]*MScheduleDoctorAdviceVM, error) {
|
795
|
795
|
var vms []*MScheduleDoctorAdviceVM
|
796
|
796
|
adviceWhere := ""
|
797
|
|
- fmt.Println("advicetype", adviceType)
|
798
|
|
- fmt.Println("patientType", patientType)
|
799
|
|
- fmt.Println("adminUserId", adminUserId)
|
800
|
797
|
adviceCondition := []interface{}{}
|
801
|
798
|
if adviceType == 0 {
|
802
|
799
|
if patientType == 0 {
|
|
@@ -1792,3 +1789,152 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
|
1792
|
1789
|
err = db.Select("x.advice_name,x.advice_desc,x.delivery_way,count(x.id) as total").Group("x.advice_name,x.advice_desc").Scan(&advice).Error
|
1793
|
1790
|
return advice, err
|
1794
|
1791
|
}
|
|
1792
|
+
|
|
1793
|
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
|
|
1794
|
+ var vms []*MScheduleDoctorAdviceVM
|
|
1795
|
+ adviceWhere := ""
|
|
1796
|
+ adviceCondition := []interface{}{}
|
|
1797
|
+ if adviceType == 0 {
|
|
1798
|
+ if patientType == 0 {
|
|
1799
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
|
|
1800
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1801
|
+
|
|
1802
|
+ } else if patientType == 1 {
|
|
1803
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
|
|
1804
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
1805
|
+
|
|
1806
|
+ } else if patientType == 2 {
|
|
1807
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
|
|
1808
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1809
|
+ }
|
|
1810
|
+
|
|
1811
|
+ } else if adviceType == 1 {
|
|
1812
|
+ if patientType == 0 {
|
|
1813
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? "
|
|
1814
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1815
|
+
|
|
1816
|
+ } else if patientType == 1 {
|
|
1817
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
|
|
1818
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
1819
|
+
|
|
1820
|
+ } else if patientType == 2 {
|
|
1821
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
|
|
1822
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1823
|
+
|
|
1824
|
+ }
|
|
1825
|
+
|
|
1826
|
+ } else if adviceType == 3 {
|
|
1827
|
+ if patientType == 0 {
|
|
1828
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? "
|
|
1829
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1830
|
+
|
|
1831
|
+ } else if patientType == 1 {
|
|
1832
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
|
|
1833
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
1834
|
+ } else if patientType == 2 {
|
|
1835
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND execution_staff = 0"
|
|
1836
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1837
|
+ }
|
|
1838
|
+
|
|
1839
|
+ } else if adviceType == 2 && len(deliverWay) > 0 {
|
|
1840
|
+ if patientType == 0 {
|
|
1841
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
|
|
1842
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
1843
|
+
|
|
1844
|
+ } else if patientType == 1 {
|
|
1845
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and delivery_way = ? "
|
|
1846
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
|
|
1847
|
+ } else if patientType == 2 {
|
|
1848
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0 and delivery_way = ?"
|
|
1849
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
|
|
1850
|
+ }
|
|
1851
|
+
|
|
1852
|
+ } else if adviceType == 2 && len(deliverWay) <= 0 {
|
|
1853
|
+ if patientType == 0 {
|
|
1854
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
|
|
1855
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1856
|
+
|
|
1857
|
+ } else if patientType == 1 {
|
|
1858
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
|
|
1859
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
|
|
1860
|
+ } else if patientType == 2 {
|
|
1861
|
+ adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND execution_staff = 0"
|
|
1862
|
+ adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
|
|
1863
|
+ }
|
|
1864
|
+
|
|
1865
|
+ }
|
|
1866
|
+
|
|
1867
|
+ db := readDb.Table("xt_schedule")
|
|
1868
|
+ if scheduleType > 0 {
|
|
1869
|
+ db = db.Where("schedule_type = ?", scheduleType)
|
|
1870
|
+ }
|
|
1871
|
+ if partitonType > 0 {
|
|
1872
|
+ db = db.Where("partition_id = ?", partitonType)
|
|
1873
|
+ }
|
|
1874
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1875
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1876
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1877
|
+ }).
|
|
1878
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1879
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1880
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1881
|
+ Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
|
|
1882
|
+ Preload("DoctorAdvices", adviceCondition...).
|
|
1883
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1884
|
+ if scheduleDate != 0 {
|
|
1885
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1886
|
+ }
|
|
1887
|
+
|
|
1888
|
+ err := db.Find(&vms).Error
|
|
1889
|
+ return vms, err
|
|
1890
|
+}
|
|
1891
|
+
|
|
1892
|
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
|
|
1893
|
+
|
|
1894
|
+ var vms []*HisMScheduleDoctorAdviceVM
|
|
1895
|
+ if len(deliverWay) > 0 {
|
|
1896
|
+ db := readDb.Table("xt_schedule")
|
|
1897
|
+ if scheduleType > 0 {
|
|
1898
|
+ db = db.Where("schedule_type = ?", scheduleType)
|
|
1899
|
+ }
|
|
1900
|
+ if partitionType > 0 {
|
|
1901
|
+ db = db.Where("partition_id = ?", partitionType)
|
|
1902
|
+ }
|
|
1903
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1904
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1905
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1906
|
+ }).
|
|
1907
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1908
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1909
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1910
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
|
|
1911
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1912
|
+ if scheduleDate != 0 {
|
|
1913
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1914
|
+ }
|
|
1915
|
+ err = db.Find(&vms).Error
|
|
1916
|
+ } else {
|
|
1917
|
+ db := readDb.Table("xt_schedule")
|
|
1918
|
+ if scheduleType > 0 {
|
|
1919
|
+ db = db.Where("schedule_type = ?", scheduleType)
|
|
1920
|
+ }
|
|
1921
|
+ if partitionType > 0 {
|
|
1922
|
+ db = db.Where("partition_id = ?", partitionType)
|
|
1923
|
+ }
|
|
1924
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
1925
|
+ Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
|
|
1926
|
+ return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
|
|
1927
|
+ }).
|
|
1928
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
1929
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
1930
|
+ Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
|
|
1931
|
+ Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
|
|
1932
|
+ Where("status = 1 AND user_org_id = ?", orgID)
|
|
1933
|
+ if scheduleDate != 0 {
|
|
1934
|
+ db = db.Where("schedule_date = ?", scheduleDate)
|
|
1935
|
+ }
|
|
1936
|
+ err = db.Find(&vms).Error
|
|
1937
|
+ }
|
|
1938
|
+
|
|
1939
|
+ return vms, err
|
|
1940
|
+}
|