angularJS redirecting to the login page and not the specified url
<p>I have an app that searches for a patient and on being found redirects to the prescription page. When nothing is found the app is fine and returns a not found message but when we find a patient it redirects to the login page instead of the prescription page.</p>

<p>Here is the function code </p>

<pre><code>$http({

            method: 'POST',
            url: 'http://104.155.102.226:8033/patientsearch/',
            data: {
                 'national_id': $scope.national_id,
                 'insurance_company':$scope.insurance_company,
                 'member_number': $scope.member_number,
                 'dob':$scope.dob,
                 'phone': $scope.phone_number
            },
            headers: {
                'accept':'application/json',
                'Content-Type':'application/json'
            }

        }).success(function(data){
            if(Object.keys(data).length == 0){

              $scope.message = "No Patient with those credentials found in our databases";

            } else {
              $timeout(function(){ 
                 sessionStorage.setItem('memberData', JSON.stringify(data));
                 $location.path('/doctors/prescribe');
              },1);
              // sessionStorage.setItem('memberData', JSON.stringify(data));
              // $location.path('/doctors/prescribe');


            }


            //console.log(memberData);

        }).error(function(error){
          console.log(error)
        });
</code></pre>