| 1 | unit uGraphs;
 | 
|---|
| 2 | 
 | 
|---|
| 3 | interface
 | 
|---|
| 4 | 
 | 
|---|
| 5 | uses
 | 
|---|
| 6 |   SysUtils, Classes, Graphics, ORFn;
 | 
|---|
| 7 | 
 | 
|---|
| 8 | type
 | 
|---|
| 9 |   TGraphSetting = class
 | 
|---|
| 10 |   public
 | 
|---|
| 11 |     ClearBackground: boolean;
 | 
|---|
| 12 |     Dates: boolean;
 | 
|---|
| 13 |     FixedDateRange: boolean;
 | 
|---|
| 14 |     FMStartDate: double;
 | 
|---|
| 15 |     FMStopDate: double;
 | 
|---|
| 16 |     Gradient: boolean;
 | 
|---|
| 17 |     HighTime: TDateTime;
 | 
|---|
| 18 |     Hints: boolean;
 | 
|---|
| 19 |     HorizontalZoom: boolean;
 | 
|---|
| 20 |     ItemsDisplayed: TStrings;
 | 
|---|
| 21 |     ItemsForDisplay: TStrings;
 | 
|---|
| 22 |     Legend: boolean;
 | 
|---|
| 23 |     Lines: boolean;
 | 
|---|
| 24 |     LowTime: TDateTime;
 | 
|---|
| 25 |     MaxGraphs: integer;
 | 
|---|
| 26 |     MaxSelect: integer;
 | 
|---|
| 27 |     MaxSelectMin: integer;
 | 
|---|
| 28 |     MaxSelectMax: integer;
 | 
|---|
| 29 |     MinGraphHeight: integer;
 | 
|---|
| 30 |     OptionSettings: string;              // only used for storage
 | 
|---|
| 31 |     Points: boolean;
 | 
|---|
| 32 |     SortByType: boolean;
 | 
|---|
| 33 |     SortColumn: integer;
 | 
|---|
| 34 |     Sources: TStrings;
 | 
|---|
| 35 |     StayOnTop: boolean;
 | 
|---|
| 36 |     Values: boolean;
 | 
|---|
| 37 |     VerticalZoom: boolean;
 | 
|---|
| 38 |     View3D: boolean;
 | 
|---|
| 39 |   end;
 | 
|---|
| 40 | 
 | 
|---|
| 41 | const
 | 
|---|
| 42 |   BIG_NUMBER = 9999999;
 | 
|---|
| 43 |   BIG_SPACES = '                                                                ';
 | 
|---|
| 44 |   FM_START_DATE = 2500101;
 | 
|---|
| 45 |   FM_STOP_DATE = 3500101;
 | 
|---|
| 46 |   MAX_ITEM_DISCLAIMER = 10;
 | 
|---|
| 47 |   NUM_COLORS = 16;
 | 
|---|
| 48 |   PROB_HEIGHT = 2;
 | 
|---|
| 49 |   RX_HEIGHT_IN = 12;
 | 
|---|
| 50 |   RX_HEIGHT_NVA = 9;
 | 
|---|
| 51 |   RX_HEIGHT_OUT = 15;
 | 
|---|
| 52 |   ZOOM_PERCENT = 95;
 | 
|---|
| 53 |   GRAPH_FLOAT = 'F';
 | 
|---|
| 54 |   GRAPH_REPORT = 'R';
 | 
|---|
| 55 | 
 | 
|---|
| 56 |     // settings use single character
 | 
|---|
| 57 |   SETTING_3D = 'A';
 | 
|---|
| 58 |   SETTING_CLEAR = 'B';
 | 
|---|
| 59 |   SETTING_DATES = 'C';
 | 
|---|
| 60 |   SETTING_GRADIENT = 'D';
 | 
|---|
| 61 |   SETTING_HINTS = 'E';
 | 
|---|
| 62 |   SETTING_LEGEND = 'F';
 | 
|---|
| 63 |   SETTING_LINES = 'G';
 | 
|---|
| 64 |   SETTING_SORT = 'H';
 | 
|---|
| 65 |   SETTING_TOP = 'I';
 | 
|---|
| 66 |   SETTING_VALUES = 'J';
 | 
|---|
| 67 |   SETTING_HZOOM = 'K';
 | 
|---|
| 68 |   SETTING_VZOOM = 'L';
 | 
|---|
| 69 |   SETTING_FIXED = 'M';
 | 
|---|
| 70 | 
 | 
|---|
| 71 |   // keypress flags
 | 
|---|
| 72 |   KEYPRESS_ON = 'YES';
 | 
|---|
| 73 |   KEYPRESS_OFF = 'NO';
 | 
|---|
| 74 | 
 | 
|---|
| 75 |   // format date/time axis
 | 
|---|
| 76 |   DFORMAT_MDY = 'm/d/yyyy';
 | 
|---|
| 77 |   DFORMAT_MYY = 'm/yy';
 | 
|---|
| 78 |   DFORMAT_YY = 'yy';
 | 
|---|
| 79 |   DWIDTH_MDY = 66;
 | 
|---|
| 80 |   DWIDTH_MYY = 30;
 | 
|---|
| 81 |   DWIDTH_YY = 18;
 | 
|---|
| 82 | 
 | 
|---|
| 83 |   // text messages
 | 
|---|
| 84 |   TXT_DISCLAIMER = 'Due to number of items and size restrictions on your display, '
 | 
|---|
| 85 |     + 'all items may not be visible.';
 | 
|---|
| 86 |   TXT_COPY_DISCLAIMER = 'Note: Graphs display limited data, view details for more information.';
 | 
|---|
| 87 |   TXT_REPORT_DISCLAIMER = 'Note: Listing displays limited data, view details for more information.';
 | 
|---|
| 88 |   TXT_INFO = 'Select multiple items using Ctrl-click or Shift-click.';
 | 
|---|
| 89 |   TXT_PRINTING = 'Graphs are being printed';
 | 
|---|
| 90 |   TXT_WARNING = 'Warning: You are using graph settings with a Special Function.';
 | 
|---|
| 91 |   TXT_WARNING_SAME_TIME = 'Warning: Items have multiple occurrences at the same time.';
 | 
|---|
| 92 |   TXT_ZOOMED = 'Zoomed Date Range: ';
 | 
|---|
| 93 | 
 | 
|---|
| 94 |   COLOR_INFO = clCream;
 | 
|---|
| 95 |   COLOR_PRINTING = clMoneyGreen;    //$CCFFFF; $CCCCFF; $CCFFCC; $FFCCCC; $FFCCFF; $FFFFCC;
 | 
|---|
| 96 |   COLOR_WARNING = clCream;  //clFuchsia;
 | 
|---|
| 97 |   COLOR_ZOOM = clCream;  //clSkyBlue;
 | 
|---|
| 98 | 
 | 
|---|
| 99 |   // hint messages for view definition
 | 
|---|
| 100 |   HINT_PAT_SOURCE     = 'Only items where the patient has data are displayed.'
 | 
|---|
| 101 |                 + #13 + 'Use this for selecting items to display on the graph.';
 | 
|---|
| 102 |   HINT_ALL_SOURCE     = 'All possible items are displayed.'
 | 
|---|
| 103 |                 + #13 + 'Use this for defining items to be displayed/saved as Views.'
 | 
|---|
| 104 |                 + #13 + 'Note: For easy use, select Views for graphing.';
 | 
|---|
| 105 |   HINT_SELECTION_INFO = 'This form is primarily used for defining views.'
 | 
|---|
| 106 |                 + #13 + 'Usually selection is done by selecting Views or Items to graph.'
 | 
|---|
| 107 |                 + #13 + 'This form defines views.'
 | 
|---|
| 108 |                 + #13 + 'The Settings form defines items that are always selectable for graphing.';
 | 
|---|
| 109 |   HINT_SOURCE         = 'These are the different types of data.'
 | 
|---|
| 110 |                 + #13 + 'Types are followed by a section showing your Personal Views, then Public Views.'
 | 
|---|
| 111 |                 + #13 + 'Click a type and then select individual items'
 | 
|---|
| 112 |                 + #13 + 'Double-click a type to select all items of this type  - <any>';
 | 
|---|
| 113 |   HINT_SELECTION      = 'Select specific items and move them to the right.'
 | 
|---|
| 114 |                 + #13 + 'Use the arrow buttons or double click.'
 | 
|---|
| 115 |                 + #13 + 'Selecting a type <any> will use all patients for that type.';
 | 
|---|
| 116 |   HINT_DISPLAY        = 'This is the list of items, types, and/or views that compose the View that will be graphed.'
 | 
|---|
| 117 |                 + #13 + 'You can save this as a personal view by clicking the Save Personal button.';
 | 
|---|
| 118 |   HINT_BTN_ADDALL     = 'Click to add all items for display.';
 | 
|---|
| 119 |   HINT_BTN_ADD1       = 'Click to add this item for display (or double-click item).';
 | 
|---|
| 120 |   HINT_BTN_REMOVE1    = 'Click to remove this item from display (or double-click item).';
 | 
|---|
| 121 |   HINT_BTN_REMOVEALL  = 'Click to remove all items from display.';
 | 
|---|
| 122 |   HINT_BTN_CLEAR      = 'Click to clear the Items and Items for Graphing lists.';
 | 
|---|
| 123 |   HINT_BTN_DELETE     = 'Click to delete the selected view.';
 | 
|---|
| 124 |   HINT_BTN_RENAME     = 'Click to rename the selected view.';
 | 
|---|
| 125 |   HINT_BTN_SAVE       = 'Click to save your view.'
 | 
|---|
| 126 |                 + #13 + 'You will give this view a name that can be selected from the graph.';
 | 
|---|
| 127 |   HINT_BTN_SAVE_PUB   = 'Click to save a public view (available to editors only).'
 | 
|---|
| 128 |                 + #13 + 'Public views can be selected by all users.';
 | 
|---|
| 129 |   HINT_APPLY          = 'Select the section you where you want to display the graph.';
 | 
|---|
| 130 |   HINT_BTN_CLOSE      = 'Click to display items for graphing.'
 | 
|---|
| 131 |                 + #13 + 'Note: If you are using this from the Options menu, '
 | 
|---|
| 132 |                 + #13 + 'items are not displayed (multiple graphs may be in use).'
 | 
|---|
| 133 |                 + #13 + 'You should save any view definitions before closing this form.';
 | 
|---|
| 134 | 
 | 
|---|
| 135 | 
 | 
|---|
| 136 | 
 | 
|---|
| 137 |   // hint messages for settings
 | 
|---|
| 138 |   SHINT_SOURCES     = 'This is a list of all the types of data that can be graphed.'
 | 
|---|
| 139 |               + #13 + 'Check the types you wish to be selectable on the graph.'
 | 
|---|
| 140 |               + #13 + 'It is best to only check the types that you frequently use.'
 | 
|---|
| 141 |               + #13 + 'If you select a view on the graph that has types defined that are not checked,'
 | 
|---|
| 142 |               + #13 + 'that type of data will become automatically checked.'
 | 
|---|
| 143 |               + #13 + 'Note: Data is only selectable if the patient has that type of data';
 | 
|---|
| 144 |   SHINT_OPTIONS     = 'Check options to change the appearance and behavior of the graph.'
 | 
|---|
| 145 |               + #13 + 'Common options are also available on the graph''s right-click menu';
 | 
|---|
| 146 |   SHINT_MAX =         'Enter the maximum number of graphs to appear on the screen.'
 | 
|---|
| 147 |               + #13 + 'This is used when individual graphs are displayed and'
 | 
|---|
| 148 |               + #13 + 'applies to both the top and bottom sections.'
 | 
|---|
| 149 |               + #13 + 'When the number of graphs exceeds this limited, the graphs are available by scrolling.';
 | 
|---|
| 150 |   SHINT_MIN         = 'Enter the minimum height of a graph (this is in pixels).'
 | 
|---|
| 151 |               + #13 + 'This will depend on the size of your display.'
 | 
|---|
| 152 |               + #13 + 'This setting assures that at least this amount of height will appear on the graph.'
 | 
|---|
| 153 |               + #13 + 'Use in combination with Max Graphs in Display.';
 | 
|---|
| 154 |   SHINT_MAX_ITEMS   = 'Enter the maximum number of items that can be graphed at one time.'
 | 
|---|
| 155 |               + #13 + 'This setting prevents you from mistakenly selecting a large number of items.';
 | 
|---|
| 156 |   SHINT_FUNCTIONS   = 'These functions are restricted to editors for evaluation.';
 | 
|---|
| 157 |   SHINT_BTN_SHOW    = 'Click these buttons to display default settings.';
 | 
|---|
| 158 |   SHINT_BTN_PER     = 'Click to display your personal settings.';
 | 
|---|
| 159 |   SHINT_BTN_PUB     = 'Click to display the default settings.'
 | 
|---|
| 160 |               + #13 + 'These settings are used when you have not saved a personal setting.';
 | 
|---|
| 161 |   SHINT_BTN_SAVE    = 'Click these buttons to save default settings.';
 | 
|---|
| 162 |   SHINT_BTN_PERSAVE = 'Click to save your personal defaults';
 | 
|---|
| 163 |   SHINT_BTN_PUBSAVE = 'Click to save the public default (available to editors only).';
 | 
|---|
| 164 |   SHINT_BTN_ALL     = 'Click to check all sources.';
 | 
|---|
| 165 |   SHINT_BTN_CLEAR   = 'Click to uncheck all sources.';
 | 
|---|
| 166 |   SHINT_BTN_CLOSE   = 'Click to display these settings for graphing.'
 | 
|---|
| 167 |               + #13 + 'To cancel any unsaved changes you''ve made, click the upper-right x box.'
 | 
|---|
| 168 |               + #13 + 'Note: If you are using this from the Options menu, '
 | 
|---|
| 169 |               + #13 + 'settings will not change your display (multiple graphs may be in use).'
 | 
|---|
| 170 |               + #13 + 'You should save any settings before closing this form.';
 | 
|---|
| 171 | 
 | 
|---|
| 172 | function GraphSettingsInit(settings: string): TGraphSetting;
 | 
|---|
| 173 | 
 | 
|---|
| 174 | 
 | 
|---|
| 175 | implementation
 | 
|---|
| 176 | 
 | 
|---|
| 177 | function GraphSettingsInit(settings: string): TGraphSetting;
 | 
|---|
| 178 | var
 | 
|---|
| 179 |   FGraphSetting: TGraphSetting;
 | 
|---|
| 180 | begin
 | 
|---|
| 181 |   FGraphSetting := TGraphSetting.Create;
 | 
|---|
| 182 |   with FGraphSetting do
 | 
|---|
| 183 |   begin
 | 
|---|
| 184 |     OptionSettings := Piece(settings, '|', 2);
 | 
|---|
| 185 |     SortColumn := strtointdef(Piece(settings, '|', 3), 0);
 | 
|---|
| 186 |     MaxGraphs := strtointdef(Piece(settings, '|', 4), 5);
 | 
|---|
| 187 |     MinGraphHeight := strtointdef(Piece(settings, '|', 5), 90);
 | 
|---|
| 188 |     MaxSelect := strtointdef(Piece(settings, '|', 7), 100);
 | 
|---|
| 189 |     MaxSelectMin := 1;
 | 
|---|
| 190 |     MaxSelectMax := strtointdef(Piece(settings, '|', 8), 1000);
 | 
|---|
| 191 |     Values := Pos(SETTING_VALUES, OptionSettings) > 0;
 | 
|---|
| 192 |     VerticalZoom := Pos(SETTING_VZOOM, OptionSettings) > 0;
 | 
|---|
| 193 |     HorizontalZoom := Pos(SETTING_HZOOM, OptionSettings) > 0;
 | 
|---|
| 194 |     View3D := Pos(SETTING_3D, OptionSettings) > 0;
 | 
|---|
| 195 |     Legend := Pos(SETTING_LEGEND, OptionSettings) > 0;
 | 
|---|
| 196 |     Dates := Pos(SETTING_DATES, OptionSettings) > 0;
 | 
|---|
| 197 |     Lines := Pos(SETTING_LINES, OptionSettings) > 0;
 | 
|---|
| 198 |     StayOnTop := Pos(SETTING_TOP, OptionSettings) > 0;
 | 
|---|
| 199 |     SortByType := Pos(SETTING_SORT, OptionSettings) > 0;
 | 
|---|
| 200 |     ClearBackground := Pos(SETTING_CLEAR, OptionSettings) > 0;
 | 
|---|
| 201 |     Gradient := Pos(SETTING_GRADIENT, OptionSettings) > 0;
 | 
|---|
| 202 |     Hints := Pos(SETTING_HINTS, OptionSettings) > 0;
 | 
|---|
| 203 |     FixedDateRange := Pos(SETTING_FIXED, OptionSettings) > 0;
 | 
|---|
| 204 |     HighTime := 0;
 | 
|---|
| 205 |     LowTime := BIG_NUMBER;
 | 
|---|
| 206 |     FMStartDate := FM_START_DATE;
 | 
|---|
| 207 |     FMStopDate := FM_STOP_DATE;
 | 
|---|
| 208 |     if SortByType then SortColumn := 1 else SortColumn := 0;
 | 
|---|
| 209 |   end;
 | 
|---|
| 210 |   Result := FGraphSetting;
 | 
|---|
| 211 | end;
 | 
|---|
| 212 | 
 | 
|---|
| 213 | end.
 | 
|---|