Procedure

TPCEData.Save

Module

uPCE

Last Modified

7/15/2014 3:26:36 PM

Comments

Procedure TPCEData.Save;
modified: 6/17/98
By: Robert Bott
Location: ISL
Purpose: Add Comments to PCE Items.

 pass the changes to the encounter to DATA2PCE,
  Pieces: Subscript^Code^Qualifier^Category^Narrative^Delete 

 into two strings, the second being for the comment.

Visibility

Public

Owner

TPCEData

Declaration

procedure Save;

Calls Hierarchy


TPCEData.Save
 ├TPCEData.IsSecondaryVisit
 ├GetLocSecondaryVisitCode
 ├GetVisitIEN
 ├TPCEDiag.DelimitedStr2
 ├TPCEProviderList.PCEProvider
 │ ├Check
 │ │ └TPCEProviderList.IndexOfProvider
 │ └TPCEProviderList.PrimaryIEN
 │   └TPCEProviderList.GetPrimaryIdx
 ├TPCEDiag.DelimitedStr
 ├TPCEProc.DelimitedStr
 │ └ModifierCode
 │   └ModifierIdx
 │     ├TPCEData.VisitDateTime
 │     │ └TPCEData.IsSecondaryVisit
 │     ├FMToday
 │     │ └FMNow
 │     └MixedCaseModifier
 ├TPCEItem.DelimitedStr2
 ├TPCEImm.DelimitedStr
 ├TPCESkin.DelimitedStr
 ├TPCEPat.DelimitedStr
 ├TPCEHealth.DelimitedStr
 ├TPCEExams.DelimitedStr
 ├SavePCEData
 ├TPCEProviderList.GetProviderData
 ├TPCEProviderList.Delete
 ├TPCEProc.Clear
 │ └TPCEItem.Clear
 │   └TPCEItem.SetComment
 ├TPCEData.StrVisitType
 │ ├GetPCEDataText
 │ │ └GetDiagnosisText
 │ ├TPCEProc.ModText
 │ │ └ModifierName
 │ │   └ModifierIdx...
 │ └TPCEData.StrVisitType
 │   └AddTxt
 ├TChanges.Add
 │ └TChangeItem.Create
 ├TPCEData.StrProcedures
 │ ├GetPCEDataText...
 │ └TPCEProc.ModText...
 ├TPCEData.StrDiagnoses
 │ └GetPCEDataText...
 ├TPCEData.StrImmunizations
 │ └GetPCEDataText...
 ├TPCEData.StrSkinTests
 │ └GetPCEDataText...
 ├TPCEData.StrPatientEds
 │ └GetPCEDataText...
 ├TPCEData.StrHealthFactors
 │ └GetPCEDataText...
 └TPCEData.StrExams
   └GetPCEDataText...

Called-By Hierarchy


                                                         TPCEData.Save
                                                TPCEData.OK2SignNote┤ 
                                                         IsOK2Sign┘ │ 
                                      TfrmDCSumm.mnuActSignClick┤   │ 
                                         TfrmDCSumm.SaveSignItem┤   │ 
                                         TfrmReview.cmdOKClick┘ │   │ 
                                               ReviewChanges┘   │   │ 
                           TfrmFrame.AllowContextChangeAll┤     │   │ 
                                TfrmFrame.FormCloseQuery┤ │     │   │ 
                              TfrmFrame.mnuFileNextClick┤ │     │   │ 
                            TfrmFrame.mnuFileOpenClick┤ │ │     │   │ 
                                TfrmFrame.UMInitiate┤ │ │ │     │   │ 
                       TfrmFrame.mnuFileNextClick...┤ │ │ │     │   │ 
                       TfrmFrame.mnuFileRefreshClick┤ │ │ │     │   │ 
                       TfrmOrders.CheckOrderStatus┤ │ │ │ │     │   │ 
                   TfrmOrders.mnuActChgEvntClick┤ │ │ │ │ │     │   │ 
                      TfrmOrders.mnuActHoldClick┤ │ │ │ │ │     │   │ 
                    TfrmOrders.mnuActUnholdClick┤ │ │ │ │ │     │   │ 
                     TfrmOrders.mnuActRenewClick┤ │ │ │ │ │     │   │ 
                    TfrmOrders.mnuActChangeClick┤ │ │ │ │ │     │   │ 
                      TfrmOrders.mnuActCopyClick┘ │ │ │ │ │     │   │ 
                            TfrmMeds.mnuActDCClick┤ │ │ │ │     │   │ 
                           TfrmMeds.CheckMedStatus┘ │ │ │ │     │   │ 
                        TfrmMeds.mnuActHoldClick┤   │ │ │ │     │   │ 
                       TfrmMeds.mnuActRenewClick┤   │ │ │ │     │   │ 
                      TfrmMeds.mnuActUnholdClick┤   │ │ │ │     │   │ 
                      TfrmMeds.mnuActChangeClick┤   │ │ │ │     │   │ 
                        TfrmMeds.mnuActCopyClick┤   │ │ │ │     │   │ 
                      TfrmMeds.mnuActRefillClick┘   │ │ │ │     │   │ 
                                  TfrmFrame.ViewInfo┘ │ │ │     │   │ 
                               TfrmDCSumm.ViewInfo┤   │ │ │     │   │ 
                             TfrmConsults.ViewInfo┤   │ │ │     │   │ 
                     TfrmFrame.pnlRemindersMouseUp┤   │ │ │     │   │ 
                      TfrmFrame.RemindersChanged┘ │   │ │ │     │   │ 
                          TfrmFrame.FormCreate┘   │   │ │ │     │   │ 
                            TfrmFrame.pnlCIRNClick┤   │ │ │     │   │ 
                      TfrmFrame.pnlVistaWebClick┤ │   │ │ │     │   │ 
                           TfrmFrame.FormKeyDown┘ │   │ │ │     │   │ 
                         TfrmFrame.pnlPatientClick┤   │ │ │     │   │ 
                           TfrmFrame.pnlVisitClick┤   │ │ │     │   │ 
                     TfrmFrame.pnlPrimaryCareClick┤   │ │ │     │   │ 
                       TfrmFrame.pnlRemindersClick┤   │ │ │     │   │ 
                        TfrmFrame.pnlPostingsClick┤   │ │ │     │   │ 
                            TfrmFrame.pnlFlagClick┤   │ │ │     │   │ 
                              TfrmFrame.laMHVClick┤   │ │ │     │   │ 
                             TfrmFrame.laVAA2Click┤   │ │ │     │   │ 
                               TfrmOrders.ViewInfo┤   │ │ │     │   │ 
                                 TfrmMeds.ViewInfo┤   │ │ │     │   │ 
                              TfrmSurgery.ViewInfo┤   │ │ │     │   │ 
                                TfrmNotes.ViewInfo┤   │ │ │     │   │ 
                             TfrmProblems.ViewInfo┘   │ │ │     │   │ 
                     TfrmFrame.mnuFileNotifRemoveClick┤ │ │     │   │ 
                             TfrmFrame.NextButtonClick┘ │ │     │   │ 
                           TfrmFrame.SetUpNextButton┘   │ │     │   │ 
                     TfrmFrame.mnuFileOpenClick...┤     │ │     │   │ 
                              TfrmFrame.FormResize┘     │ │     │   │ 
                            TfrmFrame.ChangeFont┘       │ │     │   │ 
                    TfrmFrame.LoadSizesForUser┤         │ │     │   │ 
               TfrmFrame.LoadUserPreferences┘ │         │ │     │   │ 
                      TfrmFrame.UMInitiate┘   │         │ │     │   │ 
                    TfrmFrame.mnuFontSizeClick┘         │ │     │   │ 
                           TfrmFrame.mnuFileOpenClick...┤ │     │   │ 
                           TfrmFrame.ctxContextorPending┤ │     │   │ 
                          TfrmFrame.StartCCOWContextor┘ │ │     │   │ 
                                TfrmFrame.FormCreate┘   │ │     │   │ 
                         TfrmFrame.ctxContextorCommitted┤ │     │   │ 
                       TfrmFrame.StartCCOWContextor...┘ │ │     │   │ 
                  TfrmFrame.mnuFileResumeContextGetClick┤ │     │   │ 
                  TfrmFrame.mnuFileResumeContextSetClick┘ │     │   │ 
                                  TfrmFrame.FormCloseQuery┤     │   │ 
                              TfrmFrame.mnuFileReviewClick┤     │   │ 
                                           UpdateEncounter┘     │   │ 
                         TfrmFrame.mnuFileEncounterClick┤       │   │ 
                                 TfrmFrame.ViewInfo...┤ │       │   │ 
                    TfrmODMedIV.SetValuesFromResponses┤ │       │   │ 
                             TfrmODMedIV.SetupDialog┤ │ │       │   │ 
                   TfrmODMedIV.cboSolutionMouseClick┘ │ │       │   │ 
                       TfrmODMedIV.cboSolutionExit┘   │ │       │   │ 
                  TfrmODMedIV.cboSolutionMouseClick...┤ │       │   │ 
                     TfrmODMedIV.cboAdditiveMouseClick┤ │       │   │ 
                         TfrmODMedIV.cboAdditiveExit┘ │ │       │   │ 
                                TfrmODAuto.SetupDialog┤ │       │   │ 
                                   ActivateOrderDialog┤ │       │   │ 
                           TfrmRemDlg.btnFinishClick┤ │ │       │   │ 
           TfrmConsults.mnuActNewConsultRequestClick┤ │ │       │   │ 
                   TfrmConsults.cmdNewConsultClick┘ │ │ │       │   │ 
                TfrmConsults.mnuActNewProcedureClick┤ │ │       │   │ 
                      TfrmConsults.cmdNewProcClick┘ │ │ │       │   │ 
                                        ChangeOrders┤ │ │       │   │ 
                      TfrmOrders.mnuActChangeClick┤ │ │ │       │   │ 
                        TfrmMeds.mnuActChangeClick┘ │ │ │       │   │ 
                                     ChangeOrdersEvt┤ │ │       │   │ 
                                          CopyOrders┤ │ │       │   │ 
                        TfrmOrders.mnuActCopyClick┤ │ │ │       │   │ 
                          TfrmMeds.mnuActCopyClick┤ │ │ │       │   │ 
                           TfrmODActive.btnOKClick┘ │ │ │       │   │ 
                                      TransferOrders┤ │ │       │   │ 
                        TfrmOrders.mnuActCopyClick┤ │ │ │       │   │ 
                          TfrmMeds.mnuActCopyClick┤ │ │ │       │   │ 
                           TfrmODActive.btnOKClick┘ │ │ │       │   │ 
                            TfrmOrders.lstWriteClick┤ │ │       │   │ 
               TfrmOrders.PlaceOrderForDefaultDialog┤ │ │       │   │ 
                  TfrmOrders.DisplayDefaultDlgList┤ │ │ │       │   │ 
                       TfrmOrders.ResetOrderPage┘ │ │ │ │       │   │ 
               TfrmOrders.btnDelayedOrderClick┘   │ │ │ │       │   │ 
                                 DisplayEvntDialog┤ │ │ │       │   │ 
                             SetDelayEventForMed┘ │ │ │ │       │   │ 
                      TfrmMeds.mnuActCopyClick┘   │ │ │ │       │   │ 
                                 DisplayEvntDialog┤ │ │ │       │   │ 
                                  SetViewForCopy┘ │ │ │ │       │   │ 
                    TfrmOrders.mnuActCopyClick┘   │ │ │ │       │   │ 
                                 DisplayEvntDialog┘ │ │ │       │   │ 
                                ExecuteChangeEvt┘   │ │ │       │   │ 
                 TfrmOrders.mnuActChgEvntClick┘     │ │ │       │   │ 
                             TfrmMeds.mnuActNewClick┤ │ │       │   │ 
                           TfrmOMNavA.ActivateDialog┤ │ │       │   │ 
                         TfrmOMNavA.grdMenuKeyDown┤ │ │ │       │   │ 
                         TfrmOMNavA.grdMenuMouseUp┘ │ │ │       │   │ 
                                TfrmOMSet.DoNextItem┘ │ │       │   │ 
                              TfrmOMSet.InsertList┤   │ │       │   │ 
                               ActivateOrderList┘ │   │ │       │   │ 
                     TfrmRemDlg.btnFinishClick┤   │   │ │       │   │ 
                             ActivateOrderHTML┤   │   │ │       │   │ 
                    TfrmOrders.lstWriteClick┤ │   │   │ │       │   │ 
    TfrmOrders.PlaceOrderForDefaultDialog...┘ │   │   │ │       │   │ 
                              ActivateOrderSet┤   │   │ │       │   │ 
                   TfrmRemDlg.btnFinishClick┤ │   │   │ │       │   │ 
TfrmConsults.mnuActNewConsultRequestClick...┤ │   │   │ │       │   │ 
     TfrmConsults.mnuActNewProcedureClick...┤ │   │   │ │       │   │ 
                    TfrmOrders.lstWriteClick┤ │   │   │ │       │   │ 
    TfrmOrders.PlaceOrderForDefaultDialog...┤ │   │   │ │       │   │ 
                     TfrmMeds.mnuActNewClick┤ │   │   │ │       │   │ 
                TfrmOMNavA.ActivateDialog...┤ │   │   │ │       │   │ 
                     TfrmOMSet.DoNextItem...┘ │   │   │ │       │   │ 
                       TfrmOMNavA.DoSelectList┘   │   │ │       │   │ 
                     TfrmOMNavA.grdMenuKeyUp┤     │   │ │       │   │ 
                   TfrmOMNavA.grdMenuMouseUp┘     │   │ │       │   │ 
                                        SkipToNext┤   │ │       │   │ 
                         TfrmOMSet.DoNextItem...┘ │   │ │       │   │ 
                            TfrmOMSet.UMDelayEvent┘   │ │       │   │ 
                               TfrmOMSet.InsertList...┤ │       │   │ 
                                TfrmODMeds.SetupDialog┤ │       │   │ 
                             TfrmODMeds.btnSelectClick┤ │       │   │ 
                             TfrmODMeds.UMDelayClick┘ │ │       │   │ 
                                    ExecuteRenewOrders┘ │       │   │ 
                         TfrmOrders.mnuActRenewClick┤   │       │   │ 
                           TfrmMeds.mnuActRenewClick┘   │       │   │ 
                                        EncounterPresent┤       │   │ 
                                      ReadyForNewOrder┤ │       │   │ 
                           TfrmRemDlg.btnFinishClick┤ │ │       │   │ 
        TfrmConsults.mnuActNewConsultRequestClick...┤ │ │       │   │ 
             TfrmConsults.mnuActNewProcedureClick...┤ │ │       │   │ 
                                     ChangeOrders...┤ │ │       │   │ 
                                     ChangeOrdersEvt┤ │ │       │   │ 
                                       CopyOrders...┤ │ │       │   │ 
                                   TransferOrders...┤ │ │       │   │ 
                            TfrmOrders.lstWriteClick┤ │ │       │   │ 
                             TfrmMeds.mnuActNewClick┘ │ │       │   │ 
                                     ReadyForNewOrder1┤ │       │   │ 
            TfrmOrders.PlaceOrderForDefaultDialog...┘ │ │       │   │ 
                              TfrmOrders.mnuActDCClick┤ │       │   │ 
                             TfrmOrders.mnuActRelClick┤ │       │   │ 
                            TfrmOrders.mnuActHoldClick┤ │       │   │ 
                          TfrmOrders.mnuActUnholdClick┤ │       │   │ 
                           TfrmOrders.mnuActRenewClick┤ │       │   │ 
                         TfrmOrders.mnuActReleaseClick┤ │       │   │ 
                         TfrmOrders.mnuActOnChartClick┤ │       │   │ 
                            TfrmOrders.mnuActSignClick┤ │       │   │ 
                                TfrmMeds.mnuActDCClick┤ │       │   │ 
                              TfrmMeds.mnuActHoldClick┤ │       │   │ 
                             TfrmMeds.mnuActRenewClick┤ │       │   │ 
                            TfrmMeds.mnuActUnholdClick┤ │       │   │ 
                              TfrmMeds.mnuActCopyClick┤ │       │   │ 
                            TfrmMeds.mnuActRefillClick┘ │       │   │ 
                                     EncounterPresentEDO┤       │   │ 
                                   ReadyForNewOrder...┤ │       │   │ 
                         TfrmOrders.mnuActChgEvntClick┤ │       │   │ 
                          TfrmOrders.mnuActChangeClick┤ │       │   │ 
                            TfrmOrders.mnuActCopyClick┤ │       │   │ 
                       TfrmOrders.btnDelayedOrderClick┤ │       │   │ 
                            TfrmMeds.mnuActChangeClick┤ │       │   │ 
                              TfrmMeds.mnuActCopyClick┘ │       │   │ 
                                             UpdateVisit┤       │   │ 
                                           EditPCEData┤ │       │   │ 
                             TfrmSurgery.cmdPCEClick┤ │ │       │   │ 
                                 UpdateEncounterInfo┘ │ │       │   │ 
                             TfrmNotes.cmdPCEClick┘   │ │       │   │ 
                        TfrmVitals.btnEnterVitalsClick┘ │       │   │ 
                                             UpdateVisit┤       │   │ 
                                        EncounterPresent┘       │   │ 
                         TfrmProblems.lstProbActsClick┘         │   │ 
                     TfrmProblems.wgProbDataDblClick┤           │   │ 
                           TfrmProblems.lstViewClick┘           │   │ 
                   TfrmProblems.HighlightDuplicate┘             │   │ 
                         TfrmProblems.AddProblem┤               │   │ 
              TfrmProblems.lstProbActsClick...┤ │               │   │ 
                 TfrmProblems.lstProbPickClick┤ │               │   │ 
              TfrmProblems.lstProbPickDblClick┤ │               │   │ 
              TfrmProblems.edProbEntKeyPress┘ │ │               │   │ 
                      TfrmProblems.UMPLLexicon┘ │               │   │ 
                   TfrmdlgProb.bbChangeProbClick┘               │   │ 
                           TfrmConsults.mnuActSignatureSignClick┤   │ 
                                       TfrmConsults.SaveSignItem┤   │ 
                                      TfrmReview.cmdOKClick...┘ │   │ 
                                     TfrmSurgery.mnuActSignClick┤   │ 
                                        TfrmSurgery.SaveSignItem┤   │ 
                                      TfrmReview.cmdOKClick...┘ │   │ 
                                       TfrmNotes.mnuActSignClick┤   │ 
                                          TfrmNotes.SaveSignItem┘   │ 
                                      TfrmReview.cmdOKClick...┘     │ 
                                           TfrmRemDlg.btnFinishClick┤ 
                                         TfrmEncounterFrame.SendData┘ 
                                 TfrmEncounterFrame.FormCloseQuery┘   

Calls

Name Declaration Comments
TChanges.Add procedure Add(ItemType: Integer; const AnID, ItemText, GroupName: string; SignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: String = ''; DCOrder: Boolean = False; Delay: Boolean = False; ProblemAdded: Boolean = False); -
TPCEProc.Clear procedure Clear; override; -
TPCEProviderList.Delete procedure Delete(Index: Integer); override; -
TPCEDiag.DelimitedStr function DelimitedStr: string; override; -
TPCEProc.DelimitedStr function DelimitedStr: string; override; -
TPCEImm.DelimitedStr function DelimitedStr: string; override; -
TPCESkin.DelimitedStr function DelimitedStr: string; override; -
TPCEPat.DelimitedStr function DelimitedStr: string; override; -
TPCEHealth.DelimitedStr function DelimitedStr: string; override; -
TPCEExams.DelimitedStr function DelimitedStr: string; override; -
TPCEDiag.DelimitedStr2 function DelimitedStr2: string; override; -
TPCEItem.DelimitedStr2 function DelimitedStr2: string; virtual; -
GetLocSecondaryVisitCode function GetLocSecondaryVisitCode(Loc: integer): char; -
TPCEProviderList.GetProviderData function GetProviderData(Index: integer): TPCEProviderRec; -
GetVisitIEN function GetVisitIEN(NoteIEN: Integer): string; -
TPCEData.IsSecondaryVisit function IsSecondaryVisit: boolean; -
TPCEProviderList.PCEProvider function PCEProvider: Int64; -
SavePCEData procedure SavePCEData(PCEList: TStringList; ANoteIEN, ALocation: integer); -
TPCEData.StrDiagnoses function StrDiagnoses: string; -
TPCEData.StrExams function StrExams: string; -
TPCEData.StrHealthFactors function StrHealthFactors: string; -
TPCEData.StrImmunizations function StrImmunizations: string; -
TPCEData.StrPatientEds function StrPatientEds: string; -
TPCEData.StrProcedures function StrProcedures: string; -
TPCEData.StrSkinTests function StrSkinTests: string; -
TPCEData.StrVisitType function StrVisitType: string; overload; -

Called-By

Name Declaration Comments
TfrmRemDlg.btnFinishClick procedure btnFinishClick(Sender: TObject); -
TPCEData.OK2SignNote function OK2SignNote: boolean; -
TfrmEncounterFrame.SendData procedure SendData; -


Source

2039  procedure TPCEData.Save;
2040  { pass the changes to the encounter to DATA2PCE,
2041    Pieces: Subscript^Code^Qualifier^Category^Narrative^Delete }
2042  var
2043    i: Integer;
2044    x, AVisitStr, EncName, Temp2: string;
2045    PCEList: TStringList;
2046    FileCat: char;
2047    FileDate: TFMDateTime;
2048    FileNoteIEN: integer;
2049    dstring1,dstring2: pchar; //used to separate former DelimitedStr variable
2050                               // into two strings, the second being for the comment.
2051  
2052  begin
2053    PCEList := TStringList.Create;
2054    UNxtCommSeqNum := 1;                                 
2055    try
2056      with PCEList do
2057      begin
2058        if(IsSecondaryVisit) then
2059        begin
2060          FileCat := GetLocSecondaryVisitCode(FEncLocation);
2061          FileDate := FNoteDateTime;
2062          FileNoteIEN := NoteIEN;
2063          if((NoteIEN > 0) and ((FParent = '') or (FParent = '0'))) then
2064            FParent := GetVisitIEN(NoteIEN);
2065        end
2066        else
2067        begin
2068          FileCat := FEncSvcCat;
2069          FileDate := FEncDateTime;
2070          FileNoteIEN := 0;
2071        end;
2072        AVisitStr :=  IntToStr(FEncLocation) + ';' + FloatToStr(FileDate) + ';' + FileCat;
2073        Add('HDR^' + BOOLCHAR[FEncInpatient] + U + U + AVisitStr);
2074  //      Add('HDR^' + BOOLCHAR[FEncInpatient] + U + BOOLCHAR[FNoteHasCPT] + U + AVisitStr);
2075        // set up list that can be passed via broker to set up array for DATA2PCE
2076        Add('VST^DT^' + FloatToStr(FileDate));  // Encounter Date/Time
2077        Add('VST^PT^' + Patient.DFN);               // Encounter Patient    //*DFN*
2078        if(FEncLocation > 0) then
2079          Add('VST^HL^' + IntToStr(FEncLocation));    // Encounter Location
2080        Add('VST^VC^' + FileCat);                // Encounter Service Category
2081        if(StrToIntDef(FParent,0) > 0) then
2082          Add('VST^PR^' + FParent);                 // Parent for secondary visit
2083        if(FileCat = 'E') and (FHistoricalLocation <> '') then
2084          Add('VST^OL^' + FHistoricalLocation);     // Outside Location
2085        FastAddStrings(FProviders, PCEList);
2086  
2087        if FSCChanged then
2088        begin
2089          if FSCRelated  <> SCC_NA then  Add('VST^SC^'  + IntToStr(FSCRelated));
2090          if FAORelated  <> SCC_NA then  Add('VST^AO^'  + IntToStr(FAORelated));
2091          if FIRRelated  <> SCC_NA then  Add('VST^IR^'  + IntToStr(FIRRelated));
2092          if FECRelated  <> SCC_NA then  Add('VST^EC^'  + IntToStr(FECRelated));
2093          if FMSTRelated <> SCC_NA then  Add('VST^MST^' + IntToStr(FMSTRelated));
2094          if FHNCRelated  <> SCC_NA then Add('VST^HNC^'+ IntToStr(FHNCRelated));
2095          if FCVRelated   <> SCC_NA then Add('VST^CV^' + IntToStr(FCVRelated));
2096          if FSHADRelated <> SCC_NA then Add('VST^SHD^'+ IntToStr(FSHADRelated));
2097        end;
2098       with fDiagnoses  do for i := 0 to Count - 1 do with TPCEDiag(Items[i]) do
2099          if FSend then
2100          begin
2101            Temp2 := DelimitedStr2; // Call first to make sure SaveComment is set.
2102            if(SaveComment) then
2103              dec(UNxtCommSeqNum);
2104            fProvider := FProviders.PCEProvider;
2105            // Provides user with list of dx when signing orders - Billing Aware
2106            PCEList.Add(DelimitedStr);
2107            if(SaveComment) then
2108            begin
2109              inc(UNxtCommSeqNum);
2110              if(Temp2 <> '') then
2111                PCEList.Add(Temp2);
2112            end;
2113        end;
2114        with FProcedures do for i := 0 to Count - 1 do with TPCEProc(Items[i]) do
2115          if FSend then
2116          begin
2117            PCEList.Add(DelimitedStr);
2118            PCEList.Add(DelimitedStr2);
2119          end;
2120        with FImmunizations do for i := 0 to Count - 1 do with TPCEImm(Items[i]) do
2121          if FSend then
2122          begin
2123            PCEList.Add(DelimitedStr);
2124            PCEList.Add(DelimitedStr2);
2125          end;
2126        with FSkinTests do for i := 0 to Count - 1 do with TPCESkin(Items[i]) do
2127          if FSend then
2128          begin
2129            PCEList.Add(DelimitedStr);
2130            PCEList.Add(DelimitedStr2);
2131          end;
2132        with FPatientEds do for i := 0 to Count - 1 do with TPCEPat(Items[i]) do
2133          if FSend then
2134          begin
2135            PCEList.Add(DelimitedStr);
2136            PCEList.Add(DelimitedStr2);
2137          end;
2138        with FHealthFactors do for i := 0 to Count - 1 do with TPCEHealth(Items[i]) do
2139          if FSend then
2140          begin
2141            PCEList.Add(DelimitedStr);
2142            PCEList.Add(DelimitedStr2);
2143          end;
2144        with FExams do for i := 0 to Count - 1 do with TPCEExams(Items[i]) do
2145          if FSend then
2146          begin
2147            PCEList.Add(DelimitedStr);
2148            PCEList.Add(DelimitedStr2);
2149          end;
2150  
2151        with fVisitType  do
2152        begin
2153          if Code = '' then Fsend := false;
2154          if FSend then
2155          begin
2156            PCEList.Add(DelimitedStr);
2157            PCEList.Add(DelimitedStr2);
2158          end;
2159        end;
2160        // call DATA2PCE (in background)
2161        SavePCEData(PCEList, FileNoteIEN, FEncLocation);
2162  
2163        // turn off 'Send' flags and remove items that were deleted
2164        with fDiagnoses  do for i := Count - 1 downto 0 do with TPCEDiag(Items[i]) do
2165        begin
2166          FSend := False;
2167          // for diags, toggle off AddProb flag as well
2168          AddProb := False;
2169          if FDelete then
2170          begin
2171            TPCEDiag(Items[i]).Free;
2172            Delete(i);
2173          end;
2174        end;
2175        with FProcedures do for i := Count - 1 downto 0 do with TPCEProc(Items[i]) do
2176        begin
2177          FSend := False;
2178          if FDelete then
2179          begin
2180            TPCEProc(Items[i]).Free;
2181            Delete(i);
2182          end;
2183        end;
2184        with FImmunizations do for i := Count - 1 downto 0 do with TPCEImm(Items[i]) do
2185        begin
2186          FSend := False;
2187          if FDelete then
2188          begin
2189            TPCEImm(Items[i]).Free;
2190            Delete(i);
2191          end;
2192        end;
2193        with FSkinTests do for i := Count - 1 downto 0 do with TPCESkin(Items[i]) do
2194        begin
2195          FSend := False;
2196          if FDelete then
2197          begin
2198            TPCESkin(Items[i]).Free;
2199            Delete(i);
2200          end;
2201        end;
2202        with FPatientEds do for i := Count - 1 downto 0 do with TPCEPat(Items[i]) do
2203        begin
2204          FSend := False;
2205          if FDelete then
2206          begin
2207            TPCEPat(Items[i]).Free;
2208            Delete(i);
2209          end;
2210        end;
2211        with FHealthFactors do for i := Count - 1 downto 0 do with TPCEHealth(Items[i]) do
2212        begin
2213          FSend := False;
2214          if FDelete then
2215          begin
2216            TPCEHealth(Items[i]).Free;
2217            Delete(i);
2218          end;
2219        end;
2220        with FExams do for i := Count - 1 downto 0 do with TPCEExams(Items[i]) do
2221        begin
2222          FSend := False;
2223          if FDelete then
2224          begin
2225            TPCEExams(Items[i]).Free;
2226            Delete(i);
2227          end;
2228        end;
2229        
2230        for i := FProviders.Count - 1 downto 0 do
2231        begin
2232          if(FProviders.ProviderData[i].Delete) then
2233            FProviders.Delete(i);
2234        end;
2235  
2236        if fVisitType.FDelete then fVisitType.Clear else fVisitType.FSend := False;
2237      end; {with PCEList}
2238      //if (FProcedures.Count > 0) or (FVisitType.Code <> '') then FCPTRequired := False;  
2239  
2240      // update the Changes object
2241      EncName := FormatFMDateTime('mmm dd,yy hh:nn', FileDate);
2242      x := StrVisitType;
2243      if Length(x) > 0 then Changes.Add(CH_PCE, 'V' + AVisitStr, x, EncName, CH_SIGN_NA);
2244      x := StrProcedures;
2245      if Length(x) > 0 then Changes.Add(CH_PCE, 'P' + AVisitStr, x, EncName, CH_SIGN_NA);
2246      x := StrDiagnoses;
2247      if Length(x) > 0 then Changes.Add(CH_PCE, 'D' + AVisitStr, x, EncName, CH_SIGN_NA,
2248         Parent, User.DUZ, '', False, False, ProblemAdded);
2249      x := StrImmunizations;
2250      if Length(x) > 0 then Changes.Add(CH_PCE, 'I' + AVisitStr, x, EncName, CH_SIGN_NA);
2251      x := StrSkinTests;
2252      if Length(x) > 0 then Changes.Add(CH_PCE, 'S' + AVisitStr, x, EncName, CH_SIGN_NA);
2253      x := StrPatientEds;
2254      if Length(x) > 0 then Changes.Add(CH_PCE, 'A' + AVisitStr, x, EncName, CH_SIGN_NA);
2255      x := StrHealthFactors;
2256      if Length(x) > 0 then Changes.Add(CH_PCE, 'H' + AVisitStr, x, EncName, CH_SIGN_NA);
2257      x := StrExams;
2258      if Length(x) > 0 then Changes.Add(CH_PCE, 'E' + AVisitStr, x, EncName, CH_SIGN_NA);
2259  
2260  
2261    finally
2262      PCEList.Free;
2263    end;
2264  end;