1 | unit fODAuto;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | fODBase, StdCtrls, ComCtrls, ExtCtrls, ORFn, ORCtrls;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmODAuto = class(TfrmODBase)
|
---|
11 | Label1: TLabel;
|
---|
12 | public
|
---|
13 | procedure InitDialog; override;
|
---|
14 | procedure SetupDialog(OrderAction: Integer; const ID: string); override;
|
---|
15 | procedure Validate(var AnErrMsg: string); override;
|
---|
16 | end;
|
---|
17 |
|
---|
18 | var
|
---|
19 | frmODAuto: TfrmODAuto;
|
---|
20 |
|
---|
21 | implementation
|
---|
22 |
|
---|
23 | {$R *.DFM}
|
---|
24 |
|
---|
25 | uses rODBase, rOrders, fTemplateDialog, uTemplateFields, rTemplates, uConst, uTemplates,
|
---|
26 | rConsults, uCore, uODBase;
|
---|
27 |
|
---|
28 | procedure TfrmODAuto.InitDialog;
|
---|
29 | begin
|
---|
30 | inherited;
|
---|
31 | // nothing for now
|
---|
32 | end;
|
---|
33 |
|
---|
34 | procedure TfrmODAuto.Validate(var AnErrMsg: string);
|
---|
35 | var
|
---|
36 | cptn, tmp, DocInfo: string;
|
---|
37 | TempSL: TStringList;
|
---|
38 | LType: TTemplateLinkType;
|
---|
39 | IEN: integer;
|
---|
40 | HasObjects: boolean;
|
---|
41 |
|
---|
42 | begin
|
---|
43 | inherited;
|
---|
44 | DocInfo := '';
|
---|
45 | LType := DisplayGroupToLinkType(Responses.DisplayGroup);
|
---|
46 | tmp := Responses.EValueFor('COMMENT', 1);
|
---|
47 | ExpandOrderObjects(tmp, HasObjects);
|
---|
48 | Responses.OrderContainsObjects := Responses.OrderContainsObjects or HasObjects;
|
---|
49 | if (LType <> ltNone) or HasTemplateField(tmp) then
|
---|
50 | begin
|
---|
51 | cptn := 'Reason for Request: ' + Responses.EValueFor('ORDERABLE', 1);
|
---|
52 | case LType of
|
---|
53 | ltConsult: IEN := StrToIntDef(GetServiceIEN(Responses.IValueFor('ORDERABLE', 1)),0);
|
---|
54 | ltProcedure: IEN := StrToIntDef(GetProcedureIEN(Responses.IValueFor('ORDERABLE', 1)),0);
|
---|
55 | else IEN := 0;
|
---|
56 | end;
|
---|
57 | if IEN <> 0 then
|
---|
58 | ExecuteTemplateOrBoilerPlate(tmp, IEN, LType, nil, cptn, DocInfo)
|
---|
59 | else
|
---|
60 | CheckBoilerplate4Fields(tmp, cptn);
|
---|
61 |
|
---|
62 | if tmp <> '' then
|
---|
63 | Responses.Update('COMMENT', 1, TX_WPTYPE, tmp)
|
---|
64 | else
|
---|
65 | begin
|
---|
66 | TempSL := TStringList.Create;
|
---|
67 | try
|
---|
68 | TempSL.Text := Responses.EValueFor('COMMENT', 1);
|
---|
69 | Convert2LMText(TempSL);
|
---|
70 | Responses.Update('COMMENT', 1, TX_WPTYPE, TempSL.Text);
|
---|
71 | finally
|
---|
72 | TempSL.Free;
|
---|
73 | end;
|
---|
74 | end;
|
---|
75 | end;
|
---|
76 | end;
|
---|
77 |
|
---|
78 | procedure TfrmODAuto.SetupDialog(OrderAction: Integer; const ID: string);
|
---|
79 | var
|
---|
80 | DialogNames: TDialogNames;
|
---|
81 | begin
|
---|
82 | inherited; // Responses is already loaded here
|
---|
83 | AutoAccept := True;
|
---|
84 | StatusText('Loading Dialog Definition');
|
---|
85 | FillerID := FillerIDForDialog(DialogIEN);
|
---|
86 | IdentifyDialog(DialogNames, DialogIEN);
|
---|
87 | Responses.Dialog := DialogNames.BaseName; // loads formatting info
|
---|
88 | StatusText('');
|
---|
89 | end;
|
---|
90 |
|
---|
91 | end.
|
---|