5 Replies Latest reply on Jun 28, 2017 11:35 AM by Jim Dehner

    Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

    Dan Gordon

      Hello all

      This may be very simple and I am just over thinking this.  Here is my problem:

      I am trying to create a calculated field that produces a flag, say 'Y' for each patient encounter where there is a qualified Substance for the flag.  Here is a quick chart of the sample data (also attached):


      Problem number 1 (requires a solution):  For each Patient ID, flag all records where there are any Substance that qualify (see Patient IDs 1-4).  Each patient could have up to 20 Substance codes, but only one needs to qualify for the patient to be flagged.  The end goal is to count discreet (COUNTD) the Patient Ids that are flagged. 

      Problem Number 2 – less important, but still trying to accomplish:
      I am trying to calculate another field that gives me the last substance code for each patient ID.  I have tried Max calculations, but I am not returning correct results. 

      Any assistance with this is greatly appreciated!


      Dan Gordon