Create multiple dependent Tasks

Is it possible to create a task that will initiate a Business Service that is dependent on the completion of a separate EDI data process?

I have a complex data flow with multiple EDI processes where one process must run and produce one or more files that get deposited in the source folder for the next EDI process.  The entire process is currently set up where 2 of the EDI processes execute at a specific time.  The problem with that is when a network or server interruption occurs at the time they are supposed to start, it causes a complete failure of the entire process.

I can't just set them to run anytime a file gets deposited in the source folder, since some of the processes transform data using multiple files.  Thus it must wait for all the necessary files before running.

If its not possible to accomplish this using tasks/workflows, how else might I be able to automate this flow?

Thanks!

 

  • 0
  • 0
  • 43
  • 0
  • 1

Answers

Waren, it is possible to pass messages to a business service via a scheduled task.

Create a Class that extends %SYS.Task.Definition. This will be the class executed by Task Manager.
Include Ensemble
/// Task to trigger the business service 
Class Sample.Util.Task.PatientService Extends (%SYS.Task.Definition, %Persistent) [ Inheritance = right ]
{
Parameter TaskName = "Sample.Util.Task.PatientService";
Method OnTask() As %Status
{
    SET qStatement = ##class(%SQL.Statement).%New()
    SET qStatus = qStatement.%Prepare("Select Distinct by (PatientId)  PatientId,PatientNameLast,PatientNameMiddle,PatientNameFirst,PatientAddress1,PatientAddress2,PatientCity,PatientState,PatientZipCode,PatientSexCode,PatientDateOfBirth,PatientRace,PatientPhone,PatientSSN,PatientMaritalStatus,PatientAdmissionDate,PatientDept from PREVOST_AthenaHealth.Patient Order by PatientId")
    IF qStatus'=1
    {
        WRITE !,"%Prepare failed",$System.Status.DisplayError(qStatus)
        Quit $$$ERROR($System.Status.GetErrorCodes(qStatus),$System.Status.GetErrorText(qStatus))
    }
    Set rset = qStatement.%Execute()
    set k0=0
    WHILE rset.%Next()
    {
        Set target=##class(EnsLib.HL7.Message).%New()
        .
        .
        .
        Set tSC=##class(Ens.Director).CreateBusinessService("Sample.AthenaHealth.PatientService",.tService)
        Set tSC=tService.ProcessInput(target) ; call ProcessInput(target) to send the transaction to the BS
    }
    Quit $$$OK
}

}


Create a class for your Business Service.
/// 
Class Sample.AthenaHealth.PatientService Extends Ens.BusinessService [ ProcedureBlock ]
{
/// Name of a Business Partner Profile associated with this item
Property BusinessPartner As %String(MAXLEN = 128);
/// Configuration item(s) to which to send messages
Property TargetConfigNames As %String(MAXLEN = 2000);
Parameter SETTINGS = "BusinessPartner:Info:partnerSelector,TargetConfigNames:Basic:selector?multiSelect=0&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";
Method OnProcessInput(tResult As EnsLib.HL7.Message, Output pOutput As %RegisteredObject) As %Status
{
    ;Only route to 1st TargetConfigName
    Set SC = ..SendRequestAsync($piece(..TargetConfigNames,","),tResult)
    Quit $$$OK
}

}

Create a Business Service using your newly defined class in your Production.
<Item Name=“Sample.AthenaHealth.PatientService" Category="PREVOST" ClassName=“Sample.AthenaHealth.PatientService" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="TargetConfigNames">HL7MsgRouter</Setting>
    <Setting Target="Host" Name="BusinessPartner">A60</Setting>
  </Item>