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;
//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
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;
end;
Next;
end;
end;
//Notify the OCX that patient data has changed.
Changed;
end;
end;
|