go to post Thembelani Mlalazi · Oct 27, 2022 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
go to post Thembelani Mlalazi · Jul 20, 2022 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
go to post Thembelani Mlalazi · Dec 16, 2019 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 } } } }
go to post Thembelani Mlalazi · Jun 17, 2019 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
go to post Thembelani Mlalazi · Apr 18, 2019 After some investigation on the above problem I realised that when purging record map data the data integrity check is the problem as I am using Ensemble 2014.1 the relationships on those is a one to many so when deleting these objects there is an %ondelete method which invokes a delete record method which tries to delete a record and then delete the batch but it does not check if that batch still have records associated with it. Now a new problem arises where I have tried to delete individuals records in a batch successfully but when trying to delete the batch its self it errors with a 5002 ROLLback error now the question is how to get around this problem
go to post Thembelani Mlalazi · Apr 5, 2018 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 set pResponse=##class(HSCIC.DBS.RequestRBAT).%New() set status=..Adapter.ExecuteQuery(.resultSet,..GetTheSubmissionData(pRequest.pMonth, pRequest.pApp, pRequest.pRef, pRequest.pInPat)) nbsp;if ($$$ISOK(status)) { While (resultSet.%Next(.status) && $$$ISOK(status)) { set ppResponse=##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") set status=ppResponse.%Save() if ($$$ISOK(status)) { set status=pResponse.Records.InsertObject(pobject) } } } set status=pResponse.Records.%Save() }
go to post Thembelani Mlalazi · Jan 15, 2018 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
go to post Thembelani Mlalazi · Oct 23, 2017 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