I need a solution for calculating the waiting list of outpatients in a clinic. I have the referral number which is unique to one patient. A patient will have several contacts over several months and based on the status, the patients waiting list clock is reset. I have mentioned what needs to be done each time a status is encountered. I need a vba script which can update the table I have shown below.
If Status is
711 copy the date value in the previous row of the WaitStartDate column.
712 - copy the date value in the previous row of the WaitStartDate column.
713 Insert the contact date in the same row to the WaitStartDate, come out of the loop, look at the next reference number.
714 - copy the date value in the previous row of the WaitStartDate column.
715 reset the WaitStartDate as the contact date(of the same row).
716 reset the WaitStartDate as the contact date(of the same row)
717 - copy the date value in the previous row of the WaitStartDate column.
If the first one is 711, 712, 714, 717 copy the REFERRAL_DTE to the WaitStartDate
ref.no referral date contact date status WaitStartDate
168927 19/04/2004 12/10/2004 711
168934 20/04/2004 12/05/2004 715
168934 20/04/2004 09/06/2004 715
168934 20/04/2004 29/07/2004 715
168934 20/04/2004 23/09/2004 716
168934 20/04/2004 07/10/2004 713
168934 20/04/2004 09/12/2004 711
168944 20/04/2004 22/06/2004 713
169006 21/04/2004 07/06/2004 713
169006 21/04/2004 16/08/2004 713
169006 21/04/2004 18/10/2004 713
169006 21/04/2004 13/12/2004 717
169006 21/04/2004 20/12/2004 712
169018 16/04/2004 18/05/2004 714
169018 16/04/2004 25/05/2004 713
169018 16/04/2004 01/06/2004 716
169018 16/04/2004 08/06/2004 713
169018 16/04/2004 15/06/2004 713
169018 16/04/2004 22/06/2004 716
169019 21/04/2004 26/05/2004 713
169019 21/04/2004 07/07/2004 713
169019 21/04/2004 04/08/2004 713
169019 21/04/2004 29/09/2004 717
169019 21/04/2004 13/10/2004 715
169026 21/04/2004 28/06/2004 717
169026 21/04/2004 11/10/2004 716
169028 21/04/2004 26/07/2004 715