This section in the docs discusses business processes and routers. You could use either one -- routing rules tend to be faster/easier to create.

Basically, your business process or routing rule would create a notification message and send it to a business operation. The process/router could construct the notification message directly or could call a data transformation that would create the notification message.

The operation would send the notification to an external system. One example would be to use an email operation to send the notification to an email server.

Our online learning portal also has some courses that cover these topics:

Integration Architecture
https://learning.intersystems.com/course/view.php?id=908

Building a Message Router
https://learning.intersystems.com/enrol/index.php?id=1745

Building BPL Business Processes
https://learning.intersystems.com/enrol/index.php?id=1290

Data Transformations Basics
https://learning.intersystems.com/course/view.php?id=1170

calling Method from ClassMethod

This is the problem. A Method needs to be called in the context of an instantiated object. A ClassMethod by definition isn't associated with an instantiated object.

If it's necessary to do it this way, your ClassMethod could use %New() to instantiate an object and then call the Method on that object:

set myObj = ##class(My.Object.Class).%New()
set tSC=myObj.myMethod()

But, it looks like you're working with a Business Service class. For that, it isn't enough to simply use %New(). You need to use Ens.Director::CreateBusinessService to instantiate the object before calling the Method.

https://docs.intersystems.com/irisforhealth20212/csp/docbook/DocBook.UI....

How about polling the global looking for updates? It would be lightweight to just check if the value of ^FSLOG has incremented since the last check:

set lastFSEntry = ^FSLOG

or use $order:

set lastFSEntry = $order(^FSLOG(""),-1)

As for timestamps, in my test environment all of the ^FSLOG entries seem to end with timestamps already:

^FSLOG(41)="DispatchRequest^HS.FHIRServer.Service^11062|Msg|  [1] -> DO  0|03/14/2022 01:57:19.398158PM"

Have you tried doing this instead?

SELECT EnsLib_HL7.Message.RawContent INTO :FullMessage, head.ID As ID, {fn RIGHT(%EXTERNAL(head.TimeCreated),999 )} As TimeCreated, head.SessionId As Session, head.Status As Status,
...

Also, I've gotta make a plug for keeping in mind the disclaimers on the use of RawContent:
Note that this is a truncated version suitable for use in SQL results and visual inspection, but not a complete or definitive representation of the document.  

I'm not sure if you're looking at the ^ERRORS global directly or viewing it in the management portal under System Operation >> System Logs >> Application Error log. If you're doing the former I'd suggest switching to the latter as it's easier to see what's what.

If you want to post a screenshot from Application Error log the community can chime in, but I'd suggest getting the WRC involved to take a look.

You can create a custom REST web service, use Muhammed's approach to fetch the data, and then output the raw CSV as the response.

One complication here is that %DisplayFormatted only outputs to files. You could consider outputting to the file, then read that file and output it in your response, but in a web service it would be best to output to the response directly.

In that case, you might just iterate through the result set using %Next() and either use %Print(",") to output each row or build your own row by using %Get for each column to output and adding commas between columns.

Vivek,

The method for transforming HL7 to SDA can be found here. Note that this doc covers transforming HL7>SDA>C-CDA, so you'll only be interested in the first half of that:
https://docs.intersystems.com/irisforhealth20191/csp/docbook/DocBook.UI....

And the methods for transforming SDA to FHIR can be found here:
https://docs.intersystems.com/irisforhealth20191/csp/docbook/DocBook.UI....

-Marc