go to post Rick Prichett · Sep 2, 2021 Thanks Sean! I was able to trouble shoot and came up with the below code that does add my ZM1 segment. 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}
go to post Rick Prichett · May 5, 2021 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.
go to post Rick Prichett · May 5, 2021 I am still getting "ERROR #9406: Unexpected format for value of field, members, using class base mapping". 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>
go to post Rick Prichett · Mar 11, 2021 Thanks for all your help! Our group is transitioning to Iris from Mirth and Object script is a very different beast.
go to post Rick Prichett · Mar 9, 2021 The [ ] seems to let it compile. How do I access the array? For example how would I get physicianFirstName from the array? Before I have been able to do something like this. Set pLOB = pResponse.memberPolicies.GetAt(1).insuranceInfo.lineOfBusiness I now keep getting this An error was received : ERROR <Ens>ErrException: <UNDEFINED>zgetProviderInfo+24^CDSM.ProviderAPI.EISLProviderAPIOperation.1 *tsc -- logged as '-' number - @' Set pphysicianFirstName =tsc.GetAt(0).physicianFirstName' I tried tsc.GetAt(1).physicianFirstName' as well.
go to post Rick Prichett · Mar 9, 2021 It was on another line below. The error is still there but it looks like all brackets are matched. /// REST EISL Provider API Business OperationClass CDSM.ProviderAPI.EISLProviderAPIOperation Extends EnsLib.REST.Operation [ Language = objectscript ]{ Parameter INVOCATION = "Queue"; Method getProviderInfo(pRequest As CDSM.ProviderAPI.Request, Output pResponse As CDSM.ProviderAPI.ProviderInfo) As %Status{ Try { Set tSC = $$$OK//Build the API requestSet tHttpRequest = ##class(%Net.HttpRequest).%New()Set tHttpRequest.ContentType = "application/json"Set tSC = pRequest.%JSONExportToStream(.tJSONRequest) Quit:$$$ISERR(tSC)Set tSC = tHttpRequest.EntityBody.CopyFrom(tJSONRequest) Quit:$$$ISERR(tSC)Set tSC = tHttpRequest.EntityBody.Rewind() //Build the Response#Dim tHttpResponse As %Net.HttpResponseSet tSC = ..Adapter.SendFormDataArray(.tHttpResponse,"POST",tHttpRequest) If $$$ISERR(tSC) && $IsObject(tHttpResponse) && (tHttpResponse.Data.Size) {Set tSC = $$$ERROR($$$EnsErrGeneral,$$$StatusDisplayString(tSC)_":"_tHttpResponse.Data.Read())//Quit:$$$ISERR(tSC)} If $IsObject(tHttpResponse) {$$$LOGINFO("Response is "_tHttpResponse.Data.Read())Set tSC = tHttpResponse.Data.Rewind() Quit:$$$ISERR(tSC)// Copy the contents of HttpResponse into pResponse// Navigate pResponse and grab the things we want to store into SQL// SQL InsertSet pResponse=##class(CDSM.ProviderAPI.Response).%New()Set tSC = pResponse.%JSONImport({}.%FromJSON(tHttpResponse.Data).%Get(0))}} catch {Set tSC = $$$SystemError}Quit tSC} // below is not auto generated programmer must put XData MessageMap{<MapItems> <MapItem MessageType="CDSM.ProviderAPI.Request"> <Method>getProviderInfo</Method> </MapItem></MapItems>} }
go to post Rick Prichett · Mar 9, 2021 This this error when I replace the old code with the new line. It looks to me as though all are matched. Is there a bug?
go to post Rick Prichett · Mar 9, 2021 If the [ ] brackets were stripped off would the class definition work? if so how would I strip them on in the class?
go to post Rick Prichett · Mar 9, 2021 I verified with the group sending the reply there will only be one. I would define a class but the reply does not have a tag to be identified in the reply (example above). How would I build a class in that case or would it be easier to Output pResponse As CDSM.ProviderAPI.ProviderInfo in the method as something else. This would also Set pResponse=##class(CDSM.ProviderAPI.Response).%New() need changed I do believe as well.
go to post Rick Prichett · Mar 9, 2021 How would I modify the code below to return the response so that it can be accessed as an array later in the code? /// REST EISL Provider API Business OperationClass CDSM.ProviderAPI.EISLProviderAPIOperation Extends EnsLib.REST.Operation [ Language = objectscript ]{ Parameter INVOCATION = "Queue"; Method getProviderInfo(pRequest As CDSM.ProviderAPI.Request, Output pResponse As CDSM.ProviderAPI.ProviderInfo) As %Status{ Try { Set tSC = $$$OK//Build the API requestSet tHttpRequest = ##class(%Net.HttpRequest).%New()Set tHttpRequest.ContentType = "application/json"Set tSC = pRequest.%JSONExportToStream(.tJSONRequest) Quit:$$$ISERR(tSC)Set tSC = tHttpRequest.EntityBody.CopyFrom(tJSONRequest) Quit:$$$ISERR(tSC)Set tSC = tHttpRequest.EntityBody.Rewind() //Build the Response#Dim tHttpResponse As %Net.HttpResponseSet tSC = ..Adapter.SendFormDataArray(.tHttpResponse,"POST",tHttpRequest) If $$$ISERR(tSC) && $IsObject(tHttpResponse) && (tHttpResponse.Data.Size) {Set tSC = $$$ERROR($$$EnsErrGeneral,$$$StatusDisplayString(tSC)_":"_tHttpResponse.Data.Read())//Quit:$$$ISERR(tSC)} If $IsObject(tHttpResponse) {$$$LOGINFO("Response is "_tHttpResponse.Data.Read())Set tSC = tHttpResponse.Data.Rewind() Quit:$$$ISERR(tSC)// Copy the contents of HttpResponse into pResponse// Navigate pResponse and grab the things we want to store into SQL// SQL InsertSet pResponse=##class(CDSM.ProviderAPI.Response).%New()Set tSC = pResponse.%JSONImport(tHttpResponse.Data.Read()) Quit:$$$ISERR(tSC) }} catch {Set tSC = $$$SystemError}Quit tSC} // below is not auto generated programmer must put XData MessageMap{<MapItems> <MapItem MessageType="CDSM.ProviderAPI.Request"> <Method>getProviderInfo</Method> </MapItem></MapItems>} }
go to post Rick Prichett · Mar 8, 2021 It looks like my response is not a true JSON response (encapsulated in {}) but, is returned as a JSON array like the example. is there any way to read in my response so that I can access the variables? [ { "physicianFirstName": "STEVENSON", "physicianLastName": "HOWARD", "physicianMiddleNameInitial": "W", "physicianSpecialty": "null", "physicianNPI": "null", "physicianMPIN": "null", "physicianTaxID": "null", "physicianADRId": "null", "physicianAddressLine1": "null", "physicianCity": "null", "physicianState": "null", "physicianZip": "null", "physicianZipPlus4": "null", "physicianPhone": "null", "facilityNPI": "null", "facilityAddressLine1": "\"\"", "facilityCity": "\"\"", "facilityState": "\"\"", "facilityZip": "\"\"", "error": "Invalid NPI. Requested NPI should contain 10 numeric digits", "cdsm_Physician_Issue_ID": "null" } ]
go to post Rick Prichett · Feb 15, 2021 Now that I have my cloned message being sent to my destination. Is there a way to set the target argument in the Business Process settings so that the user can pick it vs hard coding? set tSC = ..SendRequestSync("HL7FileOperation", newrequest)