[459] | 1 | unit rPCE;
|
---|
| 2 |
|
---|
| 3 | {$OPTIMIZATION OFF} // REMOVE AFTER UNIT IS DEBUGGED
|
---|
| 4 |
|
---|
| 5 | interface
|
---|
| 6 |
|
---|
| 7 | uses SysUtils, Classes, ORNet, ORFn, uPCE, UBACore, ORClasses;
|
---|
| 8 |
|
---|
| 9 | const
|
---|
| 10 | LX_ICD = 12;
|
---|
| 11 | LX_CPT = 13;
|
---|
| 12 |
|
---|
| 13 | LX_Threshold = 15;
|
---|
| 14 |
|
---|
| 15 | PCE_IMM = 20;
|
---|
| 16 | PCE_SK = 21;
|
---|
| 17 | PCE_PED = 22;
|
---|
| 18 | PCE_HF = 23;
|
---|
| 19 | PCE_XAM = 24;
|
---|
| 20 | PCE_TRT = 25;
|
---|
| 21 |
|
---|
| 22 | SCC_YES = 1;
|
---|
| 23 | SCC_NO = 0;
|
---|
| 24 | SCC_NA = -1;
|
---|
| 25 |
|
---|
| 26 | var
|
---|
| 27 | uEncLocation: integer;
|
---|
| 28 | // uEncDateTime: TFMDateTime;
|
---|
| 29 |
|
---|
| 30 | type
|
---|
| 31 | TSCConditions = record
|
---|
| 32 | SCAllow: Boolean; // prompt for service connected
|
---|
| 33 | SCDflt: Boolean; // default if prompting service connected
|
---|
| 34 | AOAllow: Boolean; // prompt for agent orange exposure
|
---|
| 35 | AODflt: Boolean; // default if prompting agent orange exposure
|
---|
| 36 | IRAllow: Boolean; // prompt for ionizing radiation exposure
|
---|
| 37 | IRDflt: Boolean; // default if prompting ionizing radiation
|
---|
| 38 | ECAllow: Boolean; // prompt for environmental conditions
|
---|
| 39 | ECDflt: Boolean; // default if prompting environmental cond.
|
---|
| 40 | MSTAllow: Boolean; // prompt for military sexual trauma
|
---|
| 41 | MSTDflt: Boolean; // default if prompting military sexual trauma
|
---|
| 42 | HNCAllow: Boolean; // prompt for Head or Neck Cancer
|
---|
| 43 | HNCDflt: Boolean; // default if prompting Head or Neck Cancer
|
---|
| 44 | CVAllow: Boolean; // prompt for Combat Veteran Related
|
---|
| 45 | CVDflt: Boolean; // default if prompting Comabt Veteran
|
---|
| 46 | end;
|
---|
| 47 |
|
---|
| 48 | TPCEListCodesProc = procedure(Dest: TStrings; SectionIndex: Integer);
|
---|
| 49 |
|
---|
| 50 | TAskPCE = (apPrimaryNeeded, apPrimaryOutpatient, apPrimaryAlways,
|
---|
| 51 | apNeeded, apOutpatient, apAlways, apNever, apDisable);
|
---|
| 52 |
|
---|
| 53 | function GetVisitCat(InitialCat: char; Location: integer; Inpatient: boolean): char;
|
---|
| 54 |
|
---|
| 55 | {assign and read values from fPCEData}
|
---|
| 56 | //function SetRPCEncouterInfo(PCEData: TPCEData): boolean;
|
---|
| 57 | function SetRPCEncLocation(Loc: Integer): boolean;
|
---|
| 58 | //function SetRPCEncDateTime(DT: TFMDateTime): boolean;
|
---|
| 59 |
|
---|
| 60 | function PCERPCEncLocation: integer;
|
---|
| 61 | //function PCERPCEncDateTime: TFMDateTime;
|
---|
| 62 | function GetLocSecondaryVisitCode(Loc: integer): char;
|
---|
| 63 |
|
---|
| 64 | {check for active person class on provider}
|
---|
| 65 | function CheckActivePerson(provider:string;DateTime:TFMDateTime): boolean;
|
---|
| 66 | function ForcePCEEntry(Loc: integer): boolean;
|
---|
| 67 |
|
---|
| 68 | {"Other" form PCE calls}
|
---|
| 69 | procedure LoadcboOther(Dest: TStrings; Location, fOtherApp: Integer);
|
---|
| 70 |
|
---|
| 71 | { Lexicon Lookup Calls }
|
---|
| 72 | function LexiconToCode(IEN, LexApp: Integer; ADate: TFMDateTime = 0): string;
|
---|
| 73 | procedure ListLexicon(Dest: TStrings; const x: string; LexApp: Integer; ADate: TFMDateTime = 0);
|
---|
| 74 | function IsActiveICDCode(ACode: string; ADate: TFMDateTime = 0): boolean;
|
---|
| 75 | function IsActiveCPTCode(ACode: string; ADate: TFMDateTime = 0): boolean;
|
---|
| 76 | function IsActiveCode(ACode: string; LexApp: integer; ADate: TFMDateTime = 0): boolean;
|
---|
| 77 |
|
---|
| 78 | { Encounter Form Elements }
|
---|
| 79 | procedure DeletePCE(const AVisitStr: string);
|
---|
| 80 | function EligbleConditions: TSCConditions;
|
---|
| 81 |
|
---|
| 82 | procedure ListVisitTypeSections(Dest: TStrings);
|
---|
| 83 | procedure ListVisitTypeCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 84 | procedure ListVisitTypeByLoc(Dest: TStrings; Location: Integer; ADateTime: TFMDateTime = 0);
|
---|
| 85 | function AutoSelectVisit(Location: integer): boolean;
|
---|
| 86 | function UpdateVisitTypeModifierList(Dest: TStrings; Index: integer): string;
|
---|
| 87 |
|
---|
| 88 | procedure ListDiagnosisSections(Dest: TStrings);
|
---|
| 89 | procedure ListDiagnosisCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 90 |
|
---|
| 91 | procedure ListExamsSections(Dest: TStrings);
|
---|
| 92 | procedure ListExamsCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 93 |
|
---|
| 94 | procedure ListHealthSections(Dest: TStrings);
|
---|
| 95 | procedure ListHealthCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 96 |
|
---|
| 97 | procedure ListImmunizSections(Dest: TStrings);
|
---|
| 98 | procedure ListImmunizCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 99 |
|
---|
| 100 | procedure ListPatientSections(Dest: TStrings);
|
---|
| 101 | procedure ListPatientCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 102 |
|
---|
| 103 | procedure ListProcedureSections(Dest: TStrings);
|
---|
| 104 | procedure ListProcedureCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 105 | function ModifierList(CPTCode: string): string;
|
---|
| 106 | procedure ListCPTModifiers(Dest: TStrings; CPTCodes, NeededModifiers: string);
|
---|
| 107 | function ModifierName(ModIEN: string): string;
|
---|
| 108 | function ModifierCode(ModIEN: string): string;
|
---|
| 109 | function UpdateModifierList(Dest: TStrings; Index: integer): string;
|
---|
| 110 |
|
---|
| 111 | procedure ListSkinSections(Dest: TStrings);
|
---|
| 112 | procedure ListSkinCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 113 |
|
---|
| 114 | procedure ListSCDisabilities(Dest: TStrings);
|
---|
| 115 | procedure LoadPCEDataForNote(Dest: TStrings; ANoteIEN: Integer; VStr: string);
|
---|
| 116 | function GetVisitIEN(NoteIEN: Integer): string;
|
---|
| 117 | procedure SavePCEData(PCEList: TStringList; ANoteIEN, ALocation: integer);
|
---|
| 118 |
|
---|
| 119 | function DataHasCPTCodes(AList: TStrings): boolean;
|
---|
| 120 | function GetAskPCE(Loc: integer): TAskPCE;
|
---|
| 121 | function HasVisit(const ANoteIEN, ALocation: integer; const AVisitDate: TFMDateTime): Integer;
|
---|
| 122 |
|
---|
| 123 | procedure LoadImmSeriesItems(Dest: TStrings);
|
---|
| 124 | procedure LoadImmReactionItems(Dest: TStrings);
|
---|
| 125 | procedure LoadSkResultsItems(Dest: TStrings);
|
---|
| 126 | procedure LoadPEDLevelItems(Dest: TStrings);
|
---|
| 127 | procedure LoadHFLevelItems(Dest: TStrings);
|
---|
| 128 | procedure LoadXAMResultsItems(Dest: TStrings);
|
---|
| 129 | procedure LoadHistLocations(Dest: TStrings);
|
---|
| 130 | procedure AddProbsToDiagnoses;
|
---|
| 131 |
|
---|
| 132 | //GAF
|
---|
| 133 | function GAFOK: boolean;
|
---|
| 134 | function MHClinic(const Location: integer): boolean;
|
---|
| 135 | procedure RecentGAFScores(const Limit: integer);
|
---|
| 136 | function SaveGAFScore(const Score: integer; GAFDate: TFMDateTime; Staff: Int64): boolean;
|
---|
| 137 | function GAFURL: string;
|
---|
| 138 | function MHTestsOK: boolean;
|
---|
| 139 | function MHTestAuthorized(Test: string): boolean;
|
---|
| 140 |
|
---|
| 141 | function AnytimeEncounters: boolean;
|
---|
| 142 | function AutoCheckout(Loc: integer): boolean;
|
---|
| 143 |
|
---|
| 144 | { Encounter }
|
---|
| 145 | //function RequireExposures(ANote: Integer): Boolean; {RAB}
|
---|
| 146 | function RequireExposures(ANote, ATitle: Integer): Boolean;
|
---|
| 147 | function PromptForWorkload(ANote, ATitle: Integer; VisitCat: Char; StandAlone: boolean): Boolean;
|
---|
| 148 | function DefaultProvider(ALocation: integer; AUser: Int64; ADate: TFMDateTime;
|
---|
| 149 | ANoteIEN: integer): string;
|
---|
| 150 | function IsUserAProvider(AUser: Int64; ADate: TFMDateTime): boolean;
|
---|
| 151 | function IsCancelOrNoShow(ANote: integer): boolean;
|
---|
[460] | 152 | function IsNonCountClinic(ALocation: integer): boolean;
|
---|
[459] | 153 |
|
---|
| 154 | // HNC Flag
|
---|
| 155 | //function HNCOK: boolean;
|
---|
| 156 |
|
---|
| 157 | implementation
|
---|
| 158 |
|
---|
| 159 | uses TRPCB, rCore, uCore, uConst, fEncounterFrame, UBAGlobals, UBAConst;
|
---|
| 160 |
|
---|
| 161 | var
|
---|
| 162 | uLastLocation: Integer;
|
---|
| 163 | uLastDFN: String;
|
---|
| 164 | uVTypeLastLoc: Integer;
|
---|
| 165 | uVTypeLastDate: double = 0;
|
---|
| 166 | uDiagnoses: TStringList;
|
---|
| 167 | uExams: TStringList;
|
---|
| 168 | uHealthFactors: TStringList;
|
---|
| 169 | uImmunizations: TStringList;
|
---|
| 170 | uPatientEds: TStringList;
|
---|
| 171 | uProcedures: TStringList;
|
---|
| 172 | uSkinTests: TStringList;
|
---|
| 173 | uVisitTypes: TStringList;
|
---|
| 174 | uVTypeForLoc: TStringList;
|
---|
| 175 | uProblems: TStringList;
|
---|
| 176 | uModifiers: TORStringList = nil;
|
---|
| 177 | uGAFOK: boolean;
|
---|
| 178 | uGAFOKCalled: boolean = FALSE;
|
---|
| 179 | uLastForceLoc: integer = -1;
|
---|
| 180 | uLastForce: boolean;
|
---|
| 181 | uHasCPT: TStringList = nil;
|
---|
| 182 | uGAFURL: string;
|
---|
| 183 | uGAFURLChecked: boolean = FALSE;
|
---|
| 184 | uMHOK: boolean;
|
---|
| 185 | uMHOKChecked: boolean = FALSE;
|
---|
| 186 | uVCInitialCat: char = #0;
|
---|
| 187 | uVCLocation: integer = -2;
|
---|
| 188 | uVCInpatient: boolean = FALSE;
|
---|
| 189 | uVCResult: char;
|
---|
| 190 | uAPUser: Int64 = -1;
|
---|
| 191 | uAPLoc: integer = -2;
|
---|
| 192 | uAPAsk: TAskPCE;
|
---|
| 193 | uAnytimeEnc: integer = -1;
|
---|
| 194 | UAutoSelLoc: integer = -1;
|
---|
| 195 | UAutoSelVal: boolean;
|
---|
| 196 | uLastChkOut: boolean;
|
---|
| 197 | uLastChkOutLoc: integer = -2;
|
---|
| 198 | uLastIsClinicLoc: integer = 0;
|
---|
| 199 | uLastIsClinic: boolean = FALSE;
|
---|
| 200 | // uHNCOK: integer = -1;
|
---|
| 201 |
|
---|
| 202 | function GetVisitCat(InitialCat: char; Location: integer; Inpatient: boolean): char;
|
---|
| 203 | var
|
---|
| 204 | tmp: string;
|
---|
| 205 |
|
---|
| 206 | begin
|
---|
| 207 | if(InitialCat <> uVCInitialCat) or (Location <> uVCLocation) or
|
---|
| 208 | (Inpatient <> uVCInpatient) then
|
---|
| 209 | begin
|
---|
| 210 | uVCInitialCat := InitialCat;
|
---|
| 211 | uVCLocation := Location;
|
---|
| 212 | uVCInpatient := Inpatient;
|
---|
| 213 | tmp := sCallV('ORWPCE GETSVC', [InitialCat, Location, BOOLCHAR[Inpatient]]);
|
---|
| 214 | if(tmp <> '') then
|
---|
| 215 | uVCResult := tmp[1]
|
---|
| 216 | else
|
---|
| 217 | uVCResult := InitialCat;
|
---|
| 218 | end;
|
---|
| 219 | Result := uVCResult
|
---|
| 220 | end;
|
---|
| 221 |
|
---|
| 222 | { Lexicon Lookup Calls }
|
---|
| 223 |
|
---|
| 224 | function LexiconToCode(IEN, LexApp: Integer; ADate: TFMDateTime = 0): string;
|
---|
| 225 | var
|
---|
| 226 | CodeSys: string;
|
---|
| 227 | begin
|
---|
| 228 | case LexApp of
|
---|
| 229 | LX_ICD: CodeSys := 'ICD';
|
---|
| 230 | LX_CPT: CodeSys := 'CHP';
|
---|
| 231 | end;
|
---|
| 232 | Result := sCallV('ORWPCE LEXCODE', [IEN, CodeSys, ADate]);
|
---|
| 233 | end;
|
---|
| 234 |
|
---|
| 235 | procedure ListLexicon(Dest: TStrings; const x: string; LexApp: Integer; ADate: TFMDateTime = 0);
|
---|
| 236 | var
|
---|
| 237 | CodeSys: string;
|
---|
| 238 | begin
|
---|
| 239 | case LexApp of
|
---|
| 240 | LX_ICD: CodeSys := 'ICD';
|
---|
| 241 | LX_CPT: CodeSys := 'CHP';
|
---|
| 242 | end;
|
---|
| 243 | CallV('ORWPCE LEX', [x, CodeSys, ADate]);
|
---|
| 244 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 245 | end;
|
---|
| 246 |
|
---|
| 247 | function IsActiveICDCode(ACode: string; ADate: TFMDateTime = 0): boolean;
|
---|
| 248 | begin
|
---|
| 249 | Result := IsActiveCode(ACode, LX_ICD, ADate);
|
---|
| 250 | end;
|
---|
| 251 |
|
---|
| 252 | function IsActiveCPTCode(ACode: string; ADate: TFMDateTime = 0): boolean;
|
---|
| 253 | begin
|
---|
| 254 | Result := IsActiveCode(ACode, LX_CPT, ADate);
|
---|
| 255 | end;
|
---|
| 256 |
|
---|
| 257 | function IsActiveCode(ACode: string; LexApp: integer; ADate: TFMDateTime = 0): boolean;
|
---|
| 258 | var
|
---|
| 259 | CodeSys: string;
|
---|
| 260 | begin
|
---|
| 261 | case LexApp of
|
---|
| 262 | LX_ICD: CodeSys := 'ICD';
|
---|
| 263 | LX_CPT: CodeSys := 'CHP';
|
---|
| 264 | end;
|
---|
| 265 | Result := (sCallV('ORWPCE ACTIVE CODE',[ACode, CodeSys, ADate]) = '1');
|
---|
| 266 | end;
|
---|
| 267 |
|
---|
| 268 | { Encounter Form Elements ------------------------------------------------------------------ }
|
---|
| 269 |
|
---|
| 270 | procedure DeletePCE(const AVisitStr: string);
|
---|
| 271 | begin
|
---|
| 272 | sCallV('ORWPCE DELETE', [AVisitStr, Patient.DFN]);
|
---|
| 273 | end;
|
---|
| 274 |
|
---|
| 275 | procedure LoadEncounterForm;
|
---|
| 276 | { load the major coding lists that are used by the encounter form for a given location }
|
---|
| 277 | var
|
---|
| 278 | i: integer;
|
---|
| 279 | uTempList: TStringList;
|
---|
| 280 | EncDt: TFMDateTime;
|
---|
| 281 |
|
---|
| 282 | begin
|
---|
| 283 | uLastLocation := uEncLocation;
|
---|
| 284 | EncDt := Trunc(uEncPCEData.VisitDateTime);
|
---|
| 285 |
|
---|
| 286 | //add problems to the top of diagnoses.
|
---|
| 287 | uTempList := TstringList.Create;
|
---|
| 288 |
|
---|
| 289 |
|
---|
| 290 | if UBAGlobals.BILLING_AWARE then //BAPHII 1.3.10
|
---|
| 291 | begin
|
---|
| 292 | UBACore.BADxList := TStringList.Create;
|
---|
| 293 | end;
|
---|
| 294 |
|
---|
| 295 | try
|
---|
| 296 | uDiagnoses.clear;
|
---|
| 297 |
|
---|
| 298 | if BILLING_AWARE then
|
---|
| 299 | begin
|
---|
| 300 | UBACore.BADxList.Clear; //BAPHII 1.3.10
|
---|
| 301 | end;
|
---|
| 302 |
|
---|
| 303 | tCallV(uTempList, 'ORWPCE DIAG', [uEncLocation, EncDt]); //BAPHII 1.3.10
|
---|
| 304 | uDiagnoses.add(utemplist.strings[0]); //BAPHII 1.3.10
|
---|
| 305 | AddProbsToDiagnoses; //BAPHII 1.3.10
|
---|
| 306 | // BA 25 AddProviderPatientDaysDx(uDxLst, IntToStr(Encounter.Provider), Patient.DFN);
|
---|
| 307 | for i := 1 to (uTempList.Count-1) do //BAPHII 1.3.10
|
---|
| 308 | uDiagnoses.add(uTemplist.strings[i]); //BAPHII 1.3.10
|
---|
| 309 |
|
---|
| 310 | finally
|
---|
| 311 | uTempList.free;
|
---|
| 312 | end;
|
---|
| 313 |
|
---|
| 314 | tCallV(uVisitTypes, 'ORWPCE VISIT', [uEncLocation, EncDt]);
|
---|
| 315 | tCallV(uProcedures, 'ORWPCE PROC', [uEncLocation, EncDt]);
|
---|
| 316 | tCallV(uImmunizations, 'ORWPCE IMM', [uEncLocation]);
|
---|
| 317 | tCallV(uSkinTests, 'ORWPCE SK', [uEncLocation]);
|
---|
| 318 | tCallV(uPatientEds, 'ORWPCE PED', [uEncLocation]);
|
---|
| 319 | tCallV(uHealthFactors, 'ORWPCE HF', [uEncLocation]);
|
---|
| 320 | tCallV(uExams, 'ORWPCE XAM', [uEncLocation]);
|
---|
| 321 |
|
---|
| 322 | if uVisitTypes.Count > 0 then uVisitTypes.Delete(0); // discard counts
|
---|
| 323 | if uDiagnoses.Count > 0 then uDiagnoses.Delete(0);
|
---|
| 324 | if uProcedures.Count > 0 then uProcedures.Delete(0);
|
---|
| 325 | if uImmunizations.Count > 0 then uImmunizations.Delete(0);
|
---|
| 326 | if uSkinTests.Count > 0 then uSkinTests.Delete(0);
|
---|
| 327 | if uPatientEds.Count > 0 then uPatientEds.Delete(0);
|
---|
| 328 | if uHealthFactors.Count > 0 then uHealthFactors.Delete(0);
|
---|
| 329 | if uExams.Count > 0 then uExams.Delete(0);
|
---|
| 330 |
|
---|
| 331 | if (uVisitTypes.Count > 0) and (CharAt(uVisitTypes[0], 1) <> U) then uVisitTypes.Insert(0, U);
|
---|
| 332 | if (uDiagnoses.Count > 0) and (CharAt(uDiagnoses[0], 1) <> U) then uDiagnoses.Insert(0, U);
|
---|
| 333 | if (uProcedures.Count > 0) and (CharAt(uProcedures[0], 1) <> U) then uProcedures.Insert(0, U);
|
---|
| 334 | if (uImmunizations.Count > 0) and (CharAt(uImmunizations[0], 1) <> U) then uImmunizations.Insert(0, U);
|
---|
| 335 | if (uSkinTests.Count > 0) and (CharAt(uSkinTests[0], 1) <> U) then uSkinTests.Insert(0, U);
|
---|
| 336 | if (uPatientEds.Count > 0) and (CharAt(uPatientEds[0], 1) <> U) then uPatientEds.Insert(0, U);
|
---|
| 337 | if (uHealthFactors.Count > 0) and (CharAt(uHealthFactors[0], 1) <> U) then uHealthFactors.Insert(0, U);
|
---|
| 338 | if (uExams.Count > 0) and (CharAt(uExams[0], 1) <> U) then uExams.Insert(0, U);
|
---|
| 339 |
|
---|
| 340 | end;
|
---|
| 341 |
|
---|
| 342 | {Visit Types-------------------------------------------------------------------}
|
---|
| 343 | procedure ListVisitTypeSections(Dest: TStrings);
|
---|
| 344 | { return section names in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 345 | var
|
---|
| 346 | i: Integer;
|
---|
| 347 | x: string;
|
---|
| 348 | begin
|
---|
| 349 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 350 | for i := 0 to uVisitTypes.Count - 1 do if CharAt(uVisitTypes[i], 1) = U then
|
---|
| 351 | begin
|
---|
| 352 | x := Piece(uVisitTypes[i], U, 2);
|
---|
| 353 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 354 | Dest.Add(IntToStr(i) + U + Piece(uVisitTypes[i], U, 2) + U + x);
|
---|
| 355 | end;
|
---|
| 356 | end;
|
---|
| 357 |
|
---|
| 358 | procedure ListVisitTypeCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 359 | { return visit types in format: visit type <TAB> amount of time <TAB> CPT code <TAB> CPT code }
|
---|
| 360 | var
|
---|
| 361 | i: Integer;
|
---|
| 362 | s: string;
|
---|
| 363 |
|
---|
| 364 | function InsertTab(x: string): string;
|
---|
| 365 | { turn the white space between the name and the number of minutes into a single tab }
|
---|
| 366 | begin
|
---|
| 367 | if CharAt(x, 20) = ' '
|
---|
| 368 | then Result := Trim(Copy(x, 1, 20)) + U + Trim(Copy(x, 21, Length(x)))
|
---|
| 369 | else Result := Trim(x) + U;
|
---|
| 370 | end;
|
---|
| 371 |
|
---|
| 372 | begin {ListVisitTypeCodes}
|
---|
| 373 | Dest.Clear;
|
---|
| 374 | i := SectionIndex + 1; // first line after the section name
|
---|
| 375 | while (i < uVisitTypes.Count) and (CharAt(uVisitTypes[i], 1) <> U) do
|
---|
| 376 | begin
|
---|
| 377 | s := Pieces(uVisitTypes[i], U, 1, 2) + U + InsertTab(Piece(uVisitTypes[i], U, 2)) + U + Piece(uVisitTypes[i], U, 1) +
|
---|
| 378 | U + IntToStr(i);
|
---|
| 379 | Dest.Add(s);
|
---|
| 380 | Inc(i);
|
---|
| 381 | end;
|
---|
| 382 | end;
|
---|
| 383 |
|
---|
| 384 | procedure ListVisitTypeByLoc(Dest: TStrings; Location: Integer; ADateTime: TFMDateTime = 0);
|
---|
| 385 | var
|
---|
| 386 | i: Integer;
|
---|
| 387 | x, SectionName: string;
|
---|
| 388 | EncDt: TFMDateTime;
|
---|
| 389 | begin
|
---|
| 390 | EncDt := Trunc(ADateTime);
|
---|
| 391 | if (uVTypeLastLoc <> Location) or (uVTypeLastDate <> EncDt) then
|
---|
| 392 | begin
|
---|
| 393 | uVTypeForLoc.Clear;
|
---|
| 394 | if Location = 0 then Exit;
|
---|
| 395 | SectionName := '';
|
---|
| 396 | CallV('ORWPCE VISIT', [Location, EncDt]);
|
---|
| 397 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
| 398 | begin
|
---|
| 399 | x := Results[i];
|
---|
| 400 | if CharAt(x, 1) = U
|
---|
| 401 | then SectionName := Piece(x, U, 2)
|
---|
| 402 | else uVTypeForLoc.Add(Piece(x, U, 1) + U + SectionName + U + Piece(x, U, 2));
|
---|
| 403 | end;
|
---|
| 404 | uVTypeLastLoc := Location;
|
---|
| 405 | uVTypeLastDate := EncDt;
|
---|
| 406 | end;
|
---|
| 407 | Dest.Assign(uVTypeForLoc);
|
---|
| 408 | end;
|
---|
| 409 |
|
---|
| 410 | function AutoSelectVisit(Location: integer): boolean;
|
---|
| 411 | begin
|
---|
| 412 | if UAutoSelLoc <> Location then
|
---|
| 413 | begin
|
---|
| 414 | UAutoSelVal := (sCallV('ORWPCE AUTO VISIT TYPE SELECT', [Location]) = '1');
|
---|
| 415 | UAutoSelLoc := Location;
|
---|
| 416 | end;
|
---|
| 417 | Result := UAutoSelVal;
|
---|
| 418 | end;
|
---|
| 419 |
|
---|
| 420 | {Diagnosis---------------------------------------------------------------------}
|
---|
| 421 | procedure ListDiagnosisSections(Dest: TStrings);
|
---|
| 422 | { return section names in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 423 | var
|
---|
| 424 | i: Integer;
|
---|
| 425 | x: string;
|
---|
| 426 | begin
|
---|
| 427 | //// if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 428 | // if (uLastDFN <> patient.DFN) then LoadEncounterForm;// commented out for CIDC needs.
|
---|
| 429 | LoadEncounterForm;
|
---|
| 430 | for i := 0 to uDiagnoses.Count - 1 do if CharAt(uDiagnoses[i], 1) = U then
|
---|
| 431 | begin
|
---|
| 432 | x := Piece(uDiagnoses[i], U, 2);
|
---|
| 433 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 434 | Dest.Add(IntToStr(i) + U + Piece(uDiagnoses[i], U, 2) + U + x);
|
---|
| 435 | end;
|
---|
| 436 | end;
|
---|
| 437 |
|
---|
| 438 | procedure ListDiagnosisCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 439 | { return diagnoses within section in format:
|
---|
| 440 | diagnosis <TAB> ICDInteger <TAB> .ICDDecimal <TAB> ICD Code }
|
---|
| 441 | var
|
---|
| 442 | i: Integer;
|
---|
| 443 | s,d: string;
|
---|
| 444 | EncDT: TFMDateTime;
|
---|
| 445 |
|
---|
| 446 | begin
|
---|
| 447 | EncDT := uEncPCEData.VisitDateTime;
|
---|
| 448 | Dest.Clear;
|
---|
| 449 | i := SectionIndex + 1; // first line after the section name
|
---|
| 450 | while (i < uDiagnoses.Count) and (CharAt(uDiagnoses[i], 1) <> U) do
|
---|
| 451 | begin
|
---|
| 452 | s := Piece(uDiagnoses[i], U, 1);
|
---|
| 453 | d := Piece(s, '.', 2);
|
---|
| 454 | s := s + U + Piece(uDiagnoses[i], U, 2) + U + Piece(s, '.', 1) + U;
|
---|
| 455 | if(d <> '') then
|
---|
| 456 | SetPiece(s, U, 4, '.' + d )
|
---|
| 457 | else // RV - CSV - need to do this so trailing "#" lines up correctly when no decimals
|
---|
| 458 | SetPiece(s, U, 4, ' ');
|
---|
| 459 |
|
---|
| 460 | //filtering out inactive codes.
|
---|
| 461 | if (Piece(uDiagnoses[i], U, 3) = '#') then
|
---|
| 462 | begin
|
---|
| 463 | SetPiece(s, U, 5, '#');
|
---|
| 464 | Dest.Add(s);
|
---|
| 465 | end
|
---|
| 466 | else if ((Piece(uDiagnoses[i], U, 3) = '') or
|
---|
| 467 | ( StrToFloat(Piece(uDiagnoses[i], U, 3)) > EncDT )) then
|
---|
| 468 | begin
|
---|
| 469 | Dest.Add(s);
|
---|
| 470 | end;
|
---|
| 471 | Inc(i);
|
---|
| 472 | end;
|
---|
| 473 | end;
|
---|
| 474 |
|
---|
| 475 | procedure AddProbsToDiagnoses;
|
---|
| 476 | var
|
---|
| 477 | i: integer; //loop index
|
---|
| 478 | EncDT: TFMDateTime;
|
---|
| 479 | begin
|
---|
| 480 | //get problem list
|
---|
| 481 | EncDT := Trunc(uEncPCEData.VisitDateTime);
|
---|
| 482 | uLastDFN := patient.DFN;
|
---|
| 483 | tCallV(uProblems, 'ORWPCE ACTPROB',[Patient.DFN, EncDT]);
|
---|
| 484 | if uProblems.count > 0 then
|
---|
| 485 | begin
|
---|
| 486 | //add category to udiagnoses
|
---|
| 487 | uDiagnoses.add(U + DX_PROBLEM_LIST_TXT);
|
---|
| 488 | for i := 1 to (uProblems.count-1) do //start with 1 because strings[0] is
|
---|
| 489 | //the count of elements.
|
---|
| 490 | begin
|
---|
| 491 | //add problems to udiagnosis.
|
---|
| 492 | if (piece(uproblems.Strings[i],U,3) = '799.9') then continue; // DON'T INCLUDE 799.9 CODES
|
---|
| 493 |
|
---|
| 494 | if (Piece(uproblems.Strings[i], U, 11) = '#') then
|
---|
| 495 | uDiagnoses.add(piece(uProblems.Strings[i],U,3) + U + // PL code inactive
|
---|
| 496 | piece(uProblems.Strings[i],U,2) + U + '#')
|
---|
| 497 | else if (Piece(uproblems.Strings[i], U, 10) = '') then // no inactive date for code
|
---|
| 498 | uDiagnoses.add(piece(uProblems.Strings[i],U,3) + U +
|
---|
| 499 | piece(uProblems.Strings[i],U,2))
|
---|
| 500 | else if (Trunc(StrToFloat(Piece(uProblems.Strings[i], U, 10))) > EncDT) then // code active as of EncDt
|
---|
| 501 | uDiagnoses.add(piece(uProblems.Strings[i],U,3) + U +
|
---|
| 502 | piece(uProblems.Strings[i],U,2))
|
---|
| 503 | else
|
---|
| 504 | uDiagnoses.add(piece(uProblems.Strings[i],U,3) + U + // PL code inactive
|
---|
| 505 | piece(uProblems.Strings[i],U,2) + U + '#');
|
---|
| 506 | end;
|
---|
| 507 |
|
---|
| 508 | //1.3.10
|
---|
| 509 | if BILLING_AWARE then
|
---|
| 510 | begin
|
---|
| 511 | // add New Section and dx codes to Encounter Diagnosis Section and Code List.
|
---|
| 512 | // Diagnoses -> Provider/Patient/24 hrs
|
---|
| 513 | uDiagnoses.add(UBAConst.ENCOUNTER_TODAYS_DX); //BAPHII 1.3.10
|
---|
| 514 | //BADxList := AddProviderPatientDaysDx(UBACore.uDxLst, IntToStr(Encounter.Provider), Patient.DFN); //BAPHII 1.3.10
|
---|
| 515 | rpcGetProviderPatientDaysDx(IntToStr(Encounter.Provider), Patient.DFN); //BAPHII 1.3.10
|
---|
| 516 |
|
---|
| 517 | for i := 0 to (UBACore.uDxLst.Count-1) do //BAPHII 1.3.10
|
---|
| 518 | uDiagnoses.add(UBACore.uDxLst[i]); //BAPHII 1.3.10
|
---|
| 519 | // Code added after presentation.....
|
---|
| 520 | // Add Personal Diagnoses Section and Codes to Encounter Diagnosis Section and Code List.
|
---|
| 521 | UBACore.uDxLst.Clear;
|
---|
| 522 | uDiagnoses.Add(UBAConst.ENCOUNTER_PERSONAL_DX);
|
---|
| 523 | UBACore.uDxLst := rpcGetPersonalDxList(User.DUZ);
|
---|
| 524 | for i := 0 to (UBACore.uDxLst.Count -1) do
|
---|
| 525 | begin
|
---|
| 526 | uDiagnoses.Add(UBACore.uDxLst.Strings[i]);
|
---|
| 527 | end;
|
---|
| 528 | end;
|
---|
| 529 |
|
---|
| 530 | end;
|
---|
| 531 | end;
|
---|
| 532 | {Immunizations-----------------------------------------------------------------}
|
---|
| 533 | procedure LoadImmReactionItems(Dest: TStrings);
|
---|
| 534 | begin
|
---|
| 535 | tCallV(Dest,'ORWPCE GET SET OF CODES',['9000010.11','.06','1']);
|
---|
| 536 | end;
|
---|
| 537 |
|
---|
| 538 | procedure LoadImmSeriesItems(Dest: TStrings);
|
---|
| 539 | {loads items into combo box on Immunixation screen}
|
---|
| 540 | begin
|
---|
| 541 | tCallV(Dest,'ORWPCE GET SET OF CODES',['9000010.11','.04','1']);
|
---|
| 542 | end;
|
---|
| 543 |
|
---|
| 544 | procedure ListImmunizSections(Dest: TStrings);
|
---|
| 545 | { return section names in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 546 | var
|
---|
| 547 | i: Integer;
|
---|
| 548 | x: string;
|
---|
| 549 | begin
|
---|
| 550 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 551 | for i := 0 to uImmunizations.Count - 1 do if CharAt(uImmunizations[i], 1) = U then
|
---|
| 552 | begin
|
---|
| 553 | x := Piece(uImmunizations[i], U, 2);
|
---|
| 554 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 555 | Dest.Add(IntToStr(i) + U + Piece(uImmunizations[i], U, 2) + U + x);
|
---|
| 556 | end;
|
---|
| 557 | end;
|
---|
| 558 |
|
---|
| 559 | procedure ListImmunizCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 560 | { return procedures within section in format: procedure <TAB> CPT code <TAB><TAB> CPT code}
|
---|
| 561 | var
|
---|
| 562 | i: Integer;
|
---|
| 563 | begin
|
---|
| 564 | Dest.Clear;
|
---|
| 565 | i := SectionIndex + 1; // first line after the section name
|
---|
| 566 | while (i < uImmunizations.Count) and (CharAt(uImmunizations[i], 1) <> U) do
|
---|
| 567 | begin
|
---|
| 568 | Dest.Add(Pieces(uImmunizations[i], U, 1, 2));
|
---|
| 569 | Inc(i);
|
---|
| 570 | end;
|
---|
| 571 | end;
|
---|
| 572 |
|
---|
| 573 |
|
---|
| 574 | {Procedures--------------------------------------------------------------------}
|
---|
| 575 | procedure ListProcedureSections(Dest: TStrings);
|
---|
| 576 | { return section names in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 577 | var
|
---|
| 578 | i: Integer;
|
---|
| 579 | x: string;
|
---|
| 580 | begin
|
---|
| 581 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 582 | for i := 0 to uProcedures.Count - 1 do if CharAt(uProcedures[i], 1) = U then
|
---|
| 583 | begin
|
---|
| 584 | x := Piece(uProcedures[i], U, 2);
|
---|
| 585 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 586 | Dest.Add(IntToStr(i) + U + Piece(uProcedures[i], U, 2) + U + x);
|
---|
| 587 | end;
|
---|
| 588 | end;
|
---|
| 589 |
|
---|
| 590 | procedure ListProcedureCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 591 | { return procedures within section in format: procedure <TAB> CPT code <TAB><TAB> CPT code}
|
---|
| 592 | //Piece 12 are CPT Modifiers, Piece 13 is a flag indicating conversion of Piece 12 from
|
---|
| 593 | //modifier code to modifier IEN (updated in UpdateModifierList routine)
|
---|
| 594 | var
|
---|
| 595 | i: Integer;
|
---|
| 596 | begin
|
---|
| 597 | Dest.Clear;
|
---|
| 598 | i := SectionIndex + 1; // first line after the section name
|
---|
| 599 | while (i < uProcedures.Count) and (CharAt(uProcedures[i], 1) <> U) do
|
---|
| 600 | begin
|
---|
| 601 | Dest.Add(Pieces(uProcedures[i], U, 1, 2) + U + Piece(uProcedures[i], U, 1) + U +
|
---|
| 602 | Piece(uProcedures[i], U, 12) + U + Piece(uProcedures[i], U, 13) + U +
|
---|
| 603 | IntToStr(i));
|
---|
| 604 | Inc(i);
|
---|
| 605 | end;
|
---|
| 606 | end;
|
---|
| 607 |
|
---|
| 608 | function MixedCaseModifier(const inStr: string): string;
|
---|
| 609 | begin
|
---|
| 610 | Result := inStr;
|
---|
| 611 | SetPiece(Result, U, 2, MixedCase(Trim(Piece(Result, U, 2))));
|
---|
| 612 | end;
|
---|
| 613 |
|
---|
| 614 | function ModifierIdx(ModIEN: string): integer;
|
---|
| 615 | var
|
---|
| 616 | EncDt: TFMDateTime;
|
---|
| 617 | begin
|
---|
| 618 | Result := uModifiers.IndexOfPiece(ModIEN);
|
---|
| 619 | if(Result < 0) then
|
---|
| 620 | begin
|
---|
| 621 | if Assigned(uEncPCEData) then // may not exist yet on display of note and PCE data
|
---|
| 622 | EncDT := Trunc(uEncPCEData.VisitDateTime)
|
---|
| 623 | else if Encounter.DateTime > 0 then // really need note date/time next, but can't get to it
|
---|
| 624 | EncDT := Trunc(Encounter.DateTime)
|
---|
| 625 | else
|
---|
| 626 | EncDT := FMToday;
|
---|
| 627 | Result := uModifiers.Add(MixedCaseModifier(sCallV('ORWPCE GETMOD', [ModIEN, EncDt])));
|
---|
| 628 | end;
|
---|
| 629 | end;
|
---|
| 630 |
|
---|
| 631 | function ModifierList(CPTCode: string): string;
|
---|
| 632 | // uModifiers list contains <@>CPTCode;ModCount;^Mod1Index^Mod2Index^...^ModNIndex
|
---|
| 633 | // or MODIEN^MODDescription^ModCode
|
---|
| 634 |
|
---|
| 635 | const
|
---|
| 636 | CPTCodeHeader = '<@>';
|
---|
| 637 |
|
---|
| 638 | var
|
---|
| 639 | i, idx: integer;
|
---|
| 640 | s, ModIEN: string;
|
---|
| 641 | EncDt: TFMDateTime;
|
---|
| 642 | begin
|
---|
| 643 | EncDT := Trunc(uEncPCEData.VisitDateTime);
|
---|
| 644 | idx := uModifiers.IndexOfPiece(CPTCodeHeader + CPTCode, ';', 1);
|
---|
| 645 | if(idx < 0) then
|
---|
| 646 | begin
|
---|
| 647 | CallV('ORWPCE CPTMODS', [CPTCode, EncDt]);
|
---|
| 648 | s := CPTCodeHeader + CPTCode + ';' + IntToStr(RPCBrokerV.Results.Count) + ';' + U;
|
---|
| 649 | for i := 0 to RPCBrokerV.Results.Count - 1 do
|
---|
| 650 | begin
|
---|
| 651 | ModIEN := piece(RPCBrokerV.Results[i], U, 1);
|
---|
| 652 | idx := uModifiers.IndexOfPiece(ModIEN);
|
---|
| 653 | if(idx < 0) then
|
---|
| 654 | idx := uModifiers.Add(MixedCaseModifier(RPCBrokerV.Results[i]));
|
---|
| 655 | s := s + IntToStr(idx) + U;
|
---|
| 656 | end;
|
---|
| 657 | idx := uModifiers.Add(s);
|
---|
| 658 | end;
|
---|
| 659 | Result := uModifiers[idx];
|
---|
| 660 | end;
|
---|
| 661 |
|
---|
| 662 | procedure ListCPTModifiers(Dest: TStrings; CPTCodes, NeededModifiers: string);
|
---|
| 663 | //CPTCodes expected in the format of code^code^code
|
---|
| 664 | //NeededModifiers in format of ModIEN1;ModIEN2;ModIEN3
|
---|
| 665 | var
|
---|
| 666 | TmpSL: TStringList;
|
---|
| 667 | i, j, idx, cnt, found: integer;
|
---|
| 668 | s, Code: string;
|
---|
| 669 |
|
---|
| 670 | begin
|
---|
| 671 | if(not assigned(uModifiers)) then uModifiers := TORStringList.Create;
|
---|
| 672 | if(copy(CPTCodes, length(CPTCodes), 1) <> U) then
|
---|
| 673 | CPTCodes := CPTCodes + U;
|
---|
| 674 | if(copy(NeededModifiers, length(NeededModifiers), 1) <> ';') then
|
---|
| 675 | NeededModifiers := NeededModifiers + ';';
|
---|
| 676 |
|
---|
| 677 | TmpSL := TStringList.Create;
|
---|
| 678 | try
|
---|
| 679 | repeat
|
---|
| 680 | i := pos(U, CPTCodes);
|
---|
| 681 | if(i > 0) then
|
---|
| 682 | begin
|
---|
| 683 | Code := copy(CPTCodes, 1, i-1);
|
---|
| 684 | delete(CPTCodes,1,i);
|
---|
| 685 | if(Code <> '') then
|
---|
| 686 | TmpSL.Add(ModifierList(Code));
|
---|
| 687 | i := pos(U, CPTCodes);
|
---|
| 688 | end;
|
---|
| 689 | until(i = 0);
|
---|
| 690 | if(TmpSL.Count = 0) then
|
---|
| 691 | s := ';0;'
|
---|
| 692 | else
|
---|
| 693 | if(TmpSL.Count = 1) then
|
---|
| 694 | s := TmpSL[0]
|
---|
| 695 | else
|
---|
| 696 | begin
|
---|
| 697 | s := '';
|
---|
| 698 | found := 0;
|
---|
| 699 | cnt := StrToIntDef(piece(TmpSL[0], ';', 2), 0);
|
---|
| 700 | for i := 1 to cnt do
|
---|
| 701 | begin
|
---|
| 702 | Code := U + Piece(TmpSL[0], U, i+1);
|
---|
| 703 | for j := 1 to TmpSL.Count-1 do
|
---|
| 704 | begin
|
---|
| 705 | if(pos(Code + U, TmpSL[j]) = 0) then
|
---|
| 706 | begin
|
---|
| 707 | Code := '';
|
---|
| 708 | break;
|
---|
| 709 | end;
|
---|
| 710 | end;
|
---|
| 711 | if(Code <> '') then
|
---|
| 712 | begin
|
---|
| 713 | s := s + Code;
|
---|
| 714 | inc(found);
|
---|
| 715 | end;
|
---|
| 716 | end;
|
---|
| 717 | s := s + U;
|
---|
| 718 | SetPiece(s , U, 1, ';' + IntToStr(Found) + ';');
|
---|
| 719 | end;
|
---|
| 720 | finally
|
---|
| 721 | TmpSL.Free;
|
---|
| 722 | end;
|
---|
| 723 |
|
---|
| 724 | Dest.Clear;
|
---|
| 725 | cnt := StrToIntDef(piece(s, ';', 2), 0);
|
---|
| 726 | if(NeededModifiers <> '') then
|
---|
| 727 | begin
|
---|
| 728 | found := cnt;
|
---|
| 729 | repeat
|
---|
| 730 | i := pos(';',NeededModifiers);
|
---|
| 731 | if(i > 0) then
|
---|
| 732 | begin
|
---|
| 733 | idx := StrToIntDef(copy(NeededModifiers,1,i-1),0);
|
---|
| 734 | if(idx > 0) then
|
---|
| 735 | begin
|
---|
| 736 | Code := IntToStr(ModifierIdx(IntToStr(idx))) + U;
|
---|
| 737 | if(pos(U+Code, s) = 0) then
|
---|
| 738 | begin
|
---|
| 739 | s := s + Code;
|
---|
| 740 | inc(cnt);
|
---|
| 741 | end;
|
---|
| 742 | end;
|
---|
| 743 | delete(NeededModifiers,1,i);
|
---|
| 744 | end;
|
---|
| 745 | until(i = 0);
|
---|
| 746 | if(found <> cnt) then
|
---|
| 747 | SetPiece(s , ';', 2, IntToStr(cnt));
|
---|
| 748 | end;
|
---|
| 749 | for i := 1 to cnt do
|
---|
| 750 | begin
|
---|
| 751 | idx := StrToIntDef(piece(s, U, i + 1), -1);
|
---|
| 752 | if(idx >= 0) then
|
---|
| 753 | Dest.Add(uModifiers[idx]);
|
---|
| 754 | end;
|
---|
| 755 | end;
|
---|
| 756 |
|
---|
| 757 | function ModifierName(ModIEN: string): string;
|
---|
| 758 | begin
|
---|
| 759 | if(not assigned(uModifiers)) then uModifiers := TORStringList.Create;
|
---|
| 760 | Result := piece(uModifiers[ModifierIdx(ModIEN)], U, 2);
|
---|
| 761 | end;
|
---|
| 762 |
|
---|
| 763 | function ModifierCode(ModIEN: string): string;
|
---|
| 764 | begin
|
---|
| 765 | if(not assigned(uModifiers)) then uModifiers := TORStringList.Create;
|
---|
| 766 | Result := piece(uModifiers[ModifierIdx(ModIEN)], U, 3);
|
---|
| 767 | end;
|
---|
| 768 |
|
---|
| 769 | function UpdateModifierList(Dest: TStrings; Index: integer): string;
|
---|
| 770 | var
|
---|
| 771 | i, idx, LastIdx: integer;
|
---|
| 772 | Tmp, OKMods, Code: string;
|
---|
| 773 | OK: boolean;
|
---|
| 774 |
|
---|
| 775 | begin
|
---|
| 776 | if(Piece(Dest[Index], U, 5) = '1') then
|
---|
| 777 | Result := Piece(Dest[Index],U,4)
|
---|
| 778 | else
|
---|
| 779 | begin
|
---|
| 780 | Tmp := Piece(Dest[Index], U, 4);
|
---|
| 781 | Result := '';
|
---|
| 782 | OKMods := ModifierList(Piece(Dest[Index], U, 1))+U;
|
---|
| 783 | i := 1;
|
---|
| 784 | repeat
|
---|
| 785 | Code := Piece(Tmp,';',i);
|
---|
| 786 | if(Code <> '') then
|
---|
| 787 | begin
|
---|
| 788 | LastIdx := -1;
|
---|
| 789 | OK := FALSE;
|
---|
| 790 | repeat
|
---|
| 791 | idx := uModifiers.IndexOfPiece(Code, U, 3, LastIdx);
|
---|
| 792 | if(idx > 0) then
|
---|
| 793 | begin
|
---|
| 794 | if(pos(U + IntToStr(idx) + U, OKMods)>0) then
|
---|
| 795 | begin
|
---|
| 796 | Result := Result + piece(uModifiers[idx],U,1) + ';';
|
---|
| 797 | OK := TRUE;
|
---|
| 798 | end
|
---|
| 799 | else
|
---|
| 800 | LastIdx := Idx;
|
---|
| 801 | end;
|
---|
| 802 | until(idx < 0) or OK;
|
---|
| 803 | inc(i);
|
---|
| 804 | end
|
---|
| 805 | until(Code = '');
|
---|
| 806 | Tmp := Dest[Index];
|
---|
| 807 | SetPiece(Tmp,U,4,Result);
|
---|
| 808 | SetPiece(Tmp,U,5,'1');
|
---|
| 809 | Dest[Index] := Tmp;
|
---|
| 810 | idx := StrToIntDef(piece(Tmp,U,6),-1);
|
---|
| 811 | if(idx >= 0) then
|
---|
| 812 | begin
|
---|
| 813 | Tmp := uProcedures[idx];
|
---|
| 814 | SetPiece(Tmp,U,12,Result);
|
---|
| 815 | SetPiece(Tmp,U,13,'1');
|
---|
| 816 | uProcedures[idx] := Tmp;
|
---|
| 817 | end;
|
---|
| 818 | end;
|
---|
| 819 | end;
|
---|
| 820 |
|
---|
| 821 | function UpdateVisitTypeModifierList(Dest: TStrings; Index: integer): string;
|
---|
| 822 | var
|
---|
| 823 | i, idx, LastIdx: integer;
|
---|
| 824 | Tmp, OKMods, Code: string;
|
---|
| 825 | OK: boolean;
|
---|
| 826 |
|
---|
| 827 | begin
|
---|
| 828 | if(Piece(Dest[Index], U, 7) = '1') then
|
---|
| 829 | Result := Piece(Dest[Index],U,6)
|
---|
| 830 | else
|
---|
| 831 | begin
|
---|
| 832 | Tmp := Piece(Dest[Index], U, 6);
|
---|
| 833 | Result := '';
|
---|
| 834 | OKMods := ModifierList(Piece(Dest[Index], U, 1))+U;
|
---|
| 835 | i := 1;
|
---|
| 836 | repeat
|
---|
| 837 | Code := Piece(Tmp,';',i);
|
---|
| 838 | if(Code <> '') then
|
---|
| 839 | begin
|
---|
| 840 | LastIdx := -1;
|
---|
| 841 | OK := FALSE;
|
---|
| 842 | repeat
|
---|
| 843 | idx := uModifiers.IndexOfPiece(Code, U, 3, LastIdx);
|
---|
| 844 | if(idx > 0) then
|
---|
| 845 | begin
|
---|
| 846 | if(pos(U + IntToStr(idx) + U, OKMods)>0) then
|
---|
| 847 | begin
|
---|
| 848 | Result := Result + piece(uModifiers[idx],U,1) + ';';
|
---|
| 849 | OK := TRUE;
|
---|
| 850 | end
|
---|
| 851 | else
|
---|
| 852 | LastIdx := Idx;
|
---|
| 853 | end;
|
---|
| 854 | until(idx < 0) or OK;
|
---|
| 855 | inc(i);
|
---|
| 856 | end
|
---|
| 857 | until(Code = '');
|
---|
| 858 | Tmp := Dest[Index];
|
---|
| 859 | SetPiece(Tmp,U,6,Result);
|
---|
| 860 | SetPiece(Tmp,U,7,'1');
|
---|
| 861 | Dest[Index] := Tmp;
|
---|
| 862 | idx := StrToIntDef(piece(Tmp,U,8),-1);
|
---|
| 863 | if(idx >= 0) then
|
---|
| 864 | begin
|
---|
| 865 | Tmp := uProcedures[idx];
|
---|
| 866 | SetPiece(Tmp,U,12,Result);
|
---|
| 867 | SetPiece(Tmp,U,13,'1');
|
---|
| 868 | uProcedures[idx] := Tmp;
|
---|
| 869 | end;
|
---|
| 870 | end;
|
---|
| 871 | end;
|
---|
| 872 |
|
---|
| 873 |
|
---|
| 874 | {SkinTests---------------------------------------------------------------------}
|
---|
| 875 | procedure LoadSkResultsItems(Dest: TStrings);
|
---|
| 876 | begin
|
---|
| 877 | tCallV(Dest,'ORWPCE GET SET OF CODES',['9000010.12','.04','1']);
|
---|
| 878 | end;
|
---|
| 879 |
|
---|
| 880 | procedure ListSkinSections(Dest: TStrings);
|
---|
| 881 | { return section names in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 882 | var
|
---|
| 883 | i: Integer;
|
---|
| 884 | x: string;
|
---|
| 885 | begin
|
---|
| 886 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 887 | for i := 0 to uSkinTests.Count - 1 do if CharAt(uSkinTests[i], 1) = U then
|
---|
| 888 | begin
|
---|
| 889 | x := Piece(uSkinTests[i], U, 2);
|
---|
| 890 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 891 | Dest.Add(IntToStr(i) + U + Piece(uSkinTests[i], U, 2) + U + x);
|
---|
| 892 | end;
|
---|
| 893 | end;
|
---|
| 894 |
|
---|
| 895 |
|
---|
| 896 | procedure ListSkinCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 897 | { return procedures within section in format: procedure <TAB> CPT code <TAB><TAB> CPT code}
|
---|
| 898 | var
|
---|
| 899 | i: Integer;
|
---|
| 900 | begin
|
---|
| 901 | Dest.Clear;
|
---|
| 902 | i := SectionIndex + 1; // first line after the section name
|
---|
| 903 | while (i < uSkinTests.Count) and (CharAt(uSkinTests[i], 1) <> U) do
|
---|
| 904 | begin
|
---|
| 905 | Dest.Add(Pieces(uSkinTests[i], U, 1, 2));
|
---|
| 906 | Inc(i);
|
---|
| 907 | end;
|
---|
| 908 | end;
|
---|
| 909 |
|
---|
| 910 |
|
---|
| 911 | {Patient Education-------------------------------------------------------------}
|
---|
| 912 | procedure LoadPEDLevelItems(Dest: TStrings);
|
---|
| 913 | begin
|
---|
| 914 | tCallV(Dest,'ORWPCE GET SET OF CODES',['9000010.16','.06','1']);
|
---|
| 915 | end;
|
---|
| 916 |
|
---|
| 917 | procedure ListPatientSections(Dest: TStrings);
|
---|
| 918 | { return Sections in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 919 | var
|
---|
| 920 | i: Integer;
|
---|
| 921 | x: string;
|
---|
| 922 | begin
|
---|
| 923 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 924 | for i := 0 to uPatientEds.Count - 1 do if CharAt(uPatientEds[i], 1) = U then
|
---|
| 925 | begin
|
---|
| 926 | x := Piece(uPatientEds[i], U, 2);
|
---|
| 927 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 928 | Dest.Add(IntToStr(i) + U + Piece(uPatientEds[i], U, 2) + U + x);
|
---|
| 929 | end;
|
---|
| 930 | end;
|
---|
| 931 |
|
---|
| 932 |
|
---|
| 933 | procedure ListPatientCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 934 | { return PatientEds within section in format: procedure <TAB> CPT code <TAB><TAB> CPT code}
|
---|
| 935 | var
|
---|
| 936 | i: Integer;
|
---|
| 937 | begin
|
---|
| 938 | Dest.Clear;
|
---|
| 939 | i := SectionIndex + 1; // first line after the section name
|
---|
| 940 | while (i < uPatientEds.Count) and (CharAt(uPatientEds[i], 1) <> U) do
|
---|
| 941 | begin
|
---|
| 942 | Dest.Add(Pieces(uPatientEds[i], U, 1, 2));
|
---|
| 943 | Inc(i);
|
---|
| 944 | end;
|
---|
| 945 | end;
|
---|
| 946 |
|
---|
| 947 |
|
---|
| 948 |
|
---|
| 949 | {HealthFactors-------------------------------------------------------------}
|
---|
| 950 | procedure LoadHFLevelItems(Dest: TStrings);
|
---|
| 951 | begin
|
---|
| 952 | tCallV(Dest,'ORWPCE GET SET OF CODES',['9000010.23','.04','1']);
|
---|
| 953 | end;
|
---|
| 954 |
|
---|
| 955 | procedure ListHealthSections(Dest: TStrings);
|
---|
| 956 | { return Sections in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 957 | var
|
---|
| 958 | i: Integer;
|
---|
| 959 | x: string;
|
---|
| 960 | begin
|
---|
| 961 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 962 | for i := 0 to uHealthFactors.Count - 1 do if CharAt(uHealthFactors[i], 1) = U then
|
---|
| 963 | begin
|
---|
| 964 | x := Piece(uHealthFactors[i], U, 2);
|
---|
| 965 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 966 | Dest.Add(IntToStr(i) + U + Piece(uHealthFactors[i], U, 2) + U + x);
|
---|
| 967 | end;
|
---|
| 968 | end;
|
---|
| 969 |
|
---|
| 970 |
|
---|
| 971 | procedure ListHealthCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 972 | { return PatientEds within section in format: procedure <TAB> CPT code <TAB><TAB> CPT code}
|
---|
| 973 | var
|
---|
| 974 | i: Integer;
|
---|
| 975 | begin
|
---|
| 976 | Dest.Clear;
|
---|
| 977 | i := SectionIndex + 1; // first line after the section name
|
---|
| 978 | while (i < uHealthFactors.Count) and (CharAt(uHealthFactors[i], 1) <> U) do
|
---|
| 979 | begin
|
---|
| 980 | Dest.Add(Pieces(uHealthFactors[i], U, 1, 2));
|
---|
| 981 | Inc(i);
|
---|
| 982 | end;
|
---|
| 983 | end;
|
---|
| 984 |
|
---|
| 985 |
|
---|
| 986 |
|
---|
| 987 | {Exams-------------------------------------------------------------------------}
|
---|
| 988 | procedure LoadXAMResultsItems(Dest: TStrings);
|
---|
| 989 | begin
|
---|
| 990 | tCallV(Dest,'ORWPCE GET SET OF CODES',['9000010.13','.04','1']);
|
---|
| 991 | end;
|
---|
| 992 |
|
---|
| 993 | procedure LoadHistLocations(Dest: TStrings);
|
---|
| 994 | var
|
---|
| 995 | i, j, tlen: integer;
|
---|
| 996 | tmp: string;
|
---|
| 997 |
|
---|
| 998 | begin
|
---|
| 999 | tCallV(Dest,'ORQQPX GET HIST LOCATIONS',[]);
|
---|
| 1000 | for i := 0 to (Dest.Count - 1) do
|
---|
| 1001 | begin
|
---|
| 1002 | tmp := MixedCase(dest[i]);
|
---|
| 1003 | j := pos(', ',tmp);
|
---|
| 1004 | tlen := length(tmp);
|
---|
| 1005 | if(j > 0) and (j < (tlen - 2)) and (pos(tmp[j+2],UpperCaseLetters) > 0) and
|
---|
| 1006 | (pos(tmp[j+3],LowerCaseLetters)>0) and ((j = (tlen-3)) or (pos(tmp[j+4],LowerCaseLetters)=0)) then
|
---|
| 1007 | tmp[j+3] := UpCase(tmp[j+3]);
|
---|
| 1008 | if(tlen > 1) then
|
---|
| 1009 | begin
|
---|
| 1010 | if(pos(tmp[tlen],Digits) > 0) and (pos(tmp[tlen-1],Digits)=0) then
|
---|
| 1011 | insert(' ',tmp, tlen);
|
---|
| 1012 | end;
|
---|
| 1013 | dest[i] := tmp;
|
---|
| 1014 | end;
|
---|
| 1015 | end;
|
---|
| 1016 |
|
---|
| 1017 | procedure ListExamsSections(Dest: TStrings);
|
---|
| 1018 | { return Sections in format: ListIndex^SectionName (sections begin with '^') }
|
---|
| 1019 | var
|
---|
| 1020 | i: Integer;
|
---|
| 1021 | x: string;
|
---|
| 1022 | begin
|
---|
| 1023 | if (uLastLocation <> uEncLocation) then LoadEncounterForm;
|
---|
| 1024 | for i := 0 to uExams.Count - 1 do if CharAt(uExams[i], 1) = U then
|
---|
| 1025 | begin
|
---|
| 1026 | x := Piece(uExams[i], U, 2);
|
---|
| 1027 | if Length(x) = 0 then x := '<No Section Name>';
|
---|
| 1028 | Dest.Add(IntToStr(i) + U + Piece(uExams[i], U, 2) + U + x);
|
---|
| 1029 | end;
|
---|
| 1030 | end;
|
---|
| 1031 |
|
---|
| 1032 |
|
---|
| 1033 | procedure ListExamsCodes(Dest: TStrings; SectionIndex: Integer);
|
---|
| 1034 | { return PatientEds within section in format: procedure <TAB> CPT code <TAB><TAB> CPT code}
|
---|
| 1035 | var
|
---|
| 1036 | i: Integer;
|
---|
| 1037 | begin
|
---|
| 1038 | Dest.Clear;
|
---|
| 1039 | i := SectionIndex + 1; // first line after the section name
|
---|
| 1040 | while (i < uExams.Count) and (CharAt(uExams[i], 1) <> U) do
|
---|
| 1041 | begin
|
---|
| 1042 | Dest.Add(Pieces(uExams[i], U, 1, 2));
|
---|
| 1043 | Inc(i);
|
---|
| 1044 | end;
|
---|
| 1045 | end;
|
---|
| 1046 |
|
---|
| 1047 |
|
---|
| 1048 |
|
---|
| 1049 |
|
---|
| 1050 |
|
---|
| 1051 | {------------------------------------------------------------------------------}
|
---|
| 1052 | function EligbleConditions: TSCConditions;
|
---|
| 1053 | { return a record listing the conditions for which a patient is eligible }
|
---|
| 1054 | var
|
---|
| 1055 | x: string;
|
---|
| 1056 | begin
|
---|
| 1057 | x := sCallV('ORWPCE SCSEL', [Patient.DFN, Encounter.DateTime, uEncLocation]);
|
---|
| 1058 | with Result do
|
---|
| 1059 | begin
|
---|
| 1060 | SCAllow := Piece(Piece(x, ';', 1), U, 1) = '1';
|
---|
| 1061 | SCDflt := Piece(Piece(x, ';', 1), U, 2) = '1';
|
---|
| 1062 | AOAllow := Piece(Piece(x, ';', 2), U, 1) = '1';
|
---|
| 1063 | AODflt := Piece(Piece(x, ';', 2), U, 2) = '1';
|
---|
| 1064 | IRAllow := Piece(Piece(x, ';', 3), U, 1) = '1';
|
---|
| 1065 | IRDflt := Piece(Piece(x, ';', 3), U, 2) = '1';
|
---|
| 1066 | ECAllow := Piece(Piece(x, ';', 4), U, 1) = '1';
|
---|
| 1067 | ECDflt := Piece(Piece(x, ';', 4), U, 2) = '1';
|
---|
| 1068 | MSTAllow := Piece(Piece(x, ';', 5), U, 1) = '1';
|
---|
| 1069 | MSTDflt := Piece(Piece(x, ';', 5), U, 2) = '1';
|
---|
| 1070 | HNCAllow := Piece(Piece(x, ';', 6), U, 1) = '1';
|
---|
| 1071 | HNCDflt := Piece(Piece(x, ';', 6), U, 2) = '1';
|
---|
| 1072 | CVAllow := Piece(Piece(x, ';', 7), U, 1) = '1';
|
---|
| 1073 | CVDflt := Piece(Piece(x, ';', 7), U, 2) = '1';
|
---|
| 1074 | end;
|
---|
| 1075 | end;
|
---|
| 1076 |
|
---|
| 1077 | procedure ListSCDisabilities(Dest: TStrings);
|
---|
| 1078 | { return text listing a patient's rated disabilities and % service connected }
|
---|
| 1079 | begin
|
---|
| 1080 | CallV('ORWPCE SCDIS', [Patient.DFN]);
|
---|
| 1081 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 1082 | end;
|
---|
| 1083 |
|
---|
| 1084 | procedure LoadPCEDataForNote(Dest: TStrings; ANoteIEN: Integer; VStr: string);
|
---|
| 1085 | begin
|
---|
| 1086 | if(ANoteIEN < 1) then
|
---|
| 1087 | CallV('ORWPCE PCE4NOTE', [ANoteIEN, Patient.DFN, VStr])
|
---|
| 1088 | else
|
---|
| 1089 | CallV('ORWPCE PCE4NOTE', [ANoteIEN]);
|
---|
| 1090 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 1091 | end;
|
---|
| 1092 |
|
---|
| 1093 | function GetVisitIEN(NoteIEN: Integer): string;
|
---|
| 1094 | begin
|
---|
| 1095 | if(NoteIEN < 1) then
|
---|
| 1096 | CallV('ORWPCE GET VISIT', [NoteIEN, Patient.DFN, Encounter.VisitStr])
|
---|
| 1097 | else
|
---|
| 1098 | CallV('ORWPCE GET VISIT', [NoteIEN]);
|
---|
| 1099 | if(RPCBrokerV.Results.Count > 0) then
|
---|
| 1100 | Result := RPCBrokerV.Results[0]
|
---|
| 1101 | else
|
---|
| 1102 | Result := '0';
|
---|
| 1103 | end;
|
---|
| 1104 |
|
---|
| 1105 | procedure SavePCEData(PCEList: TStringList; ANoteIEN, ALocation: integer);
|
---|
| 1106 | begin
|
---|
| 1107 | CallV('ORWPCE SAVE', [PCEList, ANoteIEN, ALocation]);
|
---|
| 1108 | end;
|
---|
| 1109 |
|
---|
| 1110 | {-----------------------------------------------------------------------------}
|
---|
| 1111 |
|
---|
| 1112 | function DataHasCPTCodes(AList: TStrings): boolean;
|
---|
| 1113 | var
|
---|
| 1114 | i: integer;
|
---|
| 1115 | vl: string;
|
---|
| 1116 |
|
---|
| 1117 | begin
|
---|
| 1118 | if(not assigned(uHasCPT)) then
|
---|
| 1119 | uHasCPT := TStringList.Create;
|
---|
| 1120 | Result := FALSE;
|
---|
| 1121 | i := 0;
|
---|
| 1122 | while(i < AList.Count) do
|
---|
| 1123 | begin
|
---|
| 1124 | vl := uHasCPT.Values[AList[i]];
|
---|
| 1125 | if(vl = '1') then
|
---|
| 1126 | begin
|
---|
| 1127 | Result := TRUE;
|
---|
| 1128 | exit;
|
---|
| 1129 | end
|
---|
| 1130 | else
|
---|
| 1131 | if(vl = '0') then
|
---|
| 1132 | AList.Delete(i)
|
---|
| 1133 | else
|
---|
| 1134 | inc(i);
|
---|
| 1135 | end;
|
---|
| 1136 | if(AList.Count > 0) then
|
---|
| 1137 | begin
|
---|
| 1138 | with RPCBrokerV do
|
---|
| 1139 | begin
|
---|
| 1140 | ClearParameters := True;
|
---|
| 1141 | RemoteProcedure := 'ORWPCE HASCPT';
|
---|
| 1142 | Param[0].PType := list;
|
---|
| 1143 | with Param[0] do
|
---|
| 1144 | begin
|
---|
| 1145 | for i := 0 to AList.Count-1 do
|
---|
| 1146 | Mult[inttostr(i+1)] := AList[i];
|
---|
| 1147 | end;
|
---|
| 1148 | CallBroker;
|
---|
| 1149 | for i := 0 to RPCBrokerV.Results.Count-1 do
|
---|
| 1150 | begin
|
---|
| 1151 | if(Piece(RPCBrokerV.Results[i],'=',2) = '1') then
|
---|
| 1152 | begin
|
---|
| 1153 | Result := TRUE;
|
---|
| 1154 | break;
|
---|
| 1155 | end;
|
---|
| 1156 | end;
|
---|
| 1157 | uHasCPT.AddStrings(RPCBrokerV.Results);
|
---|
| 1158 | end;
|
---|
| 1159 | end;
|
---|
| 1160 | end;
|
---|
| 1161 |
|
---|
| 1162 | function GetAskPCE(Loc: integer): TAskPCE;
|
---|
| 1163 | begin
|
---|
| 1164 | if(uAPUser <> User.DUZ) or (uAPLoc <> Loc) then
|
---|
| 1165 | begin
|
---|
| 1166 | uAPUser := User.DUZ;
|
---|
| 1167 | uAPLoc := Loc;
|
---|
| 1168 | uAPAsk := TAskPCE(StrToIntDef(sCallV('ORWPCE ASKPCE', [User.DUZ, Loc]), 0));
|
---|
| 1169 | end;
|
---|
| 1170 | Result := uAPAsk;
|
---|
| 1171 | end;
|
---|
| 1172 |
|
---|
| 1173 | function HasVisit(const ANoteIEN, ALocation: integer; const AVisitDate: TFMDateTime): Integer;
|
---|
| 1174 | begin
|
---|
| 1175 | Result := StrToIntDef(sCallV('ORWPCE HASVISIT', [ANoteIEN, Patient.DFN, ALocation, AVisitDate]), -1);
|
---|
| 1176 | end;
|
---|
| 1177 |
|
---|
| 1178 | {-----------------------------------------------------------------------------}
|
---|
| 1179 | function CheckActivePerson(provider:String;DateTime:TFMDateTime): boolean;
|
---|
| 1180 | var
|
---|
| 1181 | RetVal: String;
|
---|
| 1182 | begin
|
---|
| 1183 | Callv('ORWPCE ACTIVE PROV',[provider,FloatToStr(DateTime)]);
|
---|
| 1184 | retval := RPCBrokerV.Results[0];
|
---|
| 1185 | if StrToInt(RetVal) = 1 then result := true
|
---|
| 1186 | else result := false;
|
---|
| 1187 | end;
|
---|
| 1188 |
|
---|
| 1189 | function ForcePCEEntry(Loc: integer): boolean;
|
---|
| 1190 | begin
|
---|
| 1191 | if(Loc <> uLastForceLoc) then
|
---|
| 1192 | begin
|
---|
| 1193 | uLastForce := (sCallV('ORWPCE FORCE', [User.DUZ, Loc]) = '1');
|
---|
| 1194 | uLastForceLoc := Loc;
|
---|
| 1195 | end;
|
---|
| 1196 | Result := uLastForce;
|
---|
| 1197 | end;
|
---|
| 1198 |
|
---|
| 1199 | procedure LoadcboOther(Dest: TStrings; Location, fOtherApp: Integer);
|
---|
| 1200 | {loads items into combo box on Immunization screen}
|
---|
| 1201 | var
|
---|
| 1202 | IEN, RPC: string;
|
---|
| 1203 | TmpSL: TORStringList;
|
---|
| 1204 | i, j, idx, typ: integer;
|
---|
| 1205 |
|
---|
| 1206 | begin
|
---|
| 1207 | TmpSL := TORStringList.Create;
|
---|
| 1208 | try
|
---|
| 1209 | Idx := 0;
|
---|
| 1210 | case fOtherApp of
|
---|
| 1211 | PCE_IMM: begin typ := 1; RPC := 'ORWPCE GET IMMUNIZATION TYPE'; end;
|
---|
| 1212 | PCE_SK: begin typ := 2; RPC := 'ORWPCE GET SKIN TEST TYPE'; end;
|
---|
| 1213 | PCE_PED: begin typ := 3; RPC := 'ORWPCE GET EDUCATION TOPICS'; end;
|
---|
| 1214 | PCE_HF: begin typ := 4; RPC := 'ORWPCE GET HEALTH FACTORS TY'; Idx := 1; end;
|
---|
| 1215 | PCE_XAM: begin typ := 5; RPC := 'ORWPCE GET EXAM TYPE'; end;
|
---|
| 1216 | else begin typ := 0; RPC := ''; end;
|
---|
| 1217 | end;
|
---|
| 1218 | if typ > 0 then
|
---|
| 1219 | begin
|
---|
| 1220 | if idx = 0 then
|
---|
| 1221 | tCallV(TmpSL,RPC,[nil])
|
---|
| 1222 | else
|
---|
| 1223 | tCallV(TmpSL,RPC,[idx]);
|
---|
| 1224 | CallV('ORWPCE GET EXCLUDED', [Location, Typ]);
|
---|
| 1225 | for i := 0 to RPCBrokerV.Results.Count-1 do
|
---|
| 1226 | begin
|
---|
| 1227 | IEN := piece(RPCBrokerV.Results[i],U,2);
|
---|
| 1228 | idx := TmpSL.IndexOfPiece(IEN);
|
---|
| 1229 | if idx >= 0 then
|
---|
| 1230 | begin
|
---|
| 1231 | TmpSL.Delete(idx);
|
---|
| 1232 | if fOtherApp = PCE_HF then
|
---|
| 1233 | begin
|
---|
| 1234 | j := 0;
|
---|
| 1235 | while (j < TmpSL.Count) do
|
---|
| 1236 | begin
|
---|
| 1237 | if IEN = Piece(TmpSL[J],U,4) then
|
---|
| 1238 | TmpSL.Delete(j)
|
---|
| 1239 | else
|
---|
| 1240 | inc(j);
|
---|
| 1241 | end;
|
---|
| 1242 | end;
|
---|
| 1243 | end;
|
---|
| 1244 | end;
|
---|
| 1245 | end;
|
---|
| 1246 | Dest.Assign(TmpSL);
|
---|
| 1247 | finally
|
---|
| 1248 | TmpSL.Free;
|
---|
| 1249 | end;
|
---|
| 1250 | end;
|
---|
| 1251 |
|
---|
| 1252 | {
|
---|
| 1253 | function SetRPCEncouterInfo(PCEData: TPCEData): boolean;
|
---|
| 1254 | begin
|
---|
| 1255 | if (SetRPCEncLocation(PCEData.location) = False) or (SetRPCEncDateTime(PCEData.DateTime) = False) then
|
---|
| 1256 | result := False
|
---|
| 1257 | else result := True;
|
---|
| 1258 | end;
|
---|
| 1259 | }
|
---|
| 1260 |
|
---|
| 1261 | function SetRPCEncLocation(Loc: Integer): boolean;
|
---|
| 1262 | begin
|
---|
| 1263 | uEncLocation := Loc;
|
---|
| 1264 | Result := (uEncLocation <> 0);
|
---|
| 1265 | end;
|
---|
| 1266 |
|
---|
| 1267 | {
|
---|
| 1268 | function SetRPCEncDateTime(DT: TFMDateTime): boolean;
|
---|
| 1269 | begin
|
---|
| 1270 | uEncDateTime := 0.0;
|
---|
| 1271 | result := False;
|
---|
| 1272 | uEncDateTime := DT;
|
---|
| 1273 | if uEncDateTime > 0.0 then result := true;
|
---|
| 1274 | end;
|
---|
| 1275 | }
|
---|
| 1276 |
|
---|
| 1277 | function PCERPCEncLocation: integer;
|
---|
| 1278 | begin
|
---|
| 1279 | result := uEncLocation;
|
---|
| 1280 | end;
|
---|
| 1281 |
|
---|
| 1282 | {
|
---|
| 1283 | function PCERPCEncDateTime: TFMDateTime;
|
---|
| 1284 | begin
|
---|
| 1285 | result := uEncDateTime;
|
---|
| 1286 | end;
|
---|
| 1287 | }
|
---|
| 1288 |
|
---|
| 1289 | function GetLocSecondaryVisitCode(Loc: integer): char;
|
---|
| 1290 | begin
|
---|
| 1291 | if (Loc <> uLastIsClinicLoc) then
|
---|
| 1292 | begin
|
---|
| 1293 | uLastIsClinicLoc := Loc;
|
---|
| 1294 | uLastIsClinic := (sCallV('ORWPCE ISCLINIC', [Loc]) = '1');
|
---|
| 1295 | end;
|
---|
| 1296 | if uLastIsClinic then
|
---|
| 1297 | Result := 'I'
|
---|
| 1298 | else
|
---|
| 1299 | Result := 'D';
|
---|
| 1300 | end;
|
---|
| 1301 |
|
---|
| 1302 | function GAFOK: boolean;
|
---|
| 1303 | begin
|
---|
| 1304 | if(not uGAFOKCalled) then
|
---|
| 1305 | begin
|
---|
| 1306 | uGAFOK := (sCallV('ORWPCE GAFOK', []) = '1');
|
---|
| 1307 | uGAFOKCalled := TRUE;
|
---|
| 1308 | end;
|
---|
| 1309 | Result := uGAFOK;
|
---|
| 1310 | end;
|
---|
| 1311 |
|
---|
| 1312 | function MHClinic(const Location: integer): boolean;
|
---|
| 1313 | begin
|
---|
| 1314 | if GAFOK then
|
---|
| 1315 | Result := (sCallV('ORWPCE MHCLINIC', [Location]) = '1')
|
---|
| 1316 | else
|
---|
| 1317 | Result := FALSE;
|
---|
| 1318 | end;
|
---|
| 1319 |
|
---|
| 1320 | procedure RecentGAFScores(const Limit: integer);
|
---|
| 1321 | begin
|
---|
| 1322 | if(GAFOK) then
|
---|
| 1323 | begin
|
---|
| 1324 | with RPCBrokerV do
|
---|
| 1325 | begin
|
---|
| 1326 | ClearParameters := True;
|
---|
| 1327 | RemoteProcedure := 'ORWPCE LOADGAF';
|
---|
| 1328 | Param[0].PType := list;
|
---|
| 1329 | with Param[0] do
|
---|
| 1330 | begin
|
---|
| 1331 | Mult['"DFN"'] := Patient.DFN;
|
---|
| 1332 | Mult['"LIMIT"'] := IntToStr(Limit);
|
---|
| 1333 | end;
|
---|
| 1334 | CallBroker;
|
---|
| 1335 | end;
|
---|
| 1336 | end;
|
---|
| 1337 | end;
|
---|
| 1338 |
|
---|
| 1339 | function SaveGAFScore(const Score: integer; GAFDate: TFMDateTime; Staff: Int64): boolean;
|
---|
| 1340 | begin
|
---|
| 1341 | Result := FALSE;
|
---|
| 1342 | if(GAFOK) then
|
---|
| 1343 | begin
|
---|
| 1344 | with RPCBrokerV do
|
---|
| 1345 | begin
|
---|
| 1346 | ClearParameters := True;
|
---|
| 1347 | RemoteProcedure := 'ORWPCE SAVEGAF';
|
---|
| 1348 | Param[0].PType := list;
|
---|
| 1349 | with Param[0] do
|
---|
| 1350 | begin
|
---|
| 1351 | Mult['"DFN"'] := Patient.DFN;
|
---|
| 1352 | Mult['"GAF"'] := IntToStr(Score);
|
---|
| 1353 | Mult['"DATE"'] := FloatToStr(GAFDate);
|
---|
| 1354 | Mult['"STAFF"'] := IntToStr(Staff);
|
---|
| 1355 | end;
|
---|
| 1356 | CallBroker;
|
---|
| 1357 | end;
|
---|
| 1358 | if(RPCBrokerV.Results.Count > 0) and
|
---|
| 1359 | (RPCBrokerV.Results[0] = '1') then
|
---|
| 1360 | Result := TRUE;
|
---|
| 1361 | end;
|
---|
| 1362 | end;
|
---|
| 1363 |
|
---|
| 1364 | function GAFURL: string;
|
---|
| 1365 | begin
|
---|
| 1366 | if(not uGAFURLChecked) then
|
---|
| 1367 | begin
|
---|
| 1368 | uGAFURL := sCallV('ORWPCE GAFURL', []);
|
---|
| 1369 | uGAFURLChecked := TRUE;
|
---|
| 1370 | end;
|
---|
| 1371 | Result := uGAFURL;
|
---|
| 1372 | end;
|
---|
| 1373 |
|
---|
| 1374 | function MHTestsOK: boolean;
|
---|
| 1375 | begin
|
---|
| 1376 | if(not uMHOKChecked) then
|
---|
| 1377 | begin
|
---|
| 1378 | uMHOK := (sCallV('ORWPCE MHTESTOK', []) = '1');
|
---|
| 1379 | uMHOKChecked := TRUE;
|
---|
| 1380 | end;
|
---|
| 1381 | Result := uMHOK;
|
---|
| 1382 | end;
|
---|
| 1383 |
|
---|
| 1384 | function MHTestAuthorized(Test: string): boolean;
|
---|
| 1385 | begin
|
---|
| 1386 | Result := (sCallV('ORWPCE MH TEST AUTHORIZED', [Test, User.DUZ]) = '1');
|
---|
| 1387 | end;
|
---|
| 1388 |
|
---|
| 1389 | function AnytimeEncounters: boolean;
|
---|
| 1390 | begin
|
---|
| 1391 | if uAnytimeEnc < 0 then
|
---|
| 1392 | uAnytimeEnc := ord(sCallV('ORWPCE ANYTIME', []) = '1');
|
---|
| 1393 | Result := BOOLEAN(uAnytimeEnc);
|
---|
| 1394 | end;
|
---|
| 1395 |
|
---|
| 1396 | function AutoCheckout(Loc: integer): boolean;
|
---|
| 1397 | begin
|
---|
| 1398 | if(uLastChkOutLoc <> Loc) then
|
---|
| 1399 | begin
|
---|
| 1400 | uLastChkOutLoc := Loc;
|
---|
| 1401 | uLastChkOut := (sCallV('ORWPCE ALWAYS CHECKOUT', [Loc]) = '1');
|
---|
| 1402 | end;
|
---|
| 1403 | Result := uLastChkOut;
|
---|
| 1404 | end;
|
---|
| 1405 |
|
---|
| 1406 | { encounter capture functions ------------------------------------------------ }
|
---|
| 1407 |
|
---|
| 1408 | function RequireExposures(ANote, ATitle: Integer): Boolean; {*RAB 3/22/99*}
|
---|
| 1409 | { returns true if a progress note should require the expossure questions to be answered }
|
---|
| 1410 | begin
|
---|
| 1411 | if ANote <= 0
|
---|
| 1412 | then Result := Piece(sCallV('TIU GET DOCUMENT PARAMETERS', ['0', ATitle]), U, 15) = '1'
|
---|
| 1413 | else Result := Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [ANote]), U, 15) = '1';
|
---|
| 1414 | end;
|
---|
| 1415 |
|
---|
| 1416 | function PromptForWorkload(ANote, ATitle: Integer; VisitCat: Char; StandAlone: boolean): Boolean;
|
---|
| 1417 | { returns true if a progress note should prompt for capture of encounter }
|
---|
| 1418 | var
|
---|
| 1419 | X: string;
|
---|
| 1420 |
|
---|
| 1421 | begin
|
---|
| 1422 | Result := FALSE;
|
---|
| 1423 | if (VisitCat <> 'A') and (VisitCat <> 'I') and (VisitCat <> 'T') then exit;
|
---|
| 1424 | if ANote <= 0 then
|
---|
| 1425 | X := sCallV('TIU GET DOCUMENT PARAMETERS', ['0', ATitle])
|
---|
| 1426 | else
|
---|
| 1427 | X := sCallV('TIU GET DOCUMENT PARAMETERS', [ANote]);
|
---|
| 1428 | if(Piece(X, U, 14) = '1') then exit; // Suppress DX/CPT param is TRUE - don't ask
|
---|
| 1429 | if StandAlone then
|
---|
| 1430 | Result := TRUE
|
---|
| 1431 | else
|
---|
| 1432 | Result := (Piece(X, U, 16) = '1'); // Check Ask DX/CPT param
|
---|
| 1433 | end;
|
---|
| 1434 |
|
---|
| 1435 | function IsCancelOrNoShow(ANote: integer): boolean;
|
---|
| 1436 | begin
|
---|
| 1437 | Result := (sCallV('ORWPCE CXNOSHOW', [ANote]) = '0');
|
---|
| 1438 | end;
|
---|
| 1439 |
|
---|
[460] | 1440 | function IsNonCountClinic(ALocation: integer): boolean;
|
---|
| 1441 | begin
|
---|
| 1442 | Result := (sCallV('ORWPCE1 NONCOUNT', [ALocation]) = '1');
|
---|
| 1443 | end;
|
---|
| 1444 |
|
---|
[459] | 1445 | function DefaultProvider(ALocation: integer; AUser: Int64; ADate: TFMDateTime;
|
---|
| 1446 | ANoteIEN: integer): string;
|
---|
| 1447 | begin
|
---|
| 1448 | Result := sCallV('TIU GET DEFAULT PROVIDER', [ALocation, AUser, ADate, ANoteIEN]);
|
---|
| 1449 | end;
|
---|
| 1450 |
|
---|
| 1451 | function IsUserAProvider(AUser: Int64; ADate: TFMDateTime): boolean;
|
---|
| 1452 | begin
|
---|
| 1453 | Result := (sCallV('TIU IS USER A PROVIDER?', [AUser, ADate]) = '1');
|
---|
| 1454 | end;
|
---|
| 1455 |
|
---|
| 1456 | //function HNCOK: boolean;
|
---|
| 1457 | //begin
|
---|
| 1458 | // if uHNCOK < 0 then
|
---|
| 1459 | // uHNCOK := ord(sCallV('ORWPCE HNCOK', []) = '1');
|
---|
| 1460 | // Result := boolean(uHNCOK);
|
---|
| 1461 | //end;
|
---|
| 1462 |
|
---|
| 1463 | initialization
|
---|
| 1464 | uLastLocation := 0;
|
---|
| 1465 | uVTypeLastLoc := 0;
|
---|
| 1466 | uVTypeLastDate := 0;
|
---|
| 1467 | uDiagnoses := TStringList.Create;
|
---|
| 1468 | uExams := TStringList.Create;
|
---|
| 1469 | uHealthFactors := TStringList.Create;
|
---|
| 1470 | uImmunizations := TStringList.Create;
|
---|
| 1471 | uPatientEds := TStringList.Create;
|
---|
| 1472 | uProcedures := TStringList.Create;
|
---|
| 1473 | uSkinTests := TStringList.Create;
|
---|
| 1474 | uVisitTypes := TStringList.Create;
|
---|
| 1475 | uVTypeForLoc := TStringList.Create;
|
---|
| 1476 | uProblems := TStringList.Create;
|
---|
| 1477 |
|
---|
| 1478 | finalization
|
---|
| 1479 | uDiagnoses.Free;
|
---|
| 1480 | uExams.Free;
|
---|
| 1481 | uHealthFactors.Free;
|
---|
| 1482 | uImmunizations.Free;
|
---|
| 1483 | uPatientEds.Free;
|
---|
| 1484 | uProcedures.Free;
|
---|
| 1485 | uSkinTests.free;
|
---|
| 1486 | uVisitTypes.Free;
|
---|
| 1487 | uVTypeForLoc.Free;
|
---|
| 1488 | uProblems.Free;
|
---|
| 1489 | KillObj(@uModifiers);
|
---|
| 1490 | KillObj(@uHasCPT);
|
---|
| 1491 |
|
---|
| 1492 | end.
|
---|