Yet another bug in Delphi:
externalPatientId := IfThen( patientData <> nil, patientData.IdentPractice, '' );
Do you spot the error?
Well, I didn’t. And the code crashed. The problem is, unlike in C/C++, the patientData.IdentPractice expression will always be evaluated.
The solution, again, is to write the nice if statement

if ( patientData = nil ) then
begin
externalPatientId := '';
end
else
begin
externalPatientId := patientData.IdentPractice;
end;

Advertisements