Index: cprs/branches/GUI-config/MainU.pas
===================================================================
--- cprs/branches/GUI-config/MainU.pas	(revision 493)
+++ cprs/branches/GUI-config/MainU.pas	(revision 542)
@@ -5,5 +5,5 @@
    (c) 8/2008 Kevin Toppenberg
    Programmed by Kevin Toppenberg, Eddie Hagood  
-   
+
    Family Physicians of Greeneville, PC
    1410 Tusculum Blvd, Suite 2600
@@ -36,5 +36,5 @@
   ipSkinManager,
   {$ENDIF}
-  Trpcb,
+  Trpcb, //needed for .ptype types
   ValEdit;
 
@@ -201,5 +201,5 @@
     RPCBrokerParams : TTreeNode;
     Devices : TTreeNode;
-    FLastSelectedRow,FLastSelectedCol : integer;                  
+    FLastSelectedRow,FLastSelectedCol : integer;
     FLoadingGrid: boolean;
     DataForGrid : TStringList;   // doesn't own TGridInfo objects
@@ -208,4 +208,5 @@
     CachedWPField : TStringList;
     FVisibleGridIdx : integer;
+    FINIFileName : string;  // 8-12-09   elh
     procedure ShowDebugClick(Sender: TObject);
     function FindParam(Param : string) : string;
@@ -282,7 +283,8 @@
 
 uses
-  frmSplash, {Trpcb,}  LookupU, SubfilesU, SetSelU, SelDateTimeU, PostU,
+  frmSplash, LookupU, SubfilesU, SetSelU, SelDateTimeU, PostU,
   FMErrorU, AboutU, PleaseWaitU, EditTextU, CreateTemplateU, SkinFormU,
-  BatchAddU, DebugU;
+  BatchAddU, DebugU,
+  inifiles;  //8-12-09  elh
 
 {$R *.dfm}
@@ -343,4 +345,5 @@
     if not ORNet.ConnectToServer(RPC_CONTEXT) then begin
       DebugForm.Memo.Lines.Add('Failed connection.  Closing.');
+      messagedlg('Login Failed.',mtError,[mbOK],0);
       Close;
       Exit;
@@ -1167,5 +1170,5 @@
         Inc(GridRow);
       end;
-    end;  
+    end;
     FLoadingGrid := false;
   end;
@@ -1174,8 +1177,8 @@
   procedure TMainForm.GridSelectCell(Sender: TObject; ACol, ARow: Integer;
                                      var CanSelect: Boolean);
-    (*  
+    (*
     For Field def, here is the legend
     character     meaning
-    
+
     BC 	          The data is Boolean Computed (true or false).
     C 	          The data is Computed.
@@ -1187,15 +1190,15 @@
     Pn 	          The data is a Pointer reference to file "n".
     S 	          The data is from a discrete Set of codes.
-    
-    N 	          The data is Numeric-valued.    
-    
+
+    N 	          The data is Numeric-valued.
+
     Jn 	          To specify a print length of n characters.
     Jn,d 	        To specify printing n characters with decimals.
-    
+
     V 	          The data is a Variable pointer.
     W 	          The data is Word processing.
     WL 	          The Word processing data is normally printed in Line mode (i.e., without word wrap).
       *)
-  var oneEntry,FieldDef : string;                                     
+  var oneEntry,FieldDef : string;
       date,time: string;
       FileNum,FieldNum,SubFileNum : string;
@@ -1242,5 +1245,5 @@
           IEN := RecordORComboBox.ItemID;  //get info from selected record
           if IEN > 0 then IENS := InttoStr(IEN) + ',';
-        end;  
+        end;
         if IENS <> '' then begin
           SubFileForm := TSubFileForm.Create(self);
@@ -1250,5 +1253,5 @@
         end else begin
           MessageDlg('IENS for File="".  Can''t process.',mtInformation,[MBOK],0);
-        end;  
+        end;
       end;  
     end else if Pos('C',FieldDef)>0 then begin  //computed fields.
@@ -1268,5 +1271,5 @@
         Grid.Cells[ACol,ARow] := date;
       end;
-      CanSelect := true;    
+      CanSelect := true;
     end else if Pos('S',FieldDef)>0 then begin  //Set of Codes
       SetSelForm.PrepForm(Piece(oneEntry,'^',7));
@@ -1284,5 +1287,5 @@
         Grid.Cells[ACol,ARow] := FieldLookupForm.ORComboBox.Text;
         CanSelect := true;
-      end;      
+      end;
     end;
     if CanSelect then begin
@@ -1290,9 +1293,9 @@
       FLastSelectedCol := ACol;
     end;
-    GridInfo.ApplyBtn.Enabled := true;    
-    GridInfo.RevertBtn.Enabled := true;    
-  end;
-
-  
+    GridInfo.ApplyBtn.Enabled := true;
+    GridInfo.RevertBtn.Enabled := true;
+  end;
+
+
   function TMainForm.GetLineInfo(Grid : TStringGrid; CurrentUserData : TStringList; ARow: integer) : tFileEntry;
   var fieldNum : string;
@@ -1302,5 +1305,5 @@
   begin
     fieldNum := Grid.Cells[0,ARow];
-    gridRow := FindInStrings(fieldNum, CurrentUserData, fileNum);    
+    gridRow := FindInStrings(fieldNum, CurrentUserData, fileNum);
     if gridRow > -1 then begin
       oneEntry := CurrentUserData.Strings[gridRow];
@@ -1310,5 +1313,5 @@
       Result.IENS := Piece(oneEntry,'^',2);
       Result.oldValue := Piece(oneEntry,'^',4);
-      Result.newValue := Grid.Cells[2,ARow];     
+      Result.newValue := Grid.Cells[2,ARow];
     end else begin
       Result.Field := '';
@@ -1347,7 +1350,7 @@
       break;
     end;
-  end;  
-  
-  
+  end;
+
+
   function TMainForm.IsSubFile(FieldDef: string ; var SubFileNum : string) : boolean;
   //SubFileNum is OUT parameter
@@ -1455,6 +1458,6 @@
     FVisibleGridIdx := GetInfoIndexForGrid(Grid);
   end;
-  
-  
+
+
   procedure TMainForm.CompileChanges(Grid : TStringGrid; CurrentUserData,Changes : TStringList);
   //Output format:
@@ -1464,20 +1467,47 @@
       Entry : tFileEntry;
       oneEntry : string;
-  begin
+      iniFile : TIniFile; // 8-12-09   elh
+      UCaseOnly : boolean;
+  begin
+    FINIFileName := ExtractFilePath(ParamStr(0)) + 'GUI_Config.ini';
+    iniFile := TIniFile.Create(FINIFileName);            //8-12-09  elh
+    UCaseOnly := inifile.ReadBool('Settings','UCaseOnly',true);
+    iniFile.Free;
     for row := 1 to Grid.RowCount-1 do begin
       Entry := GetLineInfo(Grid,CurrentUserData, row);
-      if Entry.oldValue <> Entry.newValue then begin
-        if (Entry.newValue <> CLICK_FOR_SUBS) and
-          (Entry.newValue <> COMPUTED_FIELD) and
-          (Entry.newValue <> CLICK_TO_EDIT) then begin   
-          oneEntry := Entry.FileNum + '^' + Entry.IENS + '^' + Entry.Field + '^' + Entry.FieldName;
-          oneEntry := oneEntry + '^' + Entry.newValue + '^' + Entry.oldValue;
-          Changes.Add(oneEntry);
-        end;  
+      //Reject any value containing a "^"
+      //Do we need an @ here as well?
+      if (AnsiPos('^',Entry.newvalue) > 0){ or (AnsiPos('@',Entry.newvalue) > 0)} then begin
+         messagedlg('Invalid value entered for ' + Entry.Fieldname + #13 + #10
+                     + #13 + #10 + 'Invalid Entry:   ' + Entry.newvalue + #13 + #10 +
+                     'Ignoring Value.',mtError,[mbOK],0);
+      end else begin
+         if Entry.oldValue <> Entry.newValue then begin
+           if (Entry.newValue <> CLICK_FOR_SUBS) and
+              (Entry.newValue <> COMPUTED_FIELD) and
+              (Entry.newValue <> CLICK_TO_EDIT) then begin
+             oneEntry := Entry.FileNum + '^' + Entry.IENS + '^' + Entry.Field + '^' + Entry.FieldName;
+             //Test to see if change is an AV Code (2 or 11) or ES Code (20.4) in User File (200)
+             //If so, make it uppercase.       8/12/09   elh
+             if Entry.FileNum = '200' then begin
+                if ((Entry.Field = '2') and (UCaseOnly = true)) or
+                   ((Entry.Field = '11') and (UCaseOnly = true)) or
+                   ((Entry.Field = '20.4') and (UCaseOnly = true)) then begin
+                   messagedlg('Converting ' + Entry.Fieldname + ' to uppercase for VistA interactivity.' +#13 +#10 +
+                              #13 +#10 +
+                              'Old Value: ' + Entry.newvalue + '  ' + 'New Value: ' + Uppercase(Entry.newvalue),
+                              mtinformation,[mbOK],0);
+                   Entry.newValue := Uppercase(Entry.newValue);
+                end;
+             end;
+             oneEntry := oneEntry + '^' + Entry.newValue + '^' + Entry.oldValue;
+             Changes.Add(oneEntry);
+           end;
+         end;
       end;
     end;
   end;
 
-  
+
   function TMainForm.PostChanges(Grid : TStringGrid) : TModalResult;
   //Results:  mrNone -- no post done (not needed)
@@ -1705,5 +1735,5 @@
     SrchStr := FileNum + '^' + FieldNum + '^' + HelpStyle;
     Idx := CachedHelpIdx.IndexOf(SrchStr);
-    if Idx = -1 then begin    
+    if Idx = -1 then begin
       RPCBrokerV.remoteprocedure := 'TMG CHANNEL';
       RPCBrokerV.param[0].ptype := list;
@@ -1718,10 +1748,13 @@
       end else begin
         RPCBrokerV.Results.Delete(0);
-        if RPCBrokerV.Results.Strings[RPCBrokerV.Results.Count-1]='' then begin
-          RPCBrokerV.Results.Delete(RPCBrokerV.Results.Count-1);
+        if RPCBrokerV.Results.Count > 0 then begin
+          if RPCBrokerV.Results.Strings[RPCBrokerV.Results.Count-1]='' then begin
+            RPCBrokerV.Results.Delete(RPCBrokerV.Results.Count-1);
+          end;
         end;
-        result := RPCBrokerV.Results.Text;        
+        result := RPCBrokerV.Results.Text;
+        if result = '' then result := ' ';
         //Maybe later replace text with "Enter F1 for more help."
-        Result := AnsiReplaceText(Result,'Enter ''??'' for more help.','');        
+        Result := AnsiReplaceText(Result,'Enter ''??'' for more help.','');
         while Result[Length(Result)] in [#10,#13] do begin
           Result := AnsiLeftStr(Result,Length(Result)-1);
@@ -2126,9 +2159,9 @@
         SetPiece(oneEntry,'^',2,IENS);
         Data.Add(oneEntry); 
-      end;    
+      end;
     end;  
   end;
-  
-  
+
+
   procedure TMainForm.ApplicationEventsException(Sender: TObject; E: Exception);
   begin
@@ -2178,4 +2211,6 @@
   end;
 
+
+
 end.
 
