Hi @Sebastian Thiele 

Here is the Encounter resource. I'm using IRIS for Windows (x86-64) 2024.1.1

url : http://localhost:52773/csp/healthshare/learning/fhir/r4/Encounter?&date=lt2024-10-27T15:29:00Z

 
Spoiler

Hello @Kevin Mayfield 

Instead FromJSON() write a custom class to parse the Binary Resource and set it into the FHIR model class. 

Here I convert the the data (which is the Binary resource -pdf or anything) to stream and set it in the data field of the  HS.FHIR.DTL.vR4.Model.Resource.Binary class

ClassMethod SetBinaryR4(json As %DynamicObject)
{
    Set obj = ##class(HS.FHIR.DTL.vR4.Model.Resource.Binary).%New()
    Set obj.contentType = json.contentType
    #; convert to stream to prevent from the <MAXSTRING> error 
    Set dataAsStrm = json.%Get("data",,"stream")
    Set obj.data = dataAsStrm
    Set obj.id = json.id
    
    #; set binary data element as stream for "Binary" resource. 
    ZWrite obj.data.Read()
}

Thanks!

Hello @Kevin Mayfield 

%GetNext retrieves values from the JSON object/array and assigns them to a local variable. However, the BLOB/streams exceed the maximum local length (3641144), MAXLEN doesn't cause the issue because it's a registered object, and the values are currently stored in memory. Therefore, AFAIK FromJSON is not suitable for handling such a large dataset.

Hello @Ali Chaib

  1. You need to create you're custom DTL under "HS.Local.FHIR.DTL"  
  2. Once DTL is created. Execute set status = ##class(HS.FHIR.DTL.Util.API.ExecDefinition).SetCustomDTLPackage("HS.Local.FHIR.DTL")  this and this will configure the customize DTL entry in the  ^HS.XF.Config global it's responsible for execute your DTL
  3. Here is the documentation which covers most customization.
  4. As I mentioned earlier, You need to the additional properties in respective SDA extension class.

Hello @Ali Chaib

FHIR to SDA

Yes we have built in transformation class available to FHIR ⇆ SDA and HS.FHIR.DTL.Util.API.Transform.FHIRToSDA3 is used to convert to SDA3 to FHIR
If you're goal to to convert to FHIR to SDA object then "HS.FHIR.DTL.Util.HC.SDA3.FHIR.Process" use this Business Process(BP) class to convert but this will send the request to BO again based on the BP configuration. Otherwise programmatically construct the input and pass the required values to the method in TransformStream class transformation class(which is in FHIR to SDA conversion business process) HS.FHIR.DTL.Util.API.Transform.SDA3ToFHIR for convert FHIR to SDA

SDA3 to HL7 conversion

There is no method for programmatically converting from SDA to HL7 v2.

  from documentation. So, You  need to read the JSON response, extract the required information, and transform it directly into an HL7 message

There are multiple DTL's available for SDA3 to HL7 v2 in package "HS.Gateway.SDA3.SDA3ToHL7." Can you check and utilize if it's helps

Thanks!

Hi @Phillip Wu

If you're create new object values. Means, The %New() - Creates a new instance of object and It invokes the user provided callback method "%OnNew()". You can define your properties if you want in that call back methods.

Class Backup.Task Extends %Persistent
{
Property TaskName As %String;
Property TaskDescription As %String;
Method %OnNew(pTaskName As %String, pTaskDescription As %String) As %Status
{
 	Set ..TaskName = pTaskName
 	Set ..TaskDescription = pTaskDescription
 	Return $$$OK
}

ClassMethod CreateNewTask()
{
	Set taskObj = ##Class(Backup.Task).%New("DailyBackup","Runs a daily backup")
	Set st = taskObj.%Save()
}

}

 If you want to fetch the values of already stored. You have to use the %OpenId(id) and pass the id to open the instance of the expected object and you can fetch the values

ClassMethod GetTaskDetails(taskId)
{
    Set taskObj = ##Class(Backup.Task).%OpenId(taskId)
    Set lastRunStatus = taskObj.LastRunStatus
}

Hello @Ali Chaib

  • SDA, or Summary Document Architecture is an intermidary format. It's used to easily convert between multiple data formats--such as HL7 V2, C-CDA, C32, HL7 FHIR, and others.
  • I hope You are sending a GET request via HTTPOperation in FHIR interoperability production. You'll get the http response. There is no predefined transformation available to do it. You need to programmatically convert the response. I just convert the FHIR operation outcome to FHIR R4 outcome object directly.
    ClassMethod fhirresponse()
    {
    	#;Assume the json as a fhir response
    	Set fhiResponse = {"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"not-found","diagnostics":"<HSFHIRErr>ResourceNotFound","details":{"text":"No resource with type 'Task' and id '33'"}}]}
    	#dim opoutcome As HS.FHIRModel.R4.OperationOutcome = ##Class(HS.FHIRModel.R4.OperationOutcome).fromDao(fhiResponse)
    	Write opoutcome.issue
    }
    
     

Hello @Ali Chaib

I could find the relevant SDA class resource  HS.SDA3.Task for the FHIR Task. AFAMA, there is no built in DTL or relevant FHIR model class available to transfer SDA to FHIR resource. for now, You can create a your own FHIR model class for Task and create a customized DTL under HS.Local.FHIR.DTL. package use the SDA3.Task as destination class for transformation.

Yes, the journal doesn't contain that information and maybe it's operational overhead to hold this additional information. As always using the program debugger and verify the routine. 

This is a general question, as I mentioned earlier there are multiple is routines and classes executed and the global are set via indirection, Xecute the predefined code and usual direct set. 

Thanks for your response @Vic Sun 

Hello @Vic Sun

To summarize the situation, when executing a program, it calls various routines and classes, the expected global values is set somewhere in between the flow. I need to determine where a specific global was set.

The journal contains details like process ID, database values (old and new), and more. So, Maybe If the journal includes an additional entry in the format of label+offset^routine indicating where the global was set it's easy to track for my case.

Hello @Deepa Shahi

You can customize the SDA3 package. A native discrete SDA class is available to convert the data's from HL7 to FHIR and vise versa. In this case, HS.SDA3.Encounter is the SDA class. There is an additional editable extension class( "HS.Local.SDA3.EncounterExtension" - Encounter) available in these primary SDA classes to customize data elements. You can define all your required data elements in to this extension class and compile the package.

If you're using the SDA to FHIR conversion by DTL native approach.

Customize the DTL

You have to copy the existing DTL "HS.FHIR.DTL.SDA3.vR4.Encounter.Encounter" to "HS.Local.FHIR.DTL.SDA3.vR4.Encounter.Encounter". Before customizing DTLs, you need to specify a single package for all customized DTL classes. InterSystems recommends naming the class package: HS.Local.FHIR.DTL.

Now you can modify the newly copied DTL based on your requirement. this newly created DTL is not invoked by default. So, execute below code in your FHIR enabled namespace. The FHIR API classes use this HS.Local.* DTL packages while generating the resources ("Encounter" )

 set status = ##class(HS.FHIR.DTL.Util.API.ExecDefinition).SetCustomDTLPackage("HS.Local.FHIR.DTL") 

Hello @Gabriel Santos 

AFAIK, The required property keyword works on literal, Collection, stream, serial, object valued properties except the %DynamicArray and %DynamicObject. Because by default the property methods(Getter) was created and it assign the values for %DynamicArray is "[]" and "{}" for dynamicObject even though if you assign empty string it overwrites it. so, The %ValidateObject() doesn't include these two objects for validation.

As you know the swagger is used to design the API documentation first, and then build the REST API based on that design. IRIS or other API systems don't inherently know about the payload, the return response, or the specific responses for status codes like 200, 400, or 500 unless it's specified.

You're right about the traditional approach. Creating REST services manually doesn't have knowledge of these details. It generates the Swagger documentation based on the information available in the UrlMap and the class method in the dispatch class. Add your comments on top of the class method (meta data details) will be set into the description in swagger

 
Spoiler

If you want your API to be well-documented, it’s better to follow a spec-first approach, as this approach captures crucial details like paths, method types, descriptions, path parameters, query parameters, and responses.

Thanks!