Article
· Jul 30 5m read

BI and Interoperability Production documentation on MS Word

Sometimes your client may request documentation of your BI or interoperability project in a formal document. In this case, MS Word is a good alternative, as it has an advanced editor that allows you to generate professional documentation. Now it's possible!
The iris4word app has this functionality!

Final MS Word Document Word Template

 

iris4word business logic

the iris4word get BI asset list and metadata using the InterSystems IRIS BI REST API documented on (https://docs.intersystems.com/healthconnectlatest/csp/docbook/DocBook.UI.Page.cls?KEY=D2CLIENT_rest_api). There are endpoint to create, edit and query BI assets. To query we use /info endpoints:

ClassMethod GetCubesData() As %String [ Language = python ]
{
    import urllib.request
    import base64
    url = "http://localhost:52773/api/deepsee/v3/user/Info/Cubes"
    username = "_SYSTEM"
    password = "SYS"
    # Encode credentials for basic authentication
    credentials = f"{username}:{password}"
    encoded_credentials = base64.b64encode(credentials.encode()).decode()

    # Create a request object with the Authorization header
    request = urllib.request.Request(url)
    request.add_header("Authorization", f"Basic {encoded_credentials}")

    try:
        with urllib.request.urlopen(request) as response:
            # Read the response and decode it to a string
            response_string = response.read().decode('utf-8')
            return response_string
    except urllib.error.URLError as e:
        return f"Error accessing the API: {e.reason}"
    except Exception as e:
        return f"An unexpected error occurred: {e}"
}

ClassMethod GetDashboardsData() As %String [ Language = python ]
{
    import urllib.request
    import base64
    url = "http://localhost:52773/api/deepsee/v3/user/Info/Dashboards"
    username = "_SYSTEM"
    password = "SYS"
    # Encode credentials for basic authentication
    credentials = f"{username}:{password}"
    encoded_credentials = base64.b64encode(credentials.encode()).decode()

    # Create a request object with the Authorization header
    request = urllib.request.Request(url)
    request.add_header("Authorization", f"Basic {encoded_credentials}")

    try:
        with urllib.request.urlopen(request) as response:
            # Read the response and decode it to a string
            response_string = response.read().decode('utf-8')
            return response_string
    except urllib.error.URLError as e:
        return f"Error accessing the API: {e.reason}"
    except Exception as e:
        return f"An unexpected error occurred: {e}"
}

ClassMethod GetPivotsData() As %String [ Language = python ]
{
    import urllib.request
    import base64
    url = "http://localhost:52773/api/deepsee/v3/user/Info/Pivots"
    username = "_SYSTEM"
    password = "SYS"
    # Encode credentials for basic authentication
    credentials = f"{username}:{password}"
    encoded_credentials = base64.b64encode(credentials.encode()).decode()

    # Create a request object with the Authorization header
    request = urllib.request.Request(url)
    request.add_header("Authorization", f"Basic {encoded_credentials}")

    try:
        with urllib.request.urlopen(request) as response:
            # Read the response and decode it to a string
            response_string = response.read().decode('utf-8')
            return response_string
    except urllib.error.URLError as e:
        return f"Error accessing the API: {e.reason}"
    except Exception as e:
        return f"An unexpected error occurred: {e}"
}

Now, with JSON data, these data are loaded on a DynamicObject and passed to the iris4word generate the final word document, using an existent word template (but you can use any other template, or customize the app template).

/// Get word report about BI assets
ClassMethod GetBIDocReport(wordDocumentPath As %String) As %Status
{
    
    Set response = ..GetDeepSeeAssets()

    Set templatePath = $SYSTEM.Util.InstallDirectory()_"bitemplate.docx"
    Set sc = ##class(dc.iris4word.WordUtil).GenerateWordFileFromJSON(response.%ToJSON(), templatePath, wordDocumentPath)
    
    Return sc
}

The final JSON of this Dynamic Object is:

{
    "cubes": [
        {
            "name": "TemperatureCube",
            "displayName": "TemperatureCube",
            "lastModified": "2025-07-30 11:13:27",
            "type": "cube"
        }
    ],
    "dashboards": [
        {
            "fullName": "Ens/Analytics/ActivityVolumeAndDuration",
            "name": "ActivityVolumeAndDuration",
            "lastModified": "2025-03-12 01:17:52",
            "itemType": "dashboard"
        },
        {
            "fullName": "iris4word/TemperatureDashboard",
            "name": "TemperatureDashboard",
            "lastModified": "2025-07-30 11:14:31",
            "itemType": "dashboard"
        }
    ],
    "pivots": [
        {
            "fullName": "iris4word/TemperatureAnalysis",
            "name": "TemperatureAnalysis",
            "lastModified": "2025-07-30 11:30:02",
            "itemType": "pivot"
        }
    ]
}

To get interoperability production metadata, it is different, there are no REST API for that, you need use ObjectScript API:

/// Get word report about an interoperability production
ClassMethod GetEnsDocReport(wordDocumentPath As %String) As %Status
{
    #include Ensemble

    Set response = {}

    Set tSC=##class(Ens.Director).GetProductionStatus(.pProductionName,.tState)
    Set response.Name = pProductionName
    Set response.State = tState
    
    Set tProduction = ##class(Ens.Config.Production).%OpenId(pProductionName, .tSC)
    
    If tProduction.Description '= "" {
        Set response.Description = tProduction.Description
    }
    
    Set response.BusinessHosts = []
    Set i = 0
    For i=1:1:tProduction.Items.Count() {
        Set responseItem = {}
        Set tItem = tProduction.Items.GetAt(i)
        Set responseItem.Name = tItem.Name
        If tItem.Category '= "" {
            Set responseItem.Category = tItem.Category 
        }
        If tItem.ClassName '= "" {
            Set responseItem.ClassName = tItem.ClassName 
        }
        do response.BusinessHosts.%Push(responseItem)
    }

    Set templatePath = $SYSTEM.Util.InstallDirectory()_"enstemplate.docx"
    Set sc = ##class(dc.iris4word.WordUtil).GenerateWordFileFromJSON(response.%ToJSON(), templatePath, wordDocumentPath)
    
    Return sc
}

You must to open the metadata persistent class Ens.Config.Production and iterate the property Items. The iris4word transforms the data into a DynamicObject, set a template (but you can use your template) and render the final word file.

Now, it is very ease create BI and Production documentation using Word, enjoy!

Discussion (0)1
Log in or sign up to continue