Index: cprs/trunk/CPRS-Chart/Encounter/uPCE.pas
===================================================================
--- cprs/trunk/CPRS-Chart/Encounter/uPCE.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/Encounter/uPCE.pas	(revision 829)
@@ -1,4 +1,4 @@
 unit uPCE;
-
+                                                                       
 interface
 
@@ -220,4 +220,5 @@
     FHNCRelated:   Integer;                        //
     FCVRelated:    Integer;                        //
+    FSHADRelated:   Integer;                        //
     FVisitType:    TPCEProc;                       //
     FProviders:    TPCEProviderList;
@@ -248,4 +249,5 @@
     procedure SetHNCRelated(Value: Integer);
     procedure SetCVRelated(Value: Integer);
+    procedure SetSHADRelated(Value: Integer);
     procedure SetEncUseCurr(Value: Boolean);
     function GetHasData: Boolean;
@@ -286,5 +288,5 @@
     function StrExams: string;
     function StrVisitType(const ASCRelated, AAORelated, AIRRelated, AECRelated,
-                                AMSTRelated, AHNCRelated, ACVRelated: Integer): string; overload;
+                                AMSTRelated, AHNCRelated, ACVRelated, ASHADRelated: Integer): string; overload;
     function StrVisitType: string; overload;
     function StandAlone: boolean;
@@ -311,4 +313,5 @@
     property HNCRelated:   Integer  read FHNCRelated  write SetHNCRelated;
     property CVRelated:    Integer  read FCVRelated  write SetCVRelated;
+    property SHADRelated:   Integer  read FSHADRelated write SetSHADRelated;
     property VisitType:    TPCEProc read FVisitType   write SetVisitType;
     property VisitString:  string   read GetVisitString;
@@ -596,5 +599,5 @@
       begin
         Result := PCESetsOfCodes.Add(Hdr);
-        PCESetsOfCodes.AddStrings(TempSL);
+        FastAddStrings(TempSL, PCESetsOfCodes);
       end;
     finally
@@ -618,5 +621,5 @@
       HistLocations.Insert(0,'0');
     end;
-    List.AddStrings(HistLocations);
+    FastAddStrings(HistLocations, List);
   end
   else
@@ -754,5 +757,5 @@
         begin
           idx := PCESetsOfCodes.Add(Hdr);
-          PCESetsOfCodes.AddStrings(TempSL);
+          FastAddStrings(TempSL, PCESetsOfCodes);
         end;
       finally
@@ -1639,4 +1642,5 @@
   FHNCRelated  := SCC_NA;
   FCVRelated   := SCC_NA;
+  FSHADRelated := SCC_NA;
   FSCChanged   := False;
 end;
@@ -1695,4 +1699,5 @@
   FHNCRelated := SCC_NA;
   FCVRelated  := SCC_NA;
+  FSHADRelated := SCC_NA;
 
   ClearList(FDiagnoses);
@@ -2075,23 +2080,16 @@
       if(FileCat = 'E') and (FHistoricalLocation <> '') then
         Add('VST^OL^' + FHistoricalLocation);     // Outside Location
-
-      //Add('PRV^' + IntToStr(FEncProvider));       // Encounter Provider
-      //Add('PRV^' + IntToStr(UProvider.IEN));      // Encounter Provider
-      {with FProviders do for i := 0 to Count - 1 do with TPCEProvider(Items[i]) do
-        begin
-          PCEList.Add(DelimitedStr);
-        end;}
-      PCEList.AddStrings(FProviders);
-      
+      FastAddStrings(FProviders, PCEList);
+
       if FSCChanged then
       begin
-        if FSCRelated <> SCC_NA then  Add('VST^SC^'  + IntToStr(FSCRelated));
-        if FAORelated <> SCC_NA then  Add('VST^AO^'  + IntToStr(FAORelated));
-        if FIRRelated <> SCC_NA then  Add('VST^IR^'  + IntToStr(FIRRelated));
-        if FECRelated <> SCC_NA then  Add('VST^EC^'  + IntToStr(FECRelated));
-        if FMSTRelated <> SCC_NA then Add('VST^MST^' + IntToStr(FMSTRelated));
-//        if HNCOK and (FHNCRelated <> SCC_NA) then
-        if FHNCRelated <> SCC_NA then Add('VST^HNC^' + IntToStr(FHNCRelated));
-        if FCVRelated <> SCC_NA then Add('VST^CV^' + IntToStr(FCVRelated));                                      
+        if FSCRelated  <> SCC_NA then  Add('VST^SC^'  + IntToStr(FSCRelated));
+        if FAORelated  <> SCC_NA then  Add('VST^AO^'  + IntToStr(FAORelated));
+        if FIRRelated  <> SCC_NA then  Add('VST^IR^'  + IntToStr(FIRRelated));
+        if FECRelated  <> SCC_NA then  Add('VST^EC^'  + IntToStr(FECRelated));
+        if FMSTRelated <> SCC_NA then  Add('VST^MST^' + IntToStr(FMSTRelated));
+        if FHNCRelated  <> SCC_NA then Add('VST^HNC^'+ IntToStr(FHNCRelated));
+        if FCVRelated   <> SCC_NA then Add('VST^CV^' + IntToStr(FCVRelated));
+        if FSHADRelated <> SCC_NA then Add('VST^SHD^'+ IntToStr(FSHADRelated));
       end;
      with FDiagnoses  do for i := 0 to Count - 1 do with TPCEDiag(Items[i]) do
@@ -2266,7 +2264,5 @@
 begin
   Result := -1;
-//  with AList do for i := 0 to Count - 1 do with TPCEItem(Items[i]) do if Match(AnItem) and MatchProvider(AnItem)then
   with AList do for i := 0 to Count - 1 do with TPCEItem(Items[i]) do if Match(AnItem) and MatchProvider(AnItem)then
-//  with AList do for i := 0 to Count - 1 do with TPCEItem(Items[i]) do if Match(AnItem) then
   begin
     Result := i;
@@ -2289,7 +2285,5 @@
     begin
       PostItem := TPCEItem(Objects[j]);
-//      if (PreItem.Match(PostItem) and (PreItem.MatchProvider(PostItem))) then MatchFound := True;
       if (PreItem.Match(PostItem) and (PreItem.MatchProvider(PostItem))) then MatchFound := True;
-//      if (PreItem.Match(PostItem)) then MatchFound := True;
     end;
     if not MatchFound then
@@ -2423,5 +2417,4 @@
       if CurImmunization.Reaction = '' then CurImmunization.Reaction := NoPCEValue;
 
-//      if (SrcImmunization.Provider <> CurImmunization.Provider) or
       if(SrcImmunization.Series <> CurImmunization.Series) or
         (SrcImmunization.Reaction <> CurImmunization.Reaction) or
@@ -2430,5 +2423,4 @@
         (CurImmunization.Comment <> SrcImmunization.Comment)then  
       begin
-//        CurImmunization.Provider        := SrcImmunization.Provider;
         CurImmunization.Series          := SrcImmunization.Series;
         CurImmunization.Reaction        := SrcImmunization.Reaction;
@@ -2465,13 +2457,13 @@
       if CurSkinTest.Results = '' then CurSkinTest.Results := NoPCEValue;
       if SrcSkinTest.Results = '' then SrcSkinTest.Results := NoPCEValue;
-//      if (SrcSkinTest.Provider <> CurSkinTest.Provider) or
+
       if(SrcSkinTest.Results <> CurSkinTest.Results) or
         (SrcSkinTest.Reading <> CurSkinTest.Reading) or
-        (CurSkinTest.Comment <> SrcSkinTest.Comment) then 
-      begin
-//        CurSkinTest.Provider := SrcSkinTest.Provider;
+        (CurSkinTest.Comment <> SrcSkinTest.Comment) then
+      begin
+
         CurSkinTest.Results := SrcSkinTest.Results;
         CurSkinTest.Reading := SrcSkinTest.Reading;
-        CurSkinTest.Comment := SrcSkinTest.Comment;  
+        CurSkinTest.Comment := SrcSkinTest.Comment;
         CurSkinTest.FSend := True;
       end;
@@ -2502,9 +2494,7 @@
       if CurPatientEd.level = '' then CurPatientEd.level := NoPCEValue;
       if SrcPatientEd.level = '' then SrcPatientEd.level := NoPCEValue;
-//      if (SrcPatientEd.Provider <> CurPatientEd.Provider) or
       if(SrcPatientEd.Level <> CurPatientEd.Level) or
         (CurPatientEd.Comment <> SrcPatientEd.Comment) then
       begin
-//        CurPatientEd.Provider := SrcPatientEd.Provider;
         CurPatientEd.Level  := SrcPatientEd.Level;
         CurPatientEd.Comment := SrcPatientEd.Comment;  
@@ -2539,9 +2529,7 @@
       if CurHealthFactor.level = '' then CurHealthFactor.level := NoPCEValue;
       if SrcHealthFactor.level = '' then SrcHealthFactor.level := NoPCEValue;
-//      if (SrcHealthFactor.Provider <> CurHealthFactor.Provider) or
       if(SrcHealthFactor.Level <> CurHealthFactor.Level) or
         (CurHealthFactor.Comment <> SrcHealthFactor.Comment) then  
       begin
-//        CurHealthFactor.Provider := SrcHealthFactor.Provider;
         CurHealthFactor.Level  := SrcHealthFactor.Level;
         CurHealthFactor.Comment := SrcHealthFactor.Comment;  
@@ -2578,9 +2566,7 @@
       if CurExam.Results = '' then CurExam.Results := NoPCEValue;
       if SrcExam.Results = '' then SrcExam.Results := NoPCEValue;
-//      if (SrcExam.Provider <> CurExam.Provider) or
       if(SrcExam.Results <> CurExam.Results) or
         (CurExam.Comment <> SrcExam.Comment) then  
       begin
-//        CurExam.Provider := SrcExam.Provider;
         CurExam.Results  := SrcExam.Results;
         CurExam.Comment := SrcExam.Comment;  
@@ -2683,4 +2669,13 @@
 end;
 
+procedure TPCEData.SetSHADRelated(Value: Integer);
+begin
+  if (Value <> FSHADRelated) then
+  begin
+    FSHADRelated := Value;
+    FSCChanged   := True;
+  end;
+end;
+
 procedure TPCEData.SetEncUseCurr(Value: Boolean);
 begin
@@ -2694,8 +2689,6 @@
     FStandAlone   := Encounter.StandAlone;
     FStandAloneLoaded := TRUE;
-    //FCPTRequired  := Encounter.StandAlone;  
     FEncInpatient := Encounter.Inpatient;
-    //if FEncInpatient then FCPTRequired := False;   
-    //SetDefaultProvider(FProviders, FEncLocation, FNoteIEN, PersonClassDate);
+
   end else
   begin
@@ -2706,10 +2699,8 @@
     FProviders.PrimaryIdx := -1;
     FEncSvcCat    := 'A';
-    //FCPTRequired  := False;    
     FEncInpatient := False;
   end;
   //
   SetRPCEncLocation(FEncLocation);
-//  SetRPCEncDateTime(FEncDateTime);
 end;
 
@@ -2798,5 +2789,5 @@
 
 function TPCEData.StrVisitType(const ASCRelated, AAORelated, AIRRelated,
-  AECRelated, AMSTRelated, AHNCRelated, ACVRelated: Integer): string;
+  AECRelated, AMSTRelated, AHNCRelated, ACVRelated, ASHADRelated: Integer): string;
 { returns as a string the type of encounter (according to CPT) & related contitions treated }
 
@@ -2832,5 +2823,5 @@
     end;
   Result := Trim(Result + StrVisitType(FSCRelated, FAORelated, FIRRelated,
-                                       FECRelated, FMSTRelated, FHNCRelated, FCVRelated));
+                                       FECRelated, FMSTRelated, FHNCRelated, FCVRelated, FSHADRelated));
 end;
 
@@ -2901,4 +2892,5 @@
   Dest.FHNCRelated   := FHNCRelated;
   Dest.FCVRelated    := FCVRelated;
+  Dest.FSHADRelated  := FSHADRelated;
   FVisitType.CopyProc(Dest.VisitType);
   Dest.FProviders.Assign(FProviders);
@@ -2928,5 +2920,4 @@
   if(not FutureEncounter(Self)) then
   begin
-//    if(PromptForWorkload(FNoteIEN, FNoteTitle, FEncSvcCat, StandAlone) or CPTRequiredForNote(FNoteIEN)) then
     if(PromptForWorkload(FNoteIEN, FNoteTitle, FEncSvcCat, StandAlone)) then
     begin
@@ -2959,5 +2950,5 @@
 //        if HNCOK and (EC.HNCAllow and (HNCRelated = SCC_NA)) then NeedSC := TRUE;
         if(EC.HNCAllow and (HNCRelated = SCC_NA)) then NeedSC := TRUE;
-        if(EC.CVAllow and (CVRelated = SCC_NA)) then NeedSC := TRUE;
+        if(EC.CVAllow and (CVRelated = SCC_NA) and (SHADRelated = SCC_NA)) then NeedSC := TRUE;
         if(NeedSC) then
           Include(Result, ndSC);
@@ -3274,4 +3265,5 @@
   if(Result) then Result := (FHNCRelated = SCC_NA);
   if(Result) then Result := (FCVRelated = SCC_NA);
+  if(Result) then Result := (FSHADRelated = SCC_NA);
   if(Result) then Result := (FDiagnoses.Count = 0);
   if(Result) then Result := (FProcedures.Count = 0);
