Workflow - Auto relate record based on records status

I will do my best to explain this. I have two modules that are many to many related. One of the modules is essentially the parent to the other. The parent module is to house census data (healthcare) for a given date. The child module is all the patients who were receiving care based on the census date. I built a workflow that will create a new census record each day. It works. What I can’t figure out is when the new parent census record is created by the workflow, how do I go about bringing over all the patient records for the new day via a workflow? I don’t need the records modified, just related to the new census record based on the status of their care (which is a dropdown field).

Create new census record for today ---------> find all patient records that show “in progress” and relate them to today’s census.

Any ideas are greatly appreciated!!

Should all records whose status is “in progress” at any time during a day be included in that day’s census?

I don’t think AOW_Workflow is capable of doing what you’re trying to achieve. Personally I’d probably build a custom Scheduler to check for all patients with the status “in progress” right after midnight. and then use an additional before_save logic hook to catch patients whose status changes to “in progress” later on during the day.

1 Like

thanks for your reply. The answer is yes, however, there are modules based on where the patient is during their course of treatment. Some are staying in the hospital. Some are going to a specific location for outpatient follow up care. About 6 different locations/types of healthcare being delivered. I will see what I can do based on what you suggested. Thanks again.

I’m not entirely sure I understood, but keep in mind that you can’t add any data to the relationship itself, and building three-way relationships isn’t standard functionality.

If all you need is knowledge of which patients are in care (one way or another) on a given day, all you need is a daily census record and patients’ relationship to that one.

If you however also wished to distinguish between the types of service (ie. outpatient, intensive care, general ward etc.), location, field of expertise etc. on a given census day you’d have to build a more complex relationship hierarchy. Still, you could build the hierarchy automatically using Schedulers and logic hooks.

Not strictly true. From Studio, you can’t, but you’ll find some posts out there explaining how to add “fields in relationships” through code. It’s an important feature sometimes. But I wouldn’t recommend it except for developers, it’s not simple.

1 Like

@pgr good point, I should have added “without custom code”. Probably a simpler and more extendable solution would still be to create a hierarchy of relationships.

1 Like