Thembelani Mlalazi · Nov 29, 2019 go to post

Hi Jenna Poindexter

Yes %Populate exists but that's not what I am referring to the above is the correct answer  by Alexander Koblov. I was referring to this class %Library.CachePopulate not what you are pointing me to

Thembelani Mlalazi · Oct 23, 2017 go to post

Here is some code that will process your string container into lines of records that you want but you might want to change a few things to get this working with your records after converting your string container to a simple csv file you can then map it to your record mapper and process it any how.


Class TestEnvironment.Custom.GENERAL.ContainerString Extends (%Persistent, %Populate, %XML.Adaptor, %ZEN.DataModel.Adaptor)
{

Property Mystring As %String(MAXLEN = 32000, XMLPROJECTION = "CONTENT");

ClassMethod Import()
{
    // Create an instance of %XML.Reader
    Set reader = ##class(%XML.Reader).%New()

    // Begin processing of the file
    Set status = reader.OpenFile("C:\TEST\test.xml")
    If $$$ISERR(status) {do $System.Status.DisplayError(status)}

    // Associate a class name with the XML element name
    Do reader.Correlate("StringValue","TestEnvironment.Custom.GENERAL.ContainerString")
    
    // Read objects from xml file
    While (reader.Next(.object,.status)) {
	    
	   
        Write object.Mystring,!
        
//check the length of the string
         set lstr=$length(object.Mystring,",")
	    write "The length of incoming string is : "_lstr
	    if (lstr>28)
	    {
//divide by 28 for your processing
		    set div=lstr/28
		    if (div=2)
		    {
//assign your strings to something and write to file to map your records
			    set newstrObject=$piece(object.Mystring,",",1,28)
			    set secNewStrOJect=$piece(object.Mystring,",",29,56)
			 }
			 elseif (div=3)
		    {
			    set newstrObject=$piece(object.Mystring,",",1,28)
			    set secNewStrOJect=$piece(object.Mystring,",",29,56)
			     set thirdNewStrOJect=$piece(object.Mystring,",",57,84)
			     
			     write "this is the string cut1 :"_newstrObject,!
			      write "this is the string cut2 :"_secNewStrOJect,!
			       write "this is the string cut3 :"_thirdNewStrOJect,!
			 
		 }}
    }
    
    // If error found during processing, show it
    If $$$ISERR(status) {do $System.Status.DisplayError(status)}
}


}

hope this helps

Thembelani Mlalazi · Oct 24, 2017 go to post

yes it possible within your rule select the rule's constraint where you reference the source where the message is coming from and then click rule and  add when  on the condition for when select document . which will allow you to use the record mapper property

Thembelani Mlalazi · Jan 15, 2018 go to post

I am supposed to use the EnsLib.MsgRouter.VDocRoutingEngine on the process and use the following syntax to get to the property level/

Document.{Property.Property} this works

The concept is about relationships the batch needs to be instantiated outside the loop and the record created and inserted in the loop. The batch has many records so every time we loop we add to records and then save records to a batch which was created only once

Method OnRequest(pRequest As DQToolsSet.PrimaryMessageREQ, Output pResponse As HSCIC.DBS.RequestRBAT) As %Status
{
 #dim status as %Status=$$$OK
    #dim resultSet as %SQL.StatementResult
   
   setpResponse=##class(HSCIC.DBS.RequestRBAT).%New()
 setstatus=..Adapter.ExecuteQuery(.resultSet,..GetTheSubmissionData(pRequest.pMonth, pRequest.pApp, pRequest.pRef, pRequest.pInPat))

nbsp;if ($$$ISOK(status))
 {
  While (resultSet.%Next(.status) && $$$ISOK(status))
  {
  setppResponse=##class(HSCIC.DBS.RequestRMAP.Record).%New()
     set ppResponse.RequestCode=resultSet.Get("recType")
        set ppResponse.PatientID=resultSet.Get("ClientID")
        set ppResponse.DOB=resultSet.Get("DOB")
        set ppResponse.Property4=resultSet.Get("u1")
        set ppResponse.Property5=resultSet.Get("u2")
        set ppResponse.NHSNumber=resultSet.Get("NNN")
        set ppResponse.Surname=resultSet.Get("Surname")
        set ppResponse.AltSurname=resultSet.Get("u3")
        set ppResponse.GivenName=resultSet.Get("GivenName1")
        set ppResponse.AltGivenName=resultSet.Get("u4")
        set ppResponse.SpineGender=resultSet.Get("Gender")
        set ppResponse.Address1=resultSet.Get("a1")
        set ppResponse.Address2=resultSet.Get("a2")
        set ppResponse.Address3=resultSet.Get("a3")
        set ppResponse.Address4=resultSet.Get("a4")
        set ppResponse.Address5=resultSet.Get("a5")
        set ppResponse.PostCode=resultSet.Get("Postcode")
        set ppResponse.AltAddress1=resultSet.Get("p1")
        set ppResponse.AltAddress2=resultSet.Get("p2")
        set ppResponse.AltAddress3=resultSet.Get("p3")
        set ppResponse.AltAddress4=resultSet.Get("p4")
        set ppResponse.AltAddress5=resultSet.Get("p5")
        set ppResponse.AltPostCode=resultSet.Get("p6")
        set ppResponse.GPCode=resultSet.Get("GPCode")
        set ppResponse.GPPracticeCode=resultSet.Get("PracticeCode")
        set ppResponse.NewField3=resultSet.Get("u5")
        set ppResponse.NewFiel23=resultSet.Get("u6")
  
   setstatus=ppResponse.%Save()
 
   if ($$$ISOK(status))
   {
    setstatus=pResponse.Records.InsertObject(pobject)
   
      }
  
  
  }
  }
setstatus=pResponse.Records.%Save()
  }
 
Thembelani Mlalazi · Jun 17, 2019 go to post

Using the XLFOWrapper by @Attila Toth managed to twick it around to produce pdfs from stream for future reference you can visit his GitHub page or a fork repository by Tim to see the version that worked for my use case

Thembelani Mlalazi · Dec 16, 2019 go to post

This will do exactly what you want any problems give us shout

ClassMethod ImpCSV(fileName As %String = "C:\filepath where csv file is")
{
	;;Refresh globals data at the begin of proecess
	;;globals hold the file being written to data and the count of lines each file has 
	k ^ufile,^ufile2,^counter,^counter2
	set Reader =##class(%Stream.FileCharacter).%New() 
	
	;;link to the file to read	 
	set status=Reader.LinkToFile(fileName)
		
   if $$$ISERR(status)
	{
		do $System.Status.DisplayError(status)
	}
	;;initialise the counter for the file lines to write to one file	 
	set ^counter =0
	set ^counter2 =0	
	set ^ufile=""
	set ^ufile2=""
    
    ;;the count for the lines read in
	set lineCount=0
	;;start process the lines
	while 'Reader.AtEnd
	{
		;;read the incoming file
		set line=Reader.ReadLine()
		;;increment the line count by one as you read the next line
		set lineCount=lineCount+1		
	
	    ;;piece the column to check
	    ;;one is for the first column and so on
	    ;;string at after the equal sign is the value to check for 
		if ($piece(line,",",1)="Religion")
		{
			;;increment count for this file
			 set ^counter=^counter+1
			  ;;the counter is at one to assign the file path to write to
			   if (^counter=1)
				{
					;;set the file name to write to the global
					set ^ufile=..writeFileOut("fileone",".csv",line,,^counter)
				}
				else
				{
					;;check the count has no reached the limit for the number of lines to write to
					if (^counter=51)
					{
						;;reset the count if limit reach
						set ^counter=1
					    ;;new file
					    set ^ufile =..writeFileOut("fileone",".csv",line,,^counter)
					    }
					    else
					    {
						    ;;use the current file
						    do ..writeFileOut(,,line,,^counter,"REG")
						 }
					}			
		  }
		  ;;second check for the next set of data if you have more than 
		  ;;two to check for copy the below and change accordingly to accommodate the next check
		  ;;same as above
		  if ($piece(line,",",1)="description")
		  {
			  ;;set attributes for the second file to write to
			   set ^counter2=^counter2+1
			   if (^counter2=1)
			   {
					set ^ufile2=..writeFileOut("fileTwo",".csv",line,,^counter2)
				}else
				{
					if (^counter2=51)
					{
						set ^counter2=1
						;;new file
						set ^ufile2= ..writeFileOut("fileTwo",".csv",line,,^counter2)
					}else
					{
						do ..writeFileOut(,,line,,^counter2,"DESC")
					}
				}				 			
	}
		  
}

 kill ^ufile,^ufile2
}

ClassMethod writeFileOut(filename, fileext As %String, line As %String, directory = "C:\directory to store files", linecount As %Integer, FileToUse)
{
	set oLF = ##class(%Library.File).%New()
	if (linecount=1)
	{
		
	    Set filenam=directory_filename_$i(^timmmy)_fileext
	    set oLF.Name=filenam
	    if (oLF.Open("wns"))
	    {
		    set linecount=linecount+1
		    do oLF.WriteLine(line)
		    do oLF.Close()
		    ;;w oLF.Name
		    quit oLF.Name	
	   }
	}else
	{
		if (FileToUse="DESC")
		{
		     if (^ufile2'="")
		     {
		         set oLF.Name=^ufile2
			}
		}elseif(FileToUse="REG")
		{
		     if (^ufile'="")
			 {
			     set oLF.Name=^ufile
			  }
		}
	    If (##class(%File).Exists(oLF.Name))
	     {
		     
		     Do oLF.Open("EWA")
		     if (linecount'=51)
		     {
			     set linecount=linecount+1
		         do oLF.WriteLine(line)
		         do oLF.Close()
		          quit oLF.Name
		     }
		 }
	}
}
Thembelani Mlalazi · Jul 15, 2020 go to post

@Eduard Lebedyuk 
I have classes with the similar structure in your test.Serial class I have Two properties  Serial1 and Serial2 as test.Serial1 and 2 respectively and i would like to print out XML maybe populate  Serial 1 and have Serial2 as an empty object and Leave it out when printing.How do I controll that ?,as it stands it prints out the empty elements even when ignore null is set.Please not all is the same as above so I am printing from a persistent Level.The difference being I have two serial objects properties In my test.Serial equavalent

Thembelani Mlalazi · Jul 20, 2022 go to post

thank you everyone the problem I have been having is caused by the Describe column invoked by the Execute procedure  method on the procedure if data passed is not the same type as the stored procedure parameters the method issues a warning which is then log to the event log to stop that from happen I had to add the "*" to the pIO parameter of the method

Thembelani Mlalazi · Sep 20, 2022 go to post

I have set up this service within Ensemble using the the "EnsLib.HTTP.InboundAdapter"; if any one has done this before please advice currently I have done everything as per advices and followed through the ENSDEMO namespace examples still can not pass a JSON request

Thembelani Mlalazi · Oct 16, 2022 go to post

@Smythe Smythee 
the problem you are having is that the property does not exist what does your class look like. The one that handles the incoming XML and what version of HL7 are you converting to.

Thembelani Mlalazi · Oct 27, 2022 go to post

looking at your error I suppose you have a scheme same as the above since your error is complaining about the source class MSH which does not exist within the XML document.

tSC1=target.SetValueAt(source.MSH.EncodingCharacters,"MSH:EncodingCharacters","set","")

do you have this class if not then that's where the problem is look at the bold

Thembelani Mlalazi · Mar 13, 2023 go to post

@Eduard Lebedyuk 
Looking at the unpacking method I am trying to unzip a directory and looking at that you are calling some methods outside the scope I would like to test this but the link you have at the top is broken can we please see how you implement the execute and getunzip methods

Having tested this outside a restricted environment I realised my problem was the proxy server as the htttpResponse was not being instantiated, the work around was to use the proxy sever and running everything through the proxy tunnel.

ClassMethod MyReq()
{
set tSC=$$$OK
set req = ##class(%Net.HttpRequest).%New()
set req.Server = "msedgewebdriverstorage.blob.core.windows.net"
set req.ProxyPort=**
set req.ProxyServer="*******"
set req.ProxyHTTPS=1
set req.ProxyTunnel=1
set req.SSLConfiguration="Open"do:tSC req.Get("/edgewebdriver/?comp=list")     Do $System.OBJ.Dump(req.HttpResponse)
quit tSC
}

I will do it like so:

set tObj = {}.%FromJSON(stream)

set newObj=##class(HS.FHIR.DTL.vR4.Model.Resource.*).%New()

set newObj.Property=tObj.SameProperty

do newObj.%Save()

I have tried what you suggested but still getting the same error <INVALID OREF> have also checked to see if the JSON string is present and checked on the instantiated object can not pin point where the error is coming from had look here they had the same problem but my guess is we are using different versions as I don't have this class in my version  HS.FHIR.Validation.ResourceValidator

 @Enrico Parisi 
I have tried calling it that I get

<THROW>%Constructor+33^%Net.Remote.Object.1 *%Net.Remote.Exception <GATEWAY> System.Reflection.TargetInvocationException  Exception has been thrown by the target of an invocation.

@Jeffrey Drumm 
I have tried as per your suggestion but still can not login I believe changing the password here is the same as changing the pass in the management portal SystemAdministration -->configuration -->security -->users and I have read here my understanding is that the two are separate please correct me if I am wrong but I keep on coming to the same page after using the terminal ^SECURITY and restarted IRIS