Jimmy Christian · Jul 10, 2019 go to post

Yes, Thank you. I just corrected the URL and it works now. Thank you Robert.  One more question if you can assist in this context.

So the response message i got back is in the HttpResponse object.

How can i convert the HttpResponse.Data property to JSON and parse the values. Since the data i received is Stream, is there a way i can convert the stream to Dynamic Objects and parse  it?

Thank you.

Jimmy Christian.

Jimmy Christian · Jul 11, 2019 go to post

Hello Eduard,

i was able to convert the HttpResponse.Data to String and than to the Dynamic Object. Worked great. Thank you.

On the same line, i need to ask you of any template or suggestion to send a JSON data to a REST API.

For eg. below is the JSON

{"name":"abcdefghi","salary":"123","age":"23"}

How do i send it to  http://testing.restapiexample.com/api/v1/createemployee with POST request using the set tSC=..Adapter.PostURL(tConfig.URL,.tHTTPResponse,,pRequest)

Below code is not working.

Set pRequest=."{"name":"abcdefghi","salary":"123","age":"23" }"

Your help will be appreciated.

Thanks,

Jimmy Christian.

Jimmy Christian · Jul 15, 2019 go to post

Thank you Danny for help.

Yes this worked. I did not create a seperate HttpRequest but just used the PostURL method as below.

Set tSC=..Adapter.PostURL(tURL,.tHttpResponse,,pRequest1.%ToJSON()).

The code you provided is very helpful. Especially when i have to include the content type while making the http request.

The Adapter object does not have that ContentType property.

By the way i am also trying to understand when to use the PostURL or .Send or SendFormDataArray method to make a http request?

Do they provide same functionality ? If you have information and can provide me will be much appreciated.

Thank you

Jimmy Christian.

Jimmy Christian · Jul 16, 2019 go to post

Good Morning Danny,

I appreciate your help. After  changing the names i was able to  make the POST calls using SEND. Worked perfectly ! Thank you for your time.

Yes,  looks like .Send has some more configurable parameters in the HttpRequest object we send.

In the same context, would you be able to know how to set a Basic Authoriztion using User and Pass while making the call ?

Seems like i have to make Credentials using ENSEMBLE.

Than set the httprequest.username and httprequest.password using that credential object.

Please let me know if you have any information.

Thank you for time.

Regards,

Jimmy Christian.

Jimmy Christian · Jul 16, 2019 go to post

Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT

I tried dynamic objects but gives me an error, unless i am not doing it correctly or if syntax is not correct.

Set objStream = objHttpResponse.Data
     Set json =""
     While ('objStream.AtEnd) {
          Set json = json _ objStream.ReadLine()
  
     }

set iter = json.%FromJSON().%GetIterator()
   while iter.%GetNext(.key , .value )
      {
       write "key = "_key_" , value = "_value,!
             }

Jimmy Christian · Jul 16, 2019 go to post

Thank you Eduard.

So the message i posted is a response to an API call i make with JSON payload.

So i was assuming that the response would be JSON and i can try to parse it.

But if it is not a JSON, is there a utility to parse it or i need to use the provided STRING functions like ZSTRIP and so on?

Thanks,

Jimmy christian.

Jimmy Christian · Jul 16, 2019 go to post

The issue is the API  is not set up yet on the project which i am working.

But the specs has the JSON PAYLOAD as request and then the response is what i pasted above. 

So i am trying to get the code ready to parse in the meantime until the API is set up. Hopefully i will have something to work with POSTMAN as soon as API is set up.

Once i receive the response , i need to parse it for any error and then shutdown the operation.  At the most i can convert the response to string and check for error.

Jimmy Christian · Jul 16, 2019 go to post

Thank you. Yes, i am going to find out in a day or two.

Appreciate your help and time.

Jimmy Christian · Jul 17, 2019 go to post

Thank you Neerav.

The message i pasted doesnt look like  JSON. 

Looks like i may have to use some STRING functions to parse it. 

I will let you know once i get the right specs of the response. Thank you for time.

Regards,

Jimmy Christian.

Jimmy Christian · Jul 19, 2019 go to post

Thanks Sourabh.  I was able to put some debug variables and troubleshoot the issue.

Appreciate your help.

Regards,

Jimmy Christian

Jimmy Christian · Jul 19, 2019 go to post

Thats a good suggestion.

I will check that option out and see how to use POSTMAN as a proxy. Will let you know.

Thank you Jeffrey.

Jimmy Christian · Jul 30, 2019 go to post

Thank you Chris. 

So to give you a little more information, i want to disable the Operation if the response i receive after sending a message is not a valid one.

If i disable using Ens.Director,  does the last message i sent gets re-queued or is  it considered processed?

Thanks,

Jimmy Christian.

Jimmy Christian · Jul 30, 2019 go to post

Thank you Eduard. 

Exactly !

I forgot to set the return status to an error in Catch Block. 

I set to an error code and the Operation is down.

Thank you for help.

Jimmy Christian · Jul 30, 2019 go to post

Yep !

I did restart the Operation after putting the logic. I had forgotten to set the return status to an error code.

I think E=D works when the %Status has an error code.

Thank you for help.

Regards,

Jimmy Christian.

Jimmy Christian · Aug 2, 2019 go to post

Thank you Jeffrey.  This is very helpful.

I didnt realize we can use Source property in the Condition.

Jimmy Christian · Aug 6, 2019 go to post

Thank you Jenna.

You are absolutely right. I was able to update the DTL code and send a EnsStreamContainer object to the Operation.

It worked perfectly.

Regards,

Jimmy Christian.

Jimmy Christian · Dec 29, 2019 go to post

That is very helpful. I wasnt aware of this class method or class. Thank you for your assistance. I will use it and let you know if  i encounter any issue.

I also tried using another method where i read the stream object using ReadLine.

Then if the string starts with "MSH" OR "FT1" i increment the count.

In that case i have to use the Terminator character as $C(10) or $C(13) 

Regards,

Jimmy Christian.

Jimmy Christian · Dec 30, 2019 go to post

Ha ha. Thanks Jeffrey.

Yes the class name User.HL7.Stream seemed like the system defined class.

Jimmy Christian · Jan 2, 2020 go to post

Thank you Marc for the detailed information.

I earlier tried the approach using the Record Mapper but it did not seam feasible in this scenario. 

So i have done is 

Created a CUSTOM operation class which extends Ens.BusinessOperation, EnsLib.HL7.Operation.Standard

It uses the file adapter.

Then I overided the oninit and outputDocument method.

  1. The file adapter creates HL7 file as usual
  2. I created a new method which calls the override outputDocument method and passes the filename . Then I do a count of segments and create another file into which I copy all the necessary information and delete the file which was originaly created .
  3. Above method is called in oninit, so it is triggered on schedule whenever the operation starts. First I check if a file exists, if it does and is not the current file then I call this new method.
Jimmy Christian · May 29, 2020 go to post

Hello Pankaja,

Seems like for now custom code is the only option. I was not able to find any out of the box functionality for writing the counts of the total transactions without a custom code.

Here are few strategies for custom code i looked into.

1) In the File Operation , write the messages to a "Temp" File. At a certain time through a task or some other logic read from the temp file and collect all details you need and then write to another File.

2) I yet have to explore this option. At a point in time when you want your file, read from the Enslib.Hl7.Msg and create a file per your needs.

3) Write the live messages to a temp database. Generate necessary file from it when needed. Delete the messages from the DB and copy it to a Archive DB if needed.

4) As live messages are coming write to a Global and then run a task to create messages from the Globals.

Thanks,

Jimmy Christian.

Jimmy Christian · Jun 10, 2021 go to post

Hello Guilherme,

That makes sense.

I see my error now. I was trying to use session in the client method, which was causing problems.

Thanks a lot for your help!

Regards,

Jimmy Christian.

Jimmy Christian · Jun 17, 2021 go to post

Thanks Ken.

Actually i am trying to insert in the SQL utility provided in Ensemble. Not using a script.

Jimmy Christian · Jun 17, 2021 go to post

Thanks Eduard.

I get an error 

Input (UNION) encountered after the end of query^ INSERT INTO....