1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
| <%
| acc1=request("page")
| if acc1=empty then acc1=clng(1)
| QuantityInt = 20
| acc2=0
| acc3=0
|
| '查看各分公司报表权限
| if isDepartment("070109")=1 then
| OrdClassListSql=""
| If UnitNameID<>"" And UnitNameID<>"0" Then
| sql="select vOrder2 from dictionary where vtitle='UnitName' and vID="&UnitNameID
| rs.open sql,objConn,1,1
| If not rs.Eof Then
| UnitTypeID=rs(0)
| rs.close()
| sql="select vID,vtext,vOrder2 from dictionary where vID in ("&UnitTypeID&") and vtitle='OrderClass' order by vOrder"
| rs.open sql,objConn,1,1
| do while not rs.Eof
| OrderClassID = rs("vOrder2")
| OrdClassListSql = OrdClassListSql&","&OrderClassID
| rs.movenext
| Loop
| OrdClassListSql=Mid(OrdClassListSql,2)
| OrdClassListSql=Replace(OrdClassListSql,",","','")
| End If
| rs.close()
| Else
| sql="select vID,vtext,vOrder2 from dictionary where vType in (1,2) and vtitle='OrderClass' order by vOrder"
| rs.open sql,objConn,1,1
| do while not rs.Eof
| OrderClassID = rs("vOrder2")
| OrdClassListSql = OrdClassListSql&","&OrderClassID
| rs.movenext
| loop
| rs.close()
| OrdClassListSql=Mid(OrdClassListSql,2)
| OrdClassListSql=Replace(OrdClassListSql,",","','")
| End If
| end If
|
| '合作单位
| If CoopUnitID<>"" And CoopUnitID<>"0" Then
| If Left(CoopUnitID,2)="0," Then CoopUnitID=Mid(CoopUnitID,3)
| CoopUnitSql=" And (ServiceOrdUnitID in ("&CoopUnitID&")"
| sql="select HospID,HospIntroducerDate from HospData,IntroducerData where HospIntroducerID=IntroducerID and IntroducerUnitID in ("&CoopUnitID&") GROUP BY HospID,HospIntroducerDate order by HospIntroducerDate"
| rs.open sql,objConn,1,1
| If not rs.Eof Then
| UnitHospDateOld=""
| do while not rs.Eof
| If UnitHospDateOld<>rs(1) then
| UnitHospDate=UnitHospDate&"|"&rs(1)
| UnitHospID=UnitHospID&"|"
| UnitHospDateOld=rs(1)
| End If
| UnitHospID=UnitHospID&","&rs(0)
| rs.movenext
| Loop
| UnitHospDateSP = SPLIT(UnitHospDate,"|")
| UnitHospIDSP = SPLIT(UnitHospID,"|")
| for i=1 to ubound(UnitHospDateSP)
| CoopUnitSql=CoopUnitSql&" or (ServiceOrdPtOutHospID in ("&Mid(UnitHospIDSP(i),2)&") and ServiceOrd_CC_Time>='"&UnitHospDateSP(i)&"')"
| Next
| End If
| rs.close()
| CoopUnitSql=CoopUnitSql&")"
| Else
| CoopUnitSql=""
| End If
|
| If OrderTypeID<>"" And OrderTypeID<>"0" Then
| OrderTypeSql=" And ServiceOrdType in ("&OrderTypeID&")"
| Else
| OrderTypeSql=""
| End If
|
| if searchTXT<>"" Then
| searchSql=" and (HospName like '%"&searchTXT&"%') "
| else
| searchSql=""
| end If
| If InStr(orderby," desc")>1 Then
| orderbydesc=""
| descTXT="↓"
| Else
| orderbydesc=" desc"
| descTXT="↑"
| End If
| 'sql="select * from (select vID,HospName,OutHosp=(select count(ServiceOrdPtOutHosp) from ServiceOrder where ServiceOrdPtOutHosp=vID and ServiceOrd_CC_Time "&SqlOrdDateType&"),InHosp=(select count(ServiceOrdPtInHosp) from ServiceOrder where ServiceOrdPtInHosp=vID and ServiceOrd_CC_Time "&SqlOrdDateType&") from HospData,dictionary where vtitle='HospName' and HospState=1 and vtext=HospName GROUP BY vID,HospName) as aa order by OutHosp+OutHosp desc"
| If orderby="" Then
| orderby="OutHosp|InHosp desc,OutHospPrice|InHospPrice desc"
| descTXT="↓"
| End If
| '时间转算
| sql="select "&Replace(Replace(SqlOrdDateType,"between","")," and ",",")
| rs.open sql,objConn,1,1
| DataSt=rs(0)
| DataBe=rs(1)
| rs.close()
| If OrdClassType="2" Then
| '按服务单统计
| sql="select ServiceOrdID,ServiceOrdClass+convert(nvarchar(10),year(ServiceOrd_CC_Time))+right('0'+convert(nvarchar(10),month(ServiceOrd_CC_Time)),2)+right('0'+convert(nvarchar(10),day(ServiceOrd_CC_Time)),2)+'-'+right('00'+convert(nvarchar(10),ServiceOrdNo),3),DispatchOrdID=(select top 1 DispatchOrdID from DispatchOrd where ServiceOrdIDDt=ServiceOrdID order by DispatchOrdID desc),isnull((select top 1 DispatchOrdClass+convert(nvarchar(10),year(DispatchOrd_NS_Time))+right('0'+convert(nvarchar(10),month(DispatchOrd_NS_Time)),2)+right('0'+convert(nvarchar(10),day(DispatchOrd_NS_Time)),2)+'-'+right('00'+convert(nvarchar(10),DispatchOrdNo),3) from DispatchOrd where ServiceOrdIDDt=ServiceOrdID order by DispatchOrdID desc),'--'),a.vtext,CONVERT(nvarchar(20),ServiceOrd_CC_Time, 111),B.vtext,ServiceOrdTraTxnPrice=ServiceOrdTraTxnPrice+isnull((select sum(StretcherMoney) from DispatchOrd where ServiceOrdIDDt=ServiceOrdID),0),hospA.HopsProvince,hospA.HopsCity,hospA.HopsArea,hospA.HospName,HospDepartmentName=(select top 1 vtext from dictionary where vtitle='HospitalDepartment' and vID=ServiceOrdPtServicesID),ServiceOrdPtServices,hospB.HopsProvince,hospB.HopsCity,hospB.HopsArea,hospB.HospName,ServiceOrdPtName,ServiceOrdTraDistance,PaidType=(SELECT STUFF(( select ' ' + vtext from PaidMoney,dictionary where vtitle='PaidMoneyType' and vType>=1 and vID=PaidMoneyType and PaidMoney<>0 and ServiceOrdIDDt=ServiceOrdID GROUP BY vtext FOR XML PATH('')), 1, 1, '') AS PaidType) from ServiceOrder LEFT JOIN HospData as hospA on hospA.HospID=ServiceOrdPtOutHospID LEFT JOIN HospData as HospB on HospB.HospID=ServiceOrdPtInHospID,dictionary as A,dictionary as B where A.vID=ServiceOrdState and a.vtitle='ServiceOrderState' and B.vID=ServiceOrdType and b.vtitle='ServiceOrderType' and ServiceOrd_CC_Time between '"&DataSt&"' and '"&DataBe&"' "&CoopUnitSql&OrderTypeSql&" and ServiceOrdClass in ('"&OrdClassListSql&"') order by ServiceOrd_CC_Time desc"
| Else
| '按调度单统计
| sql="select ServiceOrdID,ServiceOrdClass+convert(nvarchar(10),year(ServiceOrd_CC_Time))+right('0'+convert(nvarchar(10),month(ServiceOrd_CC_Time)),2)+right('0'+convert(nvarchar(10),day(ServiceOrd_CC_Time)),2)+'-'+right('00'+convert(nvarchar(10),ServiceOrdNo),3),DispatchOrdID,DispatchOrdClass+convert(nvarchar(10),year(DispatchOrd_NS_Time))+right('0'+convert(nvarchar(10),month(DispatchOrd_NS_Time)),2)+right('0'+convert(nvarchar(10),day(DispatchOrd_NS_Time)),2)+'-'+right('00'+convert(nvarchar(10),DispatchOrdNo),3),a.vtext,CONVERT(nvarchar(20),DispatchOrd_NS_Time, 111),B.vtext,ServiceOrdTraTxnPrice+StretcherMoney,hospA.HopsProvince,hospA.HopsCity,hospA.HopsArea,hospA.HospName,HospDepartmentName=(select top 1 vtext from dictionary where vtitle='HospitalDepartment' and vID=ServiceOrdPtServicesID),ServiceOrdPtServices,hospB.HopsProvince,hospB.HopsCity,hospB.HopsArea,hospB.HospName,ServiceOrdPtName,ServiceOrdTraDistance,DispatchOrd_OAName,PaidType=(SELECT STUFF(( select ' ' + vtext from PaidMoney,dictionary where vtitle='PaidMoneyType' and vType>=1 and vID=PaidMoneyType and PaidMoney<>0 and ServiceOrdIDDt=ServiceOrdID GROUP BY vtext FOR XML PATH('')), 1, 1, '') AS PaidType) from DispatchOrd,ServiceOrder LEFT JOIN HospData as hospA on hospA.HospID=ServiceOrdPtOutHospID LEFT JOIN HospData as HospB on HospB.HospID=ServiceOrdPtInHospID,dictionary as A,dictionary as B where ServiceOrdIDDt=ServiceOrdID and DispatchOrdState in (4,5,6,7,8,9) and A.vID=DispatchOrdState and a.vtitle='DispatchOrdState' and B.vID=ServiceOrdType and b.vtitle='ServiceOrderType' and DispatchOrd_NS_Time between '"&DataSt&"' and '"&DataBe&"' "&CoopUnitSql&OrderTypeSql&" and DispatchOrdClass in ('"&OrdClassListSql&"') order by DispatchOrd_NS_Time desc"
| End If
|
| 'If Right(sql,2)=", " Then sql=Left(sql,Len(sql)-2)
| 'Response.Write sql
| rs.open sql,objConn,1,1
| if not rs.eof then
| rs.pagesize=QuantityInt
| rs.absolutepage=acc1
| acc2=rs.pagecount
| acc3=rs.recordcount
| else
| SystemMessageType=2
| SystemMessageTXT="数据库中相关无数据!"
| end If
| If SystemMessageType<>"2" then
| Dim FormArray()
| ArrayX=50
| If acc3<QuantityInt Or (is_CSV=1 And acc3>QuantityInt) Then
| ArrayY=acc3
| Else
| ArrayY=QuantityInt
| End If
| '表头
| FormFields="序号,服务单号,调度单号,状态,日期,类型,价钱,支付方式,距离,出发省份,出发市,出发区,出发医院,转出科室,转出床位,转入省份,转入市,转入区,转入医院,患者姓名"
| 'If OrdClassType<>"2" Then FormFields=FormFields&",医生,护士,司机"
| If OrdClassType<>"2" Then FormFields=FormFields&",出车成员"
| FormFields=split(FormFields,",")
| ArrayX=ubound(FormFields)+1
| REDIM FormArray(ArrayX,ArrayY+1)
| for i=0 to ubound(FormFields)
| FormArray((i+1),0)=FormFields(i)
| next
| Y=1
| do while not rs.Eof and Y<=ArrayY
| '读取数据
|
| Y=Y+1
| '读取数据--End
|
| '写入数组
| FormArray(1,Y)=(Y-1)+((acc1-1)*QuantityInt)
| FormArray(2,Y)="<a href=""ServiceOrder.gds?ServiceOrdID="&rs(0)&"&OrdDateType=4&OrdClassList=0&h_menu1_1=1"" target=""_blank"">"&rs(1)&"</a>"
| If rs(3)="--" then
| FormArray(3,Y)="--"
| Else
| FormArray(3,Y)="<a href=""DispatchOrder.gds?DispatchOrdID="&rs(2)&"&OrdDateType=4&OrdClassList=0&h_menu1_1=1"" target=""_blank"">"&rs(3)&"</a>"
| End If
| FormArray(4,Y)=rs(4)
| FormArray(5,Y)=rs(5)
| FormArray(6,Y)=rs(6)
| FormArray(7,Y)=rs(7)
| FormArray(8,Y)=rs("PaidType")
| FormArray(9,Y)=rs("ServiceOrdTraDistance")
| FormArray(10,Y)=rs(8)
| FormArray(11,Y)=rs(9)
| FormArray(12,Y)=rs(10)
| FormArray(13,Y)=rs(11)
| FormArray(14,Y)=rs(12)
| FormArray(15,Y)="<span style=""float:left; width:50%px;"">"&rs(13)&"</span>"
| FormArray(16,Y)=rs(14)
| FormArray(17,Y)=rs(15)
| FormArray(18,Y)=rs(16)
| FormArray(19,Y)=rs(17)
| FormArray(20,Y)=rs(18)
| If OrdClassType<>"2" Then
| DispatchOrdID=rs(2)
| FormArray(21,Y)=rs("DispatchOrd_OAName")
| 'FormArray(21,Y)=EntourageOANameA(3,DispatchOrdID,"UserNameReport2")&EntourageOANameA(5,DispatchOrdID,"UserNameReport2") '医生
| 'FormArray(22,Y)=EntourageOANameA(4,DispatchOrdID,"UserNameReport2")&EntourageOANameA(6,DispatchOrdID,"UserNameReport2") '护士
| 'FormArray(23,Y)=EntourageOANameA(1,DispatchOrdID,"UserNameReport2")&EntourageOANameA(2,DispatchOrdID,"UserNameReport2") '司机
| End If
|
|
|
| '写入数组--End
|
| rs.movenext
| Loop
| 'REDIM FormArray(ArrayX,Y)
| rs.close()
| End If
| %>
|
|