MACRO API

 

Installing the MACRO API

The MACRO API is installed as part of the standard MACRO installation.

Project References

When creating a MACRO API application in .NET, you will need to add the following references in your project:

·       InferMed.M40.Api

·       InferMed.M40.ApiClasses

·       InferMed.Components

·       InferMed.M40.Components.Enums

·       InferMed.M40.Events

·       InferMed.M40.ExportImport.SM

·       InferMed.M40.User

API Location

If you run your MACRO API application from within the MACRO installation folder, all the necessary files will be available. However, we recommend that you create a separate folder for your application, to avoid inadvertently affecting files in the MACRO installation folder.

 

For access to the complete set of MACRO API calls from your application, a number of MACRO files must be present in your application folder. See list of files

 

Depending on the exact API calls being used in your application, you may not need all of the files listed above. If you are using Visual Studio, the recommended approach is to mark each of the project references as 'Copy Local = True' and then simply copy the contents of your 'bin' folder after compiling your project.

Configuring the API for Windows applications

The API standard login reads the settings file MACROUserSettings40.config to detect which database connection to use.

For the API to read the settings file, you must add an application configuration file to your application project in Visual Studio. Then populate this app.config file with the following information:

 

xml version="1.0" encoding="utf-8" ?>

<configuration>

  <configSections>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

      <section name="M4Default.Properties.M4Main" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    </sectionGroup>

  </configSections>

  <applicationSettings>

    <M4Default.Properties.M4Main>

      <setting name="usersettingsfile" serializeAs="String">

        <value>C:\Program Files\InferMed\MACRO 4.0\MACROUserSettings40.config</value>

      </setting>

    </M4Default.Properties.M4Main>

  </applicationSettings>

</configuration>

 

Then set the 'usersettingsfile' value to refer to the location of your main settings file MACROUserSettings40.config.

This will be compiled as an app.exe.config file and should be included when deploying your application.

It is possible, when compiling your application to use the API, to set 'Copy Local' to true on the included InferMed references to get a full file install list in the output bin directory. This bin directory can then be deployed onto a machine without MACRO. Alternatively you can copy the compiled app.exe and app.exe.config files to the MACRO 4 installation directory to run the application.

Configuring the API for ASP.NET applications

To configure the API to operate through an ASP.NET application, ensure that:

·       The ASP.NET application that is calling the API has a web.config file with the following xml defined:

 

<appSettings>

    <add key="usersettingsfile" value="C:\Program Files\InferMed\MACRO 4.0\MACROUserSettings40.config" />

</appSettings>

 

·       The 'usersettingsfile' value in the web.config file refers to the main MACRO settings file MACROUserSettings40.config.

·       The ASP.NET application has been given permission to view the main MACRO settings file MACROUserSettings40.config in IIS.

·       The 'WebServer' parameter in the Login API call is set to true to denote that it is operating through ASP.NET and that it will look for the above defined setting.