Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
baylor2016
Creator
Creator

Missing records in FirstSortedValue?

Hi,

I am trying to get all the latest blood pressure value for each patient by using the following code, it returns very small number (480) instead of 2175.

=count(aggr(

FirstSortedValue(

distinct

{<

YearMonth,

FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'},

        FCMVISIT={1},

        BP_SYSTOLIC={"*"}

>}

BP_SYSTOLIC ,-CONTACT_DATE2,PAT_ID)

,PAT_ID)

)

The code below returns 2175

=count(distinct{<

YearMonth,

FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'},

       FCMVISIT={1},

       BP_SYSTOLIC={"*"}

>} PAT_ID

)

Not sure what the problem is.

Thanks

Longmatch

1 Solution

Accepted Solutions
baylor2016
Creator
Creator
Author

My problem was solved by added the set analysis string to the count level. Is there any to make the script shorter, or can I save the definition of set analysis to a variable? Thanks

=count( {<

YearMonth,

FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'},

        FCMVISIT={1},

        BP_SYSTOLIC={"*"}

>}

aggr(

FirstSortedValue(

{<

YearMonth,

FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'},

        FCMVISIT={1},

        BP_SYSTOLIC={"*"}

>}

BP_SYSTOLIC ,-CONTACT_DATE2)

,PAT_ID)

)

View solution in original post

8 Replies
Anil_Babu_Samineni

Try this for latest blood pressure. Just remove DISTINCT and try

=count(aggr(FirstSortedValue({<YearMonth, FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'}, FCMVISIT={1},  BP_SYSTOLIC={"*"}>} BP_SYSTOLIC ,-CONTACT_DATE2,PAT_ID),PAT_ID))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
baylor2016
Creator
Creator
Author

With DISTINCT returns 77, it returns 480 without Distinct. The correct number should be 2175.

sunny_talwar

If you are getting the count you want with one of the two expression, why are you even looking for an alternative? Also, just looking at complex expression don't really help, may be provide a sample to look at the issue

Anil_Babu_Samineni

Not sure, If second expression returns correct one then what is the use of first expression?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
baylor2016
Creator
Creator
Author

I need to get the number of patients who have high blood pressure (>140/90), I used the another one as reference making sure the number returned correct. Thanks. I will prepare a sample for this. Thanks

baylor2016
Creator
Creator
Author

My problem was solved by added the set analysis string to the count level. Is there any to make the script shorter, or can I save the definition of set analysis to a variable? Thanks

=count( {<

YearMonth,

FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'},

        FCMVISIT={1},

        BP_SYSTOLIC={"*"}

>}

aggr(

FirstSortedValue(

{<

YearMonth,

FLAG_HPN={1},

CONTACT_DATE2 = {"$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))"},

PAT_ID = {"=Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) >= 18 and

      Age(Num(V_selectedDate), Only({<CONTACT_DATE2 = {""$(='>=' & Date(V_selectedDate_3YearAgo) & '<=' & Date(V_selectedDate))""}, YearMonth>}BIRTH_DATE)) <= 59"},

       VISITTYPE={'Office Visit'},

        FCMVISIT={1},

        BP_SYSTOLIC={"*"}

>}

BP_SYSTOLIC ,-CONTACT_DATE2)

,PAT_ID)

)

sunny_talwar

You can def. save the set analysis to the variable.... the only problem you might run into is that the expression editor not understanding your syntax because of the use of variable... but it should work seamlessly.

baylor2016
Creator
Creator
Author

Thanks. It works perfectly!