Skip to content

steps should only save their model by default #1573

@fredkingham

Description

@fredkingham

At the moment pathways save the world which has lead to several surprising events.

pseudo code resolution looks like the below.

class Step:
    def pre_save(self, data, raw_data, user, patient, episode):
        return data[self.model.get_api_name()] = self.get_model_data(raw_data)

class Pathway:

    def pre_save(self, data, raw_data, user, patient, episode): pass

    def save(self, raw_data, user, patient, episode):
        data = {}
        for step in self.get_steps():
             data = step.pre_save(data, raw_data, user, patient, episode)

        data = self..pre_save(data, raw_data, user, patient, episode)
        patient.bulk_update(data, user, episode)

If a step does not have a model it should blow up.

We can probably run the has Pathway.remove_unchanged_subrecords function and compare the new to_save dictionary with the old one and make sure that we were not relying on some inference logic and explode if so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions