[459] | 1 | unit rConsults;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, dialogs, uConsults, rTIU, uTIU;
|
---|
| 6 |
|
---|
| 7 | {Consult Titles }
|
---|
| 8 | function DfltConsultTitle: integer;
|
---|
| 9 | function DfltConsultTitleName: string;
|
---|
| 10 | function DfltClinProcTitle: integer;
|
---|
| 11 | function DfltClinProcTitleName: string;
|
---|
| 12 | function IdentifyConsultsClass: integer;
|
---|
| 13 | function IdentifyClinProcClass: integer;
|
---|
| 14 | procedure ListConsultTitlesShort(Dest: TStrings);
|
---|
| 15 | procedure ListClinProcTitlesShort(Dest: TStrings);
|
---|
| 16 | function SubSetOfConsultTitles(const StartFrom: string; Direction: Integer; IDNoteTitlesOnly: boolean): TStrings;
|
---|
| 17 | function SubSetOfClinProcTitles(const StartFrom: string; Direction: Integer; IDNoteTitlesOnly: boolean): TStrings;
|
---|
| 18 | procedure ResetConsultTitles;
|
---|
| 19 | procedure ResetClinProcTitles;
|
---|
| 20 |
|
---|
| 21 | { Data Retrieval }
|
---|
| 22 | procedure GetConsultsList(Dest: TStrings; Early, Late: double;
|
---|
| 23 | Service, Status: string; SortAscending: Boolean);
|
---|
| 24 | procedure LoadConsultDetail(Dest: TStrings; IEN: integer) ;
|
---|
| 25 | function GetCurrentContext: TSelectContext;
|
---|
| 26 | procedure SaveCurrentContext(AContext: TSelectContext) ;
|
---|
| 27 | procedure DisplayResults(Dest: TStrings; IEN: integer) ;
|
---|
| 28 | procedure GetConsultRec(IEN: integer) ;
|
---|
| 29 | function ShowSF513(ConsultIEN: integer): TStrings ;
|
---|
| 30 | procedure PrintSF513ToDevice(AConsult: Integer; const ADevice: string; ChartCopy: string;
|
---|
| 31 | var ErrMsg: string);
|
---|
| 32 | function GetFormattedSF513(AConsult: Integer; ChartCopy: string): TStrings;
|
---|
| 33 | function UnresolvedConsultsExist: boolean;
|
---|
| 34 |
|
---|
| 35 | {list box fillers}
|
---|
| 36 | function SubSetOfStatus: TStrings;
|
---|
| 37 | function SubSetOfUrgencies(ConsultIEN: integer): TStrings;
|
---|
| 38 | function LoadServiceList(Purpose: integer): TStrings ;
|
---|
| 39 | function LoadServiceListWithSynonyms(Purpose: integer): TStrings ; overload;
|
---|
| 40 | function LoadServiceListWithSynonyms(Purpose, ConsultIEN: integer): TStrings ; overload;
|
---|
| 41 | function SubSetOfServices(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 42 | function FindConsult(ConsultIEN: integer): string ;
|
---|
| 43 |
|
---|
| 44 | {user access level functions}
|
---|
| 45 | function ConsultServiceUser(ServiceIEN: integer; DUZ: int64): boolean ;
|
---|
| 46 | function GetActionMenuLevel(ConsultIEN: integer): TMenuAccessRec ;
|
---|
| 47 |
|
---|
| 48 | {consult result functions}
|
---|
| 49 | function GetAssignableMedResults(ConsultIEN: integer): TStrings;
|
---|
| 50 | function GetRemovableMedResults(ConsultIEN: integer): TStrings;
|
---|
| 51 | function GetDetailedMedicineResults(ResultID: string): TStrings;
|
---|
| 52 | procedure AttachMedicineResult(ConsultIEN: integer; ResultID: string; DateTime: TFMDateTime; ResponsiblePerson: int64; AlertTo: string);
|
---|
| 53 | procedure RemoveMedicineResult(ConsultIEN: integer; ResultID: string; DateTime: TFMDateTime; ResponsiblePerson: int64);
|
---|
| 54 |
|
---|
| 55 | {Consult Request Actions}
|
---|
| 56 | procedure ReceiveConsult(Dest: TStrings; IEN: integer; ReceivedBy: int64; RcptDate: TFMDateTime; Comments: TStrings);
|
---|
| 57 | procedure ScheduleConsult(Dest: TStrings; IEN: integer; ScheduledBy: Int64; SchdDate: TFMDateTime; Alert: integer;
|
---|
| 58 | AlertTo: string; Comments: TStrings);
|
---|
| 59 | procedure DiscontinueConsult(Dest: TStrings; IEN: integer; DiscontinuedBy: int64;
|
---|
| 60 | DiscontinueDate: TFMDateTime; Comments: TStrings);
|
---|
| 61 | procedure DenyConsult(Dest: TStrings; IEN: integer; DeniedBy: int64;
|
---|
| 62 | DenialDate: TFMDateTime; Comments: TStrings);
|
---|
| 63 | procedure ForwardConsult(Dest: TStrings; IEN, ToService: integer; Forwarder, AttentionOf: int64;
|
---|
| 64 | Urgency: integer; ActionDate: TFMDateTime; Comments: TStrings);
|
---|
| 65 | procedure AddComment(Dest: TStrings; IEN: integer; Comments: TStrings; ActionDate: TFMDateTime; Alert: integer;
|
---|
| 66 | AlertTo: string) ;
|
---|
| 67 | procedure SigFindings(Dest: TStrings; IEN: integer; SigFindingsFlag: string; Comments: TStrings; ActionDate: TFMDateTime;Alert: integer;
|
---|
| 68 | AlertTo: string) ;
|
---|
| 69 | procedure AdminComplete(Dest: TStrings; IEN: integer; SigFindingsFlag: string; Comments: TStrings;
|
---|
| 70 | RespProv: Int64; ActionDate: TFMDateTime; Alert: integer; AlertTo: string) ;
|
---|
| 71 |
|
---|
| 72 | { Consults Ordering Calls }
|
---|
| 73 | function ODForConsults: TStrings;
|
---|
| 74 | function ODForProcedures: TStrings;
|
---|
| 75 | function ConsultMessage(AnIEN: Integer): string;
|
---|
| 76 | function LoadConsultsQuickList: TStrings ;
|
---|
| 77 | function GetProcedureServices(ProcIEN: integer): TStrings;
|
---|
| 78 | function ConsultCanBeResubmitted(ConsultIEN: integer): string;
|
---|
| 79 | function LoadConsultForEdit(ConsultIEN: integer): TEditResubmitRec;
|
---|
| 80 | function ResubmitConsult(EditResubmitRec: TEditResubmitRec): string;
|
---|
| 81 | function SubSetOfProcedures(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 82 | function GetDefaultReasonForRequest(Service: string; Resolve: Boolean): TStrings;
|
---|
| 83 | function ReasonForRequestEditable(Service: string): string;
|
---|
| 84 | function GetNewDialog(OrderType: string): string;
|
---|
| 85 | function GetServiceIEN(ORIEN: string): string;
|
---|
| 86 | function GetProcedureIEN(ORIEN: string): string;
|
---|
| 87 | function GetConsultOrderIEN(ConsultIEN: integer): string;
|
---|
| 88 | function GetServicePrerequisites(Service: string): TStrings;
|
---|
| 89 | procedure GetProvDxMode(var ProvDx: TProvisionalDiagnosis; SvcIEN: string);
|
---|
| 90 |
|
---|
| 91 | { Clinical Procedures Specific}
|
---|
| 92 | function GetSavedCPFields(NoteIEN: integer): TEditNoteRec;
|
---|
| 93 |
|
---|
| 94 | var
|
---|
| 95 | uConsultsClass: integer;
|
---|
| 96 | uConsultTitles: TConsultTitles;
|
---|
| 97 | uClinProcClass: integer;
|
---|
| 98 | uClinProcTitles: TClinProcTitles;
|
---|
| 99 |
|
---|
| 100 | implementation
|
---|
| 101 |
|
---|
| 102 | uses rODBase;
|
---|
| 103 |
|
---|
| 104 | var
|
---|
| 105 | uLastOrderedIEN: Integer;
|
---|
| 106 | uLastOrderMsg: string;
|
---|
| 107 |
|
---|
| 108 | { -------------------------- Consult Titles --------------------------------- }
|
---|
| 109 |
|
---|
| 110 | function IdentifyConsultsClass: integer;
|
---|
| 111 | begin
|
---|
| 112 | if uConsultsClass = 0 then
|
---|
| 113 | uConsultsClass := StrToIntDef(sCallV('TIU IDENTIFY CONSULTS CLASS',[nil]), 0) ;
|
---|
| 114 | Result := uConsultsClass;
|
---|
| 115 | end;
|
---|
| 116 |
|
---|
| 117 | procedure LoadConsultTitles;
|
---|
| 118 | { private - called one time to set up the uConsultTitles object }
|
---|
| 119 | var
|
---|
| 120 | x: string;
|
---|
| 121 | begin
|
---|
| 122 | if uConsultTitles <> nil then Exit;
|
---|
| 123 | CallV('TIU PERSONAL TITLE LIST', [User.DUZ, IdentifyConsultsClass]);
|
---|
| 124 | RPCBrokerV.Results.Insert(0, '~SHORT LIST'); // insert so can call ExtractItems
|
---|
| 125 | uConsultTitles := TConsultTitles.Create;
|
---|
| 126 | ExtractItems(uConsultTitles.ShortList, RPCBrokerV.Results, 'SHORT LIST');
|
---|
| 127 | x := ExtractDefault(RPCBrokerV.Results, 'SHORT LIST');
|
---|
| 128 | uConsultTitles.DfltTitle := StrToIntDef(Piece(x, U, 1), 0);
|
---|
| 129 | uConsultTitles.DfltTitleName := Piece(x, U, 2);
|
---|
| 130 | end;
|
---|
| 131 |
|
---|
| 132 | procedure ResetConsultTitles;
|
---|
| 133 | begin
|
---|
| 134 | if uConsultTitles <> nil then
|
---|
| 135 | begin
|
---|
| 136 | uConsultTitles.Free;
|
---|
| 137 | uConsultTitles := nil;
|
---|
| 138 | LoadConsultTitles;
|
---|
| 139 | end;
|
---|
| 140 | end;
|
---|
| 141 |
|
---|
| 142 | function DfltConsultTitle: integer;
|
---|
| 143 | { returns the user defined default Consult title (if any) }
|
---|
| 144 | begin
|
---|
| 145 | if uConsultTitles = nil then LoadConsultTitles;
|
---|
| 146 | Result := uConsultTitles.DfltTitle;
|
---|
| 147 | end;
|
---|
| 148 |
|
---|
| 149 | function DfltConsultTitleName: string;
|
---|
| 150 | { returns the name of the user defined default progress note title (if any) }
|
---|
| 151 | begin
|
---|
| 152 | if uConsultTitles = nil then LoadConsultTitles;
|
---|
| 153 | Result := uConsultTitles.DfltTitleName;
|
---|
| 154 | end;
|
---|
| 155 |
|
---|
| 156 | procedure ListConsultTitlesShort(Dest: TStrings);
|
---|
| 157 | { returns the user defined list (short list) of Consult titles }
|
---|
| 158 | begin
|
---|
| 159 | if uConsultTitles = nil then LoadConsultTitles;
|
---|
| 160 | Dest.AddStrings(uConsultTitles.ShortList);
|
---|
| 161 | if uConsultTitles.ShortList.Count > 0 then
|
---|
| 162 | begin
|
---|
| 163 | Dest.Add('0^________________________________________________________________________');
|
---|
| 164 | Dest.Add('0^ ');
|
---|
| 165 | end;
|
---|
| 166 | end;
|
---|
| 167 |
|
---|
| 168 | function SubSetOfConsultTitles(const StartFrom: string; Direction: Integer; IDNoteTitlesOnly: boolean): TStrings;
|
---|
| 169 | { returns a pointer to a list of consults progress note titles (for use in a long list box) -
|
---|
| 170 | The return value is a pointer to RPCBrokerV.Results, so the data must be used BEFORE
|
---|
| 171 | the next broker call! }
|
---|
| 172 | begin
|
---|
| 173 | (* if IDNoteTitlesOnly then // This RPC not changed for initial ID Notes release
|
---|
| 174 | CallV('TIU LONG LIST CONSULT TITLES', [StartFrom, Direction, IDNoteTitlesOnly])
|
---|
| 175 | else*)
|
---|
| 176 | CallV('TIU LONG LIST CONSULT TITLES', [StartFrom, Direction]);
|
---|
| 177 | //MixedCaseList(RPCBrokerV.Results);
|
---|
| 178 | Result := RPCBrokerV.Results;
|
---|
| 179 | end;
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | { -------------------------- Clinical Procedures Titles --------------------------------- }
|
---|
| 183 | function IdentifyClinProcClass: integer;
|
---|
| 184 | begin
|
---|
| 185 | if uClinProcClass = 0 then
|
---|
| 186 | uClinProcClass := StrToIntDef(sCallV('TIU IDENTIFY CLINPROC CLASS',[nil]), 0) ;
|
---|
| 187 | Result := uClinProcClass;
|
---|
| 188 | end;
|
---|
| 189 |
|
---|
| 190 | procedure LoadClinProcTitles;
|
---|
| 191 | { private - called one time to set up the uConsultTitles object }
|
---|
| 192 | var
|
---|
| 193 | x: string;
|
---|
| 194 | begin
|
---|
| 195 | if uClinProcTitles <> nil then Exit;
|
---|
| 196 | CallV('TIU PERSONAL TITLE LIST', [User.DUZ, IdentifyClinProcClass]);
|
---|
| 197 | RPCBrokerV.Results.Insert(0, '~SHORT LIST'); // insert so can call ExtractItems
|
---|
| 198 | uClinProcTitles := TClinProcTitles.Create;
|
---|
| 199 | ExtractItems(uClinProcTitles.ShortList, RPCBrokerV.Results, 'SHORT LIST');
|
---|
| 200 | x := ExtractDefault(RPCBrokerV.Results, 'SHORT LIST');
|
---|
| 201 | uClinProcTitles.DfltTitle := StrToIntDef(Piece(x, U, 1), 0);
|
---|
| 202 | uClinProcTitles.DfltTitleName := Piece(x, U, 2);
|
---|
| 203 | end;
|
---|
| 204 |
|
---|
| 205 | procedure ResetClinProcTitles;
|
---|
| 206 | begin
|
---|
| 207 | if uClinProcTitles <> nil then
|
---|
| 208 | begin
|
---|
| 209 | uClinProcTitles.Free;
|
---|
| 210 | uClinProcTitles := nil;
|
---|
| 211 | LoadClinProcTitles;
|
---|
| 212 | end;
|
---|
| 213 | end;
|
---|
| 214 |
|
---|
| 215 | function DfltClinProcTitle: integer;
|
---|
| 216 | { returns the user defined default ClinProc title (if any) }
|
---|
| 217 | begin
|
---|
| 218 | if uClinProcTitles = nil then LoadClinProcTitles;
|
---|
| 219 | Result := uClinProcTitles.DfltTitle;
|
---|
| 220 | end;
|
---|
| 221 |
|
---|
| 222 | function DfltClinProcTitleName: string;
|
---|
| 223 | { returns the name of the user defined default progress note title (if any) }
|
---|
| 224 | begin
|
---|
| 225 | if uClinProcTitles = nil then LoadClinProcTitles;
|
---|
| 226 | Result := uClinProcTitles.DfltTitleName;
|
---|
| 227 | end;
|
---|
| 228 |
|
---|
| 229 | procedure ListClinProcTitlesShort(Dest: TStrings);
|
---|
| 230 | { returns the user defined list (short list) of ClinProc titles }
|
---|
| 231 | begin
|
---|
| 232 | if uClinProcTitles = nil then LoadClinProcTitles;
|
---|
| 233 | Dest.AddStrings(uClinProcTitles.ShortList);
|
---|
| 234 | if uClinProcTitles.ShortList.Count > 0 then
|
---|
| 235 | begin
|
---|
| 236 | Dest.Add('0^________________________________________________________________________');
|
---|
| 237 | Dest.Add('0^ ');
|
---|
| 238 | end;
|
---|
| 239 | end;
|
---|
| 240 |
|
---|
| 241 | function SubSetOfClinProcTitles(const StartFrom: string; Direction: Integer; IDNoteTitlesOnly: boolean): TStrings;
|
---|
| 242 | { returns a pointer to a list of clinical procedures titles (for use in a long list box) -
|
---|
| 243 | The return value is a pointer to RPCBrokerV.Results, so the data must be used BEFORE
|
---|
| 244 | the next broker call! }
|
---|
| 245 | begin
|
---|
| 246 | (* if IDNoteTitlesOnly then // This RPC not changed for initial ID Notes release
|
---|
| 247 | CallV('TIU LONG LIST CLINPROC TITLES', [StartFrom, Direction, IDNoteTitlesOnly])
|
---|
| 248 | else*)
|
---|
| 249 | CallV('TIU LONG LIST CLINPROC TITLES', [StartFrom, Direction]);
|
---|
| 250 | //MixedCaseList(RPCBrokerV.Results);
|
---|
| 251 | Result := RPCBrokerV.Results;
|
---|
| 252 | end;
|
---|
| 253 |
|
---|
| 254 | {--------------- data retrieval ------------------------------------------}
|
---|
| 255 |
|
---|
| 256 | procedure GetConsultsList(Dest: TStrings; Early, Late: double;
|
---|
| 257 | Service, Status: string; SortAscending: Boolean);
|
---|
| 258 | { returns a list of consults for a patient, based on selected dates, service, status, or ALL}
|
---|
| 259 | var
|
---|
| 260 | i: Integer;
|
---|
| 261 | x, date1, date2: string;
|
---|
| 262 | begin
|
---|
| 263 | if Early <= 0 then date1 := '' else date1 := FloatToStr(Early) ;
|
---|
| 264 | if Late <= 0 then date2 := '' else date2 := FloatToStr(Late) ;
|
---|
| 265 | CallV('ORQQCN LIST', [Patient.DFN, date1, date2, Service, Status]);
|
---|
| 266 | with RPCBrokerV do
|
---|
| 267 | begin
|
---|
| 268 | if Copy(Results[0],1,1) <> '<' then
|
---|
| 269 | begin
|
---|
| 270 | SortByPiece(TStringList(Results), U, 2);
|
---|
| 271 | if not SortAscending then InvertStringList(TStringList(Results));
|
---|
| 272 | //SetListFMDateTime('mmm dd,yy', TStringList(Results), U, 2);
|
---|
| 273 | for i := 0 to Results.Count - 1 do
|
---|
| 274 | begin
|
---|
| 275 | x := MakeConsultListItem(Results[i]);
|
---|
| 276 | Results[i] := x;
|
---|
| 277 | end;
|
---|
| 278 | Dest.Assign(Results);
|
---|
| 279 | end
|
---|
| 280 | else
|
---|
| 281 | begin
|
---|
| 282 | Dest.Clear ;
|
---|
| 283 | Dest.Add('-1^No Matches') ;
|
---|
| 284 | end ;
|
---|
| 285 | end;
|
---|
| 286 | end;
|
---|
| 287 |
|
---|
| 288 | procedure LoadConsultDetail(Dest: TStrings; IEN: integer) ;
|
---|
| 289 | { returns the detail of a consult }
|
---|
| 290 | begin
|
---|
| 291 | CallV('ORQQCN DETAIL', [IEN]);
|
---|
| 292 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 293 | end;
|
---|
| 294 |
|
---|
| 295 | procedure DisplayResults(Dest: TStrings; IEN: integer) ;
|
---|
| 296 | { returns the results for a consult }
|
---|
| 297 | begin
|
---|
| 298 | CallV('ORQQCN MED RESULTS', [IEN]);
|
---|
| 299 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 300 | end;
|
---|
| 301 |
|
---|
| 302 | procedure GetConsultRec(IEN: integer);
|
---|
| 303 | {returns zero node from file 123, plus a list of all related TIU documents, if any}
|
---|
| 304 | const
|
---|
| 305 | SHOW_ADDENDA = True;
|
---|
| 306 | var
|
---|
| 307 | alist: TStrings;
|
---|
| 308 | x: string ;
|
---|
| 309 | i: integer;
|
---|
| 310 | { 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
---|
| 311 | { Pieces: EntDt^Pat^OrIFN^PtLoc^ToSvc^From^ReqDt^Typ^Urg^Place^Attn^Sts^LstAct^SndPrv^Rslt^
|
---|
| 312 | 16 17 18 19 20 21 22
|
---|
| 313 | ^EntMode^ReqTyp^InOut^SigFnd^TIUPtr^OrdFac^FrgnCslt}
|
---|
| 314 | begin
|
---|
| 315 | FillChar(ConsultRec, SizeOf(ConsultRec), 0);
|
---|
| 316 | CallV('ORQQCN GET CONSULT', [IEN, SHOW_ADDENDA]);
|
---|
| 317 | ConsultRec.IEN := IEN ;
|
---|
| 318 | alist := TStringList.Create ;
|
---|
| 319 | try
|
---|
| 320 | alist.Assign(RPCBrokerV.Results) ;
|
---|
| 321 | x := alist[0] ;
|
---|
| 322 | if Piece(x,u,1) <> '-1' then
|
---|
| 323 | with ConsultRec do
|
---|
| 324 | begin
|
---|
| 325 | EntryDate := MakeFMDateTime(Piece(x, U, 1));
|
---|
| 326 | ORFileNumber := StrToIntDef(Piece(x, U, 3),0);
|
---|
| 327 | PatientLocation := StrToIntDef(Piece(x, U, 4),0);
|
---|
| 328 | OrderingFacility := StrToIntDef(Piece(x, U, 21),0);
|
---|
| 329 | ForeignConsultFileNum := StrToIntDef(Piece(x, U, 22),0);
|
---|
| 330 | ToService := StrToIntDef(Piece(x, U, 5),0);
|
---|
| 331 | From := StrToIntDef(Piece(x, U, 6),0);
|
---|
| 332 | RequestDate := MakeFMDateTime(Piece(x, U, 7));
|
---|
| 333 | ConsultProcedure := Piece(x, U, 8) ;
|
---|
| 334 | Urgency := StrToIntDef(Piece(x, U, 9),0);
|
---|
| 335 | PlaceOfConsult := StrToIntDef(Piece(x, U, 10),0);
|
---|
| 336 | Attention := StrToInt64Def(Piece(x, U, 11),0);
|
---|
| 337 | ORStatus := StrToIntDef(Piece(x, U, 12),0);
|
---|
| 338 | LastAction := StrToIntDef(Piece(x, U, 13),0);
|
---|
| 339 | SendingProvider := StrToInt64Def(Piece(Piece(x, U, 14),';',1),0);
|
---|
| 340 | SendingProviderName := Piece(Piece(x, U, 14),';',2) ;
|
---|
| 341 | Result := Piece(x, U, 15) ;
|
---|
| 342 | ModeOfEntry := Piece(x, U, 16) ;
|
---|
| 343 | RequestType := StrToIntDef(Piece(x, U, 17),0);
|
---|
| 344 | InOut := Piece(x, U, 18) ;
|
---|
| 345 | Findings := Piece(x, U, 19) ;
|
---|
| 346 | TIUResultNarrative := StrToIntDef(Piece(x, U, 20),0);
|
---|
| 347 | //ProvDiagnosis := Piece(x, U, 23); NO!!!!! Up to 180 Characters!!!!
|
---|
| 348 | alist.delete(0) ;
|
---|
| 349 | TIUDocuments := TStringList.Create ;
|
---|
| 350 | MedResults := TStringList.Create;
|
---|
| 351 | if alist.count > 0 then
|
---|
| 352 | begin
|
---|
| 353 | SortByPiece(TStringList(alist), U, 3);
|
---|
| 354 | for i := 0 to alist.Count - 1 do
|
---|
| 355 | if Copy(Piece(Piece(alist[i], U, 1), ';', 2), 1, 4) = 'MCAR' then
|
---|
| 356 | MedResults.Add(alist[i])
|
---|
| 357 | else
|
---|
| 358 | TIUDocuments.Add(alist[i]);
|
---|
| 359 | end;
|
---|
| 360 | end {ConsultRec}
|
---|
| 361 | else
|
---|
| 362 | ConsultRec.EntryDate := -1 ;
|
---|
| 363 | finally
|
---|
| 364 | alist.free ;
|
---|
| 365 | end ;
|
---|
| 366 | end ;
|
---|
| 367 |
|
---|
| 368 | {---------------- list box fillers -----------------------------------}
|
---|
| 369 |
|
---|
| 370 | function SubSetOfStatus: TStrings;
|
---|
| 371 | { returns a pointer to a list of stati (for use in a list box) }
|
---|
| 372 | begin
|
---|
| 373 | CallV('ORQQCN STATUS', [nil]);
|
---|
| 374 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 375 | Result := RPCBrokerV.Results;
|
---|
| 376 | end;
|
---|
| 377 |
|
---|
| 378 | function SubSetOfUrgencies(ConsultIEN: integer): TStrings;
|
---|
| 379 | { returns a pointer to a list of urgencies }
|
---|
| 380 | begin
|
---|
| 381 | CallV('ORQQCN URGENCIES',[ConsultIEN]) ;
|
---|
| 382 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 383 | Result := RPCBrokerV.Results;
|
---|
| 384 | end;
|
---|
| 385 |
|
---|
| 386 | function FindConsult(ConsultIEN: integer): string ;
|
---|
| 387 | var
|
---|
| 388 | x: string;
|
---|
| 389 | begin
|
---|
| 390 | x := sCallV('ORQQCN FIND CONSULT',[ConsultIEN]);
|
---|
| 391 | Result := MakeConsultListItem(x);
|
---|
| 392 | end;
|
---|
| 393 |
|
---|
| 394 | {-----------------consult result functions-----------------------------------}
|
---|
| 395 | function GetAssignableMedResults(ConsultIEN: integer): TStrings;
|
---|
| 396 | begin
|
---|
| 397 | CallV('ORQQCN ASSIGNABLE MED RESULTS', [ConsultIEN]);
|
---|
| 398 | Result := RPCBrokerV.Results;
|
---|
| 399 | end;
|
---|
| 400 |
|
---|
| 401 | function GetRemovableMedResults(ConsultIEN: integer): TStrings;
|
---|
| 402 | begin
|
---|
| 403 | CallV('ORQQCN REMOVABLE MED RESULTS', [ConsultIEN]);
|
---|
| 404 | Result := RPCBrokerV.Results;
|
---|
| 405 | end;
|
---|
| 406 |
|
---|
| 407 | function GetDetailedMedicineResults(ResultID: string): TStrings;
|
---|
| 408 | begin
|
---|
| 409 | CallV('ORQQCN GET MED RESULT DETAILS', [ResultID]);
|
---|
| 410 | Result := RPCBrokerV.Results;
|
---|
| 411 | end;
|
---|
| 412 |
|
---|
| 413 | procedure AttachMedicineResult(ConsultIEN: integer; ResultID: string; DateTime: TFMDateTime; ResponsiblePerson: int64; AlertTo: string);
|
---|
| 414 | begin
|
---|
| 415 | CallV('ORQQCN ATTACH MED RESULTS', [ConsultIEN, ResultID, DateTime, ResponsiblePerson, AlertTo]);
|
---|
| 416 | end;
|
---|
| 417 |
|
---|
| 418 | procedure RemoveMedicineResult(ConsultIEN: integer; ResultID: string; DateTime: TFMDateTime; ResponsiblePerson: int64);
|
---|
| 419 | begin
|
---|
| 420 | CallV('ORQQCN REMOVE MED RESULTS', [ConsultIEN, ResultID, DateTime, ResponsiblePerson]);
|
---|
| 421 | end;
|
---|
| 422 | {-------------- user access level functions ---------------------------------}
|
---|
| 423 |
|
---|
| 424 | function ConsultServiceUser(ServiceIEN: integer; DUZ: int64): boolean ;
|
---|
| 425 | var
|
---|
| 426 | i: integer ;
|
---|
| 427 | begin
|
---|
| 428 | Result := False ;
|
---|
| 429 | CallV('ORWU GENERIC', ['',1,'^GMR(123.5,'+IntToStr(ServiceIEN)+',123.3,"B")']) ;
|
---|
| 430 | for i:=0 to RPCBrokerV.Results.Count-1 do
|
---|
| 431 | if StrToInt64(Piece(RPCBrokerV.Results[i],u,2))=DUZ then result := True ;
|
---|
| 432 | end ;
|
---|
| 433 |
|
---|
| 434 | function GetActionMenuLevel(ConsultIEN: integer): TMenuAccessRec ;
|
---|
| 435 | var
|
---|
| 436 | x: string;
|
---|
| 437 | begin
|
---|
| 438 | x := sCallV('ORQQCN SET ACT MENUS', [ConsultIEN]) ;
|
---|
| 439 | Result.UserLevel := StrToIntDef(Piece(x, U, 1), 1);
|
---|
| 440 | Result.AllowMedResulting := (Piece(x, U, 4) = '1');
|
---|
| 441 | Result.AllowMedDissociate := (Piece(x, U, 5) = '1');
|
---|
| 442 | Result.AllowResubmit := (Piece(x, U, 6) = '1') and (Piece(ConsultCanBeResubmitted(ConsultIEN), U, 1) <> '0');
|
---|
| 443 | Result.ClinProcFlag := StrToIntDef(Piece(x, U, 7), CP_NOT_CLINPROC);
|
---|
| 444 | Result.IsClinicalProcedure := (Result.ClinProcFlag > CP_NOT_CLINPROC);
|
---|
| 445 | end ;
|
---|
| 446 |
|
---|
| 447 | {------------------- Consult request actions -------------------------------}
|
---|
| 448 |
|
---|
| 449 | procedure ReceiveConsult(Dest: TStrings; IEN: integer; ReceivedBy: int64; RcptDate: TFMDateTime; Comments: TStrings);
|
---|
| 450 | begin
|
---|
| 451 | CallV('ORQQCN RECEIVE', [IEN, ReceivedBy, RcptDate, Comments]);
|
---|
| 452 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 453 | end;
|
---|
| 454 |
|
---|
| 455 | procedure ScheduleConsult(Dest: TStrings; IEN: integer; ScheduledBy: Int64; SchdDate: TFMDateTime; Alert: integer;
|
---|
| 456 | AlertTo: string; Comments: TStrings);
|
---|
| 457 | begin
|
---|
| 458 | CallV('ORQQCN2 SCHEDULE CONSULT', [IEN, ScheduledBy, SchdDate, Alert, AlertTo, Comments]);
|
---|
| 459 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 460 | end;
|
---|
| 461 |
|
---|
| 462 | procedure DenyConsult(Dest: TStrings; IEN: integer; DeniedBy: int64;
|
---|
| 463 | DenialDate: TFMDateTime; Comments: TStrings);
|
---|
| 464 | begin
|
---|
| 465 | CallV('ORQQCN DISCONTINUE', [IEN, DeniedBy, DenialDate,'DY',Comments]);
|
---|
| 466 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 467 | end;
|
---|
| 468 |
|
---|
| 469 | procedure DiscontinueConsult(Dest: TStrings; IEN: integer; DiscontinuedBy: int64;
|
---|
| 470 | DiscontinueDate: TFMDateTime; Comments: TStrings);
|
---|
| 471 | begin
|
---|
| 472 | CallV('ORQQCN DISCONTINUE', [IEN, DiscontinuedBy, DiscontinueDate,'DC',Comments]);
|
---|
| 473 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 474 | end;
|
---|
| 475 |
|
---|
| 476 | procedure ForwardConsult(Dest: TStrings; IEN, ToService: integer; Forwarder, AttentionOf: int64; Urgency: integer;
|
---|
| 477 | ActionDate: TFMDateTime; Comments: TStrings);
|
---|
| 478 | begin
|
---|
| 479 | CallV('ORQQCN FORWARD', [IEN, ToService, Forwarder, AttentionOf, Urgency, ActionDate, Comments]);
|
---|
| 480 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 481 | end ;
|
---|
| 482 |
|
---|
| 483 | procedure AddComment(Dest: TStrings; IEN: integer; Comments: TStrings; ActionDate: TFMDateTime; Alert: integer;
|
---|
| 484 | AlertTo: string) ;
|
---|
| 485 | begin
|
---|
| 486 | CallV('ORQQCN ADDCMT', [IEN, Comments, Alert, AlertTo, ActionDate]);
|
---|
| 487 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 488 | end ;
|
---|
| 489 |
|
---|
| 490 | procedure AdminComplete(Dest: TStrings; IEN: integer; SigFindingsFlag: string; Comments: TStrings;
|
---|
| 491 | RespProv: Int64; ActionDate: TFMDateTime; Alert: integer; AlertTo: string) ;
|
---|
| 492 | begin
|
---|
| 493 | CallV('ORQQCN ADMIN COMPLETE', [IEN, SigFindingsFlag, Comments, RespProv, Alert, AlertTo, ActionDate]);
|
---|
| 494 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 495 | end ;
|
---|
| 496 |
|
---|
| 497 | procedure SigFindings(Dest: TStrings; IEN: integer; SigFindingsFlag: string; Comments: TStrings; ActionDate: TFMDateTime; Alert: integer;
|
---|
| 498 | AlertTo: string) ;
|
---|
| 499 | begin
|
---|
| 500 | CallV('ORQQCN SIGFIND', [IEN, SigFindingsFlag, Comments, Alert, AlertTo, ActionDate]);
|
---|
| 501 | Dest.Assign(RPCBrokerV.Results); {1^Error message' or '0'}
|
---|
| 502 | end ;
|
---|
| 503 |
|
---|
| 504 | //================== Ordering functions ===================================
|
---|
| 505 | function ODForConsults: TStrings;
|
---|
| 506 | { Returns init values for consults dialog. The results must be used immediately. }
|
---|
| 507 | begin
|
---|
| 508 | CallV('ORWDCN32 DEF', ['C']);
|
---|
| 509 | Result := RPCBrokerV.Results;
|
---|
| 510 | end;
|
---|
| 511 |
|
---|
| 512 | function ODForProcedures: TStrings;
|
---|
| 513 | { Returns init values for procedures dialog. The results must be used immediately. }
|
---|
| 514 | begin
|
---|
| 515 | CallV('ORWDCN32 DEF', ['P']);
|
---|
| 516 | Result := RPCBrokerV.Results;
|
---|
| 517 | end;
|
---|
| 518 |
|
---|
| 519 | function SubSetOfProcedures(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 520 | begin
|
---|
| 521 | begin
|
---|
| 522 | CallV('ORWDCN32 PROCEDURES', [StartFrom, Direction]);
|
---|
| 523 | Result := RPCBrokerV.Results;
|
---|
| 524 | end;
|
---|
| 525 | end;
|
---|
| 526 |
|
---|
| 527 | function LoadServiceList(Purpose: integer): TStrings ;
|
---|
| 528 | // Purpose: 0=display all services, 1=forward or order from possible services
|
---|
| 529 | begin
|
---|
| 530 | Callv('ORQQCN SVCTREE',[Purpose]) ;
|
---|
| 531 | MixedCaseList(RPCBrokerV.Results) ;
|
---|
| 532 | Result := RPCBrokerV.Results;
|
---|
| 533 | end ;
|
---|
| 534 |
|
---|
| 535 | function LoadServiceListWithSynonyms(Purpose: integer): TStrings ;
|
---|
| 536 | // Param 1 = Starting service (1=All Services)
|
---|
| 537 | // Param 2 = Purpose: 0=display all services, 1=forward or order from possible services
|
---|
| 538 | // Param 3 = Show synonyms
|
---|
| 539 | begin
|
---|
| 540 | Callv('ORQQCN SVC W/SYNONYMS',[1, Purpose, True]) ;
|
---|
| 541 | MixedCaseList(RPCBrokerV.Results) ;
|
---|
| 542 | Result := RPCBrokerV.Results;
|
---|
| 543 | end ;
|
---|
| 544 |
|
---|
| 545 | function LoadServiceListWithSynonyms(Purpose, ConsultIEN: integer): TStrings ;
|
---|
| 546 | // Param 1 = Starting service (1=All Services)
|
---|
| 547 | // Param 2 = Purpose: 0=display all services, 1=forward or order from possible services
|
---|
| 548 | // Param 3 = Show synonyms
|
---|
| 549 | // Param 4 = Consult IEN
|
---|
| 550 | begin
|
---|
| 551 | Callv('ORQQCN SVC W/SYNONYMS',[1, Purpose, True, ConsultIEN]) ;
|
---|
| 552 | MixedCaseList(RPCBrokerV.Results) ;
|
---|
| 553 | Result := RPCBrokerV.Results;
|
---|
| 554 | end ;
|
---|
| 555 |
|
---|
| 556 | function SubSetOfServices(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 557 | // used only on consults order dialog for service long combo box, which needs to include quick orders
|
---|
| 558 | begin
|
---|
| 559 | CallV('ORQQCN SVCLIST', [StartFrom, Direction]);
|
---|
| 560 | Result := RPCBrokerV.Results;
|
---|
| 561 | end;
|
---|
| 562 |
|
---|
| 563 | function LoadConsultsQuickList: TStrings ;
|
---|
| 564 | begin
|
---|
| 565 | Callv('ORWDXQ GETQLST',['CSLT', 'Q']) ;
|
---|
| 566 | Result := RPCBrokerV.Results;
|
---|
| 567 | end ;
|
---|
| 568 |
|
---|
| 569 | function ShowSF513(ConsultIEN: integer): TStrings ;
|
---|
| 570 | var
|
---|
| 571 | x: string;
|
---|
| 572 | i: integer;
|
---|
| 573 | begin
|
---|
| 574 | CallV('ORQQCN SHOW SF513',[ConsultIEN]) ;
|
---|
| 575 | if RPCBrokerV.Results.Count > 0 then
|
---|
| 576 | begin
|
---|
| 577 | x := RPCBrokerV.Results[0];
|
---|
| 578 | i := Pos('-', x);
|
---|
| 579 | x := Copy(x, i, 999);
|
---|
| 580 | RPCBrokerV.Results[0] := x;
|
---|
| 581 | end;
|
---|
| 582 | Result := RPCBrokerV.Results;
|
---|
| 583 | end ;
|
---|
| 584 |
|
---|
| 585 | procedure PrintSF513ToDevice(AConsult: Integer; const ADevice: string; ChartCopy: string;
|
---|
| 586 | var ErrMsg: string);
|
---|
| 587 | { prints a SF 513 on the selected device }
|
---|
| 588 | begin
|
---|
| 589 | ErrMsg := sCallV('ORQQCN PRINT SF513', [AConsult, ChartCopy, ADevice]);
|
---|
| 590 | // if Piece(ErrMsg, U, 1) = '0' then ErrMsg := '' else ErrMsg := Piece(ErrMsg, U, 2);
|
---|
| 591 | end;
|
---|
| 592 |
|
---|
| 593 | function GetFormattedSF513(AConsult: Integer; ChartCopy: string): TStrings;
|
---|
| 594 | begin
|
---|
| 595 | CallV('ORQQCN SF513 WINDOWS PRINT',[AConsult, ChartCopy]);
|
---|
| 596 | Result := RPCBrokerV.Results;
|
---|
| 597 | end;
|
---|
| 598 |
|
---|
| 599 | function UnresolvedConsultsExist: boolean;
|
---|
| 600 | begin
|
---|
| 601 | Result := (sCallV('ORQQCN UNRESOLVED', [Patient.DFN]) = '1');
|
---|
| 602 | end;
|
---|
| 603 |
|
---|
| 604 | function ConsultMessage(AnIEN: Integer): string;
|
---|
| 605 | begin
|
---|
| 606 | if AnIEN = uLastOrderedIEN then Result := uLastOrderMsg else
|
---|
| 607 | begin
|
---|
| 608 | Result := sCallV('ORWDCN32 ORDRMSG', [AnIEN]);
|
---|
| 609 | uLastOrderedIEN := AnIEN;
|
---|
| 610 | uLastOrderMsg := Result;
|
---|
| 611 | end;
|
---|
| 612 | end;
|
---|
| 613 |
|
---|
| 614 | function GetProcedureIEN(ORIEN: string): string;
|
---|
| 615 | begin
|
---|
| 616 | Result := sCallV('ORQQCN GET PROC IEN', [ORIEN]);
|
---|
| 617 | end;
|
---|
| 618 |
|
---|
| 619 | function GetProcedureServices(ProcIEN: integer): TStrings;
|
---|
| 620 | begin
|
---|
| 621 | CallV('ORQQCN GET PROC SVCS',[ProcIEN]) ;
|
---|
| 622 | Result := RPCBrokerV.Results;
|
---|
| 623 | end;
|
---|
| 624 |
|
---|
| 625 | function ConsultCanBeResubmitted(ConsultIEN: integer): string;
|
---|
| 626 | begin
|
---|
| 627 | Result := sCallV('ORQQCN CANEDIT', [ConsultIEN]);
|
---|
| 628 | end;
|
---|
| 629 |
|
---|
| 630 | function LoadConsultForEdit(ConsultIEN: integer): TEditResubmitRec;
|
---|
| 631 | var
|
---|
| 632 | Dest: TStringList;
|
---|
| 633 | EditRec: TEditResubmitRec;
|
---|
| 634 | begin
|
---|
| 635 | Dest := TStringList.Create;
|
---|
| 636 | try
|
---|
| 637 | tCallV(Dest, 'ORQQCN LOAD FOR EDIT',[ConsultIEN]) ;
|
---|
| 638 | with EditRec do
|
---|
| 639 | begin
|
---|
| 640 | Changed := False;
|
---|
| 641 | IEN := ConsultIEN;
|
---|
| 642 | ToService := StrToIntDef(Piece(ExtractDefault(Dest, 'SERVICE'), U, 2), 0);
|
---|
| 643 | RequestType := Piece(ExtractDefault(Dest, 'TYPE'), U, 3);
|
---|
| 644 | OrderableItem := StrToIntDef(Piece(ExtractDefault(Dest, 'PROCEDURE'), U, 1), 0);
|
---|
| 645 | ConsultProc := Piece(ExtractDefault(Dest, 'PROCEDURE'), U, 3);
|
---|
| 646 | ConsultProcName := Piece(ExtractDefault(Dest, 'PROCEDURE'), U, 2);
|
---|
| 647 | Urgency := StrToIntDef(Piece(ExtractDefault(Dest, 'URGENCY'), U, 3), 0);
|
---|
| 648 | UrgencyName := Piece(ExtractDefault(Dest, 'URGENCY'), U, 2);
|
---|
| 649 | Place := Piece(ExtractDefault(Dest, 'PLACE'), U, 1);
|
---|
| 650 | PlaceName := Piece(ExtractDefault(Dest, 'PLACE'), U, 2);
|
---|
| 651 | Attention := StrToInt64Def(Piece(ExtractDefault(Dest, 'ATTENTION'), U, 1), 0);
|
---|
| 652 | AttnName := Piece(ExtractDefault(Dest, 'ATTENTION'), U, 2);
|
---|
| 653 | InpOutp := Piece(ExtractDefault(Dest, 'CATEGORY'), U, 1);
|
---|
| 654 | ProvDiagnosis := Piece(ExtractDefault(Dest, 'DIAGNOSIS'), U, 1);
|
---|
| 655 | ProvDxCode := Piece(ExtractDefault(Dest, 'DIAGNOSIS'), U, 2);
|
---|
| 656 | ProvDxCodeInactive := (Piece(ExtractDefault(Dest, 'DIAGNOSIS'), U, 3) = '1');
|
---|
| 657 | RequestReason := TStringList.Create;
|
---|
| 658 | ExtractText(RequestReason, Dest, 'REASON');
|
---|
| 659 | LimitStringLength(RequestReason, 74);
|
---|
| 660 | DenyComments := TStringList.Create;
|
---|
| 661 | ExtractText(DenyComments, Dest, 'DENY COMMENT');
|
---|
| 662 | OtherComments := TStringList.Create;
|
---|
| 663 | ExtractText(OtherComments, Dest, 'ADDED COMMENT');
|
---|
| 664 | NewComments := TStringList.Create;
|
---|
| 665 | end;
|
---|
| 666 | Result := EditRec;
|
---|
| 667 | finally
|
---|
| 668 | Dest.Free;
|
---|
| 669 | end;
|
---|
| 670 | end;
|
---|
| 671 |
|
---|
| 672 | function ResubmitConsult(EditResubmitRec: TEditResubmitRec): string;
|
---|
| 673 | var
|
---|
| 674 | i: integer;
|
---|
| 675 | begin
|
---|
| 676 | with RPCBrokerV, EditResubmitRec do
|
---|
| 677 | begin
|
---|
| 678 | ClearParameters := True;
|
---|
| 679 | RemoteProcedure := 'ORQQCN RESUBMIT';
|
---|
| 680 | Param[0].PType := literal;
|
---|
| 681 | Param[0].Value := IntToStr(IEN);
|
---|
| 682 | Param[1].PType := list;
|
---|
| 683 | with Param[1] do
|
---|
| 684 | begin
|
---|
| 685 | if ToService > 0 then
|
---|
| 686 | Mult['1'] := 'GMRCSS^' + IntToStr(ToService);
|
---|
| 687 | if ConsultProc <> '' then
|
---|
| 688 | Mult['2'] := 'GMRCPROC^' + ConsultProc ;
|
---|
| 689 | if Urgency > 0 then
|
---|
| 690 | Mult['3'] := 'GMRCURG^' + IntToStr(Urgency);
|
---|
| 691 | if Length(Place) > 0 then
|
---|
| 692 | Mult['4'] := 'GMRCPL^' + Place;
|
---|
| 693 | if Attention > 0 then
|
---|
| 694 | Mult['5'] := 'GMRCATN^' + IntToStr(Attention)
|
---|
| 695 | else if Attention = -1 then
|
---|
| 696 | Mult['5'] := 'GMRCATN^' + '@';
|
---|
| 697 | if RequestType <> '' then
|
---|
| 698 | Mult['6'] := 'GMRCRQT^' + RequestType;
|
---|
| 699 | if Length(InpOutP) > 0 then
|
---|
| 700 | Mult['7'] := 'GMRCION^' + InpOutp;
|
---|
| 701 | if Length(ProvDiagnosis) > 0 then
|
---|
| 702 | Mult['8'] := 'GMRCDIAG^' + ProvDiagnosis + U + ProvDxCode;
|
---|
| 703 | if RequestReason.Count > 0 then
|
---|
| 704 | begin
|
---|
| 705 | Mult['9'] := 'GMRCRFQ^20';
|
---|
| 706 | for i := 0 to RequestReason.Count - 1 do
|
---|
| 707 | Mult['9,' + IntToStr(i+1)] := RequestReason.Strings[i];
|
---|
| 708 | end;
|
---|
| 709 | if NewComments.Count > 0 then
|
---|
| 710 | begin
|
---|
| 711 | Mult['10'] := 'COMMENT^';
|
---|
| 712 | for i := 0 to NewComments.Count - 1 do
|
---|
| 713 | Mult['10,' + IntToStr(i+1)] := NewComments.Strings[i];
|
---|
| 714 | end;
|
---|
| 715 | end;
|
---|
| 716 | CallBroker;
|
---|
| 717 | Result := '0';
|
---|
| 718 | //Result := Results[0];
|
---|
| 719 | end;
|
---|
| 720 | end;
|
---|
| 721 |
|
---|
| 722 | function GetCurrentContext: TSelectContext;
|
---|
| 723 | var
|
---|
| 724 | x: string;
|
---|
| 725 | AContext: TSelectContext;
|
---|
| 726 | begin
|
---|
| 727 | x := sCallV('ORQQCN2 GET CONTEXT', [User.DUZ]) ;
|
---|
| 728 | with AContext do
|
---|
| 729 | begin
|
---|
| 730 | Changed := True;
|
---|
| 731 | BeginDate := Piece(x, ';', 1);
|
---|
| 732 | EndDate := Piece(x, ';', 2);
|
---|
| 733 | Status := Piece(x, ';', 3);
|
---|
| 734 | Service := Piece(x, ';', 4);
|
---|
| 735 | GroupBy := Piece(x, ';', 5);
|
---|
| 736 | Ascending := (Piece(x, ';', 6) = '1');
|
---|
| 737 | end;
|
---|
| 738 | Result := AContext;
|
---|
| 739 | end;
|
---|
| 740 |
|
---|
| 741 | procedure SaveCurrentContext(AContext: TSelectContext) ;
|
---|
| 742 | var
|
---|
| 743 | x: string;
|
---|
| 744 | begin
|
---|
| 745 | with AContext do
|
---|
| 746 | begin
|
---|
| 747 | SetPiece(x, ';', 1, BeginDate);
|
---|
| 748 | SetPiece(x, ';', 2, EndDate);
|
---|
| 749 | SetPiece(x, ';', 3, Status);
|
---|
| 750 | SetPiece(x, ';', 4, Service);
|
---|
| 751 | SetPiece(x, ';', 5, GroupBy);
|
---|
| 752 | SetPiece(x, ';', 6, BOOLCHAR[Ascending]);
|
---|
| 753 | end;
|
---|
| 754 | CallV('ORQQCN2 SAVE CONTEXT', [x]);
|
---|
| 755 | end;
|
---|
| 756 |
|
---|
| 757 | function GetDefaultReasonForRequest(Service: string; Resolve: Boolean): TStrings;
|
---|
| 758 | begin
|
---|
| 759 | CallV('ORQQCN DEFAULT REQUEST REASON',[Service, Patient.DFN, Resolve]) ;
|
---|
| 760 | Result := RPCBrokerV.Results;
|
---|
| 761 | end;
|
---|
| 762 |
|
---|
| 763 | function ReasonForRequestEditable(Service: string): string;
|
---|
| 764 | begin
|
---|
| 765 | Result := sCallV('ORQQCN EDIT DEFAULT REASON', [Service]);
|
---|
| 766 | end;
|
---|
| 767 |
|
---|
| 768 | function GetServicePrerequisites(Service: string): TStrings;
|
---|
| 769 | begin
|
---|
| 770 | CallV('ORQQCN2 GET PREREQUISITE',[Service, Patient.DFN]) ;
|
---|
| 771 | Result := RPCBrokerV.Results;
|
---|
| 772 | end;
|
---|
| 773 |
|
---|
| 774 | function GetNewDialog(OrderType: string): string;
|
---|
| 775 | { get dialog for new consults}
|
---|
| 776 | begin
|
---|
| 777 | Result := sCallV('ORWDCN32 NEWDLG', [OrderType, Encounter.Location]);
|
---|
| 778 | end;
|
---|
| 779 |
|
---|
| 780 | function GetServiceIEN(ORIEN: string): string;
|
---|
| 781 | begin
|
---|
| 782 | Result := sCallV('ORQQCN GET SERVICE IEN', [ORIEN]);
|
---|
| 783 | end;
|
---|
| 784 |
|
---|
| 785 | procedure GetProvDxMode(var ProvDx: TProvisionalDiagnosis; SvcIEN: string);
|
---|
| 786 | var
|
---|
| 787 | x: string;
|
---|
| 788 | begin
|
---|
| 789 | x := sCallV('ORQQCN PROVDX', [SvcIEN]);
|
---|
| 790 | ProvDx.Reqd := Piece(x, U, 1);
|
---|
| 791 | ProvDx.PromptMode := Piece(x, U, 2);
|
---|
| 792 | end;
|
---|
| 793 |
|
---|
| 794 | function GetConsultOrderIEN(ConsultIEN: integer): string;
|
---|
| 795 | begin
|
---|
| 796 | Result := sCallV('ORQQCN GET ORDER NUMBER', [ConsultIEN]);
|
---|
| 797 | end;
|
---|
| 798 |
|
---|
| 799 | function GetSavedCPFields(NoteIEN: integer): TEditNoteRec;
|
---|
| 800 | var
|
---|
| 801 | x: string;
|
---|
| 802 | AnEditRec: TEditNoteRec;
|
---|
| 803 | begin
|
---|
| 804 | x := sCallV('ORWTIU GET SAVED CP FIELDS', [NoteIEN]);
|
---|
| 805 | with AnEditRec do
|
---|
| 806 | begin
|
---|
| 807 | Author := StrToInt64Def(Piece(x, U, 1), 0);
|
---|
| 808 | Cosigner := StrToInt64Def(Piece(x, U, 2), 0);
|
---|
| 809 | ClinProcSummCode := StrToIntDef(Piece(x, U, 3), 0);
|
---|
| 810 | ClinProcDateTime := StrToFMDateTime(Piece(x, U, 4));
|
---|
| 811 | Title := StrToIntDef(Piece(x, U, 5), 0);
|
---|
| 812 | end;
|
---|
| 813 | Result := AnEditRec;
|
---|
| 814 | end;
|
---|
| 815 |
|
---|
| 816 | initialization
|
---|
| 817 | uLastOrderedIEN := 0;
|
---|
| 818 | uLastOrderMsg := '';
|
---|
| 819 | uConsultsClass := 0;
|
---|
| 820 | uClinProcClass := 0;
|
---|
| 821 |
|
---|
| 822 | finalization
|
---|
| 823 | if uConsultTitles <> nil then uConsultTitles.Free;
|
---|
| 824 | if uClinProcTitles <> nil then uClinProcTitles.Free;
|
---|
| 825 |
|
---|
| 826 | end.
|
---|