Use Delphi to compile complex hospital reports

Source: Internet
Author: User

Use Delphi to compile complex hospital reports

Computer Room of Wuxi Chinese Medicine Hospital, Jiangsu Province
Yuan Bo
---- The information management system of our hospital adopts Delphi programming. Due to different requirements of different subjects, the forms of reports are also diverse, which makes writing a headache. Delphi runs on a Windows platform, printing is completely different from DOS, and quick report is difficult to control and occupy resources. For a report with a slightly complicated and special requirements, quick report cannot be implemented. Here are some typical report implementation methods in programming.

---- 1. Which unit has several thick accounts in the finance department? The finance department of our hospital proposes to print the accounts of the pharmaceutical store. If you take off the manual accounts, the Office is modernized and the requirements are reasonable, the President also said this should be the case. Looking at the red-green, uniformly printed, and row-distance small account cards provided by the finance department, I can't help but think of the frugal virtues of the Chinese. Considering that at least one drug is printed, and there are no fewer table lines, there are more than two thousand medicines in the Chinese Medicine Hospital, therefore, this report must be printed using a laser printer (as to how to make the President agree to buy a laser printer, it is another thing. How can office automation be free of cost ). The idea of program implementation is basically to use the printing paper as a canvas to draw a small rectangle on top, specifically implemented by the following processes: (set form name to ttzview ).

First, define two classes in the program:
Titlerecord = record
Currect: trect;
Atitle: string;
End;
Detailrecord = record
Arect: trect;
Alignment: word;
End;

---- Create the following four processes;
---- Rectdraw (acanvas: TCanvas; s: string; R: trect; frame: Boolean; position: Word );

---- This process is used to draw a rectangle. frame decides whether to draw a line (of course we need to draw it here !);

---- Printinitit (firsttop, firstleft: integer );

---- This process is used for initialization, that is, to define the position of each small rectangle on the paper;

---- Printtitle (acanvas: TCanvas );

---- This process prints the header, because the header is always larger;

---- Printdetail (acanvas: TCanvas; qtz: tdataset; acount: integer; firstpage: integer );

---- This process prints the specific content. If 40 rows are printed on one page, the page is changed. One of the pages can only be one drug;

---- Printhj (acanvas: TCanvas );

---- At first glance, we can see that this process is to print the total!

---- You only need to create a botton and call printinitit, printtitle, printdetail, and printhj in sequence,

---- (Call format: printtitle (printer. Canvas );)

---- By The Way, qtz is the queried account data. We won't talk about how to generate it here.

---- The specific procedure is as follows:

---- This program runs on the delphi1, delphi3 win3.2, Win95, win97, and Win98 platforms. By the way, the library structure of the account database is provided.

---- 2. Complicated Reports that cannot be used properly

---- The oncology department of our hospital needs to print the patient's medical records. This is part of the modernization of special specialists. The Health Bureau must complete the task to check the cases. There are more than 100 items in each medical record. If you use qreport and add or subtract a project in the middle (this is often the case), adjusting the arrangement of dozens of items will make people faint. I suddenly created more than 100 temporary variables, painted on the virtual canvas, and ran well on my pii233, 64 M memory, but switched to 486 of the oncology department, when the 8 M memory is on the machine (don't laugh), the system stack immediately overflows, so I had to sacrifice the pointer method (my programming level seems to have grown again, and I have to steal it). The method is as follows:

Create the titleprint class first:
Titleprint = ^ titlerecord;
Titlerecord = record
Currect: trect;
Atitle: String [50];
End;
Create another process: printnow (the form name is
Zlk, printdot is the number of printer points, usually the needle hitting is 180 );
Procedure tzlk. printnow (acanvas: TCanvas );
VaR I, X, Y, pc_count: integer;
Myprint: array [0 .. 200] of titleprint;
Begin
Firsttop: = round (INT (0.5/2.54 * printdot ));
Firstleft: = round (INT (0.1/2.54 * printdot ));
Rowheight: = round (INT (0.7/2.54 * printdot ));
X: = 0 + firstleft; Y: = round (int
(1.3/2.54 * printdot) + firsttop;
Pc_count: = 0;
INC (pc_count); New (myprint [pc_count]);
Myprint [pc_count] ^. currect: = rect
(X + round (INT (0.1/2.54 * printdot) + firstleft, y,
X + round (INT (3.0/2.54 * printdot) + firstleft,
Y + firsttop + round (INT (0.5/2.54 * printdot )));
Myprint [pc_count] ^. atitle: = lname.
Caption + dbname. text;
Acanvas. moveTo (myprint [pc_count] ^.
Currect. Left,
Myprint [pc_count] ^. currect. Top-round
(Rowheight/5 ));
{The following four rows must be repeated for more than 100 times, which is almost the same,
I won't write it all out to earn the draft fee}
INC (pc_count); New (myprint [pc_count]);
Myprint [pc_count] ^. currect: = scalerect (
Myprint [pc_count-1] ^. currect, round (int
(2.5/2.54 * printdot), 0 );
Myprint [pc_count] ^. atitle: = lxb. Caption + cxb. text;
Acanvas. lineto (myprint [I] ^. currect. Right,
Myprint [I] ^. currect. Top-round (rowheight/5 ));
.......

{Print}
Printtitle (acanvas );
{This function is not provided. It doesn't matter whether the header is used}
For I: = 1 to pc_count do
Begin
Rectdraw (acanvas, myprint [I] ^. atitle,
Myprint [I] ^. currect, false,
Dt_left or dt_singleline or dt_vcenter );
End;
Dispose (myprint [pc_count]);
{Don't forget to release the memory occupied by the pointer}
End;

---- Create a botton, add a True Print judgment, and then call these functions.
---- (Call format: printtitle (printer. Canvas );)

---- After reading the above two examples, do you think that printing in Windows is actually very simple, just like you hand-painted tables, and the table content is centered, left, or right, it is determined by the alignment of the printed content, and the printing format is determined by the display format of the content. You do not need to calculate it yourself, which is very convenient.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.