ActiveX/COM+ Object Client example code

From Medical-Objects Documentation Wiki
Jump to: navigation, search

procedure TfrmMain.SendReferral(Sender: TObject); var SendResult: ISendResult;

   i: Integer;

begin

 FCOMOBJ := CoMOMessage.Create;
 FCOMOBJ.Passphrase := 'accountpassword';
 //Utility object for determining the Online Status and Report Delivery Status
 FUtilityObj := CoUtility.Create;
 //Define the patient
 FCOMOBJ.Patient.FirstName := 'Andrew';
 FCOMOBJ.Patient.LastName := 'McIntyre';
 FCOMOBJ.Patient.DateOfBirth := GetPatientDOB();
 FCOMOBJ.Patient.Sex := Male;
 FCOMOBJ.Patient.Address.StreetAddress := '1 Medical-Objects Road';
 FCOMOBJ.Patient.Address.City := 'BUDERIM';
 FCOMOBJ.Patient.Address.Postcode := '4556';
 
 //Who is it going to
 FCOMOBJ.SendTo.FirstName := 'Melissa';
 FCOMOBJ.SendTo.LastName := 'White';
 FCOMOBJ.SendTo.IDs.AddProviderNo('0191322W');
 //Who is being sent from
 FCOMOBJ.SentFrom.FirstName := 'Jared';
 FCOMOBJ.SentFrom.MiddleName := 'Michael';
 FCOMOBJ.SentFrom.LastName := 'Davison';
 FCOMOBJ.SentFrom.Prefix := 'Mr';
 FCOMOBJ.SentFrom.IDs.AddProviderNo('JD455600041');
 //What is the content of the report
 FCOMOBJ.Content.Title := 'Letter';
 FCOMOBJ.Content.Content := mmMainContentBody.Lines.Text;
 FCOMOBJ.Content.ReportID := '235667'; 
 FCOMOBJ.Content.ContentType := MOCom_TLB.Text;
 SendResult := FCOMOBJ.Send;
 if SendResult.ErrorCount > 0 then
 begin
   memo1.Lines.Clear;
   for i := 0 to SendResult.ErrorCount -1 do
     mmErrors.Lines.Add(SendResult.ErrorMessages[i]);
   showmessage('Send failed');  
 end else begin
   showmessage('Sent OK');  
 end;

end;

procedure TfrmMain.IsProviderOnline(Sender: TObject); begin

 ShowMessage(edtProviderNo.Text + ' routable = ' + BoolToStr(FUtilityObj.IsProviderOnline(Edit1.Text), True));

end;

Personal tools