Workflow engine

Discussion in 'Feature: Requests and Planning' started by Graham, Aug 1, 2012.

  1. Graham

    Graham Developer Staff Member

    Amazon Simple Work Flow ( http://aws.amazon.com/swf/ ) is a programmable workflow engine. Workflows can create child work flows, etc.
    So, one could create a workflow that involves ordering a blood test, checking that it has been done, checking for normality, deciding whether to send a copy to the patient, or some other action, and perhaps triggering some checklist for patients who are diabetic if the test is a blood sugar. Actions can be performed by agents, or people, and from any device that has an internet connection.

    Would be a lot of work but would be interesting in tying everything together.
    Jason likes this.
  2. Graham

    Graham Developer Staff Member



    This is a video that explains how SWF works. Workflows can last up to 1 year, and if you need longer, you can run again.
  3. Graham

    Graham Developer Staff Member

    So, let's consider a HbA1c workflow.

    DM patient detected ( at consult, when diagnosis added, or when DB scanned )
    A serial HbA1c workflow is initiated
    HbA1c is ordered -> result is waited ( has timeout at 7 months ) -> result received -> workflow terminates, and new serial HbA1c workflow is initiated

    If result waiting times out,
    1. alert is sent to user, and workflow is cancelled ( eg. patient deceased or left the practice )
    2. Or email reminder send to patient
    3. Or user increases timeout
    If result is abnormal
    1. Alert is sent to user
    All the decision making is made by the decider process which could be running on any CPU, and worker processes likewise. But they need a way to interrogate the Synapse database
    Decider, and workers can ask for input from users

    So, you could have potentially 1000s of workers and workflows running to automate the practice.
    What happens if the CPU running a worker, or decider crashes? Nothing. Workflows are stateless and can be restarted at any time.
  4. Graham

    Graham Developer Staff Member

    After working on this for a couple of days I have made some progress and can now call the Amazon SWF api.
    Now to see if I can get anything else working ....
  5. Graham

    Graham Developer Staff Member

    Can start a workflow, schedule a task, complete the task and then close the workflow down.
    You need to be signed up to Amazon SWF to use this.
    Note that tasks can be done by any software or person that can interact with the Amazon SWF api.
    So you could have a task like review an abnormal result and you could do that on your smart phone ...
  6. Jason

    Jason Developer / Handyman Staff Member

    Sounds cool :)
    I'd like to be able to do this from a Synapse popup.
    .... as fast as possible.
    Control + t (New task on this patient).
    order bone density for this patient. Indication: osteoporosis.
    [enter] (popup automatically closes).
  7. Graham

    Graham Developer Staff Member

    So, have to make some decisions on how this works.

    Order-future-investigation workflow
    Date for when investigation has to be ordered ( can be years in the future though workflows only last 1 year, can just create a child workflow for the next year)
    Person for whom the test is being ordered
    Person who has to order the test ie. complete the task
    Another task to notify patient
    Another task to check for when test is done somehow ...
    Close workflow.
  8. Jason

    Jason Developer / Handyman Staff Member

    Weird time restriction.
    Wonder why something like that would be in it.
  9. Graham

    Graham Developer Staff Member

    I would guess Amazon need to put a limit otherwise just increases their computational needs
  10. Graham

    Graham Developer Staff Member

    Beginning to think this is just for office tasks .. and keep ticklers separate.
    Can now schedule a workflow but working this out on how to effectively integrate is proving difficult.
  11. Graham

    Graham Developer Staff Member

    Simple Workflow or Task Engine

    This is for passing tasks to the secretary/receptionist or whoever. It is not for ticklers.
    So, a task might be to make an appt for someone, contact them etc.

    1. You need to sign up to Amazon Simple Workflow ( http://aws.amazon.com/swf/ ) and we are hoping to stay within the free level
    2. Make sure that your keys are saved in Settings/User/Backup S3 (AWS keys ) which are the same keys used for backups
    3. In the SWF console ( https://console.aws.amazon.com/swf/home ) create a domain named "867530903" used for all the workflows. We can change this later on, but it is currently hard coded into Synapse
    4. Click on Workflow types, select 867530903 from the Domain dropdown, and register a new workflow type named "BookOurApptsWorkflow" version 1.0
    5. Use these values

    6. Task List: mainTaskList
      Execution Start To Close Timeout: 7 days
      Task Start To Close Timeout: 10 minutes
      Child Policy: TERMINATE
    1. Register a new activity type named "bookOurAppt" version 1.0
    2. Task List: mainTaskList
      Task Schedule To Start Timeout: 5 minutes
      Task Start To Close Timeout: 10 minutes
    3. (page 2 items)
    4. Task Schedule To Close Timeout: 7 days
    5. Task Heartbeat Timeout: Not Specified
    1. Download the decider.exe from http://synapsebeta.s3.amazonaws.com/decider.exe and run it once. It will produce an error message (just press enter) and will create a template config file (called: swf-config-skeleton.r). Open this in a text editor and save it as swf-config.r (make sure it ends in .r not .r.txt) This program will run 24/7.
    2. Update Synapse to 218 B93 which has the task management
    Running the Synapse Task Manager
    1. In Settings/Lists/SWF, click on "Get Temporary Credentials" ( might need to do that twice ) so that the keys appear. These keys can last 24 hours or less depending on what master keys you used
    2. Click on "list active workflows" to ensure that your keys work
    3. Click on in the functions list, the "Tasks, Manage" entry
    4. Click on "Office Task" for a non-patient entry
    5. Enter the task in the "Data" line, and then "Start Workflow"
    6. Close the task manager
    7. To see the active workflows, go to Settings/list/swf and click on "list active workflows" You can click on anyone of them, and then the task history appears.
    To perform the task, go to Settings/list/swf, and click on "Work a task". Once you have the task up, you MUST either cancel, complete or postpone. If it's a patient task, you can't complete until the patient is selected​

    The workflow definition above lasts a week. After that it times out and is cancelled. There is no way in Synapse to track timed out tasks so you'll need the Amazon SWF console in the meantime.

    To bring up the task manager in a consult, with the cursor on some text, click Control-T to bring up the task manager, and the underlying text is transferred to the task screen.

    Why is this so complex? Because you can have unlimited Synapse clients working on tasks, and you can write your own client for use on a phone, web page etc.
    Jason likes this.
  12. Graham

    Graham Developer Staff Member

    Although the definition for a task above can only last 10 mins, the tasks created by Synapse will last 7 days before timing out. If they timeout I don't know what happens as I haven't been there yet!!

    Let's see how this works before I make it more configurable.
  13. Graham

    Graham Developer Staff Member

    BTW, currently this runs independently of the Synapse database.
    Once we have some experience we can figure out what we need to capture as opposed to leaving it all on Amazon.
  14. Jason

    Jason Developer / Handyman Staff Member

    I was demoing a great Office Task (TODO app).
    https://www.producteev.com/

    More here
  15. Graham

    Graham Developer Staff Member

    Can now postpone tasks so that they don't appear for upto 6 days. No point going beyond that as the workflow only lasts 7 days.
  16. Jason

    Jason Developer / Handyman Staff Member

    I saw this available via control + t.

    Manage.Tasks.synapse.jpg

    Are you still using it ?
  17. Graham

    Graham Developer Staff Member

    No, I'm not. Can't recall why though.
  18. Jason

    Jason Developer / Handyman Staff Member

    What about an alternative ?

Share This Page