<commit_before>/** @jsx React.DOM */
/**
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 */

var React = window.React;
var _ = window._;
var moment = window.moment;
var bows = window.bows;
var config = window.config;

var watson = window.tideline.watson;

var utils = require('../../core/utils');
var Header = require('../../components/chart').header;
var Daily = require('../../components/chart').daily;
var Weekly = require('../../components/chart').weekly;
var Settings = require('../../components/chart').settings;

var Messages = require('../../components/messages');

var PatientData = React.createClass({
  propTypes: {
    patientData: React.PropTypes.object,
    patient: React.PropTypes.object,
    fetchingPatientData: React.PropTypes.bool,
    isUserPatient: React.PropTypes.bool,
    queryParams: React.PropTypes.object.isRequired,
    uploadUrl: React.PropTypes.string,
    onRefresh: React.PropTypes.func,
    onFetchMessageThread: React.PropTypes.func,
    onSaveComment: React.PropTypes.func,
    onEditMessage: React.PropTypes.func,
    onCreateMessage: React.PropTypes.func,
    onUpdatePatientData: React.PropTypes.func,
    user: React.PropTypes.object,
    trackMetric: React.PropTypes.func.isRequired
  },

  getInitialState: function() {
    var params = this.props.queryParams;
    var state = {
      chartPrefs: {
        bgUnits: 'mg/dL',
        hiddenPools: {
          // pass null here to *completely* disable the tabular display of basal settings
          basalSettings: null
        }
      },
      chartType: 'daily',
      createMessage: null,
      createMessageDatetime: null,
      datetimeLocation: null,
      initialDatetimeLocation: null,
      messages: null
    };

    return state;
  },

  componentWillMount: function() {
    var params = this.props.queryParams;

    if (!_.isEmpty(params)) {
      this.setState({
        chartPrefs: {
          hiddenPools: {
            basalSettings: params.showbasalsettings ?  true : null
          },
          bolusRatio: params.dynamicCarbs ? 0.5 : 0.35,
          dynamicCarbs: !!params.dynamicCarbs
        }
      });
    }
  },

  log: bows('PatientData'),

  render: function() {
    var patientData = this.renderPatientData();
    var messages = this.renderMessagesContainer();

    /* jshint ignore:start */
    return (
      <div className="patient-data js-patient-data-page">
        {messages}
        {patientData}<commit_msg>don't blow away bgUnits preference; fixes React required prop warning<commit_after>/** @jsx React.DOM */
/**
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 */

var React = window.React;
var _ = window._;
var moment = window.moment;
var bows = window.bows;
var config = window.config;

var watson = window.tideline.watson;

var utils = require('../../core/utils');
var Header = require('../../components/chart').header;
var Daily = require('../../components/chart').daily;
var Weekly = require('../../components/chart').weekly;
var Settings = require('../../components/chart').settings;

var Messages = require('../../components/messages');

var PatientData = React.createClass({
  propTypes: {
    patientData: React.PropTypes.object,
    patient: React.PropTypes.object,
    fetchingPatientData: React.PropTypes.bool,
    isUserPatient: React.PropTypes.bool,
    queryParams: React.PropTypes.object.isRequired,
    uploadUrl: React.PropTypes.string,
    onRefresh: React.PropTypes.func,
    onFetchMessageThread: React.PropTypes.func,
    onSaveComment: React.PropTypes.func,
    onEditMessage: React.PropTypes.func,
    onCreateMessage: React.PropTypes.func,
    onUpdatePatientData: React.PropTypes.func,
    user: React.PropTypes.object,
    trackMetric: React.PropTypes.func.isRequired
  },

  getInitialState: function() {
    var params = this.props.queryParams;
    var state = {
      chartPrefs: {
        bgUnits: 'mg/dL',
        hiddenPools: {
          // pass null here to *completely* disable the tabular display of basal settings
          basalSettings: null
        }
      },
      chartType: 'daily',
      createMessage: null,
      createMessageDatetime: null,
      datetimeLocation: null,
      initialDatetimeLocation: null,
      messages: null
    };

    return state;
  },

  componentWillMount: function() {
    var params = this.props.queryParams;

    if (!_.isEmpty(params)) {
      this.setState({
        chartPrefs: {
          bgUnits: this.state.chartPrefs.bgUnits,
          hiddenPools: {
            basalSettings: params.showbasalsettings ?  true : null
          },
          bolusRatio: params.dynamicCarbs ? 0.5 : 0.35,
          dynamicCarbs: params.dynamicCarbs
        }
      });
    }
  },

  log: bows('PatientData'),

  render: function() {
    var patientData = this.renderPatientData();
    var messages = this.renderMessagesContainer();

    /* jshint ignore:start */
    return (
      <div className="patient-data js-patient-data-page">
        {messages}
        {patientData}
{'fraction_non_alphanumeric': 0.1109850939727803, 'fraction_numerical': 0.0032404406999351912, 'mean_word_length': 2.980012894906512, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '506951', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1717, 'n_words': 504}