Пример #1
0
 def dispatch(self, request, *args, **kwargs):
     self.name = kwargs.get('name', 'pathway')
     self.pathway = Pathway.get(self.name)()
     self.is_modal = request.GET.get("is_modal", False)
     return super(PathwayTemplateView, self).dispatch(
         request, *args, **kwargs
     )
Пример #2
0
    def create(self, request, **kwargs):
        # actually saves the pathway
        pathway = Pathway.get(self.name)()
        data = request.data

        before_patient = None
        before_episode = None

        if self.episode_id:
            before_episode = Episode.objects.get(id=self.episode_id)

        if self.patient_id:
            before_patient = Patient.objects.get(id=self.patient_id)
        patient, episode = pathway.save(data,
                                        user=request.user,
                                        patient=before_patient,
                                        episode=before_episode)
        redirect = pathway.redirect_url(user=request.user,
                                        patient=patient,
                                        episode=episode)

        episode_id = None

        if episode:
            episode_id = episode.id

        return json_response({
            "episode_id": episode_id,
            "patient_id": patient.id,
            "redirect_url": redirect
        })
Пример #3
0
    def create(self, request, **kwargs):
        # actually saves the pathway
        pathway = Pathway.get(self.name)()
        data = request.data

        before_patient = None
        before_episode = None

        if self.episode_id:
            before_episode = Episode.objects.get(id=self.episode_id)

        if self.patient_id:
            before_patient = Patient.objects.get(id=self.patient_id)
        patient, episode = pathway.save(
            data,
            user=request.user,
            patient=before_patient,
            episode=before_episode
        )
        redirect = pathway.redirect_url(
            user=request.user, patient=patient, episode=episode
        )

        episode_id = None

        if episode:
            episode_id = episode.id

        return json_response({
            "episode_id": episode_id,
            "patient_id": patient.id,
            "redirect_url": redirect
        })
Пример #4
0
    def retrieve(self, *args, **kwargs):
        # gets the pathways
        pathway_cls = Pathway.get(self.name)
        episode = None
        patient = None

        if self.episode_id:
            episode = Episode.objects.get(id=self.episode_id)

        if self.patient_id:
            patient = Patient.objects.get(id=self.patient_id)
        pathway = pathway_cls()
        is_modal = self.request.GET.get("is_modal", False) == "True"
        serialised = json_response(
            pathway.to_dict(is_modal,
                            user=self.request.user,
                            patient=patient,
                            episode=episode))
        return serialised
Пример #5
0
    def retrieve(self, *args, **kwargs):
        # gets the pathways
        pathway_cls = Pathway.get(self.name)
        episode = None
        patient = None

        if self.episode_id:
            episode = Episode.objects.get(id=self.episode_id)

        if self.patient_id:
            patient = Patient.objects.get(id=self.patient_id)
        pathway = pathway_cls()
        is_modal = self.request.GET.get("is_modal", False) == "True"
        serialised = json_response(
            pathway.to_dict(
                is_modal,
                user=self.request.user,
                patient=patient,
                episode=episode
            )

        )
        return serialised
Пример #6
0
 def test_get_by_hyphenated_slug(self):
     self.assertEqual(PathwayExample, Pathway.get('dog-owner'))
Пример #7
0
 def test_get_by_hyphenated_slug(self):
     self.assertEqual(PathwayExample, Pathway.get('dog-owner'))
Пример #8
0
 def dispatch(self, request, *args, **kwargs):
     self.name = kwargs.get('name', 'pathway')
     self.pathway = Pathway.get(self.name)()
     self.is_modal = request.GET.get("is_modal", False)
     return super(PathwayTemplateView,
                  self).dispatch(request, *args, **kwargs)