[459] | 1 | unit rODAllergy;
|
---|
| 2 |
|
---|
| 3 | {$O-}
|
---|
| 4 |
|
---|
| 5 | interface
|
---|
| 6 |
|
---|
| 7 | uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, dialogs, rMisc ;
|
---|
| 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 | function SearchForAllergies(StringToMatch: string): TStrings;
|
---|
| 52 | function SubsetofSymptoms(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 53 | function ODForAllergies: TStrings;
|
---|
| 54 | function GetCWADInfo(const DFN: string): string;
|
---|
| 55 | function SaveAllergy(EditRec: TAllergyRec): string;
|
---|
| 56 | function LoadAllergyForEdit(AllergyIEN: integer): TAllergyRec;
|
---|
| 57 | function SendARTBulletin(AFreeTextEntry: string; AComment: TStringList): string;
|
---|
| 58 | function RPCEnterNKAForPatient: string;
|
---|
| 59 |
|
---|
| 60 | // site parameter functions
|
---|
| 61 | function ARTPatchInstalled: boolean;
|
---|
| 62 | function GetSiteParams: TGMRASiteParams;
|
---|
| 63 | function MarkIDBand: boolean;
|
---|
| 64 | function RequireOriginatorComments: boolean;
|
---|
| 65 | function EnableErrorComments: boolean;
|
---|
| 66 |
|
---|
| 67 | implementation
|
---|
| 68 |
|
---|
| 69 | const
|
---|
| 70 | NO_YES: array[Boolean] of string = ('NO', 'YES');
|
---|
| 71 |
|
---|
| 72 | var
|
---|
| 73 | uARTPatchInstalled: TARTPatchInstalled;
|
---|
| 74 | uGMRASiteParams: TGMRASiteParams;
|
---|
| 75 |
|
---|
| 76 | function ODForAllergies: TStrings;
|
---|
| 77 | begin
|
---|
| 78 | CallV('ORWDAL32 DEF',[nil]);
|
---|
| 79 | Result := RPCBrokerV.Results;
|
---|
| 80 | end;
|
---|
| 81 |
|
---|
| 82 | function SearchForAllergies(StringToMatch: string): TStrings;
|
---|
| 83 | begin
|
---|
| 84 | CallV('ORWDAL32 ALLERGY MATCH',[StringToMatch]);
|
---|
| 85 | Result := RPCBrokerV.Results;
|
---|
| 86 | end;
|
---|
| 87 |
|
---|
| 88 | function SubsetofSymptoms(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 89 | begin
|
---|
| 90 | Callv('ORWDAL32 SYMPTOMS',[StartFrom, Direction]);
|
---|
| 91 | Result := RPCBrokerV.Results;
|
---|
| 92 | end;
|
---|
| 93 |
|
---|
| 94 | function GetCWADInfo(const DFN: string): string;
|
---|
| 95 | begin
|
---|
| 96 | Result := sCallV('ORWPT CWAD',[DFN]);
|
---|
| 97 | end;
|
---|
| 98 |
|
---|
| 99 | function LoadAllergyForEdit(AllergyIEN: integer): TAllergyRec;
|
---|
| 100 | var
|
---|
| 101 | Dest: TStringList;
|
---|
| 102 | EditRec: TAllergyRec;
|
---|
| 103 | x: string;
|
---|
| 104 | begin
|
---|
| 105 | Dest := TStringList.Create;
|
---|
| 106 | try
|
---|
| 107 | tCallV(Dest, 'ORWDAL32 LOAD FOR EDIT', [AllergyIEN]) ;
|
---|
| 108 | if Piece(RPCBrokerV.Results[0], U, 1) <> '-1' then
|
---|
| 109 | begin
|
---|
| 110 | with EditRec do
|
---|
| 111 | begin
|
---|
| 112 | Changed := False;
|
---|
| 113 | IEN := AllergyIEN;
|
---|
| 114 | CausativeAgent := ExtractDefault(Dest, 'CAUSATIVE AGENT');
|
---|
| 115 | AllergyType := ExtractDefault(Dest, 'ALLERGY TYPE');
|
---|
| 116 | NatureOfReaction := ExtractDefault(Dest, 'NATURE OF REACTION');
|
---|
| 117 | SignsSymptoms := TStringList.Create;
|
---|
| 118 | ExtractItems(SignsSymptoms, Dest, 'SIGN/SYMPTOMS');
|
---|
| 119 | MixedCaseByPiece(SignsSymptoms, U, 4);
|
---|
| 120 | x := ExtractDefault(Dest, 'ORIGINATOR');
|
---|
| 121 | Originator := StrToInt64Def(Piece(x, U, 1), 0);
|
---|
| 122 | OriginatorName := Piece(x, U, 2);
|
---|
| 123 | Originated := StrToFMDateTime(ExtractDefault(Dest, 'ORIGINATED'));
|
---|
| 124 | Comments := TStringList.Create;
|
---|
| 125 | ExtractText(Comments, Dest, 'COMMENTS');
|
---|
| 126 | IDBandMarked := TStringList.Create;
|
---|
| 127 | ExtractItems(IDBandMarked, Dest, 'ID BAND MARKED');
|
---|
| 128 | ChartMarked := TStringList.Create;
|
---|
| 129 | ExtractItems(ChartMarked, Dest, 'CHART MARKED');
|
---|
| 130 | //x := ExtractDefault(Dest, 'VERIFIER');
|
---|
| 131 | //Verifier := StrToInt64Def(Piece(x, U, 1), 0);
|
---|
| 132 | //VerifierName := Piece(x, U, 2);
|
---|
| 133 | //x := ExtractDefault(Dest, 'VERIFIED');
|
---|
| 134 | //Verified := Piece(x, U, 1) = 'YES';
|
---|
| 135 | //if Verified then
|
---|
| 136 | // VerifiedDateTime := StrToFMDateTime(Piece(x, U, 2));
|
---|
| 137 | x := ExtractDefault(Dest, 'ENTERED IN ERROR');
|
---|
| 138 | EnteredInError := Piece(x, U, 1) = 'YES';
|
---|
| 139 | DateEnteredInError := StrToFloatDef(Piece(x, U, 2), 0);
|
---|
| 140 | UserEnteringInError := StrToInt64Def(Piece(x, U, 3), 0);
|
---|
| 141 | ErrorComments := TStringList.Create;
|
---|
| 142 | Observed_Historical := ExtractDefault(Dest, 'OBS/HIST');
|
---|
| 143 | Observations := TStringList.Create;
|
---|
| 144 | ExtractText(Observations, Dest, 'OBSERVATIONS');
|
---|
| 145 | //ReactionDate := StrToFMDateTime(Piece(ExtractDefault(Dest, 'REACTDT'), U, 3));
|
---|
| 146 | //Severity := Piece(ExtractDefault(Dest, 'SEVERITY'), U, 3);
|
---|
| 147 | NoKnownAllergies := (StrToIntDef(Piece(ExtractDefault(Dest, 'NKA'), U, 3), 0) > 0);
|
---|
| 148 | NewComments := TStringList.Create;
|
---|
| 149 | end;
|
---|
| 150 | end
|
---|
| 151 | else
|
---|
| 152 | EditRec.IEN := -1;
|
---|
| 153 | Result := EditRec;
|
---|
| 154 | finally
|
---|
| 155 | Dest.Free;
|
---|
| 156 | end;
|
---|
| 157 | end;
|
---|
| 158 |
|
---|
| 159 | function SaveAllergy(EditRec: TAllergyRec): string;
|
---|
| 160 | var
|
---|
| 161 | i: integer;
|
---|
| 162 | begin
|
---|
| 163 | with RPCBrokerV, EditRec do
|
---|
| 164 | begin
|
---|
| 165 | ClearParameters := True;
|
---|
| 166 | RemoteProcedure := 'ORWDAL32 SAVE ALLERGY';
|
---|
| 167 | Param[0].PType := literal;
|
---|
| 168 | Param[0].Value := IntToStr(IEN);
|
---|
| 169 | Param[1].PType := literal;
|
---|
| 170 | Param[1].Value := Patient.DFN;
|
---|
| 171 | Param[2].PType := list;
|
---|
| 172 | with Param[2] do
|
---|
| 173 | begin
|
---|
| 174 | if NoKnownAllergies then
|
---|
| 175 | Mult['"GMRANKA"'] := NO_YES[NoKnownAllergies];
|
---|
| 176 | if CausativeAgent <> '' then
|
---|
| 177 | Mult['"GMRAGNT"'] := CausativeAgent;
|
---|
| 178 | if AllergyType <> '' then
|
---|
| 179 | Mult['"GMRATYPE"'] := AllergyType ;
|
---|
| 180 | if NatureOfReaction <> '' then
|
---|
| 181 | Mult['"GMRANATR"'] := NatureOfReaction ;
|
---|
| 182 | if Originator > 0 then
|
---|
| 183 | Mult['"GMRAORIG"'] := IntToStr(Originator);
|
---|
| 184 | if Originated > 0 then
|
---|
| 185 | Mult['"GMRAORDT"'] := FloatToStr(Originated);
|
---|
| 186 | with SignsSymptoms do if Count > 0 then
|
---|
| 187 | begin
|
---|
| 188 | Mult['"GMRASYMP",0'] := IntToStr(Count);
|
---|
| 189 | for i := 0 to Count - 1 do
|
---|
| 190 | Mult['"GMRASYMP",' + IntToStr(i+1)] := Pieces(Strings[i], U, 1, 5);
|
---|
| 191 | end;
|
---|
| 192 | //if Verified then
|
---|
| 193 | // Mult['"GMRAVER"'] := NO_YES[Verified];
|
---|
| 194 | //if Verifier > 0 then
|
---|
| 195 | // Mult['"GMRAVERF"'] := IntToStr(Verifier);
|
---|
| 196 | //if VerifiedDateTime > 0 then
|
---|
| 197 | // Mult['"GMRAVERD"'] := FloatToStr(VerifiedDateTime);
|
---|
| 198 | if EnteredInError then
|
---|
| 199 | begin
|
---|
| 200 | Mult['"GMRAERR"'] := NO_YES[EnteredInError];
|
---|
| 201 | Mult['"GMRAERRBY"'] := IntToStr(UserEnteringInError);
|
---|
| 202 | Mult['"GMRAERRDT"'] := FloatToStr(DateEnteredInError);
|
---|
| 203 | with ErrorComments do if Count > 0 then
|
---|
| 204 | begin
|
---|
| 205 | Mult['"GMRAERRCMTS",0'] := IntToStr(Count);
|
---|
| 206 | for i := 0 to Count - 1 do
|
---|
| 207 | Mult['"GMRAERRCMTS",' + IntToStr(i+1)] := Strings[i];
|
---|
| 208 | end;
|
---|
| 209 | end ;
|
---|
| 210 | with ChartMarked do if Count > 0 then
|
---|
| 211 | begin
|
---|
| 212 | Mult['"GMRACHT",0'] := IntToStr(Count);
|
---|
| 213 | for i := 0 to Count - 1 do
|
---|
| 214 | Mult['"GMRACHT",' + IntToStr(i+1)] := Strings[i];
|
---|
| 215 | end;
|
---|
| 216 | with IDBandMarked do if Count > 0 then
|
---|
| 217 | begin
|
---|
| 218 | Mult['"GMRAIDBN",0'] := IntToStr(Count);
|
---|
| 219 | for i := 0 to Count - 1 do
|
---|
| 220 | Mult['"GMRAIDBN",' + IntToStr(i+1)] := Strings[i];
|
---|
| 221 | end;
|
---|
| 222 | if Length(Observed_Historical) > 0 then
|
---|
| 223 | Mult['"GMRAOBHX"'] := Observed_Historical;
|
---|
| 224 | if ReactionDate > 0 then
|
---|
| 225 | Mult['"GMRARDT"'] := FloatToStr(ReactionDate);
|
---|
| 226 | if Length(Severity) > 0 then
|
---|
| 227 | Mult['"GMRASEVR"'] := Severity;
|
---|
| 228 | with NewComments do if Count > 0 then
|
---|
| 229 | begin
|
---|
| 230 | Mult['"GMRACMTS",0'] := IntToStr(Count);
|
---|
| 231 | for i := 0 to Count - 1 do
|
---|
| 232 | Mult['"GMRACMTS",' + IntToStr(i+1)] := Strings[i];
|
---|
| 233 | end;
|
---|
| 234 | end;
|
---|
| 235 | CallBroker;
|
---|
| 236 | Result := Results[0];
|
---|
| 237 | end;
|
---|
| 238 | end;
|
---|
| 239 |
|
---|
| 240 | function RPCEnterNKAForPatient: string;
|
---|
| 241 | begin
|
---|
| 242 | with RPCBrokerV do
|
---|
| 243 | begin
|
---|
| 244 | ClearParameters := True;
|
---|
| 245 | RemoteProcedure := 'ORWDAL32 SAVE ALLERGY';
|
---|
| 246 | Param[0].PType := literal;
|
---|
| 247 | Param[0].Value := '0';
|
---|
| 248 | Param[1].PType := literal;
|
---|
| 249 | Param[1].Value := Patient.DFN;
|
---|
| 250 | Param[2].PType := list;
|
---|
| 251 | with Param[2] do
|
---|
| 252 | Mult['"GMRANKA"'] := 'YES';
|
---|
| 253 | CallBroker;
|
---|
| 254 | Result := Results[0];
|
---|
| 255 | end;
|
---|
| 256 | end;
|
---|
| 257 |
|
---|
| 258 | function SendARTBulletin(AFreeTextEntry: string; AComment: TStringList): string;
|
---|
| 259 | var
|
---|
| 260 | i: integer;
|
---|
| 261 | begin
|
---|
| 262 | with RPCBrokerV do
|
---|
| 263 | begin
|
---|
| 264 | ClearParameters := True;
|
---|
| 265 | RemoteProcedure := 'ORWDAL32 SEND BULLETIN';
|
---|
| 266 | Param[0].PType := literal;
|
---|
| 267 | Param[0].Value := User.DUZ;
|
---|
| 268 | Param[1].PType := literal;
|
---|
| 269 | Param[1].Value := Patient.DFN;
|
---|
| 270 | Param[2].PType := literal;
|
---|
| 271 | Param[2].Value := AFreeTextEntry;
|
---|
| 272 | if AComment.Count > 0 then with Param[3] do
|
---|
| 273 | begin
|
---|
| 274 | PType := list;
|
---|
| 275 | for i := 0 to AComment.Count - 1 do
|
---|
| 276 | Mult[IntToStr(Succ(i)) + ',0'] := AComment[i];
|
---|
| 277 | Mult['0'] := '^^' + IntToStr(AComment.Count);
|
---|
| 278 | end;
|
---|
| 279 | CallBroker;
|
---|
| 280 | Result := Results[0];
|
---|
| 281 | end;
|
---|
| 282 | end;
|
---|
| 283 |
|
---|
| 284 | // Site parameter functions
|
---|
| 285 |
|
---|
| 286 | function ARTPatchInstalled: boolean;
|
---|
| 287 | begin
|
---|
| 288 | with uARTPatchInstalled do
|
---|
| 289 | if not PatchChecked then
|
---|
| 290 | begin
|
---|
| 291 | PatchInstalled := ServerHasPatch('GMRA*4.0*21');
|
---|
| 292 | PatchChecked := True;
|
---|
| 293 | end;
|
---|
| 294 | Result := uARTPatchInstalled.PatchInstalled;
|
---|
| 295 | end;
|
---|
| 296 |
|
---|
| 297 | function GetSiteParams: TGMRASiteParams;
|
---|
| 298 | var
|
---|
| 299 | x: string;
|
---|
| 300 | begin
|
---|
| 301 | with uGMRASiteParams do
|
---|
| 302 | if not ParamsSet then
|
---|
| 303 | begin
|
---|
| 304 | x := sCallV('ORWDAL32 SITE PARAMS', [nil]);
|
---|
| 305 | MarkIDBandFlag := (Piece(x, U, 5) <> '0');
|
---|
| 306 | OriginatorCommentsRequired := (Piece(x, U, 4) = '1');
|
---|
| 307 | ErrorCommentsEnabled := (Piece(x, U, 11) = '1');
|
---|
| 308 | ParamsSet := True;
|
---|
| 309 | end;
|
---|
| 310 | Result := uGMRASiteParams;
|
---|
| 311 | end;
|
---|
| 312 |
|
---|
| 313 | function MarkIDBand: boolean;
|
---|
| 314 | begin
|
---|
| 315 | Result := GetSiteParams.MarkIDBandFlag;
|
---|
| 316 | end;
|
---|
| 317 |
|
---|
| 318 | function RequireOriginatorComments: boolean;
|
---|
| 319 | begin
|
---|
| 320 | Result := GetSiteParams.OriginatorCommentsRequired;
|
---|
| 321 | end;
|
---|
| 322 |
|
---|
| 323 | function EnableErrorComments: boolean;
|
---|
| 324 | begin
|
---|
| 325 | Result := GetSiteParams.ErrorCommentsEnabled;
|
---|
| 326 | end;
|
---|
| 327 |
|
---|
| 328 | end.
|
---|