set dynObj = {}.%FromJSON(Person.%ToJSON())- Log in to post comments
set dynObj = {}.%FromJSON(Person.%ToJSON())Something like this operation should do it for you.
Class Component.Outbound.JsonHttpsOut Extends Ens.BusinessOperation
{
Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter";
Property Adapter As EnsLib.HTTP.OutboundAdapter;
Method SendMessage(pMsgOut As %DynamicObject, Output pMsgIn As %Net.HttpResponse) As %Status
{
S tSC=$$$OK
Set tHttpRequest=##class(%Net.HttpRequest).%New(), tHttpRequest.WriteRawMode=1, token =##class(%DynamicObject).%New(), tSC=$$$OK
Set tHttpRequest.SSLConfiguration=..Adapter.SSLConfig
Set tSC = tHttpRequest.SetHeader("Content-Type", ..ContentType)
d tHttpRequest.EntityBody.Write(pMsgOut.%ToJSON())
#dim tHttpResponse As %Net.HttpResponse
Set tHttpResponse = ##class(%Net.HttpResponse).%New()
S send="POST"
Set tSC=..Adapter.SendFormDataArray(.tHttpResponse, send, tHttpRequest)
if (tHttpResponse.StatusCode="200"){
set message=tHttpResponse.StatusCode_": "_tHttpResponse.StatusLine_". "
if $IsObject(tHttpResponse.Data)
{
while 'tHttpResponse.Data.AtEnd {
set message=message_tHttpResponse.Data.Read(,.tSC1)
if 'tSC1 quit
}
$$$TRACE(message)
s tSC=$$$ERROR("9999",message)
}
s tSC=$$$OK
}
else
{
set message=tHttpResponse.StatusCode_": "_tHttpResponse.StatusLine_". "
if $IsObject(tHttpResponse.Data)
{
//set message=""
while 'tHttpResponse.Data.AtEnd {
set message=message_tHttpResponse.Data.Read(,.tSC1)
if 'tSC1 quit
}
$$$TRACE(message)
s tSC=$$$ERROR("9999",message)
}
Set ..Adapter.URL=$REPLACE(..Adapter.URL,..tmpurl,"") //sets adapter url back to standard if it was last used to remove an MRN
}
Q tSC
}
You can do something similar by doing all transfroms in something like 2.4 ADT_A01, and then using code similar to below on all transforms to change the message Doctype to match the intended schema.
//this part collates the info to set the doctype
set version=target.GetValueAt("MSH:VersionID.versionID")
set type=target.GetValueAt("MSH:MessageType.messagetype")
set trigger=target.GetValueAt("MSH:MessageType.triggerevent")
//set trigger="A05"
if ((trigger = "A08")!(trigger = "A11")!(trigger = "A27")!(trigger = "A03")!(trigger = "A12")!(trigger = "A13")){SET trigger = "A01"}
//this sets the doctype
set target.DocType=version_":"_type_"_"_trigger
//set target.DocType="2.4:ADT_A05"
]]></code>
Set tSC = ..SendRequestSync(..TargetConfigName, tRequest, .tResponse)
if (($P(tResponse.Response.Status," ",1)>199) && ($P(tResponse.Response.Status," ",1)<399))
{ Set tResponseQuickStream = ##class(HS.SDA3.QuickStream).%OpenId(tResponse.QuickStreamId)
Set tSC = $$$ERROR($$$GeneralError, tResponseQuickStream.Read())
//Set BundleObject=##class(HS.FHIR.DTL.vR4.Model.Resource.Bundle).FromJSON(tResponseQuickStream,"vR4")
Set BundleObject=##class(%DynamicObject).%FromJSON(tResponseQuickStream)
}
{
Set tResponseQuickStream = ##class(HS.SDA3.QuickStream).%OpenId(tResponse.QuickStreamId)
Set tSC = $$$ERROR($$$GeneralError, tResponseQuickStream.Read())
Set BundleObject=##class(HS.FHIR.DTL.vR4.Model.Resource.Bundle).FromJSON(tResponseQuickStream,"vR4")
Quit BundleObject
}
You can use the line similar to below instead of Bundle if you are unsure of the payload as well
there should be a merge operation on the fhir server for this, or you should be able to use the link element on a patient to assign one as the mast record. See https://www.hl7.org/fhir/patient.html or https://www.hl7.org/fhir/patient-operation-merge.html for more info.
We sent the EnsLib.HTTP.GenericService into a process that did this, hope it helps.
Class Component.httpResendMessage Extends Ens.BusinessProcess
{
Method OnRequest(pRequest As EnsLib.HTTP.GenericMessage, Output pResponse As EnsLib.HTTP.GenericMessage) As %Status
{
set tSC=$$$OK
s namespace = $REPLACE(pRequest.HTTPHeaders.GetAt("IParams_1"),"namespace=","")
s ClientDocGUID= $REPLACE(pRequest.HTTPHeaders.GetAt("IParams_2"),"ClientDocGUID=","")
s pResponse=##class(EnsLib.HTTP.GenericMessage).%New()
set pResponseBody=##Class(%Stream.GlobalCharacter).%New()
d pResponseBody.Write("<HTML><HEAD>Uh oh.</HEAD><BODY><BR><STRONG>Error: Invalid Patient ID</STRONG></BODY></HTML>")
do pResponseBody.Rewind()
d pResponse.HTTPHeaders.SetAt("HTTP/1.1 400 Bad Request","StatusLine")
d pResponse.HTTPHeaders.SetAt("text/html; charset=utf-8","Content-Type")
do pResponse.StreamSet(pResponseBody)
quit tSC
}
}
go into the terminal and the namespace you want to disable, then type Set ^%SYS("sql","sys","autotune") = 0
You could also try adding a code section to you DTL, similar to this.
//this part collates the info to set the doctype
set version=target.GetValueAt("MSH:VersionID.versionID")
set type=target.GetValueAt("MSH:MessageType.messagetype")
set trigger=target.GetValueAt("MSH:MessageType.triggerevent")
//set trigger="A05"
if ((trigger = "A08")!(trigger = "A11")!(trigger = "A27")!(trigger = "A03")!(trigger = "A12")!(trigger = "A13")){SET trigger = "A01"}
//this sets the doctype
set target.DocType=version_":"_type_"_"_trigger
//set target.DocType="2.4:ADT_A05"