Editing
Mental health expansion
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====People waiting >5 days for first contact==== <syntaxhighlight lang="sql" line> select ContractID, ContractName, ClientID, EpisodeContractID, NoteDate, ContactTypeID, ContactTypeActive, case when ContactTypeID in ( 2, 3, 4, 13, 15, 19, 20, 24, 27, 34, 35, 37, 38, 39, 41, 63, 68, 69, 72, 75, 76, 77, 83, 85, 86, 88, 89, 90, 93, 94, 97, 98 ) then 1 else 0 end as [Direct contact] into #mhbase from vClientNotesDocuments where ContractID in (13,11) and datepart(mm, NoteDate) = 6 and datepart(yy, NoteDate) = 2025 and UserID <> 1111; select eco.EpisodeContractID, ec.ContractName, ec.EpisodeContractStartDate into #mhnewec from vEpisodeContracts ec join vClientEpisodeContractOrder eco on ec.EpisodeContractID = eco.EpisodeContractID where ec.ContractID in (13,11) and datepart(mm, ec.EpisodeContractStartDate) = 6 and datepart(yy, ec.EpisodeContractStartDate) = 2025 and ec.EpisodeContractID in (select distinct EpisodeContractID from #mhbase); -- Get earliest direct contact for each EpisodeContract with ctea as ( select cnd.EpisodeContractID, min(cnd.NoteDate) as firstnote from vClientNotesDocuments cnd where cnd.EpisodeContractID in (select EpisodeContractID from #mhnewec) and ContactTypeID in ( 2, 3, 4, 13, 15, 19, 20, 24, 27, 34, 35, 37, 38, 39, 41, 63, 68, 69, 72, 75, 76, 77, 83, 85, 86, 88, 89, 90, 93, 94, 97, 98 ) group by cnd.EpisodeContractID ) -- Count people who waited >5 days for first contact, only if there's enough time in the month select ec.ContractName, count(*) as ClientsWaitingOver5Days from #mhnewec ec left join ctea c on ec.EpisodeContractID = c.EpisodeContractID where datediff(day, ec.EpisodeContractStartDate, c.firstnote) > 5 and datediff(day, ec.EpisodeContractStartDate, eomonth(ec.EpisodeContractStartDate)) > 5 group by ec.ContractName ; </syntaxhighlight>
Summary:
Please note that all contributions to Kautepedia are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Kautepedia:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
British English
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
British English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information