@Sean Connelly

Class TOpp Extends Ens.BusinessOperation
{
Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter";
Property Adapter As EnsLib.SQL.OutboundAdapter;
Parameter INVOCATION = "Queue";
Method CheckRequests(pRequest As Ens.Request, Output pResponse As Ens.Response) As %Status
{
 set query= ";with apt as"
 _"("
 _" Select ac.ClientID from AmsAppointmentContact ac join AmsAppointment a on a.SequenceID = ac.SequenceID where"
 _"  a.AppointmentDate > CAST(DATEADD(M,-6,GETDATE()) AS DATE) and a.CancellationDateTime is null "
 _" ),"
 _" ref as"
 _"("
 _" select ClientID"
 _"  from"
 _" ( select ROW_NUMBER() OVER(PARTITION BY ClientID ORDER BY ReferralNumber) rn, * from AmsReferral"
 _"   where DischargeDateTime is null) a"
 _"  where rn = 1 "
 _" ),"
 _"  inp as"
 _" ("
 _" select ClientID"
 _" from"
 _"("
 _" select ROW_NUMBER() OVER (PARTITION BY ClientID ORDER BY EventNumber) as rn,* from ImsEvent"
 _" where DischargeDate is null) a "
 _"  where rn = 1"
 _" ),"
 _" cohort as "
 _" (select ClientID from "
 _" ( "
 _" select row_number() OVER(PARTITION BY ClientID ORDER BY ClientID) as rn,ClientID from "
 _" (select * from apt"
 _" union all "
 _"  select * from ref "
 _"  union all "
 _"  select * from inp) a) b where rn=1 "
 _" ) "
 _" select '10' as recType, c.ClientID, CONVERT(VARCHAR(8), c.DateOfBirth, 112) as DOB, '' as u1, '' as u2, ISNULL(c.NNN, '') as NNN,"
 _" cn.Surname, '' as u3, cn.GivenName1, '' as u4, g.SpineCode as Gender,"
 _" '' as a1,'' as a2,'' as a3,'' as a4,'' as a5 ,ca.PostCode,'' as p1,'' as p2,'' as p3,'' as p4,'' as p5,'ZZ99' as p6, ch.GPCode, ch.PracticeCode,'' as u5,'' as u6 "
 _" from ClientIndex c left join ClientName cn on cn.ClientID = c.ClientID left join ClientAddress ca on ca.ClientID = c.ClientID left join ClientHealthCareProvider ch on c.ClientID = ch.ClientID "
 _" left join GenGender g on g.Code = c.Gender join cohort on cohort.ClientID = c.ClientID where "
  _" c.DateOfDeath is null and ca.ToDate is null and ca.AddressGroup = 1 and cn.AliasType = '1' and ch.ToDate is null and c.NonClient = 0"
 
 set file = ##class(%Stream.FileCharacter).%New()
 set fileName="C:\File\123.txt"
 set sc=""
  do file.LinkToFile(fileName)
  while 'file.AtEnd {
 
  set rs = ##class(%SQL.Statement).%ExecDirect(, query)
  set sc = rs.%DisplayFormatted(100,file)
}
 quit sc
 
}
XData MessageMap
{
<MapItems>
  <MapItem MessageType="Ens.Request">
    <Method>CheckRequests</Method>
  </MapItem>
</MapItems>
}
}

@Sean Connelly thanks I have tried your suggestions both but still not writing anything to a file and  no file is being created am I missing anything please advise thanks in advance

@Scott Roth  have tried your suggestion still same problem .Under Data Settings I have a query "SELECT ID FROM dbs.DBS WHERE Status='Pending'" and the above code just in case I did not do it right please advise

@Dmitriy Maslennikov I have  done this for starters but got an error ^
<INVALID OREF>zTalkToTheWorld

here is my code

 

 

Method TalkToTheWorld()
{
 Set httprequest=##class(%Net.HttpRequest).%New()
 Set httprequest.Server="https://maps.googleapis.com/maps/api/distancematrix/json?origins=BRISTOL&destinations=LONDON&key=TZhydlRg6-dUm-EoIuees43456rtyu7 "
 Do httprequest.Get("/")
 Do httprequest.HttpResponse.OutputToDevice()
 Do httprequest.Get("/cache/")
 Do httprequest.HttpResponse.OutputToDevice()
}

 

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

@Jeffrey.Drumn Assuming I got this right He is trying to get to reference a property from a record mapper that will work just fine here is an example

TestEnvironment.Record being my record mapper class and the Document.wardAge being my property (WARDAGE)

On the condition I would like to do something like this but I do not get the opportunity to actual get to the schema that I would like to reference to get to that. Message will be the root of my xml document Header an element with attribute Action @Robert.Cemper

@David Foard In  your Rule on the when  condition select the  (Document.RecordMapper.Property) make show you are referencing a record mapper on the constraint of the rule