import { _ as __extends, d as __assign, a as __spreadArray } from './index.js';
import { BaseEditPanelForm, BaseEditPanel } from '@lm_fe/components_m';
import _set from 'lodash/set';
import _map from 'lodash/map';
import _isObject from 'lodash/isObject';
import _get from 'lodash/get';
import { formatDateTime } from '@lm_fe/utils';
import dayjs from 'dayjs';
import 'react';
import '@lm_fe/env';
import 'antd/es/tabs/style';
import 'antd/es/tabs';
import 'lodash/size';
import 'lodash/orderBy';
import '@lm_fe/components';
import 'antd/es/collapse/style';
import 'antd/es/collapse';
import 'antd/es/badge/style';
import 'antd/es/badge';
import 'antd/es/button/style';
import 'antd/es/button';
import 'lodash/assign';
import '@ant-design/icons';
import '@lm_fe/service';
import '@lm_fe/pages';
var AdmissionForm = function (_super) {
  __extends(AdmissionForm, _super);
  function AdmissionForm() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  return AdmissionForm;
}(BaseEditPanelForm);
var fromApi = function fromApi(data, nativeFormDescriptions) {
  var result = {};
  _map(nativeFormDescriptions, function (desctiption, key) {
    var tranferRules = desctiption.tranfer_rules;
    var type = 'default';
    var path = key;
    if (tranferRules && JSON.parse(tranferRules)) {
      var tranferRulesJson = JSON.parse(tranferRules);
      type = _get(tranferRulesJson, 'type') ? _get(tranferRulesJson, 'type') : 'default';
      path = _get(tranferRulesJson, 'path') ? _get(tranferRulesJson, 'path') : key;
    }
    switch (type) {
      case 'key_and_keyNote':
        _set(result, "".concat(key, ".key"), _get(data, path));
        _set(result, "".concat(key, ".keyNote"), _get(data, "".concat(path, "Note")));
        break;
      case 'stage':
        _set(result, "".concat(key, ".0"), _get(data, "".concat(key, "h")));
        _set(result, "".concat(key, ".1"), _get(data, "".concat(key, "m")));
        break;
      case 'apgar':
        _map(_get(data, 'noenateRecord'), function (record, index) {
          _set(result, "".concat(key, ".").concat(index, ".apgar1"), _get(record, 'apgar1'));
          _set(result, "".concat(key, ".").concat(index, ".apgar5"), _get(record, 'apgar5'));
          _set(result, "".concat(key, ".").concat(index, ".apgar10"), _get(record, 'apgar10'));
        });
        break;
      case 'moment':
        _set(result, key, dayjs(_get(data, path)));
        break;
      case 'default':
      default:
        _set(result, key, _get(data, path));
        break;
    }
  });
  return __assign(__assign({}, result), {
    id: _get(data, 'id')
  });
};
var toApi = function toApi(data, nativeFormDescriptions) {
  var isObjectKeyArray = [];
  var isNotObjectKeyArray = [];
  _map(data, function (item, key) {
    if (_isObject(item)) {
      isObjectKeyArray.push(key);
    } else {
      isNotObjectKeyArray.push(key);
    }
  });
  var result = {};
  var dataKeys = __spreadArray(__spreadArray([], isObjectKeyArray, true), isNotObjectKeyArray, true);
  _set(result, 'noenateRecords', _get(data, 'fetusAppendages'));
  _map(dataKeys, function (key) {
    var item = _get(data, key);
    var tranferRules = _get(nativeFormDescriptions, "".concat(key, ".tranfer_rules"));
    var type = 'default';
    var path = key;
    if (tranferRules && JSON.parse(tranferRules)) {
      var tranferRulesJson = JSON.parse(tranferRules);
      type = _get(tranferRulesJson, 'type') ? _get(tranferRulesJson, 'type') : 'default';
      path = _get(tranferRulesJson, 'path') ? _get(tranferRulesJson, 'path') : key;
    }
    switch (type) {
      case 'key_and_keyNote':
        _set(result, path, _get(item, 'key'));
        _set(result, "".concat(path, "Note"), _get(item, 'keyNote'));
        break;
      case 'stage':
        _set(result, "".concat(key, "h"), Number(_get(item, '0')));
        _set(result, "".concat(key, "m"), Number(_get(item, '1')));
        break;
      case 'apgar':
        _map(_get(data, 'noenateRecord'), function (record, index) {
          _set(result, "".concat(key, ".").concat(index, ".apgar1"), _get(record, 'apgar1'));
          _set(result, "".concat(key, ".").concat(index, ".apgar5"), _get(record, 'apgar5'));
          _set(result, "".concat(key, ".").concat(index, ".apgar10"), _get(record, 'apgar10'));
        });
        break;
      case 'moment':
        _set(result, path, formatDateTime(item));
        break;
      case 'fetusAppendages':
        break;
      case 'default':
      default:
        _set(result, path, item);
        break;
    }
  });
  return result;
};
var WifePanel = function (_super) {
  __extends(WifePanel, _super);
  function WifePanel() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  WifePanel.defaultProps = {
    baseUrl: '/api/gynecological-patients',
    moduleName: 'gynecological-patients',
    title: '女方档案',
    toApi: toApi,
    fromApi: fromApi,
    Form: AdmissionForm
  };
  return WifePanel;
}(BaseEditPanel);
export { WifePanel as default };
//# sourceMappingURL=gynecological-diseases.women.edit.js.map
