Exemple #1
0
    def save(self, data, user=None, patient=None, episode=None):
        if patient and not episode:
            episode = patient.create_episode()

        for step in self.get_steps():
            step.pre_save(
                data, user, patient=patient, episode=episode
            )

        # if there is an episode, remove unchanged subrecords
        if patient:
            data = self.remove_unchanged_subrecords(episode, data, user)
        else:
            # We can't import these at module load because we're imported by
            # opal.core.pathways.__init__
            from opal.models import Patient

            patient = Patient()

        patient.bulk_update(data, user, episode=episode)

        if not episode and patient.episode_set.count() == 1:
            episode = patient.episode_set.first()

        return patient, episode
Exemple #2
0
 def setUp(self):
     super(AbstractPatientTestCase, self).setUp()
     self.patient = Patient()
     self.patient.save()
     self.patient.demographics_set.update(
         consistency_token="12345678",
         first_name="John",
         surname="Smith",
         hospital_number="AA1111",
         date_of_birth="1972-06-20",
     )
     self.demographics = self.patient.demographics_set.get()
Exemple #3
0
class AbstractPatientTestCase(TestCase):
    def setUp(self):
        super(AbstractPatientTestCase, self).setUp()
        self.patient = Patient()
        self.patient.save()
        self.patient.demographics_set.update(
            consistency_token="12345678",
            first_name="John",
            surname="Smith",
            hospital_number="AA1111",
            date_of_birth="1972-06-20",
        )
        self.demographics = self.patient.demographics_set.get()
    def save(self, data, user):
        patient = self.patient
        episode = self.episode

        for step in self.get_steps():
            step.pre_save(data, user)

        if not patient:
            if "demographics" in data:
                hospital_number = data["demographics"][0]["hospital_number"]
                patient_query = Patient.objects.filter(demographics__hospital_number=hospital_number)
                patient = patient_query.first()

            if not patient:
                patient = Patient()

        patient.bulk_update(data, user, episode=episode)
        return patient
Exemple #5
0
    def save(self, data, user):
        patient = self.patient
        episode = self.episode

        for step in self.get_steps():
            step.pre_save(data, user)

        if not patient:
            if "demographics" in data:
                hospital_number = data["demographics"][0]["hospital_number"]
                patient_query = Patient.objects.filter(
                    demographics__hospital_number=hospital_number)
                patient = patient_query.first()

            if not patient:
                patient = Patient()

        patient.bulk_update(data, user, episode=episode)
        return patient
Exemple #6
0
    def save(self, data, user=None, patient=None, episode=None):
        if patient and not episode:
            episode = patient.create_episode()

        for step in self.get_steps():
            step.pre_save(data, user, patient=patient, episode=episode)

        # if there is an episode, remove unchanged subrecords
        if patient:
            data = self.remove_unchanged_subrecords(episode, data, user)
        else:
            patient = Patient()

        patient.bulk_update(data, user, episode=episode)

        if not episode and patient.episode_set.count() == 1:
            episode = patient.episode_set.first()

        return patient, episode
Exemple #7
0
    def save(self, data, user=None, patient=None, episode=None):
        if patient and not episode:
            episode = patient.create_episode()

        for step in self.get_steps():
            step.pre_save(
                data, user, patient=patient, episode=episode
            )

        # if there is an episode, remove unchanged subrecords
        if patient:
            data = self.remove_unchanged_subrecords(episode, data, user)
        else:
            patient = Patient()

        patient.bulk_update(data, user, episode=episode)

        if not episode and patient.episode_set.count() == 1:
            episode = patient.episode_set.first()

        return patient, episode