Nicholai Mitchko · Jun 4, 2019 go to post

To use FHIR in HealthConnect you will probably want to start with the installer kits. Each of these will add some bits and pieces of functionality to your current working production:

For example, to install a foundation namespace and add FHIR STU3 support to it:

SET nNamespace = "FHIR"

// Switch to the HSLIB so we can call our installer methods
ZN "HSLIB"

// Make the new namespace
SET sc = ##class(HS.HC.Util.Installer).InstallFoundation(nNamespace)
THROW:$$$ISERR(sc) ##class(%Exception.StatusException).CreateFromStatus(sc)

// Add in all of the FHIR components and create a web app
SET sc = ##class(HS.HC.Util.Installer.Kit.FHIR.HealthConnect).Add( , nNamespace, "STU3", "/csp/healthshare/" _ nNamespace _ "/fhir/stu3", "/csp/healthshare/" _ nNamespace _ "/fhir-oidc/stu3")
THROW:$$$ISERR(sc) ##class(%Exception.StatusException).CreateFromStatus(sc)

Once you have this installed, you can use a custom business process to coordinate all of the downstream calls to the external systems. For example, your production might request downstream resources and construct a FHIR response bundle from them.

Nicholai Mitchko · Jun 4, 2019 go to post

You can change the header keys of a %Net.HttpRequest

// Make Request
  SET tHttpRequest=##class(%Net.HttpRequest).%New()

  // Set header
  SET tSC = tHttpRequest.SetHeader("Content-Type", "text/plain")

  // Check for Errors
  THROW:$$$ISERR(tSC) ##class(%Exception.StatusException).CreateFromStatus(tSC)

Thus, to put this all together;

  1. Extend the EnsLib.HL7.Operation.HTTPOperation
  2. Copy the SendMessage method from the super EnsLib.HL7.HTTPOperation
  3. Make a small change to set the header after the first line.
// Sample Code, Not Complete
Class Niko.EnsLib.HL7.Operation.HTTPOperation Extends EnsLib.HL7.Operation.HTTPOperation
{

Method SendMessage(pMsgOut As EnsLib.HL7.Message, Output pMsgIn As EnsLib.HL7.Message, pExpectedSequenceNumber As %String) As %Status
{
    Set pMsgIn=$$$NULLOREF, tHttpRequest=##class(%Net.HttpRequest).%New(), tHttpRequest.WriteRawMode=1
    // Add these two lines after the firt in SendMessage. Change the content type to your desired header.
    SET tSC = tHttpRequest.SetHeader("Content-Type", "text/plain")
    THROW:$$$ISERR(tSC) ##class(%Exception.StatusException).CreateFromStatus(tSC)

    // Copy the rest of the SendMessage Method from the standard EnsLib.HL7.Operation.HTTPOperation
}
}