MediSoft Reports Home

Focus Reports Products
      What is Focus Reports?
      Focus Reports Standard
      Focus Reports Professional

Price List
      Focus Reports Prices

Report Store
      Find a Focus Reports Dealer

News
      What's New with Focus Reports

Download Files
      Focus Reports Download Page

Support
      Focus Reports Knowledge Base

Dealers Only
      Dealer Zone

Contact Us
      Contact Inborne Technology

 

Knowledge Base > Focus Reports Developer > Calculations Start Over | Login
Search the Knowledge Base
 
Start Search in the Following Category

RAP code to calculate a patient's age

How to create a variable field on the visual designer and calculate a patient's age:

  1. Place a variable on the visual design screen
  2. Display the Report Tree toolbar (View|Toolbars|Report Tree), right click the new variable and select Rename from the context menu. Rename the variable to vAge.
  3. Right click the variable and select Calculations from the context menu.
  4. Copy and paste the following code into the code space in the Calculation window:

start copy on line below--
{Calculates the patient's age}

if Patient['Date of Birth'] = 0 then
vAge.AsString := '(no entered birthdate)'
else
begin
DecodeDate(Patient['Date of Birth'],DOByear, DOBmonth, DOBday);
DecodeDate(CurrentDate, NowYear, NowMonth, NowDay);
vAge.Value := NowYear - DOByear;
if (DOBMonth > NowMonth) then vAge.value := vAge.value - 1;
if (DOBMonth = NowMonth) and (DOBday > NowDay) then vAge.value := vAge.value - 1;
end;
-- end copy on the line above

Where “Patient” is written in the code, this needs to be the name of the query the data is pulling from

If you look at the code under the “Calc” tab there is a begin…end statement with the code inside of it.  Before the begin statement insert the code:

Var

   DOBmonth, DOBday, DOByear : integer;

   NowMonth, NowDay, NowYear : integer;

This declares the variables that are used within the code.

Inborne Technology Corporation makes every effort to ensure accuracy of information in our knowledge base. Proper application of this information is entirely your responsibility.

Ask a Question
Submit a Question
Knowledge Base Software - myKB.com

Copyright © 2001-2007 Inborne Technology Corporation. All Rights Reserved.
No text or graphics may be duplicated from this web site without the express written permission of owner.
Inborne Technology Corporation  ·  (800) 752-3565