<commit_before>(function () {

    angular
        .module('app')
        .controller('PatientController', [
            '$scope', '$stateParams', 'Restangular', '$mdToast', '$translate', 'AuthService',
            PatientController
        ]);

    function PatientController($scope, $stateParams, Restangular, $mdToast, $translate, AuthService) {
        var vm = this;
        var user = AuthService.getUser();

        if (user.role == 'patient') {
            $scope.user = user.person;
            $scope.patient_email = user.email;
        } else {
            Restangular.one('patients', $stateParams.userId).get()
                .then(function (response) {
                    $scope.user = response;
                    return Restangular.one('users', response.user_id).get();
                })
                .then(function (user) {
                    $scope.patient_email = user.email;
                });
        }


        $scope.update = function () {
            Restangular.one('patients', $stateParams.userId).get()
                .then(function (doctor) {
                    for (var property in patient) {
                        if ($scope.patient.hasOwnProperty(property)) {
                            patient[property] = $scope.patient[property];
                        }
                    }
                    return patient;
                })
                .then(function (editedPatient) {
                    return editedPatient.put();
                })
                .then(function (response) {
                        AuthService.updateUser();
                        $scope.showSimpleToast($translate.instant('DONE'));
                    },<commit_msg>redirect to 404 if patient not found<commit_after>(function () {

    angular
        .module('app')
        .controller('PatientController', [
            '$scope', '$stateParams', 'Restangular', '$mdToast', '$translate', 'AuthService', '$state',
            PatientController
        ]);

    function PatientController($scope, $stateParams, Restangular, $mdToast, $translate, AuthService, $state) {
        var vm = this;
        var user = AuthService.getUser();

        if (user.role == 'patient') {
            $scope.user = user.person;
            $scope.patient_email = user.email;
        } else {
            Restangular.one('patients', $stateParams.userId).get()
                .then(function (response) {
                        $scope.user = response;
                        return Restangular.one('users', response.user_id).get();
                    },
                    function (response) {
                        if(response.status === 404){
                            $state.go('404')
                        }
                        if(response.status === 403){
                            $state.go('403')
                        }
                    })
                .then(function (user) {
                    $scope.patient_email = user.email;
                });
        }


        $scope.update = function () {
            Restangular.one('patients', $stateParams.userId).get()
                .then(function (doctor) {
                    for (var property in patient) {
                        if ($scope.patient.hasOwnProperty(property)) {
                            patient[property] = $scope.patient[property];
                        }
                    }
                    return patient;
                })
                .then(function (editedPatient) {
                    return editedPatient.put();
                })
                .then(function (response) {
                        AuthService.updateUser();
                        $scope.showSimpleToast($translate.instant('DONE'));
                    },
{'fraction_non_alphanumeric': 0.12075371549893843, 'fraction_numerical': 0.003980891719745223, 'mean_word_length': 1.2528392109982067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2752912', 'n_tokens_mistral': 928, 'n_tokens_neox': 842, 'n_words': 156}