| 1 | //kt -- Modified with SourceScanner on 7/15/2007
 | 
|---|
| 2 | unit fClinicWardMeds;
 | 
|---|
| 3 | 
 | 
|---|
| 4 | interface
 | 
|---|
| 5 | 
 | 
|---|
| 6 | uses
 | 
|---|
| 7 |   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 | 
|---|
| 8 |   Dialogs, fAutoSz, StdCtrls, ExtCtrls, ORCtrls,ORFn, rCore, uCore, oRNet, Math,
 | 
|---|
| 9 |   DKLang;
 | 
|---|
| 10 | 
 | 
|---|
| 11 | type
 | 
|---|
| 12 |   TfrmClinicWardMeds = class(TfrmAutoSz)
 | 
|---|
| 13 |     stxtLine3: TStaticText;
 | 
|---|
| 14 |     stxtLine2: TStaticText;
 | 
|---|
| 15 |     stxtLine1: TStaticText;
 | 
|---|
| 16 |     btnClinic: TButton;
 | 
|---|
| 17 |     btnWard: TButton;
 | 
|---|
| 18 |     procedure btnClinicClick(Sender: TObject);
 | 
|---|
| 19 |     procedure btnWardClick(Sender: TObject);
 | 
|---|
| 20 | 
 | 
|---|
| 21 |   private
 | 
|---|
| 22 |     //kt Begin Mod (change Consts to Vars) 7/15/2007
 | 
|---|
| 23 |     LOCATION_CHANGE_1  : string;  //kt
 | 
|---|
| 24 |     LOCATION_CHANGE_2  : string;  //kt
 | 
|---|
| 25 |     LOCATION_CHANGE_3  : string;  //kt
 | 
|---|
| 26 |     PRINT_LOCATION_1   : string;  //kt
 | 
|---|
| 27 |     PRINT_LOCATION_2   : string;  //kt
 | 
|---|
| 28 |     //kt End Mod -------------------
 | 
|---|
| 29 |     { Private declarations }
 | 
|---|
| 30 |     procedure StartLocationCheck;
 | 
|---|
| 31 |     procedure rpcChangeOrderLocation(pOrderList:TStringList);
 | 
|---|
| 32 |     procedure BuildMessage(MsgSw:string);
 | 
|---|
| 33 |     function  BuildOrderLocList(pOrderList:TStringList; pLocation:integer):TStringList;
 | 
|---|
| 34 |     procedure SetupVars;
 | 
|---|
| 35 | 
 | 
|---|
| 36 |   public
 | 
|---|
| 37 |     { Public declarations }
 | 
|---|
| 38 |     // passes order list and selected locations to rpc to be saved with order.
 | 
|---|
| 39 |     procedure ClinicOrWardLocation(pOrderList:TStringList; pEncounterLoc: integer; pEncounterLocName: string; var RetLoc: integer); overload;
 | 
|---|
| 40 |     // returns Location selected by user.
 | 
|---|
| 41 |     function  ClinicOrWardLocation(pEncounterLoc: integer):integer;overLoad;
 | 
|---|
| 42 |     function  rpcIsPatientOnWard(Patient: string): boolean;
 | 
|---|
| 43 |     function  SelectPrintLocation(pEncounterLoc:integer):integer;
 | 
|---|
| 44 |   end;
 | 
|---|
| 45 | 
 | 
|---|
| 46 | var
 | 
|---|
| 47 |   frmClinicWardMeds: TfrmClinicWardMeds;
 | 
|---|
| 48 |   ALocation,AWardLoc, AClinicLoc : integer;
 | 
|---|
| 49 |   ASelectedLoc: integer;
 | 
|---|
| 50 |   AName, ASvc, AWardName, AClinicName: string;
 | 
|---|
| 51 |   AOrderLocList: TStringList;
 | 
|---|
| 52 |   AMsgSw: string;
 | 
|---|
| 53 | 
 | 
|---|
| 54 | const
 | 
|---|
| 55 | //LOCATION_CHANGE_1 = 'This patient is currently admitted to ward';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 56 | //LOCATION_CHANGE_2 = 'These orders are written at clinic';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 57 | //LOCATION_CHANGE_3 = 'Where do you want the orders administered?';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 58 |    //GE CQ9537  - Message text
 | 
|---|
| 59 | //PRINT_LOCATION_1 = 'The patient has been admitted to Ward ';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 60 | //PRINT_LOCATION_2 =  'Should the orders be printed using the new location?';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 61 |   LOC_PRINT_MSG    = 'P';
 | 
|---|
| 62 |   LOC_MSG          = 'L';
 | 
|---|
| 63 | 
 | 
|---|
| 64 | implementation
 | 
|---|
| 65 | 
 | 
|---|
| 66 | uses fFrame;
 | 
|---|
| 67 | 
 | 
|---|
| 68 | {$R *.dfm}
 | 
|---|
| 69 | 
 | 
|---|
| 70 | //entry point
 | 
|---|
| 71 |  
 | 
|---|
| 72 |  
 | 
|---|
| 73 | procedure TfrmClinicWardMeds.SetupVars;
 | 
|---|
| 74 | //kt Added entire function to replace constant declarations 7/15/2007
 | 
|---|
| 75 | begin
 | 
|---|
| 76 |   LOCATION_CHANGE_1 := DKLangConstW('fClinicWardMeds_This_patient_is_currently_admitted_to_ward');
 | 
|---|
| 77 |   LOCATION_CHANGE_2 := DKLangConstW('fClinicWardMeds_These_orders_are_written_at_clinic');
 | 
|---|
| 78 |   LOCATION_CHANGE_3 := DKLangConstW('fClinicWardMeds_Where_do_you_want_the_orders_administered');
 | 
|---|
| 79 |   PRINT_LOCATION_1 := DKLangConstW('fClinicWardMeds_The_patient_has_been_admitted_to_Ward');
 | 
|---|
| 80 |   PRINT_LOCATION_2 :=  DKLangConstW('fClinicWardMeds_Should_the_orders_be_printed_using_the_new_location'); 
 | 
|---|
| 81 | end;
 | 
|---|
| 82 |  
 | 
|---|
| 83 | function  TfrmClinicWardMeds.ClinicOrWardLocation(pEncounterLoc:integer):integer;
 | 
|---|
| 84 | begin
 | 
|---|
| 85 |   // Patient's current location
 | 
|---|
| 86 |    AClinicLoc  := pEncounterLoc;
 | 
|---|
| 87 |    AClinicName := Encounter.LocationName;
 | 
|---|
| 88 |    AMsgSw := LOC_MSG;
 | 
|---|
| 89 |    StartLocationCheck;
 | 
|---|
| 90 |    Result := ASelectedLoc;
 | 
|---|
| 91 |    frmClinicWardMeds.Close;
 | 
|---|
| 92 | end;
 | 
|---|
| 93 | 
 | 
|---|
| 94 | //entry point
 | 
|---|
| 95 | procedure TfrmClinicWardMeds.ClinicOrWardLocation(pOrderList:TStringList;pEncounterLoc:integer;pEncounterLocName:string; var RetLoc: integer);
 | 
|---|
| 96 | begin
 | 
|---|
| 97 |   AClinicLoc        := pEncounterLoc;
 | 
|---|
| 98 |   AClinicName       := pEncounterLocName;
 | 
|---|
| 99 |   AOrderLocList     := TStringList.create;
 | 
|---|
| 100 |   AOrderLocList.Clear;
 | 
|---|
| 101 |   AMsgSw := LOC_MSG;
 | 
|---|
| 102 |   StartLocationCheck;
 | 
|---|
| 103 |   if pOrderList.Count > 0 then
 | 
|---|
| 104 |      begin
 | 
|---|
| 105 |        rpcChangeOrderLocation(BuildOrderLocList(pOrderList, ASelectedLoc));
 | 
|---|
| 106 |        RetLoc := ASelectedLoc
 | 
|---|
| 107 |      end;
 | 
|---|
| 108 |   if Assigned(AOrderLocList) then FreeAndNil(AOrderLocList);
 | 
|---|
| 109 |   frmClinicWardMeds.Close;
 | 
|---|
| 110 | end;
 | 
|---|
| 111 | 
 | 
|---|
| 112 | // returns button selected by user - ward or clinic.  print location
 | 
|---|
| 113 | //entry point  -
 | 
|---|
| 114 | function  TfrmClinicWardMeds.SelectPrintLocation(pEncounterLoc:integer):integer;
 | 
|---|
| 115 | begin
 | 
|---|
| 116 |    AClinicLoc        := pEncounterLoc;
 | 
|---|
| 117 |    AMsgSw            := LOC_PRINT_MSG;
 | 
|---|
| 118 |    StartLocationCheck;
 | 
|---|
| 119 |    Result := ASelectedLoc;
 | 
|---|
| 120 |    frmClinicWardMeds.Close;
 | 
|---|
| 121 | end;
 | 
|---|
| 122 | 
 | 
|---|
| 123 | procedure TfrmClinicWardMeds.StartLocationCheck;
 | 
|---|
| 124 | begin
 | 
|---|
| 125 | 
 | 
|---|
| 126 |   frmClinicWardMeds := TfrmClinicWardMeds.Create(Application);
 | 
|---|
| 127 |  // ResizeFormToFont(TForm(frmClinicWardMeds));
 | 
|---|
| 128 |   CurrentLocationForPatient(Patient.DFN, ALocation, AName, ASvc);
 | 
|---|
| 129 |   AWardLoc := ALocation; //current location
 | 
|---|
| 130 |   AWardName := AName; // current location name
 | 
|---|
| 131 |   if AMsgSW = LOC_PRINT_MSG then BuildMessage(AMsgSw)
 | 
|---|
| 132 |   else
 | 
|---|
| 133 |      if (ALocation > 0) and (ALocation <> AClinicLoc) then BuildMessage(AMsgSw); //Location has changed, patient admitted
 | 
|---|
| 134 | end;
 | 
|---|
| 135 | 
 | 
|---|
| 136 | procedure TfrmClinicWardMeds.btnClinicClick(Sender: TObject);
 | 
|---|
| 137 | begin
 | 
|---|
| 138 |   inherited;
 | 
|---|
| 139 |   ASelectedLoc := AClinicLoc;
 | 
|---|
| 140 |   frmClinicWardMeds.Close;
 | 
|---|
| 141 | end;
 | 
|---|
| 142 | 
 | 
|---|
| 143 | procedure TfrmClinicWardMeds.btnWardClick(Sender: TObject);
 | 
|---|
| 144 | begin
 | 
|---|
| 145 |   inherited;
 | 
|---|
| 146 |    ASelectedLoc := AWardLoc;
 | 
|---|
| 147 |    frmClinicWardMeds.Close;
 | 
|---|
| 148 | end;
 | 
|---|
| 149 | 
 | 
|---|
| 150 | procedure TfrmClinicWardMeds.BuildMessage(MsgSw:string);
 | 
|---|
| 151 | var
 | 
|---|
| 152 |  ALine1Len, ALine2Len, ALine3Len, ALongLine: integer;
 | 
|---|
| 153 | begin
 | 
|---|
| 154 |   SetupVars;  //kt added 7/15/2007 to replace constants with vars.
 | 
|---|
| 155 |     with frmClinicWardMeds do
 | 
|---|
| 156 |     begin
 | 
|---|
| 157 | //     btnWard.Caption   := 'Ward';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 158 |        btnWard.Caption   := DKLangConstW('fClinicWardMeds_Ward'); //kt added 7/15/2007
 | 
|---|
| 159 | //     btnClinic.Caption := 'Clinic';  <-- original line.  //kt 7/15/2007
 | 
|---|
| 160 |        btnClinic.Caption := DKLangConstW('fClinicWardMeds_Clinic'); //kt added 7/15/2007
 | 
|---|
| 161 |        // message text
 | 
|---|
| 162 |        if MsgSw = LOC_MSG then
 | 
|---|
| 163 |        begin
 | 
|---|
| 164 |           //AClinicName := 'this is my long test clinic Name';
 | 
|---|
| 165 |           stxtLine1.Caption := LOCATION_CHANGE_1 + ' :' + AWardName;
 | 
|---|
| 166 |           stxtLine2.Caption := LOCATION_CHANGE_2+ ' :' + AClinicName;
 | 
|---|
| 167 |           stxtLine3.Caption := LOCATION_CHANGE_3;
 | 
|---|
| 168 |        end
 | 
|---|
| 169 |        else
 | 
|---|
| 170 |           begin
 | 
|---|
| 171 |               stxtLine1.Caption := PRINT_LOCATION_1 + ':' + AWardName;
 | 
|---|
| 172 |               stxtLine2.Caption := PRINT_LOCATION_2;
 | 
|---|
| 173 |               stxtLine3.Caption := '';
 | 
|---|
| 174 |           end;
 | 
|---|
| 175 |     stxtLine2.Left := stxtLine1.left;
 | 
|---|
| 176 |     stxtLine3.Left := stxtLine1.left;
 | 
|---|
| 177 |     ALine1Len := TextWidthByFont(frmClinicWardMeds.stxtLine1.Font.Handle, frmClinicWardMeds.stxtLine1.Caption);
 | 
|---|
| 178 |     ALine2Len := TextWidthByFont(frmClinicWardMeds.stxtLine2.Font.Handle, frmClinicWardMeds.stxtLine2.Caption);
 | 
|---|
| 179 |     ALine3Len := TextWidthByFont(frmClinicWardMeds.stxtLine3.Font.Handle, frmClinicWardMeds.stxtLine3.Caption)+25;
 | 
|---|
| 180 |     ALongLine := Max(ALine1Len,ALine2Len);
 | 
|---|
| 181 |     ALongLine := Max(ALine3Len,ALongLine);
 | 
|---|
| 182 |     frmClinicWardMeds.Width := (ALongLine + frmClinicWardMeds.stxtLine1.Left + 15);
 | 
|---|
| 183 |     end;
 | 
|---|
| 184 |     frmClinicWardMeds.ShowModal;
 | 
|---|
| 185 |     frmClinicWardMeds.Release;
 | 
|---|
| 186 | 
 | 
|---|
| 187 | end;
 | 
|---|
| 188 | 
 | 
|---|
| 189 | function  TfrmClinicWardMeds.BuildOrderLocList(pOrderList:TStringList; pLocation:integer):TStringList;
 | 
|---|
| 190 | var i:integer;
 | 
|---|
| 191 |     AOrderLoc: string;
 | 
|---|
| 192 | begin
 | 
|---|
| 193 |    AOrderLocList.clear;
 | 
|---|
| 194 |    for i := 0 to pOrderList.Count -1 do
 | 
|---|
| 195 |    begin
 | 
|---|
| 196 |       AOrderLoc := Piece(pOrderList.Strings[i],U,1) + U + IntToStr(pLocation);
 | 
|---|
| 197 |       AOrderLocList.Add(AOrderLoc);
 | 
|---|
| 198 |    end;
 | 
|---|
| 199 |    Result := AOrderLocList; //return value
 | 
|---|
| 200 | end;
 | 
|---|
| 201 | 
 | 
|---|
| 202 | procedure TfrmClinicWardMeds.rpcChangeOrderLocation(pOrderList:TStringList);
 | 
|---|
| 203 | begin
 | 
|---|
| 204 | // OrderIEN^Location  -- used to alter location if ward is selected.
 | 
|---|
| 205 | 
 | 
|---|
| 206 |    CallV('ORWDX CHANGE',[pOrderList, Patient.DFN]); 
 | 
|---|
| 207 | end;
 | 
|---|
| 208 | 
 | 
|---|
| 209 | function TfrmClinicWardMeds.rpcIsPatientOnWard(Patient: string): boolean;
 | 
|---|
| 210 | begin
 | 
|---|
| 211 |   result := sCallV('ORWDX1 PATWARD',[Patient]) = '1'; 
 | 
|---|
| 212 | end;
 | 
|---|
| 213 | 
 | 
|---|
| 214 | 
 | 
|---|
| 215 | end.
 | 
|---|