<commit_before>/**
 * @tag controllers, home
 */
jQuery.Controller.extend('smart_ui_server.Controllers.Record',
/* @Static */
{

},
/* @Prototype */
{	
    	
   init: function(params) {
	this.RECENT_RECORDS = {};
	this.current_patient_label = $('#current_patient');
	this.current_patient_label.text("");
},
    
    'patient_record.selected subscribe': function(topic, record_id) {
    	this.RECORD_ID = record_id;		  
	    this._load_record();
	}, 

  after_record_obtained: function(record) {

	  RecordController.CURRENT_RECORD = record;
 	  this.current_patient_label.html("<a id='prev_pt' href='#prev_pt_req'>previous patient &lt;</a>"+
					  "<span id='pt_label'>"+record.label+"</span>"+
					  "<a id='next_pt' href='#next_pt_req'>&gt; next patient</a>");

	  OpenAjax.hub.publish("pha.exit_app_context");
	  SMART.context_changed();

	  // If there was an app open on the old record, open it automatically
	  // on the new one.
	  if (RecordController.APP_ID) {
	      var app = $.grep(PHAController.phas, function(pha) {return (pha.id === RecordController.APP_ID);})[0];
	      OpenAjax.hub.publish("pha.launch", app);
	  }

  },
  
  _load_record: function() {
      var record_id = this.RECORD_ID;
	  // if the 'new' selection ain't new, we're done here.
	  if ( this.CURRENT_RECORD && record_id == this.CURRENT_RECORD.record_id ) {
		  return;
	  }
	  
	  var already_obtained = RecordController.RECENT_RECORDS[record_id];
	  
	  if (already_obtained)
		  this.after_record_obtained(already_obtained);
      else
    	  Record.get(record_id,this.callback(after_record_obtained));
    },


'history.prev_pt_req.index subscribe': function(topic) {
    location.hash = "prev_pt";
    var prev = null;
    var answer = null;
    $.each(RecordController.records, function(k,v) {
	k = v.record_id;
	if (prev !== null && k == RecordController.CURRENT_RECORD.record_id)
	    {
	    answer = prev;
	    return false;
	    }
	prev = k;
    });

    var r = this.RECENT_RECORDS[(answer || prev)];
    this.after_record_obtained(r);
    PatientListController.patient_selected(r.label);
},

'history.next_pt_req.index subscribe': function(topic) {
    location.hash = "next_pt";

    var first = null;
    var answer = null;

    $.each(RecordController.records, function(k,v) {
	    k = v.record_id;
	    if (answer === "next")
	    {
		answer = k;
		return false;
	    }
	    if (k == RecordController.CURRENT_RECORD.record_id)
	    {
		answer = "next";
	    }

	if (first === null)
	    first = k;

    });

    console.log("consier next " + answer + "," + first);
    var r = this.RECENT_RECORDS[(answer || first)];
    this.after_record_obtained(r);
    PatientListController.patient_selected(r.label);
}

 
});<commit_msg>strip logging messages<commit_after>/**
 * @tag controllers, home
 */
jQuery.Controller.extend('smart_ui_server.Controllers.Record',
/* @Static */
{

},
/* @Prototype */
{	
    	
   init: function(params) {
	this.RECENT_RECORDS = {};
	this.current_patient_label = $('#current_patient');
	this.current_patient_label.text("");
},
    
    'patient_record.selected subscribe': function(topic, record_id) {
    	this.RECORD_ID = record_id;		  
	    this._load_record();
	}, 

  after_record_obtained: function(record) {

	  RecordController.CURRENT_RECORD = record;
 	  this.current_patient_label.html("<a id='prev_pt' href='#prev_pt_req'>previous patient &lt;</a>"+
					  "<span id='pt_label'>"+record.label+"</span>"+
					  "<a id='next_pt' href='#next_pt_req'>&gt; next patient</a>");

	  OpenAjax.hub.publish("pha.exit_app_context");
	  SMART.context_changed();

	  // If there was an app open on the old record, open it automatically
	  // on the new one.
	  if (RecordController.APP_ID) {
	      var app = $.grep(PHAController.phas, function(pha) {return (pha.id === RecordController.APP_ID);})[0];
	      OpenAjax.hub.publish("pha.launch", app);
	  }

  },
  
  _load_record: function() {
      var record_id = this.RECORD_ID;
	  // if the 'new' selection ain't new, we're done here.
	  if ( this.CURRENT_RECORD && record_id == this.CURRENT_RECORD.record_id ) {
		  return;
	  }
	  
	  var already_obtained = RecordController.RECENT_RECORDS[record_id];
	  
	  if (already_obtained)
		  this.after_record_obtained(already_obtained);
      else
    	  Record.get(record_id,this.callback(after_record_obtained));
    },


'history.prev_pt_req.index subscribe': function(topic) {
    location.hash = "prev_pt";
    var prev = null;
    var answer = null;
    $.each(RecordController.records, function(k,v) {
	k = v.record_id;
	if (prev !== null && k == RecordController.CURRENT_RECORD.record_id)
	    {
	    answer = prev;
	    return false;
	    }
	prev = k;
    });

    var r = this.RECENT_RECORDS[(answer || prev)];
    this.after_record_obtained(r);
    PatientListController.patient_selected(r.label);
},

'history.next_pt_req.index subscribe': function(topic) {
    location.hash = "next_pt";

    var first = null;
    var answer = null;

    $.each(RecordController.records, function(k,v) {
	    k = v.record_id;
	    if (answer === "next")
	    {
		answer = k;
		return false;
	    }
	    if (k == RecordController.CURRENT_RECORD.record_id)
	    {
		answer = "next";
	    }

	if (first === null)
	    first = k;

    });

    var r = this.RECENT_RECORDS[(answer || first)];
    this.after_record_obtained(r);
    PatientListController.patient_selected(r.label);
}

 
});
{'fraction_non_alphanumeric': 0.14898336414048058, 'fraction_numerical': 0.0003696857670979667, 'mean_word_length': 3.2978554408260523, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5009753', 'n_tokens_mistral': 2004, 'n_tokens_neox': 1847, 'n_words': 332}