csx před 3 roky
rodič
revize
f9ae2c7ada

+ 121 - 0
controllers/his_charge_api_controller.go Zobrazit soubor

@@ -0,0 +1,121 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"github.com/astaxie/beego"
7
+	"time"
8
+)
9
+
10
+type HisChargeApiController struct {
11
+	BaseAuthAPIController
12
+}
13
+
14
+func HisChargeApiRegistRouters() {
15
+	beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
16
+	beego.Router("/api/his/chargestatistics/summary", &HisChargeApiController{}, "get:GetChargeStatisticsSummary")
17
+	beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
18
+
19
+}
20
+
21
+func (c *HisChargeApiController) GetChargeStatisticsDetail() {
22
+	start_time := c.GetString("start_time")
23
+	end_time := c.GetString("end_time")
24
+	adminUser := c.GetAdminUserInfo()
25
+
26
+	timeLayout := "2006-01-02"
27
+	loc, _ := time.LoadLocation("Local")
28
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
29
+	if err != nil {
30
+
31
+	}
32
+	startRecordDateTime := startTime.Unix()
33
+
34
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
35
+	if err != nil {
36
+
37
+	}
38
+	endRecordDateTime := endTime.Unix()
39
+
40
+	chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
41
+
42
+	if err == nil {
43
+		c.ServeSuccessJSON(map[string]interface{}{
44
+			"patients": chargePatient,
45
+		})
46
+		return
47
+	} else {
48
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
49
+		return
50
+
51
+	}
52
+
53
+}
54
+
55
+func (c *HisChargeApiController) GetChargeStatisticsSummary() {
56
+	start_time := c.GetString("start_time")
57
+	end_time := c.GetString("end_time")
58
+	adminUser := c.GetAdminUserInfo()
59
+
60
+	timeLayout := "2006-01-02"
61
+	loc, _ := time.LoadLocation("Local")
62
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
63
+	if err != nil {
64
+
65
+	}
66
+	startRecordDateTime := startTime.Unix()
67
+
68
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
69
+	if err != nil {
70
+
71
+	}
72
+	endRecordDateTime := endTime.Unix()
73
+
74
+	chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
75
+
76
+	if err == nil {
77
+		c.ServeSuccessJSON(map[string]interface{}{
78
+			"patients": chargePatient,
79
+		})
80
+		return
81
+	} else {
82
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
83
+		return
84
+
85
+	}
86
+
87
+}
88
+
89
+func (c *HisChargeApiController) GetChargeStatisticsSettle() {
90
+	start_time := c.GetString("start_time")
91
+	end_time := c.GetString("end_time")
92
+	adminUser := c.GetAdminUserInfo()
93
+
94
+	timeLayout := "2006-01-02"
95
+	loc, _ := time.LoadLocation("Local")
96
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
97
+	if err != nil {
98
+
99
+	}
100
+	startRecordDateTime := startTime.Unix()
101
+
102
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
103
+	if err != nil {
104
+
105
+	}
106
+	endRecordDateTime := endTime.Unix()
107
+
108
+	chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
109
+
110
+	if err == nil {
111
+		c.ServeSuccessJSON(map[string]interface{}{
112
+			"patients": chargePatient,
113
+		})
114
+		return
115
+	} else {
116
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
117
+		return
118
+
119
+	}
120
+
121
+}

+ 284 - 9
controllers/public_api_controller.go Zobrazit soubor

@@ -67,6 +67,8 @@ func PublicApiRegistRouters() {
67 67
 
68 68
 	beego.Router("/groupno", &PublicApiController{}, "get:HandleGroupNo")
69 69
 
70
+	beego.Router("/handle10215", &PublicApiController{}, "get:Handle10215")
71
+
70 72
 	//beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
71 73
 
72 74
 }
@@ -609,15 +611,16 @@ func (c *PublicApiController) HandleData() {
609 611
 }
610 612
 
611 613
 func (c *PublicApiController) HandleGroupNo() {
612
-	pts, _ := service.GetHisPrescriptionTemplateTwo()
613
-	for _, item := range pts {
614
-		if len(item.HisPrescriptionAdviceTemplate) > 0 {
615
-			for index, subItem := range item.HisPrescriptionAdviceTemplate {
616
-				subItem.Groupno = int64(index + 1)
617
-				service.SaveAdviceTemplate(subItem)
618
-			}
619
-		}
620
-	}
614
+	//service.GetAllPatientChargeDetails(10138, 1634054400)
615
+	//pts, _ := service.GetHisPrescriptionTemplateTwo()
616
+	//for _, item := range pts {
617
+	//	if len(item.HisPrescriptionAdviceTemplate) > 0 {
618
+	//		for index, subItem := range item.HisPrescriptionAdviceTemplate {
619
+	//			subItem.Groupno = int64(index + 1)
620
+	//			service.SaveAdviceTemplate(subItem)
621
+	//		}
622
+	//	}
623
+	//}
621 624
 }
622 625
 
623 626
 func InitRoleAndPurviews(org_ids []int64) {
@@ -1757,3 +1760,275 @@ func PathExists(path string) (bool, error) {
1757 1760
 	}
1758 1761
 	return false, err
1759 1762
 }
1763
+
1764
+func (c *PublicApiController) Handle10215() {
1765
+
1766
+	//projects,_ := service.GetAllInfo(10215,2284)
1767
+	//
1768
+	//for _, item := range projects{
1769
+	//	service.UpdateStatus(item.ID, item.PrescriptionId)
1770
+	//}
1771
+	//projects_two,_ := service.GetAllInfo(10215,2277)
1772
+	//
1773
+	//for _, item := range projects_two{
1774
+	//	service.UpdateStatus(item.ID, item.PrescriptionId)
1775
+	//}
1776
+
1777
+	//service.GetAllInfo(10215,2284)
1778
+	//service.GetAllInfo(10215,2277)
1779
+
1780
+	his, _ := service.GetAllPT(10215)
1781
+	for _, item := range his {
1782
+
1783
+		info := &models.HisPrescriptionInfoTemplate{
1784
+			UserOrgId:   item.UserOrgId,
1785
+			RecordDate:  0,
1786
+			PatientId:   item.PatientId,
1787
+			Status:      1,
1788
+			Ctime:       time.Now().Unix(),
1789
+			Mtime:       time.Now().Unix(),
1790
+			Type:        2,
1791
+			Creator:     0,
1792
+			Modifier:    0,
1793
+			PType:       0,
1794
+			PTemplateId: item.ID,
1795
+			MedType:     "14",
1796
+		}
1797
+		service.CreateHisPrescriptionInfoTemplate(info)
1798
+
1799
+		pro := &models.HisPrescriptionProjectTemplate{
1800
+			ProjectId:          1750,
1801
+			Price:              6.00,
1802
+			UserOrgId:          10215,
1803
+			Status:             1,
1804
+			Ctime:              time.Now().Unix(),
1805
+			Mtime:              time.Now().Unix(),
1806
+			PatientId:          item.PatientId,
1807
+			RecordDate:         0,
1808
+			Count:              1,
1809
+			FeedetlSn:          "",
1810
+			MedListCodg:        "",
1811
+			SingleDose:         "1",
1812
+			DeliveryWay:        "",
1813
+			ExecutionFrequency: "",
1814
+			Day:                "1",
1815
+			Remark:             "",
1816
+			Unit:               "",
1817
+			Type:               2,
1818
+			PrescriptionId:     info.ID,
1819
+			FrequencyType:      1,
1820
+			DayCount:           0,
1821
+			WeekDay:            "",
1822
+		}
1823
+		service.CreateHisPrescriptionProjectTemplate(pro)
1824
+
1825
+		pro2 := &models.HisPrescriptionProjectTemplate{
1826
+			ProjectId:          2462,
1827
+			Price:              4.94,
1828
+			UserOrgId:          10215,
1829
+			Status:             1,
1830
+			Ctime:              time.Now().Unix(),
1831
+			Mtime:              time.Now().Unix(),
1832
+			PatientId:          item.PatientId,
1833
+			RecordDate:         0,
1834
+			Count:              1,
1835
+			FeedetlSn:          "",
1836
+			MedListCodg:        "",
1837
+			SingleDose:         "1",
1838
+			DeliveryWay:        "",
1839
+			ExecutionFrequency: "",
1840
+			Day:                "1",
1841
+			Remark:             "",
1842
+			Unit:               "",
1843
+			Type:               3,
1844
+			PrescriptionId:     info.ID,
1845
+			FrequencyType:      1,
1846
+			DayCount:           0,
1847
+			WeekDay:            "",
1848
+		}
1849
+		service.CreateHisPrescriptionProjectTemplate(pro2)
1850
+		//
1851
+		//
1852
+		infos, _ := service.GetAllPTInfo(10215, item.ID)
1853
+		//	// fmt.Println(infos)
1854
+		for _, subItem := range infos {
1855
+
1856
+			if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
1857
+
1858
+				for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
1859
+
1860
+					if ssubItem.DrugId == 1234 {
1861
+						pro := &models.HisPrescriptionProjectTemplate{
1862
+							ProjectId:          2326,
1863
+							Price:              0.86,
1864
+							UserOrgId:          ssubItem.UserOrgId,
1865
+							Status:             1,
1866
+							Ctime:              time.Now().Unix(),
1867
+							Mtime:              time.Now().Unix(),
1868
+							PatientId:          ssubItem.PatientId,
1869
+							RecordDate:         ssubItem.AdviceDate,
1870
+							Count:              1,
1871
+							FeedetlSn:          "",
1872
+							MedListCodg:        "",
1873
+							SingleDose:         "1",
1874
+							DeliveryWay:        "",
1875
+							ExecutionFrequency: "",
1876
+							Day:                "1",
1877
+							Remark:             "",
1878
+							Unit:               "",
1879
+							Type:               3,
1880
+							PrescriptionId:     info.ID,
1881
+							FrequencyType:      ssubItem.FrequencyType,
1882
+							DayCount:           ssubItem.DayCount,
1883
+							WeekDay:            ssubItem.WeekDay,
1884
+						}
1885
+						service.CreateHisPrescriptionProjectTemplate(pro)
1886
+
1887
+					}
1888
+					if ssubItem.DrugId == 1288 {
1889
+
1890
+						pro := &models.HisPrescriptionProjectTemplate{
1891
+							ProjectId:          2326,
1892
+							Price:              0.86,
1893
+							UserOrgId:          ssubItem.UserOrgId,
1894
+							Status:             1,
1895
+							Ctime:              time.Now().Unix(),
1896
+							Mtime:              time.Now().Unix(),
1897
+							PatientId:          ssubItem.PatientId,
1898
+							RecordDate:         ssubItem.AdviceDate,
1899
+							Count:              1,
1900
+							FeedetlSn:          "",
1901
+							MedListCodg:        "",
1902
+							SingleDose:         "1",
1903
+							DeliveryWay:        "",
1904
+							ExecutionFrequency: "",
1905
+							Day:                "1",
1906
+							Remark:             "",
1907
+							Unit:               "",
1908
+							Type:               3,
1909
+							PrescriptionId:     info.ID,
1910
+							FrequencyType:      ssubItem.FrequencyType,
1911
+							DayCount:           ssubItem.DayCount,
1912
+							WeekDay:            ssubItem.WeekDay,
1913
+						}
1914
+						service.CreateHisPrescriptionProjectTemplate(pro)
1915
+
1916
+					}
1917
+					if ssubItem.DrugId == 1306 {
1918
+
1919
+						pro := &models.HisPrescriptionProjectTemplate{
1920
+							ProjectId:          2325,
1921
+							Price:              1.11,
1922
+							UserOrgId:          ssubItem.UserOrgId,
1923
+							Status:             1,
1924
+							Ctime:              time.Now().Unix(),
1925
+							Mtime:              time.Now().Unix(),
1926
+							PatientId:          ssubItem.PatientId,
1927
+							RecordDate:         ssubItem.AdviceDate,
1928
+							Count:              1,
1929
+							FeedetlSn:          "",
1930
+							MedListCodg:        "",
1931
+							SingleDose:         "1",
1932
+							DeliveryWay:        "",
1933
+							ExecutionFrequency: "",
1934
+							Day:                "1",
1935
+							Remark:             "",
1936
+							Unit:               "",
1937
+							Type:               3,
1938
+							PrescriptionId:     info.ID,
1939
+							FrequencyType:      ssubItem.FrequencyType,
1940
+							DayCount:           ssubItem.DayCount,
1941
+							WeekDay:            ssubItem.WeekDay,
1942
+						}
1943
+						service.CreateHisPrescriptionProjectTemplate(pro)
1944
+
1945
+						pro2 := &models.HisPrescriptionProjectTemplate{
1946
+							ProjectId:          1727,
1947
+							Price:              2.50,
1948
+							UserOrgId:          ssubItem.UserOrgId,
1949
+							Status:             1,
1950
+							Ctime:              time.Now().Unix(),
1951
+							Mtime:              time.Now().Unix(),
1952
+							PatientId:          ssubItem.PatientId,
1953
+							RecordDate:         ssubItem.AdviceDate,
1954
+							Count:              1,
1955
+							FeedetlSn:          "",
1956
+							MedListCodg:        "",
1957
+							SingleDose:         "1",
1958
+							DeliveryWay:        "",
1959
+							ExecutionFrequency: "",
1960
+							Day:                "1",
1961
+							Remark:             "",
1962
+							Unit:               "",
1963
+							Type:               2,
1964
+							PrescriptionId:     info.ID,
1965
+							FrequencyType:      ssubItem.FrequencyType,
1966
+							DayCount:           ssubItem.DayCount,
1967
+							WeekDay:            ssubItem.WeekDay,
1968
+						}
1969
+						service.CreateHisPrescriptionProjectTemplate(pro2)
1970
+
1971
+					}
1972
+					if ssubItem.DrugId == 1291 {
1973
+
1974
+						pro := &models.HisPrescriptionProjectTemplate{
1975
+							ProjectId:          2322,
1976
+							Price:              0.68,
1977
+							UserOrgId:          ssubItem.UserOrgId,
1978
+							Status:             1,
1979
+							Ctime:              time.Now().Unix(),
1980
+							Mtime:              time.Now().Unix(),
1981
+							PatientId:          ssubItem.PatientId,
1982
+							RecordDate:         ssubItem.AdviceDate,
1983
+							Count:              1,
1984
+							FeedetlSn:          "",
1985
+							MedListCodg:        "",
1986
+							SingleDose:         "1",
1987
+							DeliveryWay:        "",
1988
+							ExecutionFrequency: "",
1989
+							Day:                "1",
1990
+							Remark:             "",
1991
+							Unit:               "",
1992
+							Type:               3,
1993
+							PrescriptionId:     info.ID,
1994
+							FrequencyType:      ssubItem.FrequencyType,
1995
+							DayCount:           ssubItem.DayCount,
1996
+							WeekDay:            ssubItem.WeekDay,
1997
+						}
1998
+						service.CreateHisPrescriptionProjectTemplate(pro)
1999
+
2000
+						pro2 := &models.HisPrescriptionProjectTemplate{
2001
+							ProjectId:          1727,
2002
+							Price:              2.50,
2003
+							UserOrgId:          ssubItem.UserOrgId,
2004
+							Status:             1,
2005
+							Ctime:              time.Now().Unix(),
2006
+							Mtime:              time.Now().Unix(),
2007
+							PatientId:          ssubItem.PatientId,
2008
+							RecordDate:         ssubItem.AdviceDate,
2009
+							Count:              1,
2010
+							FeedetlSn:          "",
2011
+							MedListCodg:        "",
2012
+							SingleDose:         "1",
2013
+							DeliveryWay:        "",
2014
+							ExecutionFrequency: "",
2015
+							Day:                "1",
2016
+							Remark:             "",
2017
+							Unit:               "",
2018
+							Type:               2,
2019
+							PrescriptionId:     info.ID,
2020
+							FrequencyType:      ssubItem.FrequencyType,
2021
+							DayCount:           ssubItem.DayCount,
2022
+							WeekDay:            ssubItem.WeekDay,
2023
+						}
2024
+						service.CreateHisPrescriptionProjectTemplate(pro2)
2025
+					}
2026
+				}
2027
+
2028
+			}
2029
+
2030
+		}
2031
+
2032
+	}
2033
+
2034
+}

+ 82 - 0
models/his_charge_models.go Zobrazit soubor

@@ -0,0 +1,82 @@
1
+package models
2
+
3
+type HisChargePrescriptionProject struct {
4
+	ID         int64      `gorm:"column:id" json:"id" form:"id"`
5
+	ProjectId  int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
+	UserOrgId  int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
+	Status     int64      `gorm:"column:status" json:"status" form:"status"`
8
+	PatientId  int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
+	RecordDate int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
+	Count      int64      `gorm:"column:count" json:"count" form:"count"`
11
+	HisProject HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
12
+	GoodInfo   GoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
13
+}
14
+
15
+func (HisChargePrescriptionProject) TableName() string {
16
+	return "his_prescription_project"
17
+}
18
+
19
+type HisChargeDoctorAdviceInfo struct {
20
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
21
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
22
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
23
+	AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
24
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
25
+}
26
+
27
+func (HisChargeDoctorAdviceInfo) TableName() string {
28
+	return "his_doctor_advice_info"
29
+}
30
+
31
+type HisChargeOrderInfo struct {
32
+	ID                           int64                        `gorm:"column:id" json:"id" form:"id"`
33
+	OrderNumber                  string                       `gorm:"column:order_number" json:"order_number" form:"order_number"`
34
+	AdviceId                     int64                        `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
35
+	DetItemFeeSumamt             float64                      `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
36
+	Cnt                          float64                      `gorm:"column:cnt" json:"cnt" form:"cnt"`
37
+	Pric                         float64                      `gorm:"column:pric" json:"pric" form:"pric"`
38
+	MedChrgitmType               string                       `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
39
+	Status                       int64                        `gorm:"column:status" json:"status" form:"status"`
40
+	ChldMedcFlag                 string                       `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
41
+	ChrgitmLv                    string                       `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
42
+	UserOrgId                    int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
43
+	ProjectId                    int64                        `gorm:"column:project_id" json:"project_id" form:"project_id"`
44
+	Type                         int64                        `gorm:"column:type" json:"type" form:"type"`
45
+	HisChargePrescriptionProject HisChargePrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"project"`
46
+	HisChargeDoctorAdviceInfo    HisChargeDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"advice"`
47
+}
48
+
49
+func (HisChargeOrderInfo) TableName() string {
50
+	return "his_order_info"
51
+}
52
+
53
+type ChargePatient struct {
54
+	ID             int64             `gorm:"column:id" json:"id" form:"id"`
55
+	UserOrgId      int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
56
+	Name           string            `gorm:"column:name" json:"name" form:"name"`
57
+	Lapseto        int64             `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
58
+	Status         int64             `gorm:"column:status" json:"status" form:"status"`
59
+	HisChargeOrder []*HisChargeOrder `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"orders"`
60
+}
61
+
62
+func (ChargePatient) TableName() string {
63
+	return "xt_patients"
64
+}
65
+
66
+type HisChargeOrder struct {
67
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
68
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
69
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
70
+	SettleAccountsDate int64  `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
71
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
72
+	Number             string `gorm:"column:number" json:"number" form:"number"`
73
+	OrderStatus        int64  `gorm:"column:order_status" json:"order_status" form:"order_status"`
74
+	MdtrtId            string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
75
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
76
+
77
+	HisChargeOrderInfo []*HisChargeOrderInfo `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"orders"`
78
+}
79
+
80
+func (HisChargeOrder) TableName() string {
81
+	return "his_order"
82
+}

+ 30 - 0
service/his_charge_service.go Zobrazit soubor

@@ -0,0 +1,30 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+func GetAllPatientChargeDetails(org_id int64, start_time int64, end_time int64) (patients []*models.ChargePatient, err error) {
9
+	err = readDb.Model(&models.ChargePatient{}).Select("id,user_org_id,name,lapseto,status").Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
10
+		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").Where("status = 1  AND settle_accounts_date >= ? AND settle_accounts_date <= ?", start_time, end_time).
11
+			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
12
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Preload("HisChargeDoctorAdviceInfo", "status = 1").Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
13
+					return db.Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1 ")
14
+				}).Where("status = 1 ")
15
+			})
16
+	}).Where("user_org_id = ? AND status = 1", org_id).Find(&patients).Error
17
+	return
18
+}
19
+
20
+//func GetAllPatientChargeDetails(org_id int64,start_time int64, end_time int64)(patients []*models.ChargePatient,err error){
21
+//	err = readDb.Model(&models.ChargePatient{}).Select("id,user_org_id,name,lapseto,status").Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
22
+//		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").Where("status = 1  AND settle_accounts_date >= ? AND settle_accounts_date <= ?", start_time,end_time).
23
+//			Preload("HisChargeOrderInfo",  func(db *gorm.DB) *gorm.DB {
24
+//				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Preload("HisChargeDoctorAdviceInfo","status = 1").Preload("HisChargePrescriptionProject",  func(db *gorm.DB) *gorm.DB {
25
+//					return db.Preload("HisProject","status = 1").Preload("GoodInfo","status = 1").Where("status = 1 ")
26
+//				}).Where("status = 1 ")
27
+//			})
28
+//	}).Where("user_org_id = ? AND status = 1",org_id).Find(&patients).Error
29
+//	return
30
+//}