Index: cprs/branches/foia-cprs/CPRS-Chart/uReminders.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/uReminders.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/uReminders.pas	(revision 460)
@@ -20,4 +20,5 @@
     FNoResolve: boolean;
     FWHReviewIEN: string;  // AGP CHANGE 23.13 Allow for multiple processing of WH Review of Result Reminders
+    FRemWipe: integer;
   protected
     function GetIEN: string; virtual;
@@ -48,4 +49,5 @@
     property DlgData: string read FDlgData; //AGP Change 24.8
     property WHReviewIEN: string read FWHReviewIEN write FWHReviewIEN;  //AGP CHANGE 23.13
+    property RemWipe: integer read FRemWipe write FRemWipe;
   end;
 
@@ -99,5 +101,5 @@
     FMSTPrompt: TRemPrompt;
     FWHPrintDevice, FWHResultChk, FWHResultNot: String;
-    //FRemWHNotPurpose: TStrings;
+    FVitalDateTime: TFMDateTime;  //AGP Changes 26.1
   protected
     procedure Check4ChildrenSharedPrompts;
@@ -156,5 +158,5 @@
     property WHResultChk: String read FWHResultChk write FWHResultChk;
     property WHResultNot: String read FWHResultNot write FWHResultNot;
-    //property RemWHNotPurpose: TStrings read FRemWHNotPurpose write FRemWHNotPurpose;
+    property VitalDateTime: TFMDateTime read FVitalDateTime write FVitalDateTime;
   end;
 
@@ -170,5 +172,5 @@
     FPCERoot: TRemPCERoot;
     FParent: TRemDlgElement;
-    FRec3: string;  
+    FRec3: string;
     FActiveDates: TStringList; //Active dates for finding items. (rectype 3)
 //    FRoot: string;
@@ -219,4 +221,5 @@
     FMonthReq: boolean;
     FPrintNow: String;
+    FMHTestComplete: integer;
   protected
     function RemDataActive(RData: TRemData; EncDt: TFMDateTime):Boolean;
@@ -292,4 +295,5 @@
   NotPurposeValue: string;
   WHRemPrint: string;
+  InitialRemindersLoaded: boolean = FALSE;
 
 const
@@ -298,5 +302,4 @@
   RemPriorityText: array[1..3] of string = ('High','','Low');
   ClinMaintText = 'Clinical Maintenance';
-  InitialRemindersLoaded: boolean = FALSE;
 
   dtUnknown = TRemDataType(-1);
@@ -432,5 +435,5 @@
 
 uses rCore, uCore, rReminders, fRptBox, uConst, fReminderDialog, fNotes, rMisc,
-     fMHTest, rPCE, rTemplates, dShared, uTemplateFields, fIconLegend, fReminderTree;
+     fMHTest, rPCE, rTemplates, dShared, uTemplateFields, fIconLegend, fReminderTree, uInit;
 
 type
@@ -896,5 +899,6 @@
         begin
           Sts := Piece(Data, U, 6);
-          if(Sts = '0') or (Sts = '1') then
+          //if(Sts = '0') or (Sts = '1') then
+          if(Sts = '0') or (Sts = '1') or (Sts = '3') or (Sts = '4') then     //AGP Error change 26.8
           begin
             Result := TRUE;
@@ -1086,5 +1090,6 @@
     begin
       Tmp := Piece(Data, U, 6);
-      if(Tmp = '1') then iidx := 2
+      //if(Tmp = '1') then iidx := 2
+      if (Tmp = '3') or (Tmp = '4') or (Tmp = '1') then iidx :=2     //AGP ERROR CHANGE 26.8
       else if(Tmp = '0') then iidx := 3
       else
@@ -1334,4 +1339,6 @@
          if(NewStatus = '1') then Msg := 'Due'
     else if(NewStatus = '0') then Msg := 'Applicable'
+    else if(NewStatus = '3') then Msg := 'Error'    //AGP Error code change 26.8
+    else if (NewStatus = '4') then Msg := 'CNBD'    //AGP Error code change 26.8
     else                          Msg := 'Not Applicable';
     Msg := RName + ' is ' + Msg + '.';
@@ -1829,5 +1836,6 @@
       Data := RemCode + EvaluatedReminders[i];
       Tmp := Piece(Data,U,6);
-           if(Tmp = '1') then Add2Tree(rfDue, DueCatID)
+      //     if(Tmp = '1') then Add2Tree(rfDue, DueCatID)
+      if(Tmp = '1') or (Tmp = '3') or (Tmp = '4') then Add2Tree(rfDue, DueCatID) //AGP Error code change 26.8
       else if(Tmp = '0') then Add2Tree(rfApplicable, ApplCatID)
       else                    Add2Tree(rfNotApplicable, NotApplCatID);
@@ -2390,4 +2398,8 @@
 begin
   TempSL := GetDlgSL;
+  if Piece(TempSL[0],U,2)='1' then
+    begin
+      Self.RemWipe := 1;
+    end;
   idx := -1;
   repeat
@@ -2919,8 +2931,8 @@
 
 begin
-  Tmp := Piece(FRec1, U, 4);
-  if(Tmp = 'D') then Result := etDisplayOnly
-  else if(Tmp = 'T') then Result := etTaxonomy
-  else Result := etCheckBox;
+      Tmp := Piece(FRec1, U, 4);
+      if(Tmp = 'D') then Result := etDisplayOnly
+      else if(Tmp = 'T') then Result := etTaxonomy
+      else Result := etCheckBox;
 end;
 
@@ -3013,5 +3025,5 @@
         dt := Code2DataType(piece(TempSL[idx], U, r3Type));
         if(dt <> dtUnknown) and ((dt <> dtOrder) or
-          (CharAt(piece(TempSL[idx], U, 11),1) in ['D', 'Q', 'M', 'O'])) and
+          (CharAt(piece(TempSL[idx], U, 11),1) in ['D', 'Q', 'M', 'O', 'A'])) and   //AGP change 26.10 for allergy orders
           ((dt <> dtMentalHealthTest) or MHTestsOK) then
         begin
@@ -3542,5 +3554,5 @@
           DoLbl := Prompt.Required;
           case pt of
-            ptComment, ptQuantity, ptSkinReading:
+            ptComment, ptQuantity:
               begin
                 Ctrl.edt := TEdit.Create(AOwner);
@@ -3578,5 +3590,5 @@
             ptVisitLocation, ptLevelUnderstanding,
             ptSeries, ptReaction, ptExamResults,
-            ptLevelSeverity, ptSkinResults:
+            ptLevelSeverity, ptSkinResults, ptSkinReading:
               begin
                 Ctrl.cbo := TORComboBox.Create(AOwner);
@@ -3585,6 +3597,16 @@
                 Ctrl.cbo.Style := orcsDropDown;
                 Ctrl.cbo.Pieces := '2';
-                Ctrl.cbo.Tag := ComboPromptTags[pt];
-                PCELoadORCombo(Ctrl.cbo, MinX, MaxX);
+                if pt = ptSkinReading then
+                  begin
+                     Ctrl.cbo.Pieces := '1';
+                     Ctrl.cbo.Items.Add('');
+                     for j := 0 to 50 do Ctrl.cbo.Items.Add(inttostr(j));
+                     GetComboBoxMinMax(Ctrl.cbo,MinX, MaxX);
+                  end;
+                if pt <> ptSkinReading then
+                  begin
+                     Ctrl.cbo.Tag := ComboPromptTags[pt];
+                     PCELoadORCombo(Ctrl.cbo, MinX, MaxX);
+                  end;
                 if pt = ptVisitLocation then
                 begin
@@ -4184,5 +4206,5 @@
     end;
   end;
-
+  
 begin
   Result := nil;
@@ -4398,5 +4420,4 @@
 end;
 
-{ TODO -oLori -cNext : TRemDlgElement.AddText }
 procedure TRemDlgElement.AddText(Lst: TStrings);
 var
@@ -4655,13 +4676,25 @@
                 (not Prompt.Forced) then
         begin
-          if (Pt = ptMHTest) and ((Prompt.FValue = '') or (pos('X',Prompt.FValue)>0)) then
+          if (Pt = ptMHTest) and (Prompt.FMHTestComplete = 2) then
             begin
-               if Prompt.FValue = '' then
-                  WordWrap('MH test '+ Piece(Prompt.FData.FRec3,U,8) + ' not done',List,65,6);
-               if pos('X',Prompt.FValue)>0 then
-                  WordWrap('You are missing one or more responses in the MH test '+
-                           Piece(Prompt.FData.FRec3,U,8),List,65,6);
-               WordWrap(' ',List,65,6);
+               if ((Prompt.FValue = '') or (pos('X',Prompt.FValue)>0)) then
+                  begin
+                    if Prompt.FValue = '' then
+                        WordWrap('MH test '+ Piece(Prompt.FData.FRec3,U,8) + ' not done',List,65,6);
+                    if pos('X',Prompt.FValue)>0 then
+                        WordWrap('You are missing one or more responses in the MH test '+
+                               Piece(Prompt.FData.FRec3,U,8),List,65,6);
+                   WordWrap(' ',List,65,6);
+                  end;
             end;
+          if (Pt = ptMHTest) and (Prompt.FMHTestComplete = 0) or (Prompt.FValue = '') then
+                  begin
+                    if Prompt.FValue = '' then
+                        WordWrap('MH test '+ Piece(Prompt.FData.FRec3,U,8) + ' not done',List,65,6);
+                    if pos('X',Prompt.FValue)>0 then
+                        WordWrap('You are missing one or more responses in the MH test '+
+                               Piece(Prompt.FData.FRec3,U,8),List,65,6);
+                   WordWrap(' ',List,65,6);
+                  end;
           if (Pt = ptGAF) and ((Prompt.FValue = '0') or (Prompt.FValue = '')) then
             begin
@@ -4952,5 +4985,6 @@
           unt := Prompt.VitalUnitValue;
           ConvertVital(v, rte, unt);
-          txt := U + VitalCodes[v] + U + rte + U + FloatToStr(RemForm.PCEObj.VisitDateTime);
+          //txt := U + VitalCodes[v] + U + rte + U + FloatToStr(RemForm.PCEObj.VisitDateTime);  AGP Change 26.1 commented out
+          txt := U + VitalCodes[v] + U + rte + U + '0'; //AGP Change 26.1 Use for Vital date/time
           if(not Finishing) then
             txt := Char(ord('A')+ord(v)) + FormatVitalForNote(txt);  // Add vital sort char
@@ -5309,5 +5343,5 @@
       NeedRedraw := FALSE;
       case pt of
-        ptComment, ptQuantity, ptSkinReading:
+        ptComment, ptQuantity:
           TmpValue := (Sender as TEdit).Text;
 
@@ -5480,7 +5514,7 @@
                        end;
         end;
-        
+
         ptExamResults, ptSkinResults, ptLevelSeverity,
-        ptSeries, ptReaction, ptLevelUnderstanding:
+        ptSeries, ptReaction, ptLevelUnderstanding, ptSkinReading: //(AGP Change 26.1)
           TmpValue := (Sender as TORComboBox).ItemID;
         else
@@ -5492,4 +5526,6 @@
                              idx := -1;
                              TmpValue := (Sender as TORComboBox).ItemID;
+                             if FParent.VitalDateTime = 0 then
+                                  FParent.VitalDateTime := FMNow;
                            end;
               else
@@ -5497,5 +5533,12 @@
             end;
             if(idx > 0) then
-              SetPiece(TmpValue, ';', idx, TORExposedControl(Sender).Text);
+              begin
+                 //AGP Change 26.1 change Vital time/date to Now instead of encounter date/time
+                 SetPiece(TmpValue, ';', idx, TORExposedControl(Sender).Text);
+                 if (FParent.VitalDateTime > 0) and (TORExposedControl(Sender).Text = '') then
+                       FParent.VitalDateTime := 0;
+                 if (FParent.VitalDateTime = 0) and (TORExposedControl(Sender).Text <> '') then
+                       FParent.VitalDateTime := FMNow;
+              end;
           end
           else
@@ -5634,6 +5677,11 @@
                     Result := tmp;
 
-      ptSkinReading: if(StrToIntDef(tmp,0) <> 0) then
-                       Result := tmp;
+     (* ptSkinReading: if(StrToIntDef(tmp,0) <> 0) then
+                       Result := tmp;  *)
+
+     ptSkinReading:   // (AGP Change 26.1)
+       begin
+         Result := tmp;
+       end;
 
       ptVisitDate:
@@ -6151,6 +6199,6 @@
         (FCurrentControl as TUpDown).Position := StrToIntDef(GetValue,1);
 
-      ptSkinReading:
-        (FCurrentControl as TUpDown).Position := StrToIntDef(GetValue,0);
+     (* ptSkinReading:
+        (FCurrentControl as TUpDown).Position := StrToIntDef(GetValue,0); *)
 
       ptVisitDate:
@@ -6191,5 +6239,5 @@
 
       ptExamResults, ptSkinResults, ptLevelSeverity,
-      ptSeries, ptReaction, ptLevelUnderstanding:
+      ptSeries, ptReaction, ptLevelUnderstanding, ptSkinReading: //(AGP Change 26.1)
         (FCurrentControl as TORComboBox).SelectByID(GetValue);
 
@@ -6426,8 +6474,9 @@
 var
   TmpSL: TStringList;
-  i: integer;
+  i, TestComp: integer;
   Before, After: string;
 
 begin
+  TestComp := 0;
   if(MHTestAuthorized(FData.Narrative)) then
   begin
@@ -6440,9 +6489,17 @@
       Before := GetValue;
       After := PerformMHTest(Before, FData.Narrative, TmpSL);
-      if(Before <> After) then
+      if uinit.TimedOut then After := '';
+      if pos(U,After)>0 then
+        begin
+          TestComp := StrtoInt(Piece(After,U,2));
+          self.FMHTestComplete := TestComp;
+          After := Piece(After,U,1);
+        end;
+      if(Before <> After) and (not uInit.TimedOut) then
       begin
         if(After = '') or (FParent.ResultDlgID = 0) then
           FMiscText := ''
         else
+        if TestComp > 0 then
         begin
           MentalHealthTestResults(FMiscText, FParent.ResultDlgID, FData.Narrative,
@@ -6464,12 +6521,14 @@
       end;
     finally
-      FParent.FReminder.EndTextChanged(Sender);
-    end;
-    if(FParent.ElemType = etDisplayOnly) and (not assigned(FParent.FParent)) then
-      RemindersInProcess.Notifier.Notify;
-  end
-  else
-    InfoBox('Not Authorized to score the ' + FData.Narrative + ' test.',
-            'Insufficient Authorization', MB_OK + MB_ICONERROR);
+      if not uInit.TimedOut then
+         FParent.FReminder.EndTextChanged(Sender);
+    end;
+    if not uInit.TimedOut then
+         if(FParent.ElemType = etDisplayOnly) and (not assigned(FParent.FParent)) then
+            RemindersInProcess.Notifier.Notify;
+          end
+    else
+                InfoBox('Not Authorized to score the ' + FData.Narrative + ' test.',
+                   'Insufficient Authorization', MB_OK + MB_ICONERROR);
 end;
 
