function updateSampleAttributes(curr, prev, aspect) {
  modelUtils.removeExtraAttributes(curr, sampleFieldsArr);
  const now = new Date().toISOString();

  if (!curr.hasOwnProperty(sampFields.VALUE)) {
    /*
     * If no value is provided and this is a new sample, set value to empty
     * string, which will generate a status of "Invalid". If this is NOT a new
     * sample, treat it like a PATCH and keep the value from the "prev" version
     * of the sample.
     */
    if (prev && prev.hasOwnProperty(sampFields.VALUE)) {
      curr[sampFields.VALUE] = prev[sampFields.VALUE];
    } else {
      curr[sampFields.VALUE] = '';
    }
  }

  /* Just in case curr.value was undefined... */
  if (curr[sampFields.VALUE] === undefined) curr[sampFields.VALUE] = '';

  if (!prev) {
    /*
     * This is a brand new sample so calculate current status based on value,
     * set previous status to invalid, and set status changed at to now.
     */
    curr[sampFields.STATUS] =
      sampleUtils.computeStatus(aspect, curr[sampFields.VALUE]);
    curr[sampFields.PRVS_STATUS] = dbConstants.statuses.Invalid;
    curr[sampFields.STS_CHANGED_AT] = now;
  } else if (curr[sampFields.VALUE] === prev[sampFields.VALUE]) {
    /*
     * Value is same so no need to recalculate status. Just carry over the
     * status, previous status, and status changed at from the old sample.
     */
    curr[sampFields.STATUS] = prev[sampFields.STATUS];
    curr[sampFields.PRVS_STATUS] = prev[sampFields.PRVS_STATUS];
    curr[sampFields.STS_CHANGED_AT] = prev[sampFields.STS_CHANGED_AT];
  } else {
    /*
     * The value is different so we need to calculate the status.
     */
    curr[sampFields.STATUS] =
      sampleUtils.computeStatus(aspect, curr[sampFields.VALUE]);
    if (curr[sampFields.STATUS] === prev[sampFields.STATUS]) {
      /*
       * The status is the same so carry over the previous status and status
       * changed at from the old sample.
       */
      curr[sampFields.PRVS_STATUS] = prev[sampFields.PRVS_STATUS];
      curr[sampFields.STS_CHANGED_AT] = prev[sampFields.STS_CHANGED_AT];
    } else {
      /*
       * The status is different so assign previous status based on the old
       * sample's status, and set status changd at to now.
       */
      curr[sampFields.PRVS_STATUS] = prev[sampFields.STATUS];
      curr[sampFields.STS_CHANGED_AT] = now;
    }
  }

  let rlinks;

  // if related link is passed in query object
  if (curr[sampFields.RLINKS]) {
    rlinks = curr[sampFields.RLINKS];
  } else if (!prev) { // if we are creating new sample
    rlinks = []; // default value
  }

  if (rlinks) curr[sampFields.RLINKS] = JSON.stringify(rlinks);

  if (!prev) curr[sampFields.CREATED_AT] = now;
  curr[sampFields.UPD_AT] = now;
} // updateSampleAttributes
/**
 * Update the sample from the request body. Updates in place. Compares to the
 * previous state of the same sample, recalcuates status as needed.
 *
 * @param  {Object} qbObj - current sample (from request body)
 * @param  {Object} prev - previous sample
 * @param  {Object} aspect - aspect used to recalculate status
 */
Update the sample from the request body. Updates in place. Compares to the
previous state of the same sample, recalcuates status as needed.

@param  {Object} qbObj - current sample (from request body)
@param  {Object} prev - previous sample
@param  {Object} aspect - aspect used to recalculate status
Update the sample from the request body . Updates in place . Compares to the previous state of the same sample recalcuates status as needed . @param { Object } qbObj - current sample ( from request body ) @param { Object } prev - previous sample @param { Object } aspect - aspect used to recalculate status
function updateSampleAttributes(curr, prev, aspect) {
  modelUtils.removeExtraAttributes(curr, sampleFieldsArr);
  const now = new Date().toISOString();
  if (!curr.hasOwnProperty(sampFields.VALUE)) {
    if (prev && prev.hasOwnProperty(sampFields.VALUE)) {
      curr[sampFields.VALUE] = prev[sampFields.VALUE];
    } else {
      curr[sampFields.VALUE] = '';
    }
  }
  if (curr[sampFields.VALUE] === undefined) curr[sampFields.VALUE] = '';
  if (!prev) {
    curr[sampFields.STATUS] =
      sampleUtils.computeStatus(aspect, curr[sampFields.VALUE]);
    curr[sampFields.PRVS_STATUS] = dbConstants.statuses.Invalid;
    curr[sampFields.STS_CHANGED_AT] = now;
  } else if (curr[sampFields.VALUE] === prev[sampFields.VALUE]) {
    curr[sampFields.STATUS] = prev[sampFields.STATUS];
    curr[sampFields.PRVS_STATUS] = prev[sampFields.PRVS_STATUS];
    curr[sampFields.STS_CHANGED_AT] = prev[sampFields.STS_CHANGED_AT];
  } else {
    curr[sampFields.STATUS] =
      sampleUtils.computeStatus(aspect, curr[sampFields.VALUE]);
    if (curr[sampFields.STATUS] === prev[sampFields.STATUS]) {
      curr[sampFields.PRVS_STATUS] = prev[sampFields.PRVS_STATUS];
      curr[sampFields.STS_CHANGED_AT] = prev[sampFields.STS_CHANGED_AT];
    } else {
      curr[sampFields.PRVS_STATUS] = prev[sampFields.STATUS];
      curr[sampFields.STS_CHANGED_AT] = now;
    }
  }
  let rlinks;
  if (curr[sampFields.RLINKS]) {
    rlinks = curr[sampFields.RLINKS];
  } else if (!prev) { 
    rlinks = []; 
  }
  if (rlinks) curr[sampFields.RLINKS] = JSON.stringify(rlinks);
  if (!prev) curr[sampFields.CREATED_AT] = now;
  curr[sampFields.UPD_AT] = now;
} 
function updateSampleAttributes ( curr , prev , aspect ) { modelUtils . removeExtraAttributes ( curr , sampleFieldsArr ) ; const now = new Date ( ) . toISOString ( ) ; if ( ! curr . hasOwnProperty ( sampFields . VALUE ) ) { if ( prev && prev . hasOwnProperty ( sampFields . VALUE ) ) { curr [ sampFields . VALUE ] = prev [ sampFields . VALUE ] ; } else { curr [ sampFields . VALUE ] = '' ; } } if ( curr [ sampFields . VALUE ] === undefined ) curr [ sampFields . VALUE ] = '' ; if ( ! prev ) { curr [ sampFields . STATUS ] = sampleUtils . computeStatus ( aspect , curr [ sampFields . VALUE ] ) ; curr [ sampFields . PRVS_STATUS ] = dbConstants . statuses . Invalid ; curr [ sampFields . STS_CHANGED_AT ] = now ; } else if ( curr [ sampFields . VALUE ] === prev [ sampFields . VALUE ] ) { curr [ sampFields . STATUS ] = prev [ sampFields . STATUS ] ; curr [ sampFields . PRVS_STATUS ] = prev [ sampFields . PRVS_STATUS ] ; curr [ sampFields . STS_CHANGED_AT ] = prev [ sampFields . STS_CHANGED_AT ] ; } else { curr [ sampFields . STATUS ] = sampleUtils . computeStatus ( aspect , curr [ sampFields . VALUE ] ) ; if ( curr [ sampFields . STATUS ] === prev [ sampFields . STATUS ] ) { curr [ sampFields . PRVS_STATUS ] = prev [ sampFields . PRVS_STATUS ] ; curr [ sampFields . STS_CHANGED_AT ] = prev [ sampFields . STS_CHANGED_AT ] ; } else { curr [ sampFields . PRVS_STATUS ] = prev [ sampFields . STATUS ] ; curr [ sampFields . STS_CHANGED_AT ] = now ; } } let rlinks ; if ( curr [ sampFields . RLINKS ] ) { rlinks = curr [ sampFields . RLINKS ] ; } else if ( ! prev ) { rlinks = [ ] ; } if ( rlinks ) curr [ sampFields . RLINKS ] = JSON . stringify ( rlinks ) ; if ( ! prev ) curr [ sampFields . CREATED_AT ] = now ; curr [ sampFields . UPD_AT ] = now ; }
Update the sample from the request body.
Update the sample from the request body .
/*
     * If no value is provided and this is a new sample, set value to empty
     * string, which will generate a status of "Invalid". If this is NOT a new
     * sample, treat it like a PATCH and keep the value from the "prev" version
     * of the sample.
     */ /* Just in case curr.value was undefined... */ /*
     * This is a brand new sample so calculate current status based on value,
     * set previous status to invalid, and set status changed at to now.
     */ /*
     * Value is same so no need to recalculate status. Just carry over the
     * status, previous status, and status changed at from the old sample.
     */ /*
     * The value is different so we need to calculate the status.
     */ /*
       * The status is the same so carry over the previous status and status
       * changed at from the old sample.
       */ /*
       * The status is different so assign previous status based on the old
       * sample's status, and set status changd at to now.
       */ // if related link is passed in query object // if we are creating new sample // default value // updateSampleAttributes