database.js
// when patient ID is changed, all visits must be updated
when patient ID is changed, all visits must be updated
when patient ID is changed all visits must be updated
function updateVisits(oldId, newId) {
  var results = visits.chain().find({'pid':oldId}).data();
  for(var i = 0; i < results.length; i++) {
    results[i].pid = newId;
  } 
  visits.update(results);
}
function updateVisits ( oldId , newId ) { var results = visits . chain ( ) . find ( { 'pid' : oldId } ) . data ( ) ; for ( var i = 0 ; i < results . length ; i ++ ) { results [ i ] . pid = newId ; } visits . update ( results ) ; }
when patient ID is changed, all visits must be updated
when patient ID is changed all visits must be updated