Class TMP.AppointmentReqMsg Extends Ens.Request
{ // ProcessingFlag property is used to determine if the appt is for Cerner, Cerner and VistA or just VistA. // This flag is used by the BP Property ProcessingFlag As %String; Property MessageId As %String; Property ControlId As %String; Property LogicAppRunId As %String(MAXLEN = 150); Property AppointmentID As %String(MAXLEN = 150); Property AppointmentType As %String; Property StartTime As %String; Property Duration As %String; Property VisitStatus As %String; Property CancelCode As %String; Property CancelReason As %String; Property CancelRemarks As %String(MAXLEN = 160); Property ClinicallyIndicatedDate As %String; Property Comments As %String(MAXLEN = 160); Property VvdUrl As %String(MAXLEN = 500); Property SchedulerInfo As array Of SchedulerInfo; Property PatientInfo As TMP.PatientInfo; Property ProviderFacility As %String; Property PatientFacility As %String; // Property PatientResources As list Of AppointmentResources; Property PatientResources As TMP.AppointmentResources; Property ProviderResources As TMP.AppointmentResources;

***Disclaminer, I consider myself to be a fairly new Cache Objectscript developer. If any developers with more experience have suggestions for how to do this easier, more efficient, etc. Please share. I am eager to learn more that will help me in the future. :) 

I have done this in the past, I created a business service with the EnsLib.HTTP.InboundAdapter to receive the JSON message on a REST end point. I also created a class for the JSON message structure. In the business service, I receive the JSON message and pass it to a business operation. In the business operation I have a transform that transforms the JSON to HL7 message, then the business process passes the HL7 message to a business operation to send to a new HL7 end point. This code was created in Ensemble 2017. If you are using IRIS, there are more classes for JSON message handling you might be able to use.

My business service handles several different JSON messages, this is the one of the methods I have for one of the messages. In the method I convert the JSON object that was received into a new object of type TMP.AppointmentReqMsg. TMP.AppointmentReqMsg is the class that defines the JSON message structure. 

The new JSON object is passed to a business process to process the message. In the business process, I have a transform that transforms the JSON object to HL7. Then the business process will call the business operation that sends the HL7 message on to an HL7 end point.

Hope this helps.

Method appointmentAction1(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object, pAppointment As %Stream.Object) As %Status
{  $$$LOGWARNING("In processing appointments")  #dim ApptArray As %List
 #dim tSC,tSC1,tSC2 As %Status = $$$OK  #dim processingFlag As %String
 #dim patientFacility As %String
 #dim providerFacility As %String
 #dim pFlag,provFlag,patFlag AS %Numeric = 0
 pJSON=pInput.Read()  set sc=##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(pJSON,"TMP.AppointmentReqMsg",.pRequestBody,1)
 s:##class(Ens.Util.FunctionSet).Lookup("CernerSites",pRequestBody.ProviderFacility)>0 provFlag=1
 S:##class(Ens.Util.FunctionSet).Lookup("CernerSites",pRequestBody.PatientFacility)>0 patFlag=1
     pFlag=provFlag+patFlag   ;pFlag=0;VistA only, pFlag=2;Cerner only, pFlag=1;Cerner and VistA
 $$$LOGWARNING("checking json")
 s:##class(Ens.Util.FunctionSet).Lookup("CernerSites",pRequestBody.PatientResources.Facility)'>0 tSC2 = ..checkJSON(pRequestBody.PatientResources.Resources)
 $$$LOGWARNING("checking json returned "_tSC2)
 $p(tSC2,"^",1)=2 tSC=..ReturnJSONAckMsg(.pRequestBody,tSC2)
 q:$p(tSC2,"^",1)=2 200
 s:##class(Ens.Util.FunctionSet).Lookup("CernerSites",pRequestBody.ProviderResources.Facility)'>0 tSC2 = ..checkJSON(pRequestBody.ProviderResources.Resources)
 $$$LOGWARNING("checking json returned "_tSC2)
 $p(tSC2,"^",1)=2 tSC=..ReturnJSONAckMsg(.pRequestBody,tSC2)
 q:$p(tSC2,"^",1)=2 200
 badResponse.ControlId = pRequestBody.ControlId
 badResponse.MessageId = pRequestBody.MessageId
 badResponse.OrganizationName = "CVT15"
 if +$L(patientFacility)>0
 s:$g(VistABO)="" badResponse.FailureReason="Patient Site is not configured in HealthConnect"
 if $L(providerFacility)>0
  s:##class(Ens.Util.FunctionSet).Lookup("CernerSites",providerFacility)>0 provprocessingFlag="Cerner"
  s:$g(VistABO1)="" badResponse.FailureReason="Provider Site is not configured in HealthConnect"
 if badResponse.FailureReason'="" 
    set tSC=..SendRequestSync("ProcessBadApptRequest",.badResponse,.pResponse) Quit:$$$ISERR(tSC)
 if pFlag=0
  tSC1 = ..SendRequestSync("ProcessVistAAppointments",.pRequestBody,.pResponse)
 if pFlag=1
  tSC1 = ..SendRequestSync("ProcessCernerAndVistAAppointments",.pRequestBody,.pResponse)
 if pFlag=2
  tSC1 = ..SendRequestSync("ProcessCernerOnlyAppointments",.pRequestBody,.pResponse)
 }  }  
 Quit tSC1

I created a class for the JSON message and then used a data transformation in Ensemble/IRIS to transform the JSON message to an HL7 message. 

you can define a message class for your JSON message. then set up your transform to transform the data from the HL7 message to the JSON message. then in your business process use the built in SQL commands to store the JSON string in SQL Server. 

Thanks for the help Vic, Ben and Evgeny,

You have provide some good information and I am going to try both the Project in Studio deployment and also try the Ens.Deployment,Utils to see which one works best for our needs.

Thanks Evgeny,

Not sure if that ZPM Package Manager is available on the version of Ensemble our client is running. They are not ready to upgrade to IRIS on this project yet. But I will take a look at it. Never know when I might need it in the future.

Thanks Vic, the problem is we are one of two teams updating the production. Fortunately, both teams are working in separate efforts and are not working in the same classes in the production. The work our team is doing is creating new business services, process and operations and message classes. but the deployment happens by another team so I am looking to create a simple deployment package they would run to add our new components to the production. I am trying not to have to write a step by step deployment guide that tells them to create this business service with this class, this business process with this bpl, etc.

Thanks Vic and Ben. it looks like what you and Ben Spead are saying is to build a new project that contains just my code to be deployed and then use the Ens.Deployment.Utils class to deploy that project. But does it set up the business operations, services and processes in the production so that they don't have to be set up and configured manually to use the classes? Trying to make it as simple and automated as possible.