var MeasurePeriod = { "low": <%= js_for_value(measure_period.low) %>, "high": <%= js_for_value(measure_period.high) %> } hqmfjs.MeasurePeriod = function(patient) { return [new hQuery.CodedEntry( { "start_time": MeasurePeriod.low.asDate().getTime()/1000, "end_time": MeasurePeriod.high.asDate().getTime()/1000, "codes": {} } )]; } if (typeof effective_date === 'number') { MeasurePeriod.high.date = new Date(1000*effective_date); // add one minute before pulling off the year. This turns 12-31-2012 23:59 into 1-1-2013 00:00 => 1-1-2012 00:00 MeasurePeriod.low.date = new Date(1000*(effective_date+60)); MeasurePeriod.low.date.setFullYear(MeasurePeriod.low.date.getFullYear()-1); }