Module

rODAllergy

Path

C:\CPRS\CPRS30\Orders\rODAllergy.pas

Last Modified

7/15/2014 3:26:42 PM

Units Used in Interface

Name Comments
fNotes -
rCore -
rMisc -
uCore -

Functions

Name Owner Declaration Scope Comments
ARTPatchInstalled - function ARTPatchInstalled: boolean; Interfaced
Site parameter functions
Site parameter functions
EnableErrorComments - function EnableErrorComments: boolean; Interfaced -
GetAllergyTitleText - function GetAllergyTitleText: string; Interfaced -
GetCWADInfo - function GetCWADInfo(const DFN: string): string; Interfaced -
GetSiteParams - function GetSiteParams: TGMRASiteParams; Interfaced -
IsARTClinicalUser - function IsARTClinicalUser(var AMessage: string): boolean; Interfaced
Function IsARTClinicalUser(var AMessage: string): boolean;
const
  TX_NO_AUTH = 'You are not authorized to perform this action.' + CRLF +
               'Either the ORES or ORELSE key is required.';
begin
  Result := (User.UserClass > UC_CLERK);     // User has ORES or ORELSE key
  if not Result then AMessage := TX_NO_AUTH else AMessage := '';
end;
LoadAllergyForEdit - function LoadAllergyForEdit(AllergyIEN: integer): TAllergyRec; Interfaced -
MarkIDBand - function MarkIDBand: boolean; Interfaced -
ODForAllergies - function ODForAllergies: TStrings; Interfaced -
RequireOriginatorComments - function RequireOriginatorComments: boolean; Interfaced -
RPCEnterNKAForPatient - function RPCEnterNKAForPatient: string; Interfaced -
SaveAllergy - function SaveAllergy(EditRec: TAllergyRec): string; Interfaced -
SearchForAllergies - function SearchForAllergies(StringToMatch: string): TStrings; Interfaced -
SendARTBulletin - function SendARTBulletin(AFreeTextEntry: string; AComment: TStringList): string; Interfaced -
SubsetofSymptoms - function SubsetofSymptoms(const StartFrom: string; Direction: Integer): TStrings; Interfaced -

Global Variables

Name Type Declaration Comments
uARTClinUser uARTClinUser: TARTClinUser; -
uARTPatchInstalled uARTPatchInstalled: TARTPatchInstalled; -
uGMRASiteParams uGMRASiteParams: TGMRASiteParams; -

Constants

Name Declaration Scope Comments
NO_YES array[Boolean] of string = ('NO', 'YES') Global -


Module Source

1     unit rODAllergy;
2     
3     {$O-}
4     
5     interface
6     
7     uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, dialogs, rMisc,fNotes ;
8     
9     type
10      TAllergyRec = record
11        Changed:             boolean;
12        IEN:                 Integer;
13        CausativeAgent:      string;
14        AllergyType:         string;
15        NatureOfReaction:    string;
16        SignsSymptoms:       TStringList;
17        Originator:          int64;
18        OriginatorName:      string;
19        Originated:          TFMDateTime;
20        Comments:            TStringList;
21        IDBandMarked:        TStringList;
22        ChartMarked:         TStringList;
23        Verifier:            int64;
24        VerifierName:        string;
25        Verified:            boolean;
26        VerifiedDateTime:    TFMDateTime;
27        EnteredInError:      boolean;
28        DateEnteredInError:  TFMDateTime;
29        UserEnteringInError: int64;
30        ErrorComments:       TStringList;
31        Observed_Historical: string;
32        Observations:        TStringList;
33        ReactionDate:        TFMDateTime;
34        Severity:            string;
35        NoKnownAllergies:    Boolean;
36        NewComments:         TStringList;
37      end;
38    
39      TARTPatchInstalled = record
40        PatchInstalled: boolean;
41        PatchChecked: boolean;
42      end;
43    
44      TGMRASiteParams = record
45        MarkIDBandFlag:              Boolean;
46        OriginatorCommentsRequired:  Boolean;
47        ErrorCommentsEnabled:        Boolean;
48        ParamsSet:                   Boolean;
49      end;
50    
51      TARTClinUser = record
52        IsClinUser: boolean;
53        ReasonFailed: string;
54        AccessChecked: boolean;
55      end;
56    
57    function SearchForAllergies(StringToMatch: string): TStrings;
58    function SubsetofSymptoms(const StartFrom: string; Direction: Integer): TStrings;
59    function ODForAllergies: TStrings;
60    function GetCWADInfo(const DFN: string): string;
61    function SaveAllergy(EditRec: TAllergyRec): string;
62    function LoadAllergyForEdit(AllergyIEN: integer): TAllergyRec;
63    function SendARTBulletin(AFreeTextEntry: string; AComment: TStringList): string;
64    function RPCEnterNKAForPatient: string;
65    
66    // site parameter functions
67    function ARTPatchInstalled: boolean;
68    function GetSiteParams: TGMRASiteParams;
69    function MarkIDBand: boolean;
70    function RequireOriginatorComments: boolean;
71    function EnableErrorComments: boolean;
72    function IsARTClinicalUser(var AMessage: string): boolean;
73    function GetAllergyTitleText: string;
74    
75    implementation
76    
77    const
78      NO_YES: array[Boolean] of string = ('NO', 'YES');
79    
80    var
81      uARTPatchInstalled: TARTPatchInstalled;
82      uGMRASiteParams: TGMRASiteParams;
83      uARTClinUser: TARTClinUser;
84    
85    function ODForAllergies: TStrings;
86    begin
87      CallV('ORWDAL32 DEF',[nil]);
88      Result := RPCBrokerV.Results;
89    end;
90    
91    function SearchForAllergies(StringToMatch: string): TStrings;
92    begin
93      CallV('ORWDAL32 ALLERGY MATCH',[StringToMatch]);
94      Result := RPCBrokerV.Results;
95    end;
96    
97    function SubsetofSymptoms(const StartFrom: string; Direction: Integer): TStrings;
98    begin
99      Callv('ORWDAL32 SYMPTOMS',[StartFrom, Direction]);
100     Result := RPCBrokerV.Results;
101   end;
102   
103   function GetCWADInfo(const DFN: string): string;
104   begin
105     Result := sCallV('ORWPT CWAD',[DFN]);
106   end;
107   
108   function LoadAllergyForEdit(AllergyIEN: integer): TAllergyRec;
109   var
110     Dest: TStringList;
111     EditRec: TAllergyRec;
112     x: string;
113   begin
114     Dest := TStringList.Create;
115     try
116       tCallV(Dest, 'ORWDAL32 LOAD FOR EDIT', [AllergyIEN]) ;
117       if Piece(RPCBrokerV.Results[0], U, 1) <> '-1' then
118       begin
119         with EditRec do
120           begin
121             Changed             := False;
122             IEN                 := AllergyIEN;
123             CausativeAgent      := ExtractDefault(Dest, 'CAUSATIVE AGENT');
124             AllergyType         := ExtractDefault(Dest, 'ALLERGY TYPE');
125             NatureOfReaction    := ExtractDefault(Dest, 'NATURE OF REACTION');
126             SignsSymptoms       := TStringList.Create;
127             ExtractItems(SignsSymptoms, Dest, 'SIGN/SYMPTOMS');
128             MixedCaseByPiece(SignsSymptoms, U, 4);
129             x                   := ExtractDefault(Dest, 'ORIGINATOR');
130             Originator          := StrToInt64Def(Piece(x, U, 1), 0);
131             OriginatorName      := Piece(x, U, 2);
132             Originated          := StrToFMDateTime(ExtractDefault(Dest, 'ORIGINATED'));
133             Comments            := TStringList.Create;
134             ExtractText(Comments, Dest, 'COMMENTS');
135             IDBandMarked        := TStringList.Create;
136             ExtractItems(IDBandMarked, Dest, 'ID BAND MARKED');
137             ChartMarked         := TStringList.Create;
138             ExtractItems(ChartMarked, Dest, 'CHART MARKED');
139             //x                   := ExtractDefault(Dest, 'VERIFIER');
140             //Verifier            := StrToInt64Def(Piece(x, U, 1), 0);
141             //VerifierName        := Piece(x, U, 2);
142             //x                   := ExtractDefault(Dest, 'VERIFIED');
143             //Verified            := Piece(x, U, 1) = 'YES';
144             //if Verified then
145             //  VerifiedDateTime  := StrToFMDateTime(Piece(x, U, 2));
146             x                   := ExtractDefault(Dest, 'ENTERED IN ERROR');
147             EnteredInError      := Piece(x, U, 1) = 'YES';
148             DateEnteredInError  := StrToFloatDef(Piece(x, U, 2), 0);
149             UserEnteringInError := StrToInt64Def(Piece(x, U, 3), 0);
150             ErrorComments       := TStringList.Create;
151             Observed_Historical := ExtractDefault(Dest, 'OBS/HIST');
152             Observations        := TStringList.Create;
153             ExtractText(Observations, Dest, 'OBSERVATIONS');
154             //ReactionDate        := StrToFMDateTime(Piece(ExtractDefault(Dest, 'REACTDT'), U, 3));
155             //Severity            := Piece(ExtractDefault(Dest, 'SEVERITY'), U, 3);
156             NoKnownAllergies    := (StrToIntDef(Piece(ExtractDefault(Dest, 'NKA'), U, 3), 0) > 0);
157             NewComments         := TStringList.Create;
158           end;
159       end
160       else
161         EditRec.IEN := -1;
162       Result := EditRec;
163     finally
164       Dest.Free;
165     end;
166   end;
167   
168   function SaveAllergy(EditRec: TAllergyRec): string;
169   var
170     i: integer;
171   begin
172   
173     with RPCBrokerV, EditRec do
174       begin
175         ClearParameters := True;
176         RemoteProcedure := 'ORWDAL32 SAVE ALLERGY';
177         Param[0].PType := literal;
178         Param[0].Value := IntToStr(IEN);
179         Param[1].PType := literal;
180         Param[1].Value := Patient.DFN;
181         Param[2].PType := list;
182         with Param[2] do
183           begin
184             if NoKnownAllergies then
185               Mult['"GMRANKA"']  := NO_YES[NoKnownAllergies];
186             if CausativeAgent <> '' then
187               Mult['"GMRAGNT"']  := CausativeAgent;
188             if AllergyType <> '' then
189               Mult['"GMRATYPE"'] := AllergyType ;
190             if NatureOfReaction <> '' then
191               Mult['"GMRANATR"'] := NatureOfReaction ;
192             if Originator > 0 then
193               Mult['"GMRAORIG"'] := IntToStr(Originator);
194             if Originated > 0 then
195               Mult['"GMRAORDT"'] := FloatToStr(Originated);
196             with SignsSymptoms do if Count > 0 then
197               begin
198                 Mult['"GMRASYMP",0'] := IntToStr(Count);
199                 for i := 0 to Count - 1 do
200                   Mult['"GMRASYMP",' + IntToStr(i+1)] := Pieces(Strings[i], U, 1, 5);
201               end;
202             //if Verified then
203             //  Mult['"GMRAVER"']  := NO_YES[Verified];
204             //if Verifier > 0 then
205             //  Mult['"GMRAVERF"'] := IntToStr(Verifier);
206             //if VerifiedDateTime > 0 then
207             //  Mult['"GMRAVERD"'] := FloatToStr(VerifiedDateTime);
208             if EnteredInError then
209               begin
210                 Mult['"GMRAERR"']  := NO_YES[EnteredInError];
211                 Mult['"GMRAERRBY"']  := IntToStr(UserEnteringInError);
212                 Mult['"GMRAERRDT"']  := FloatToStr(DateEnteredInError);
213                 with ErrorComments do if Count > 0 then
214                   begin
215                     Mult['"GMRAERRCMTS",0'] := IntToStr(Count);
216                     for i := 0 to Count - 1 do
217                       Mult['"GMRAERRCMTS",' + IntToStr(i+1)] := Strings[i];
218                   end;
219   
220               end ;
221             with ChartMarked do if Count > 0 then
222               begin
223                 Mult['"GMRACHT",0'] := IntToStr(Count);
224                 for i := 0 to Count - 1 do
225                   Mult['"GMRACHT",' + IntToStr(i+1)] := Strings[i];
226               end;
227             with IDBandMarked do if Count > 0 then
228               begin
229                 Mult['"GMRAIDBN",0'] := IntToStr(Count);
230                 for i := 0 to Count - 1 do
231                   Mult['"GMRAIDBN",' + IntToStr(i+1)] := Strings[i];
232               end;
233             if Length(Observed_Historical) > 0 then
234               Mult['"GMRAOBHX"'] :=  Observed_Historical;
235             if ReactionDate > 0 then
236               Mult['"GMRARDT"']  :=  FloatToStr(ReactionDate);
237             if Length(Severity) > 0 then
238               Mult['"GMRASEVR"'] :=  Severity;
239             with NewComments do if Count > 0 then
240               begin
241                 Mult['"GMRACMTS",0'] := IntToStr(Count);
242                 for i := 0 to Count - 1 do
243                   Mult['"GMRACMTS",' + IntToStr(i+1)] := Strings[i];
244               end;
245           end;
246           CallBroker;
247           Result := Results[0];
248           // Include "Allergy Entered in Error" items require signature list.
249           //cq-8002  -piece 2 is Allergy Entered in Error (IEN)
250          // code added allowing v27 GUI changes to continue if M change is not released prior.
251          //cq-14842 -  add observed/drug allergies to the fReview/fSignOrders forms for signature.
252          if Length(Piece(Result,'^',2))> 0 then
253            Changes.Add(10, Piece(Result,'^',2), GetAllergyTitleText, '', 1)
254          else
255             exit;
256           end;
257   end;
258   
259   function RPCEnterNKAForPatient: string;
260   begin
261     with RPCBrokerV do
262       begin
263         ClearParameters := True;
264         RemoteProcedure := 'ORWDAL32 SAVE ALLERGY';
265         Param[0].PType := literal;
266         Param[0].Value := '0';
267         Param[1].PType := literal;
268         Param[1].Value := Patient.DFN;
269         Param[2].PType := list;
270         with Param[2] do
271           Mult['"GMRANKA"']  := 'YES';
272         CallBroker;
273         Result := Results[0];
274       end;
275   end;
276   
277   function SendARTBulletin(AFreeTextEntry: string; AComment: TStringList): string;
278   var
279     i: integer;
280   begin
281     with RPCBrokerV do
282       begin
283         ClearParameters := True;
284         RemoteProcedure := 'ORWDAL32 SEND BULLETIN';
285         Param[0].PType := literal;
286         Param[0].Value := User.DUZ;
287         Param[1].PType := literal;
288         Param[1].Value := Patient.DFN;
289         Param[2].PType := literal;
290         Param[2].Value := AFreeTextEntry;
291         if AComment.Count > 0 then with Param[3] do
292           begin
293             PType := list;
294             for i := 0 to AComment.Count - 1 do
295               Mult[IntToStr(Succ(i)) + ',0'] := AComment[i];
296             Mult['0'] := '^^' + IntToStr(AComment.Count);
297           end;
298         CallBroker;
299         Result := Results[0];
300       end;
301   end;
302   
303   // Site parameter functions
304   
305   function ARTPatchInstalled: boolean;
306   begin
307     with uARTPatchInstalled do
308       if not PatchChecked then
309         begin
310           PatchInstalled := ServerHasPatch('GMRA*4.0*21');
311           PatchChecked := True;
312         end;
313     Result := uARTPatchInstalled.PatchInstalled;
314   end;
315   
316   function GetSiteParams: TGMRASiteParams;
317   var
318     x: string;
319   begin
320     with uGMRASiteParams do
321       if not ParamsSet then
322         begin
323           x := sCallV('ORWDAL32 SITE PARAMS', [nil]);
324           MarkIDBandFlag := (Piece(x, U, 5) <> '0');
325           OriginatorCommentsRequired := (Piece(x, U, 4) = '1');
326           ErrorCommentsEnabled := (Piece(x, U, 11) = '1');
327           ParamsSet := True;
328         end;
329     Result := uGMRASiteParams;
330   end;
331   
332   function MarkIDBand: boolean;
333   begin
334     Result := GetSiteParams.MarkIDBandFlag;
335   end;
336   
337   function RequireOriginatorComments: boolean;
338   begin
339     Result := GetSiteParams.OriginatorCommentsRequired;
340   end;
341   
342   function EnableErrorComments: boolean;
343   begin
344     Result := GetSiteParams.ErrorCommentsEnabled;
345   end;
346   
347   (*function IsARTClinicalUser(var AMessage: string): boolean;
348   const
349     TX_NO_AUTH = 'You are not authorized to perform this action.' + CRLF +
350                  'Either the ORES or ORELSE key is required.';
351   begin
352     Result := (User.UserClass > UC_CLERK);     // User has ORES or ORELSE key
353     if not Result then AMessage := TX_NO_AUTH else AMessage := '';
354   end;*)
355   
356   function IsARTClinicalUser(var AMessage: string): boolean;
357   const
358     TX_NO_AUTH = 'You are not authorized to perform this action.' + CRLF;
359   var
360     x: string;
361   begin
362     with uARTClinUser do
363     begin
364       if not AccessChecked then
365         begin
366           x := sCallV('ORWDAL32 CLINUSER',[nil]);
367           IsClinUser := (Piece(x, U, 1) = '1');
368           if not IsClinUser then ReasonFailed := TX_NO_AUTH + Piece(x, U, 2) else ReasonFailed := '';
369           AccessChecked := True;
370         end;
371       Result   := IsClinUser;
372       AMessage := ReasonFailed ;
373     end;
374   end;
375   
376   function GetAllergyTitleText: string;
377   begin
378       Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(floatToStr(FMToday))) +
379                 '  ' + 'Adverse React/Allergy' + ', ' + Encounter.LocationName + ', ' + User.Name;
380   end;
381   
382   end.

Module Calls (2 levels)


rODAllergy
 ├rCore
 │ └uCore
 ├uCore...
 └rMisc
   └fOrders

Module Called-By (2 levels)


                  rODAllergy
                   uOrders┤ 
                   uCore┤ │ 
                 fODBase┤ │ 
                 rODBase┤ │ 
                  fFrame┤ │ 
                 fOrders┤ │ 
             fOrdersSign┤ │ 
                   fMeds┤ │ 
               fARTAllgy┤ │ 
                  fNotes┤ │ 
               fConsults┤ │ 
         fReminderDialog┤ │ 
                 fReview┤ │ 
            fOrdersRenew┤ │ 
               fOrdersCV┤ │ 
                 fODMeds┤ │ 
                 fOMNavA┤ │ 
         fOrderSaveQuick┤ │ 
                  fOMSet┤ │ 
          fOrdersRelease┤ │ 
                 fOMHTML┤ │ 
               fODMedNVA┤ │ 
fODChangeUnreleasedRenew┤ │ 
          fOrdersOnChart┤ │ 
         fODReleaseEvent┤ │ 
               fODActive┘ │ 
                 fFrame...┤ 
                    fCover┤ 
               fFrame...┤ │ 
            fARTAllgy...┘ │ 
                 fAllgyBox┤ 
               fCover...┘ │ 
              fARTAllgy...┤ 
                fAllgyFind┤ 
            fARTAllgy...┤ │ 
                fODAllgy┘ │ 
                  fODAllgy┘