Example #1
0
    def get_steps(self, patient=None, episode=None, user=None):
        all_steps = []
        for step in self.steps:
            if inspect.isclass(step) and issubclass(step, models.Model):
                if step._is_singleton:
                    all_steps.append(Step(model=step))
                else:
                    all_steps.append(Step(model=step, multiple=True))
            else:
                all_steps.append(step)

        return all_steps
Example #2
0
 def test_to_dict_model_passed_in(self):
     step_dict = Step(model=test_models.Colour).to_dict()
     self.assertEqual(
         step_dict["display_name"],
         "Colour",
     )
     self.assertEqual(step_dict["icon"], "fa fa-comments")
     self.assertEqual(step_dict["api_name"], "colour")
     self.assertEqual(step_dict["model_api_name"], "colour")
Example #3
0
class DrugPathway(PagePathway):
    display_name = "Induction Drugs"
    slug = "induction_drugs"
    steps = (Step(
        template="pathways/induction_drugs.html",
        display_name="blah",
        icon="fa fa icon",
        step_controller="InductionDrugController",
    ), )
Example #4
0
class InfusionPathway(PagePathway):
    display_name = "Infusion Pathway"
    slug = "infusion_pathway"
    steps = (Step(
        template="pathways/new_infusions.html",
        display_name="New Infusions",
        step_controller="NewInfusionsController",
        model=models.Infusion,
    ), )
Example #5
0
class AnaestheticDetailsPathway(PagePathway):
    display_name = "Anaesthetic details"
    slug = "details"
    template = "pathways/anaesthetic_details.html"
    steps = [
        Step(
            model=models.OperationDetails,
            base_template="pathways/preop_step_base_template.html",
        )
    ]
Example #6
0
class PreOpPathway(PagePathway):
    display_name = "Pre Op"
    slug = "preop"
    template = "pathways/preop.html"

    steps = [
        Step(
            model=models.PatientPhysicalAttributes,
            base_template="pathways/preop_step_base_template.html",
        ),
        Step(
            model=models.AnaestheticAssesment,
            base_template="pathways/preop_step_base_template.html",
        ),
        Step(
            model=models.DrugHistory,
            base_template="pathways/preop_step_base_template.html",
        ),
        Step(
            model=models.AirwayAssessment,
            base_template="pathways/preop_step_base_template.html",
        ),
        Step(model=models.Bloods,
             base_template="pathways/preop_step_base_template.html"),
        Step(
            model=models.AnaestheticPlan,
            base_template="pathways/preop_step_base_template.html",
        ),
    ]
Example #7
0
 def test_arguments_passed_in_overide_model(self):
     step_dict = Step(model=test_models.Colour,
                      display_name="Some Step",
                      icon="fa fa-some-step",
                      api_name="some_step",
                      model_api_name="some_model_api_step",
                      template="some_template.html").to_dict()
     self.assertEqual(
         step_dict["display_name"],
         "Some Step",
     )
     self.assertEqual(step_dict["icon"], "fa fa-some-step")
     self.assertEqual(step_dict["api_name"], "some_step")
     self.assertEqual(step_dict["model_api_name"], "some_model_api_step")
Example #8
0
 def test_to_dict_args_passed_in(self):
     step_dict = Step(display_name="Some Step",
                      icon="fa fa-some-step",
                      api_name="some_step",
                      model_api_name="some_model_api_step",
                      template="some_template.html",
                      step_controller="somewhere").to_dict()
     self.assertEqual(
         step_dict["display_name"],
         "Some Step",
     )
     self.assertEqual(step_dict["icon"], "fa fa-some-step")
     self.assertEqual(step_dict["api_name"], "some_step")
     self.assertEqual(step_dict["model_api_name"], "some_model_api_step")
     self.assertEqual(step_dict["step_controller"], "somewhere")
Example #9
0
class ReferralPathway(PagePathway):
    display_name = "Referral"
    slug = "referral_form"
    template = "pathways/odonto_pathway_base.html"

    steps = (
        Step(
            display_name='Patient Details',
            template="pathways/steps/patient_detail.html",
            base_template="pathways/step_wrappers/odonto_page_wrapper.html",
            multiple=False
        ),
        Step(
            model=models.CarerDetails,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
        Step(
            model=models.GPDetails,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
        Step(
            model=models.ReferralReason,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
        Step(
            model=models.Xray,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
        Step(
            model=models.Disability,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
        Step(
            model=models.MedicalIssues,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
        Step(
            model=models.MentalHealthIssues,
            base_template="pathways/step_wrappers/odonto_page_wrapper.html"),
    )

    def save(self, data, user, *args, **kwargs):
        data[models.Demographics.get_api_name()][0]["hospital_number"] = omodels.Patient.objects.count()
        patient, episode = super(ReferralPathway, self).save(data, user, *args, **kwargs)
        episode.active = True
        episode.save()
        referral = episode.referraldetails_set.first()
        referral.when = datetime.date.today()
        referral.who = user
        referral.save()
        return patient, episode
Example #10
0
class NewReferral(WizardPathway):
    display_name = 'New referral'
    icon = 'fa-plus'
    slug = 'new_referral'
    finish_button_text = "Create new referral"
    finish_button_icon = None
    template = "pathway/base/rbhl_page_pathway_base.html"
    steps = [
        FindPatientStep(
            base_template="pathway/steps/step_base_without_display_name.html"),
        Step(display_name="Referral details",
             template="pathway/new_referral.html",
             base_template="pathway/steps/step_base_without_display_name.html")
    ]

    def save(self, *args, **kwargs):
        patient, episode = super().save(*args, **kwargs)
        clinical_log = episode.cliniclog_set.get()
        clinical_log.active = True
        clinical_log.save()
        return patient, episode
Example #11
0
class PairMonitor(PagePathway):
    display_name = "Pair with monitor"
    modal_template = 'pathways/modal_without_patient_header.html'
    slug = "pair_monitor"
    finish_button_text = 'Pair'
    finish_button_icon = ''
    steps = (
        Step(
            model=models.Pairing,
            step_controller="PairMonitorController",
            multiple=False
        ),
    )

    @transaction.atomic
    def save(self, data, user=None, patient=None, episode=None):
        monitor_id = data.pop(
            models.Pairing.get_api_name()
        )[0]["monitor_id"]

        models.Pairing.subscribe(patient.id, monitor_id)
        return patient, episode
Example #12
0
class UnPairMonitor(PagePathway):
    display_name = "Disconnect from monitor"
    slug = "unpair_monitor"
    modal_template = "pathways/modal_only_cancel.html"
    finish_button_text = "Disconnect"
    finish_button_icon = "fa fa-sign-out"

    steps = (
        Step(
            display_name="UnpairMonitor",
            template="pathways/unpair.html",
            step_controller="UnPairMonitorController"
        ),
    )

    @transaction.atomic
    def save(self, data, user=None, patient=None, episode=None):
        pairings = models.Pairing.objects.filter(
            patient=patient,
            stop=None
        )
        for pairing in pairings:
            pairing.unsubscribe()
        return patient, episode
Example #13
0
 def test_no_display_name(self):
     with self.assertRaises(exceptions.InitializationError) as er:
         Step(template="some_template.html")
     self.assertEqual(str(er.exception),
                      "A step needs either a display_name or a model")
Example #14
0
 def test_step_cant_be_multiple_without_a_model(self):
     with self.assertRaises(exceptions.InitializationError):
         Step(multiple=True)
Example #15
0
 def test_no_template(self):
     with self.assertRaises(exceptions.InitializationError) as er:
         Step(display_name="no template")
     self.assertEqual(str(er.exception),
                      "A step needs either a template or a model")
Example #16
0
 def test_model_has_no_form_template(self):
     mock_model = MagicMock(name='Model')
     mock_model.get_form_template.return_value = None
     step = Step(model=mock_model)
     with self.assertRaises(exceptions.MissingTemplateError):
         step.get_template()
Example #17
0
 def test_model_has_no_form_template(self):
     mock_model = MagicMock(name='Model')
     mock_model.get_form_template.return_value = None
     step = Step(model=mock_model)
     with self.assertRaises(exceptions.MissingTemplateError):
         step.get_template()