Hi Bobby,
A great way to identify what part of the selection formula is failing is by copying all the code in the selection formula > creating a new formula from the field explorer > pasting the code in there > dragging and dropping the formula on the details section > commenting the record selection formula.
The formula returns True or False for each row and you can then try to find out why it fails for some why passes for the others.
I'm guessing this could be due to the parenthesis. Does the following work:
(
{HSP_TRTMT_TEAM.TRTMNT_TM_BEGIN_DT} IN [CurrentDate -4 TO CurrentDate -1] and
{HSP_TRTMT_TEAM.TRTMNT_TM_BEGIN_DT} <= cdatetime(currentdate - 1, time(20,56,00)) and
(
(IsNull({HSP_TRTMT_TEAM.TRTMNT_TM_END_DT}) or {HSP_TRTMT_TEAM.TRTMNT_TM_END_DT} >= cdatetime(currentdate - 1, time(20,56,00))) OR
(
(Not(IsNull({HSP_TRTMT_TEAM.TRTMNT_TM_END_DT})) AND {HSP_TRTMT_TEAM.TRTMNT_TM_END_DT} >= cdatetime(currentdate - 1, time(20,56,00))) OR
(Not(IsNull({PAT_ENC_HSP.HOSP_DISCH_TIME})) AND {PAT_ENC_HSP.HOSP_DISCH_TIME} >= cdatetime(currentdate - 1, time(20,56,00)))
)
)
)
and
{HSP_ACCOUNT.LOC_ID} = 410 and
{HSP_TRTMT_TEAM.PROV_ID} <> '411467' and
({ZC_TRTMT_TEAM_REL.NAME} = "Hospitalist" or
{HSP_TRTMT_TEAM.PROV_ID} = '11095')
-Abhilash