$scope.showPage = function()

in clns-eTarget/src/main/webapp/js/app.js [830:1072]


  $scope.showPage = function(page, personID) {
    // Check if they are leaving the page without saving the meeting outcome
    $anchorScroll();
    if($scope.meeting.new) {
      var leavePage = confirm('You have an unsaved meeting outcome. Are you sure you want to leave the page?');
      if(leavePage) {
        alert('The latest meeting outcome will not be saved.')
        $scope.cancelMeetingOutcome();
      } else {
        return false;
      }
    }

    // Clear the significantMutations, ready for the next patient
    $scope.currentPatient.significantMutations = {
      tumourNGS: [],
      latestTumourNGS: [],
      ctDNA: [],
      fmTumour: {
    	  copyNumberAlteration: [],
    	  rearrangement: [],
    	  shortVariant: []
      },
      fmBlood: {
    	  copyNumberAlteration: [],
    	  rearrangement: [],
    	  shortVariant: []
      },
      latestCtDNA: [],
      latestFmTumour: {
    	  copyNumberAlteration: [],
    	  rearrangement: [],
    	  shortVariant: []
      },
      latestFmBlood: {
    	  copyNumberAlteration: [],
    	  rearrangement: [],
    	  shortVariant: []
      },
      summery:[],
      meetingOutcomeSummaryCNA: {},
      meetingOutcomeSummaryR: {},
      meetingOutcomeSummarySV: {}
    };
    
    

    ////console.log(page, personID);
    $scope.currentPatient.person_id = personID;

    if(page == 'list') {
      $scope.page = {
        "list": true,
        "detail": false,
        "status": false,
        "genepanel": false,
        "admin": false,
        "search": false
      };
      $scope.cancelMeetingOutcome();
      $scope.getAllPatients();

    } else if(page == 'search'){
      $scope.page = {
        "list": false,
        "detail": false,
        "status": false,
        "genepanel": false,
        "admin": false,
        "search": true
      };
      $scope.cancelMeetingOutcome();
      $scope.getAllPatients();
    
    } else if(page == 'genepanel') {
        $scope.page = {
          "list": false,
          "detail": false,
          "status": false,
          "genepanel": true,
          "admin": false,
          "search": false
        };
        $scope.getAllGenes();
        $scope.getAllGenesPanel();
    } else if(page == 'admin') {
    	$scope.page = {
	        "list": false,
	        "detail": false,
	        "status": false,
	        "genepanel": false,
	        "admin": true,
	        "search": false
	    };

      // Fetch data
      $http({
        method: 'GET',
        url: 'api/data.jsp?endpoint=listadminusers&random='+Math.random()
      }).then(function successCallback(response) {
        $scope.admin.users = response.data;

      }, function errorCallback(response) {
        console.log('Error fetching list of admin users: '+response.status);
      });

    } else if(page == 'status') {
      $scope.page = {
        "list": false,
        "detail": false,
        "status": true,
        "admin": false,
        "search": false
      };

      // Fetch the system status data every 1 minute
      //setInterval(function() {
        $http({
          method: 'GET',
          url: 'api/data.jsp?endpoint=systemstatus'
        }).then(function successCallback(response) {
          //console.log('Fetched system status.');
          //console.log(response.data);

          $scope.system.status = response.data;

        }, function errorCallback(response) {
          //console.log('Error fetching system status: '+response.status);
        });
      //}, 30000);

    } else if(page == 'detail') {
//    	console.log('load page detail ' + personID);
    	$scope.timestamp = Date.now();
      // Get the patient details
      $http({
        method: 'GET',
        url: 'api/data.jsp?endpoint=patient&personID='+personID
      }).then(function successCallback(response) {
        //console.log('Fetched patient details.');
        ////console.log(response.data);

        // Update the model
        $scope.currentPatient.id = response.data.targetID;
        $scope.currentPatient.disease = response.data.conditionName;
        $scope.currentPatient.age = response.data.personAge;
        $scope.currentPatient.gender = response.data.genderName;
        $scope.currentPatient.site = response.data.site;
        $scope.currentPatient.dateConsent = response.data.consentDate;
        $scope.currentPatient.dateDiagnosis = response.data.conditionStartDate;
        //$scope.currentPatient.specimenDate1 = response.data.specimenDate1;
        $scope.currentPatient.editLockMessage = response.data.editLockMessage;
        $scope.currentPatient.trialFile = response.data.trialFile;
        $scope.currentPatient.qciFiles = response.data.qciFiles;
        $scope.currentPatient.rnaFiles = response.data.rnaFiles;

        $scope.print.targetID = response.data.targetID;
        $scope.print.consultant = response.data.consultant;
        

        // Change the view
        $scope.page = {
          "list": false,
          "detail": true,
          "status": false,
          "admin": false,
          "search": false
        };
        $scope.showQCIBaseline('');
        
      }, function errorCallback(response) {
//        console.log('Error fetching patient details: '+response.status);
      });

      // Get the treatment history / general information
      $scope.loadGeneralInfo(personID);
      
      // Get the tumour NGS details
      $scope.loadTumour(personID);

      // Get the NGS subset
      $scope.loadNGSSubset(personID);

      // Get the NGS exploratory subset
      $scope.loadNGSExploartory(personID);

      // Get the Foundation Medicine Tumour data 
      $scope.loadFMTumour(personID);
      
      // Get the Foundation Medicine Blood data
      $scope.loadFMBlood(personID);
      
      // Get IHC Report 
      $scope.loadIHCReport(personID);
      
      // Get configured genomics data
      $scope.loadGenomicsData(personID);
      
      // Patient PDX/CDX
      if($scope.pdxcdx=='true'){
	      $http({
	        method: 'GET',
	        url: 'api/data.jsp?endpoint=pdxcdx&personID='+personID,
	      }).then(function successCallback(response) {
	        $scope.pdxcdx = response.data;
	
	      }, function errorCallback(response) {
	//        console.log('Error fetching current user: '+response.status);
	      });
      }
      // Patient meeting outcome
      $http({
        method: 'GET',
        url: 'api/data.jsp?endpoint=getmeetingoutcome&personID='+personID
      }).then(function successCallback(response) {
        // Update the meeting outcome table
    	$scope.meeting.edits=0;
        $scope.meeting.outcome = response.data;

        $scope.getLatestMutationSelections();
        $scope.getLatestVersionMutationSelections();

      }, function errorCallback(response) {
//        console.log('Error fetching meeting outcome: '+response.status);
      });
      
      if(typeof $scope.genePanles=='undefined'){
    	// get gene penels
          $http({
            method: 'GET',
            url: 'rest/GenePanels'
          }).then(function successCallback(response) {
            $scope.genePanels = response.data;
          }, function errorCallback(response) {
//            console.log('Error fetching genePanels: '+response.status);
          });
      }
    }
    $scope.showTumourBaseline(1);
    $scope.showFMBloodBaseline(1);
    $scope.showFMTumourBaseline(1);
    $scope.showIHCBaseline(1);
  };