Calculated field based on Rank of Appointments. (Urgent assistance required)


As depicted in the screenshot, our objective is to introduce a calculated field. If a patient reaches the 4th appointment, we aim to display “Care Plan” in every row—not just adjacent to the 4th row but also in the 1st and 2nd rows. In cases where the patient doesn’t reach the 4th appointment, the desired outcome is to exhibit "No Care Plan.

Hello @Abhishek_24, I think the best approach here would be to utilize the countOver function to count the number of Date or Rank of Visit values for each Patient ID.

Something like this:
Number of Visits = countOver({Date}, [{Patient ID}], PRE_AGG)

Alternatively, you could also use maxOver to get the highest Rank of Visit for each Patient ID rather than counting:
Max Visits = maxOver({Rank of Visit}, [{Patient ID}], PRE_AGG)

Then you can write an ifelse statement to return one of your 2 options using Number of Visits or Max Visits:
Type = ifelse({Number of Visits} >= 4, "Care Plan", "No Care Plan")

That should give you the result you are expecting. I will mark this as the solution, but if you have any follow-up questions, please let me know.

1 Like