Skip to main content

Requirements for a Simple Plug-in

Requirements for a Simple Plug-in

To define a simple plug-in, create a class as follows:

  • Use %DeepSee.KPIPlugInOpens in a new tab as a superclass.

  • Define an XData block named KPI that specifies at least one property. For example:

    XData KPI [ XMLNamespace = "http://www.intersystems.com/deepsee/kpi" ]
    {
    <kpi name="PluginDemo" displayName="PluginDemo" caption="PluginDemo" >
    
    <property name="PatientCount" displayName="PatientCount" />
    <property name="HighScoreCount" displayName="HighScoreCount" />
    
    </kpi>
    }

    You can also include filters, as with other KPIs.

    For details, see Reference Information for KPI and Plug-in Classes.

  • Specify the BASECUBE class parameter. For a simple plug-in, specify the logical name of a single cube or subject area. (But also see Creating a Plug-in for Multiple Cubes, later in this page.)

  • Specify the base MDX query to use. Either specify the mdx attribute of <kpi> or implement the %OnGetMDX() method in the following generic way:

    Method %OnGetMDX(ByRef pMDX As %String) As %Status
    {
        Set pMDX = "SELECT FROM "_..#BASECUBE
        Quit $$$OK
    }
    

    InterSystems IRIS automatically applies context information (row, column, and filter) to this base query.

  • Specify the fields that need to be available to the %OnCompute method. These can be fields in the source table of the cube or can be fields in the fact table. You can specify a hardcoded list, or you can use a callback to define the list of fields.

    To specify these fields:

    • If the fields you want to use are in the fact table, specify the LISTINGSOURCE class parameter as "FactTable". (For details on the fact table, see Details for the Fact and Dimension Tables.)

      If you omit this parameter or specify it as "SourceTable", the plug-in queries the source table of the given cube.

    • If you want to specify a hardcoded list of field names, specify the LISTINGFIELDS class parameter. Specify a comma-separated list of fields to use.

      For example:

      Parameter LISTINGFIELDS = "Field1, Field2, Field3";

      You can specify an alias for any field. For example:

      Parameter LISTINGFIELDS = "Field1, Field2 as FieldAlias, Field3";

      You can also use arrow syntax and SQL functions, as with other listings.

      If you use arrow syntax, be sure to specify an alias for the field.

    • Or if you want to define the list of fields programmatically, implement the %OnGetListingFields() method. For example, the following method causes the plug-in to retrieve a single field:

      Method %OnGetListingFields() As %String
      {
          //could use an API to get the field name, but in this case factName is set 
          //so the field name is known
          Set tListingFields = "MxTestScore"
          Quit tListingFields
      }

      For information, see Defining a Listing for a KPI.

    Note:

    For a plug-in, the LISTINGFIELDS parameter and the %OnGetListingFields() do not define a detail listing or any listing fields. These options only define the fields that are available to the %OnCompute() method.

  • Implement the %OnCompute() method. The following section provides details on this task.

  • Optionally specify the PLUGINTYPE and PUBLIC class parameters. See How Plug-ins Can Be Used.

FeedbackOpens in a new tab