<commit_before>import {
  DATATYPE_TYPE_FROM_NAME,
  UI_BEHAVIOUR,
} from 'constants/pogues-constants';
import { uuid } from 'utils/utils';

export function stateToRemote(state, response) {
  const {
    id,
    mandatory,
    typeName,
    maxLength: MaxLength,
    pattern: Pattern,
    minimum: Minimum,
    maximum: Maximum,
    decimals: Decimals,
    unit: Unit,
    format: Format,
    mihours: Mihours,
    miminutes: Miminutes,
    mihundhours: Mihundhours,
    mihundredths: Mihundredths,
    miyears: Miyears,
    mimonths: Mimonths,
    mahours: Mahours,
    maminutes: Maminutes,
    mahundhours: Mahundhours,
    mahundredths: Mahundredths,
    mayears: Mayears,
    mamonths: Mamonths,
    codesListId: CodeListReference,
    visHint: visualizationHint,
    hasSpecialCode,
    specialLabel,
    specialCode,
    specialUiBehaviour,
    specialFollowUpMessage,
    collectedVariable: CollectedVariableReference,
  } = state;
  const find = response
    ? response.find(
        element =>
          element.CollectedVariableReference === CollectedVariableReference,
      )
    : undefined;

  const model = {
    id: find ? find.id : id || uuid(),
    Datatype: {
      typeName,
      type: DATATYPE_TYPE_FROM_NAME[typeName],
    },
  };

  if (CollectedVariableReference !== undefined)
    model.CollectedVariableReference = CollectedVariableReference;
  if (CodeListReference !== undefined)
    model.CodeListReference = CodeListReference;
  if (mandatory !== undefined)
    model.mandatory = mandatory === '' ? false : mandatory;
  if (visualizationHint !== undefined)
    model.Datatype.visualizationHint = visualizationHint;
  if (MaxLength !== undefined) model.Datatype.MaxLength = MaxLength;
  if (Pattern !== undefined) model.Datatype.Pattern = Pattern;
  if (Minimum !== undefined) model.Datatype.Minimum = Minimum;
  if (Maximum !== undefined) model.Datatype.Maximum = Maximum;
  if (Decimals !== undefined) model.Datatype.Decimals = Decimals;
  if (Unit !== undefined) model.Datatype.Unit = Unit;
  if (Format !== undefined) model.Datatype.Format = Format;
  if (Mihours !== undefined) model.Datatype.Mihours = Mihours;
  if (Miminutes !== undefined) model.Datatype.Miminutes = Miminutes;
  if (Mihundhours !== undefined) model.Datatype.Mihundhours = Mihundhours;
  if (Mihundredths !== undefined) model.Datatype.Mihundredths = Mihundredths;
  if (Miyears !== undefined) model.Datatype.Miyears = Miyears;
  if (Mimonths !== undefined) model.Datatype.Mimonths = Mimonths;
  if (Mahours !== undefined) model.Datatype.Mahours = Mahours;
  if (Maminutes !== undefined) model.Datatype.Maminutes = Maminutes;
  if (Mahundhours !== undefined) model.Datatype.Mahundhours = Mahundhours;
  if (Mahundredths !== undefined) model.Datatype.Mahundredths = Mahundredths;
  if (Mayears !== undefined) model.Datatype.Mayears = Mayears;
  if (Mamonths !== undefined) model.Datatype.Mamonths = Mamonths;

  if (hasSpecialCode) {
    model.nonResponseModality = {
      value: specialCode,
      label: specialLabel,
      firstIntentionDisplay:
        specialUiBehaviour === UI_BEHAVIOUR.FIRST_INTENTION,
      invite: specialFollowUpMessage,
    };
  }
  console.log('model', model)
  return model;
}<commit_msg>delete console log<commit_after>import {
  DATATYPE_TYPE_FROM_NAME,
  UI_BEHAVIOUR,
} from 'constants/pogues-constants';
import { uuid } from 'utils/utils';

export function stateToRemote(state, response) {
  const {
    id,
    mandatory,
    typeName,
    maxLength: MaxLength,
    pattern: Pattern,
    minimum: Minimum,
    maximum: Maximum,
    decimals: Decimals,
    unit: Unit,
    format: Format,
    mihours: Mihours,
    miminutes: Miminutes,
    mihundhours: Mihundhours,
    mihundredths: Mihundredths,
    miyears: Miyears,
    mimonths: Mimonths,
    mahours: Mahours,
    maminutes: Maminutes,
    mahundhours: Mahundhours,
    mahundredths: Mahundredths,
    mayears: Mayears,
    mamonths: Mamonths,
    codesListId: CodeListReference,
    visHint: visualizationHint,
    hasSpecialCode,
    specialLabel,
    specialCode,
    specialUiBehaviour,
    specialFollowUpMessage,
    collectedVariable: CollectedVariableReference,
  } = state;
  const find = response
    ? response.find(
        element =>
          element.CollectedVariableReference === CollectedVariableReference,
      )
    : undefined;

  const model = {
    id: find ? find.id : id || uuid(),
    Datatype: {
      typeName,
      type: DATATYPE_TYPE_FROM_NAME[typeName],
    },
  };

  if (CollectedVariableReference !== undefined)
    model.CollectedVariableReference = CollectedVariableReference;
  if (CodeListReference !== undefined)
    model.CodeListReference = CodeListReference;
  if (mandatory !== undefined)
    model.mandatory = mandatory === '' ? false : mandatory;
  if (visualizationHint !== undefined)
    model.Datatype.visualizationHint = visualizationHint;
  if (MaxLength !== undefined) model.Datatype.MaxLength = MaxLength;
  if (Pattern !== undefined) model.Datatype.Pattern = Pattern;
  if (Minimum !== undefined) model.Datatype.Minimum = Minimum;
  if (Maximum !== undefined) model.Datatype.Maximum = Maximum;
  if (Decimals !== undefined) model.Datatype.Decimals = Decimals;
  if (Unit !== undefined) model.Datatype.Unit = Unit;
  if (Format !== undefined) model.Datatype.Format = Format;
  if (Mihours !== undefined) model.Datatype.Mihours = Mihours;
  if (Miminutes !== undefined) model.Datatype.Miminutes = Miminutes;
  if (Mihundhours !== undefined) model.Datatype.Mihundhours = Mihundhours;
  if (Mihundredths !== undefined) model.Datatype.Mihundredths = Mihundredths;
  if (Miyears !== undefined) model.Datatype.Miyears = Miyears;
  if (Mimonths !== undefined) model.Datatype.Mimonths = Mimonths;
  if (Mahours !== undefined) model.Datatype.Mahours = Mahours;
  if (Maminutes !== undefined) model.Datatype.Maminutes = Maminutes;
  if (Mahundhours !== undefined) model.Datatype.Mahundhours = Mahundhours;
  if (Mahundredths !== undefined) model.Datatype.Mahundredths = Mahundredths;
  if (Mayears !== undefined) model.Datatype.Mayears = Mayears;
  if (Mamonths !== undefined) model.Datatype.Mamonths = Mamonths;

  if (hasSpecialCode) {
    model.nonResponseModality = {
      value: specialCode,
      label: specialLabel,
      firstIntentionDisplay:
        specialUiBehaviour === UI_BEHAVIOUR.FIRST_INTENTION,
      invite: specialFollowUpMessage,
    };
  }
  return model;
}
{'fraction_non_alphanumeric': 0.10932876498987697, 'fraction_numerical': 0.0, 'mean_word_length': 3.9248466257668713, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1771363', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2001, 'n_words': 438}