-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMDN110UT.pas
754 lines (555 loc) · 20.8 KB
/
MDN110UT.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
{===============================================================================
Program ID : MDN110UT
Program Name : 중환자실 통합기록지 - 간호사정
Program Desc. : 중환자실 통합기록지 중 간호사정 부부을 관리한다.
Author : ByoungSik, Lee
Date : 2010.12.16
===============================================================================}
unit MDN110UT;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, ExtCtrls, Buttons, Grids, BaseGrid, AdvGrid, RxGIF,
AdvPicture, AdvPanel, Db, DBClient, Variants, RxAnimate, RxGIFCtrl, AdvObj;
type
TMDN110FT = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Panel2: TPanel;
stb_Message: TStatusBar;
bbt_Close: TBitBtn;
asg_Header: TAdvStringGrid;
asg_Data: TAdvStringGrid;
Panel3: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
dtp_ActDate: TDateTimePicker;
sbt_Previous: TSpeedButton;
sbt_Next: TSpeedButton;
Label20: TLabel;
AdvPanel1: TAdvPanel;
Memo1: TMemo;
cds_ItemValues: TClientDataSet;
cds_ItemValuessetcode: TStringField;
cds_ItemValuesitemcode: TStringField;
cds_ItemValuesvaluecd: TStringField;
cds_ItemValuesvaluenm: TStringField;
cds_ItemValuesdispseq: TStringField;
// Event Handler -----------------------------------------------------------
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure bbt_CloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure asg_HeaderGetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
procedure asg_DataGetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
procedure asg_DataCanEditCell(Sender: TObject; ARow, ACol: Integer; var CanEdit: Boolean);
procedure asg_DataGetEditorType(Sender: TObject; ACol, ARow: Integer; var AEditor: TEditorType);
procedure dtp_ActDateCloseUp(Sender: TObject);
procedure sbt_PreviousClick(Sender: TObject);
procedure sbt_NextClick(Sender: TObject);
procedure asg_HeaderGetEditMask(Sender: TObject; ACol, ARow: Integer;
var Value: String);
//--------------------------------------------------------------------------
private
{ Private declarations }
FDuties : TList; // Duty별 사정 정보
FRecItems : TList; // 기록 항목 리스트
// 초기화
procedure Initialize;
// 조회
procedure Search;
// 기록 항목 리스트 조회
procedure LoadRecordItemList;
// 전체 입력항목별 입력 값 목록 조회
procedure LoadAllItemValues;
public
{ Public declarations }
end;
var
MDN110FT: TMDN110FT;
implementation
uses
VarCom, TuxCom, HisUtil, CComFunc, MComFunc, MDCLASS1;
{$R *.DFM}
//------------------------------------------------------------------------------
// Form onClose Event Handler
//
// Author : ByoungSik, Lee
// Date : 2010.12.16
//------------------------------------------------------------------------------
procedure TMDN110FT.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
//------------------------------------------------------------------------------
// Form onDestroy Event Handler
//
// Author : ByoungSik, Lee
// Date : 2010.12.16
//------------------------------------------------------------------------------
procedure TMDN110FT.FormDestroy(Sender: TObject);
begin
MDN110FT := Nil;
end;
//------------------------------------------------------------------------------
// [종료] Button onClick Event Handler
// - Close Form
//
// Author : ByoungSik, Lee
// Date : 2010.12.23
//------------------------------------------------------------------------------
procedure TMDN110FT.bbt_CloseClick(Sender: TObject);
begin
Close;
end;
//------------------------------------------------------------------------------
// Form onCreate Event Handler
// - Allocate Resources
//
// Author : ByoungSik, Lee
// Date : 2011.01.06
//------------------------------------------------------------------------------
procedure TMDN110FT.FormCreate(Sender: TObject);
begin
//---------------------------------------------------------------
// 1. Temporary Storage
//---------------------------------------------------------------
FDuties := TList.Create;
FRecItems := TList.Create;
end;
//------------------------------------------------------------------------------
// - 초기화
//
// Author : ByoungSik, Lee
// Date : 2011.01.05
//------------------------------------------------------------------------------
procedure TMDN110FT.Initialize;
var
sysdate : TDateTime; // current system date
begin
// Get Current System Date
GetSysDate(sysdate);
//-------------------------------------------------------------------
// 1. Grid Setting
//-------------------------------------------------------------------
// 1.1. Header
with asg_Header do begin
ClearRows(1, 1);
MergeCells(0, 1, 3, 1);
Cells[0, 1] := '시 간';
end;
// 1.2. Data
with asg_Data do begin
ClearRows(1, RowCount);
RowCount := 1;
end;
//-------------------------------------------------------------------
// 2. Set Default Value
//-------------------------------------------------------------------
dtp_ActDate.Date := sysdate;
end;
//------------------------------------------------------------------------------
// Form onShow Event Handler
//
// Author : ByoungSik, Lee
// Date : 2011.01.05
//------------------------------------------------------------------------------
procedure TMDN110FT.FormShow(Sender: TObject);
begin
//------------------------------------------------------------------
// 1. 초기화
//------------------------------------------------------------------
// 1.1. initiate Control
Initialize;
// 1.2. Load initial code data
LoadAllItemValues;
//------------------------------------------------------------------
// 2. 간호사정 내역 조회
//------------------------------------------------------------------
Search;
end;
//------------------------------------------------------------------------------
// 조회
//
// Author : ByongSik, Lee
// Date : 2011.01.06
//------------------------------------------------------------------------------
procedure TMDN110FT.Search;
begin
//--------------------------------------------------------------------
// 1. Header 정보 조회
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// 2. 기록 항목 목록 조회
//--------------------------------------------------------------------
LoadRecordItemList;
//--------------------------------------------------------------------
// 3. 간호사정 기록 조회
//--------------------------------------------------------------------
end;
//------------------------------------------------------------------------------
// 기록 항목 리스트 조회
//
// Author : ByongSik, Lee
// Date : 2011.01.06
//------------------------------------------------------------------------------
procedure TMDN110FT.LoadRecordItemList;
var
recItems : HmdIccomt; // 기록지 Set 코드 관리
iRowCnt : Integer; // the number of rows searched
i : Integer; // Loop Index
leafItem : HmdIccomt; // Temporary Variable
{ parameters }
AsSetType : String; // Set 구분
AsActDate : String; // 기록일자(YYYYMMDD)
{ for control [Cell 병합용]}
iLargeBaseRow : Integer; // 대분류 Base Row Index
iLargeRowSpan : Integer; // 대분류 RowSpan 수
iMiddleBaseRow : Integer; // 중분류 Base Row Index
iMiddleRowSpan : Integer; // 중분류 RowSpan 수
sLargePrev : String; // 이전 대분류
sMiddlePrev : String; // 이전 중분류
begin
//-----------------------------------------------------------------
// 1. Initiate
//-----------------------------------------------------------------
// 1.1. reset grid
with asg_Data do begin
ClearRows(0, RowCount);
RowCount := 1;
end;
// 1.2. reset list
FRecItems.Clear;
//-----------------------------------------------------------------
// 2. 조회
//-----------------------------------------------------------------
Screen.Cursor := crHourGlass;
try
// Create Object
recItems := HmdIccomt.Create;
//-----------------------------------------------
// 2.1. Set Parameter Value
//-----------------------------------------------
AsSetType := 'ASS'; // 'ASS' : 간호사정
AsActDate := FormatDateTime('YYYYMMDD', dtp_ActDate.Date); // 기록일자
//-----------------------------------------------
// 2.2. Load Data
//-----------------------------------------------
iRowCnt := recItems.LoadSetItemListWithTree(AsSetType, AsActDate);
// Show Error Message
if iRowCnt < 0 then begin
ShowErrMsg;
Exit;
end
else if iRowCnt = 0 then begin
Exit;
end;
//-----------------------------------------------
// 2.3. Display Data
//-----------------------------------------------
with asg_Data do begin
RowCount := iRowCnt;
iLargeBaseRow := 0;
iLargeRowSpan := 1;
iMiddleBaseRow := 0;
iMiddleRowSpan := 1;
sLargePrev := '';
sMiddlePrev := '';
for i := 0 to iRowCnt - 1 do begin
// 2.3.1. Display Classification
Cells[0, i] := recItems.sL_Title[i]; // 대분류
Cells[1, i] := recItems.sM_Title[i]; // 중분류
Cells[2, i] := recItems.sS_Title[i]; // 소분류
// Add Control
// 2.3.2. restore classification code
leafItem := HmdIccomt.Create;
with leafItem do begin
if recItems.sM_LeafYn[i] = 'Y' then begin
// 중분류 코드가 Leaf인 경우
sSetCode := recItems.sM_SetCode [i]; // Set 코드
sTitle := recItems.sM_Title [i]; // Set 명
sInputTyp := recItems.sM_InputTyp[i]; // 입력 형식
sItemCode := recItems.sM_ItemCode[i]; // 입력항목 코드
end
else if recItems.sS_LeafYn[i] = 'Y' then begin
// 소분류 코드가 Leaf인 경우
sSetCode := recItems.sS_SetCode [i]; // Set 코드
sTitle := recItems.sS_Title [i]; // Set 명
sInputTyp := recItems.sS_InputTyp[i]; // 입력 형식
sItemCode := recItems.sS_ItemCode[i]; // 입력항목 코드
end;
end;
FRecItems.Add(leafItem);
// 2.3.3. Row Span
// 대분류 ------------------------
if recItems.sL_SetCode[i] <> sLargePrev then begin
// 이전 분류와 다른 경우
if i > 0 then begin
MergeCells(0, iLargeBaseRow, 1, iLargeRowSpan);
iLargeRowSpan := 1;
end;
iLargeBaseRow := i;
end
else begin
// 이전 분류와 동일한 경우
Inc(iLargeRowSpan);
if i = (RowCount - 1) then begin
MergeCells(0, iLargeBaseRow, 1, iLargeRowSpan);
end;
end;
// 중분류 ------------------------
if recItems.sM_SetCode[i] <> sMiddlePrev then begin
// 이전 분류와 다른 경우
if (i > 0) and (iMiddleRowSpan > 1) then begin
MergeCells(1, iMiddleBaseRow, 1, iMiddleRowSpan);
iMiddleRowSpan := 1;
end;
iMiddleBaseRow := i;
if recItems.sM_LeafYn[i] = 'Y' then MergeCells(1, i, 2, 1);
end
else begin
// 이전 분류와 동일한 경우
Inc(iMiddleRowSpan);
if i = (RowCount - 1) then begin
MergeCells(1, iMiddleBaseRow, 1, iMiddleRowSpan);
end;
end;
// set previous value
sLargePrev := recItems.sL_SetCode[i];
sMiddlePrev := recItems.sM_SetCode[i];
end;
end;
finally
Screen.Cursor := crDefault;
recItems.Free;
end;
end;
//------------------------------------------------------------------------------
// [Header] Grid onGetAlignment Event Handler
// - set cell text alignment
//
// Author : ByoungSik, Lee
// Date : 2011.01.06
//------------------------------------------------------------------------------
procedure TMDN110FT.asg_HeaderGetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
begin
// Horizontal Alignment
HAlign := taCenter;
// Vertical Alignment
VAlign := vtaCenter;
end;
//------------------------------------------------------------------------------
// [Data] Grid onGetAlignment Event Handler
// - set cell text alignment
//
// Author : ByoungSik, Lee
// Date : 2011.01.06
//------------------------------------------------------------------------------
procedure TMDN110FT.asg_DataGetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
begin
// Horizontal Alignment
if ACol = 0 then HAlign := taCenter;
// Vertical Alignment
VAlign := vtaCenter;
end;
//------------------------------------------------------------------------------
// [Data] Grid onCanEditCell Event Handler
// - Set if Cell Can be Editable or not
//
// Author : ByoungSik, Lee
// Date : 2011.01.06
//------------------------------------------------------------------------------
procedure TMDN110FT.asg_DataCanEditCell(Sender: TObject; ARow, ACol: Integer; var CanEdit: Boolean);
begin
// CanEdit := ACol in [3..5];
end;
//------------------------------------------------------------------------------
// [Data] Grid onGetEditorType Event Handler
// - 항목의 입력 형식에 따라 Cell의 Contorl을 Setting 함.
//
// Author : ByoungSik, Lee
// Date : 2011.01.07
//------------------------------------------------------------------------------
procedure TMDN110FT.asg_DataGetEditorType(Sender: TObject; ACol, ARow: Integer; var AEditor: TEditorType);
var
i, j : Integer; // Loop Index
begin
with HmdIccomt(FRecItems.Items[ARow]) do begin
Memo1.Lines.Add('[' + sSetCode + ':' + sInputTyp + ':' + sItemCode + ']');
with cds_ItemValues do begin
Memo1.Lines.Add('tot cnt : ' + IntToStr(RecordCount));
// 1. 입력항목 코드에 따른 입력 값 목록 검색
Filter := 'setcode = ''' + sSetCode + ''' '
+ 'and itemcode = ''' + sItemCode + ''' ';
Filtered := True;
Memo1.Lines.Add('rec cnt : ' + IntToStr(RecordCount));
// 2. 입력 형식에 따른 Control 생성
with asg_Data do begin
if sInputTyp = 'CO' then begin
AEditor := edComboList;
ClearComboString;
for i := 1 to RecordCount do begin
RecNo := i;
AddComboString(FindField('valuenm').AsString);
end;
end
else if sInputTyp = 'DT' then begin
AEditor := edDateEdit;
end
else if sInputTyp = 'CK' then begin
end;
end;
// Refresh
Filtered := False;
end;
end;
end;
//------------------------------------------------------------------------------
// 전체 입력항목별 입력 값 목록 조회
// - 매번 서비스 호출을 해야하는 비용을 줄이기위해 코드 정보를 미리 임시 저장소에
// Load 함.
//
// Author : ByoungSik, Lee
// Date : 2011.01.10
//------------------------------------------------------------------------------
procedure TMDN110FT.LoadAllItemValues;
var
items : HmdIcivlt; // 입력 항목별 입력 값 관리
iRowCnt : Integer; // the number of searched rows
i : Integer; // Loop Index
{ parameters }
AsActDate : String; // 수행일자
begin
//-------------------------------------------------------------------
// 1. Initiate
//-------------------------------------------------------------------
if cds_ItemValues <> nil then cds_ItemValues.Close;
//-------------------------------------------------------------------
// 2. 조회
//-------------------------------------------------------------------
Screen.Cursor := crHourGlass;
try
// Create Object
items := HmdIcivlt.Create;
cds_ItemValues.CreateDataSet;
//------------------------------------------------
// 2.1. Set Value
//------------------------------------------------
AsActDate := FormatDateTime('YYYYMMDD', dtp_ActDate.Date);
//------------------------------------------------
// 2.2. Load Data
//------------------------------------------------
iRowCnt := items.LoadAllItemValueListBySetType('ASS', AsActDate);
// Show Error Message
if iRowCnt < 0 then begin
ShowErrMsg;
Exit;
end
else if iRowCnt = 0 then begin
Exit;
end;
//------------------------------------------------
// 2.3. Restore Data to Cache
//------------------------------------------------
for i := 0 to iRowCnt - 1 do begin
with cds_ItemValues do begin
// 1. Append New Row
Append;
// 2. Set Value to each field of new row
FindField('setcode' ).AsString := items.sSetCode [i]; // Set 코드
FindField('itemcode').AsString := items.sItemCode[i]; // 입력항목 코드
FindField('valuecd' ).AsString := items.sValueCd [i]; // 입력 값 코드
FindField('valuenm' ).AsString := items.sValueNm [i]; // 입력 값 이름
FindField('dispseq' ).AsString := items.sDispSeq [i]; // 출력 순서
end;
end;
// Refresh
cds_ItemValues.Filtered := False;
finally
Screen.Cursor := crDefault;
items.Free;
end;
end;
//------------------------------------------------------------------------------
// [사정일자] DateTimePicker onCloseUp Event Handler
// - Refresh Data
//
// Author : ByoungSik, Lee
// Date : 2011.01.10
//------------------------------------------------------------------------------
procedure TMDN110FT.dtp_ActDateCloseUp(Sender: TObject);
begin
//-----------------------------------------------------------------
// 1. 조회
//-----------------------------------------------------------------
Search;
end;
//------------------------------------------------------------------------------
// [이전 일자] Button onClick Event Handler
// - Search Assessment of Previous Date
//
// Author : ByoungSik, Lee
// Date : 2011.01.10
//------------------------------------------------------------------------------
procedure TMDN110FT.sbt_PreviousClick(Sender: TObject);
begin
//------------------------------------------------------------------
// 1. Set Date
//------------------------------------------------------------------
dtp_ActDate.Date := dtp_ActDate.Date - 1;
//------------------------------------------------------------------
// 2. 조회
//------------------------------------------------------------------
Search;
end;
//------------------------------------------------------------------------------
// [다음 일자] Button onClick Event Handler
// - Search Assessment of Next Date
//
// Author : ByoungSik, Lee
// Date : 2011.01.10
//------------------------------------------------------------------------------
procedure TMDN110FT.sbt_NextClick(Sender: TObject);
begin
//------------------------------------------------------------------
// 1. Set Date
//------------------------------------------------------------------
dtp_ActDate.Date := dtp_ActDate.Date + 1;
//------------------------------------------------------------------
// 2. 조회
//------------------------------------------------------------------
Search;
end;
//------------------------------------------------------------------------------
// [Header] Grid onGetEditMask Event Handler
// - Duty별 시간을 입력하기위한 MaskEdit 생성
//
// Author : ByoungSik, Lee
// Date : 2011.01.12
//------------------------------------------------------------------------------
procedure TMDN110FT.asg_HeaderGetEditMask(Sender: TObject; ACol, ARow: Integer; var Value: String);
begin
Value := '##:##';
end;
initialization
RegisterClass(TMDN110FT);
finalization
UnRegisterClass(TMDN110FT);
end.