help
 
--> GROWTH CHARTS | Back to startpage
Program
Swedish Growth Charts - BVC 2000
Date of support information
2002-03-24
Support #
 
Topic
Example: Assigning patient data to a Growth Chart
   

Introduction
This example source code shows you how to assign patient data to the fields of the growth chart object. Although this example uses Delphi code you should have no trouble adapting the code your own development language.

For a complete list of fields available: List of patient data fields

Change the name GrowthChart in the code below to the name of the ActiveX or the GraphX property of the VCL component that you have just included on your form. Change TblPatient and TblVisit to whatever table component names you use.

Note!
Remember to call the Changed method after setting the new data to force a re-draw of the graph object.

Source code example
procedure TMyApplication.TblPatientAfterScroll(DataSet: TDataSet);
begin

//Feed the ActiveX with the appropriate data
with GrowthChart do
    begin
    //Clear all the data
    ClearData;

    //Initialize Patient Data
    PatientData.Field['Id'] := TblPatient.FieldByName('ID').AsString;
    PatientData.Field['SurName'] := TblPatient.FieldByName('Surname').AsString;
    PatientData.Field['FirstName'] :=
                          TblPatient.FieldByName('First name').AsString;
    PatientData.Field['Sex'] := TblPatient.FieldByName('Sex').AsString;

    //Make sure you always set the fields IsMale and BirthDate
    //Both of these fields are mandatory

    if TblPatient.FieldByName('Sex').AsString = 'Male' then
       PatientData.Field['IsMale'] := True
    else
       PatientData.Field['IsMale'] := False;

    PatientData.Field['BirthDate'] :=
                        TblPatient.FieldByName('Birth date').AsDateTime;

   //Indicate that corrected age curve should be traced for children with
   //gestational age less than 37 weeks

    PatientData.Field['CorrectedAgeCurve'] := True;

   //Set birth data to be displayed in the text boxes (not used in the graph)
    PatientData.Field['BL'] := TblPatient.FieldByName('BirthLength').AsString;
    PatientData.Field['BW'] := TblPatient.FieldByName('BirthWeight').AsString;
    PatientData.Field['BHCirc'] := TblPatient.FieldByName('BirthHeadCirc').AsString;


   //Create a visit record which corresponds to data at birth (used in the graph)

   //This method should be used if the birth data in your database is not stored
   //as a visit at the date of birth.
   with VisitData.New do  
        begin
        Field['DateVisit'] := PatientData.Field['BirthDate'];
        Field['Height'] := TblBirth.FieldByName('BL').Value; //Birth length 
        Field['Weight'] := TblBirth.FieldByName('BW').Value; //Birth weight
        Field['HeadCirc'] := TblBirth.FieldByName('BH Circ').Value; //Birth head circ 
        end;

    //Add all visits to the Visit Data structure
    with TblVisit do
        begin
        First;
        //Scroll through all of the visits for this patient
        while not EOF do
            begin
            with VisitData.New do //Create new visit
                begin
                Field['DateVisit'] := TblVisit.FieldByName('Date/Visit').Value;
                Field['Height'] := TblVisit.FieldByName('Height').Value;
                Field['Weight'] := TblVisit.FieldByName('Weight').Value;
                Field['HeadCirc'] := TblVisit.FieldByName('HeadCirc').Value;
                end;
            Next;
            end;
        end;

    //Notify the OCX that patient data has changed.
    Changed;
    end;
end;