You can delete the application error logs for all days by executing the below code for specific namespace 

ClassMethod DeleteAppErrorLog(Namespace As %String = {$Namespace}) As %Status
{
    New $Namespace
    Set $Namespace = "%SYS"
    Return ##class(SYS.ApplicationError).DeleteByNamespace(Namespace)
}

Delete by date

ClassMethod DeleteAppErrorLogByDT(pNamespace As %String = {$Namespace},pDate ={$ZD(+$H)}) As %Status
{
    New $Namespace
    Set $Namespace = "%SYS"
    Return ##class(SYS.ApplicationError).DeleteByDate(pNamespace,pDate)
}

Maybe can you try to wrap the HL7 message like below format and set the ContentType As "application/xml"  in additional setting in the Business operation "EnsLib.HL7.Operation.HTTPOperation" and check for the response headers as well if required.

<?xml version="1.0" encoding="UTF-8"?>
<HL7Message>
<![CDATA[
MSH|^~\&|... your message ...
PID|... etc ...
]]>
</HL7Message>

We can use the %IsDefined method  to check the key is defined, and %Size() to determine the number of the elements in an Object or Array. These methods help to prevent from the <INVALID OREF> and <UNDEFINED>

// verify the "items" is present and it has values
If responseData.%IsDefined("items")&&(responseData.items.%Size()) {
    Set item1 = responseData.items.%Get(0)
    If $IsObject(item1) {
        Write item1.portalUrl
    }
    /*another*/
    If $IsObject(item1)&&(item1.%IsDefined("portalUrl")) {
        Write item1.portalUrl
    }
}

The %GetTypeOf method is used to determine the type of a key, and it returns 'unassigned' if the key does not exist

If responseData.%GetTypeOf("items")="array" {
    Set item1 = responseData.items.%Get(0)
    If $IsObject(item1) {
        Write item1.portalUrl
    }
}

Hi @Pravin Barton

The {Contents} has the id of the stream property. So, We can open the the stream object  by using OID and then convert to JSON like below. and the stream write need to use %ToJSON() for JSON serialization stream.Write({"msg":"hello world!"}.%ToJSON())


Trigger ExtractKeys [ Event = INSERT/UPDATE, Foreach = row/object, Time = AFTER ]
{
    new contentsJSON, id, msg
    
    if {Contents*C} {
        set contentsJSON = {}.%FromJSON(##class(%Stream.GlobalCharacter).%Open($lb({Contents},"%Stream.GlobalCharacter","^PAB.DebugStreamS")))
        set id = {ID}
        set msg = contentsJSON.msg
        &sql(update learn_Smp.NewClass13 set msg = :msg where Id = :id)
        $$$ThrowSQLIfError(SQLCODE, %msg)
    }
}

Thanks!

Hi @Julian Matthews

The Ens.StreamContainer class is a %Persistent class and it stores the different types of stream in it. So, If you delete the row/record by id / or by query it will delete the entry as well as the stream contents(it's also part of the row) from the Ens.StreamContainer table. So, be cautious before deleting the container. %OnDelete  callback method is used to do some additional function while deleting the object.

Hello @Nezla,

The %SYS.Task class has the task details which includes the status of the task. The "Suspended" column has value if incase the task is errored out while running ("Suspend Leave" ) or the task is suspended ("Suspend Reschedule"). Based on this column you can find out the suspended /errored task. Use the below query for the TaskName and additional details.

select Name,Status,TaskClass,Suspended from %SYS.Task

Hello  @Michael Wood,

here are several approaches you can take to handle this. One option is to create a file service that reads the file as a stream and sends it to a custom business process. You can then convert that stream into a JSON object and iterate through each DynamicObject entry. Alternatively, you could send the stream to BPL and process the JSON there

Simplified sample of process the JSON. 


Class Samples.Introp.JSONFileService Extends Ens.BusinessService
{

Parameter ADAPTER = "EnsLib.File.InboundAdapter";

Method OnProcessInput(pInput As %Stream.Object, Output pOutput As %RegisteredObject) As %Status
{
	Do ..SendRequestSync("JSONFileProcess",pInput,pOutput)
	Quit $$$OK
}

}

Class Samples.Introp.JSONFileProcess Extends Ens.BusinessProcess [ ClassType = persistent ]
{

Method OnRequest(pRequest As Ens.Request, Output pResponse As Ens.Response) As %Status
{
	Set json = {}.%FromJSON(pRequest)
	
	Set iter = json.%GetIterator()
	
	while iter.%GetNext(.key,.val)
	{
		s ^test($Classname(),$NOW(),key)=val.%ToJSON()
	}

	Quit $$$OK
}
}

Thanks!

Hello @Krishnaveni Kapu 

%SYS.Task is responsible for store, suspend and resume for all the tasks. so, your can execute the below method programmatically to achieve it. It expects the task id as the first argument

You can execute the below query to get the task id, name and additional information

select Suspended,Name,id from %SYS.Task

suspend

Flag

1 - Suspend the task, but leave it in task queue (default)
2 - Suspend the task, remove from task queue, and reschedule for next time

Set taskId = 1001
Set flag = 2
Write ##class(%SYS.Task).Suspend(taskId,flag)

resume

Set taskId=1001
Write ##class(%SYS.Task).Resume(taskId)

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!

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!

Hello @Yone Moreno 

Try this below input in your DTL. Because the property Informes as a list so you have to create the xml data like below  Property Informes As list Of EsquemasDatos.DragoAP.Portal360.Informes(XMLNAME = "Informes");

You can create a main object and set all the properties and use obj.XMLExportToString(.xmlString) for the xml structure of the class object. That will be helpful for forming the input  for DTL as well.

<InformeVisitaRequest>
	<Paciente>
		<NumExpediente>12</NumExpediente>
		<Informes>
			<Informes>
				<Fecha_Creacion>tescreation</Fecha_Creacion>
				<Id_Visita>tesVistia</Id_Visita>
				<Titulo>tesTitulo</Titulo>
				<Desc_Tipo_Plant>Desc_Tipo_Plant</Desc_Tipo_Plant>
				<NumExpediente>1212</NumExpediente>
			</Informes>
		</Informes>
	</Paciente>
</InformeVisitaRequest>

Thanks!

Hello @Martin Nielsen 

Quick note, You can get the manually created web applications via /v1/{namespace}/restapps in the web application "/api/mgmnt" ex: http://localhost:52773/api/mgmnt/v1/learning/restapps. This will list down all the v1 applications and from that you can use the web app name to get the openAPI(swagger 2.0) by using the the url /v1/{namespace}/spec/{web app name} ex: http://localhost:52773/api/mgmnt/v1/learning/spec/dc/samprest

Hello @Martin Nielsen

I did some analysis about this. As of my understanding, I found this is because of the method DispatchRequest in the %CSP.REST. The below piece of code is actually skip your accountId due to forward your request to another "DispatchRequest" in the other dispatch class(for your case "AnotherController" class). But these are rewritten in IRIS already. You can try override this method for testing.

Set tMatchUrl=$Piece(tMatchUrl,tMatchcher.Group(1),"2",*),tForward=$LisGet(tMapEntry,3)
Actual Url: /1001/anothercontroller/001
Url after above line executed: /001