Thanks for the response Julius. I have used that before when the property came in the JSON consistently in the same format. In this case it can come in as:
"members": null,
or as:
"members": [
{
"dob": "1905-05-01",
"firstName": "BOB",
"middleName": "T",
"nameSuffix": "",
"genderCode": "M",
"lastName": "COLLINS",
"memberId": "123421741",
"relationship": "Subscriber"
}
],
Not sure this way will accommodate the two possible structures.
Is there anything else that needs to be set along with the %DynamicArray? I also tried %DynamicObject as well.
Property members As %DynamicArray; Property relationship As %String; Storage Default
{
<Data name="members">
<Attribute>members</Attribute>
<Structure>node</Structure>
<Subscript>"members"</Subscript>
</Data>
Method OnRequest(pRequest As EnsLib.HL7.Message, Output pResponse As Ens.Response) As %Status
{
#dim newrequest = pRequest.%ConstructClone()
#dim eException As %Exception.AbstractException
#dim tSC As %Status =$$$OK
SET FedExID = "123456"
SET segcount = newrequest.SegCountGet()
$$$LOGINFO("segcount "_segcount)
SET newsegpos = segcount +1
$$$LOGINFO("newsegpos "_newsegpos)
SET zm1str = "ZM1|1|||||||||||||||||||" _FedExID
#;SET zm1str = "ZM1|1|||||||||||||||||||" _FedExID _"|"
SET zm1 = ##class(EnsLib.HL7.Segment).ImportFromString(zm1str,.sc,pRequest.Separators)
$$$QuitOnError(sc)
SET newseg = newrequest.SetSegmentAt(zm1,newsegpos)
$$$QuitOnError(newseg)
SET pRequest = newrequest
#;SET tSC = ..SendRequestSync("HL7FileOperation", newrequest)
SET tSC = ..SendRequestSync(..TargetConfigName, newrequest)
#;return newrequest Quit tSC
}