import 'antd/es/empty/style';
import _Empty from 'antd/es/empty';
import 'antd/es/button/style';
import _Button from 'antd/es/button';
import 'antd/es/message/style';
import _message from 'antd/es/message';
import 'lodash/split';
import 'lodash/size';
import 'lodash/set';
import 'lodash/isString';
import 'lodash/includes';
import _get from 'lodash/get';
import 'lodash/forEach';
import 'lodash/floor';
import _cloneDeep from 'lodash/cloneDeep';
import { s as styleInject, g as DoctorEnd_DiagnosesTemplate, b as __awaiter, c as __generator, a as __spreadArray, d as __assign } from './index.js';
import { BookOutlined, SyncOutlined, SettingOutlined } from '@ant-design/icons';
import { OkButton } from '@lm_fe/components_m';
import { mchcEnv } from '@lm_fe/env';
import { request, getSearchParamsAll } from '@lm_fe/utils';
import React__default, { useState, useEffect } from 'react';
import { r as requestMethods_further, D as DiagnosesWeek, a as DiagnosesItem } from './diagnoses-week.js';
import { mchcModal__ } from '@lm_fe/pages';
import 'antd/es/tabs/style';
import 'antd/es/tabs';
import 'lodash/orderBy';
import 'lodash/map';
import '@lm_fe/components';
import 'antd/es/collapse/style';
import 'antd/es/collapse';
import 'antd/es/badge/style';
import 'antd/es/badge';
import 'lodash/assign';
import '@lm_fe/service';
var css_248z = ".diagWrapper-new {\n  padding: 8px;\n  overflow-y: auto;\n  border: 1px solid #d7dce7;\n  padding-right: 0px;\n}\n.diagWrapper-new .diagIpt {\n  padding-bottom: 5px;\n}\n.diagWrapper-new .firstDiag {\n  display: flex;\n  align-items: center;\n  margin: 7px 0px 7px 5px;\n  font-weight: 600;\n  color: #150f55;\n}\n.diagWrapper-new .firstDiag .diagNum {\n  border-radius: 50%;\n  width: 20px;\n  height: 20px;\n  line-height: 20px;\n  text-align: center;\n  border: 2px solid #d7dce7;\n  background-color: #fff;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  color: #333541;\n  margin-right: 6px;\n  font-weight: 400;\n}\n.diagWrapper-new .singleDiag {\n  display: flex;\n  align-items: center;\n  margin: 7px 0 7px 5px;\n  font-weight: 600;\n  color: #150f55;\n}\n.diagWrapper-new input::-webkit-input-placeholder {\n  /* WebKit browsers */\n  color: #242741;\n}\n.diagWrapper-new input:-moz-placeholder {\n  /* Mozilla Firefox 4 to 18 */\n  color: #242741;\n}\n.diagWrapper-new input::-moz-placeholder {\n  /* Mozilla Firefox 19+ */\n  color: #242741;\n}\n.diagWrapper-new input:-ms-input-placeholder {\n  /* Internet Explorer 10+ */\n  color: #242741;\n}\n.diagWrapper-new .diagGP {\n  display: inline-block;\n  width: 12px;\n  height: 21px;\n  line-height: 21px;\n  border-bottom: 1px #fe708b solid;\n}\n.diagWrapper-new .diagWeek {\n  width: 34px;\n  padding: 0 2px;\n}\n.diagWrapper-new .diagWord {\n  display: flex;\n  align-items: center;\n  border-radius: 2px;\n  color: #150f55;\n  cursor: pointer;\n  background-color: #fce6ea;\n  flex-wrap: wrap;\n}\n.diagWrapper-new .remark {\n  color: #a39b9b;\n}\n.diagWrapper-new .diagHighrisk {\n  background-color: #fcb9c5;\n}\n.diagWrapper-new .diagNote {\n  min-width: 60px;\n  height: 28px;\n  flex: 1;\n  border: 0 none;\n  outline: none;\n  box-shadow: none;\n  background-color: transparent;\n  border-bottom: 1px #fe708b solid;\n}\n.diagWrapper-new .diagNote::-ms-input-placeholder {\n  text-align: center;\n}\n.diagWrapper-new .diagNote::-webkit-input-placeholder {\n  text-align: center;\n}\n.diagWrapper-new .diag-popover {\n  display: flex;\n  align-items: center;\n}\n.diagWrapper-new .diag-popover2 {\n  display: flex;\n  align-items: center;\n}\n.diagWrapper-new .diag-words {\n  overflow: hidden;\n  text-overflow: ellipsis;\n  display: -webkit-box !important;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 2;\n}\n.diagWrapper-new .delBtn {\n  color: #8a8a8a;\n  font-size: 24px;\n}\n.diagHandle {\n  cursor: pointer;\n  color: #150f55;\n}\n";
styleInject(css_248z);
function Diagnoses(props) {
  var _this = this;
  var _a = useState(false),
    visible = _a[0],
    setVisible = _a[1];
  var _b = useState(false);
  _b[0];
  _b[1];
  var diagnosesWord = props.diagnosesWord,
    noshowlist = props.noshowlist,
    isAllPregnancies = props.isAllPregnancies,
    _c = props.diagnosesList,
    diagnosesList = _c === void 0 ? [] : _c,
    headerInfo = props.headerInfo,
    saveHeaderInfo = props.saveHeaderInfo,
    setDiagnosesList = props.setDiagnosesList,
    changeSyphilis = props.changeSyphilis;
  props.changeScreening;
  var page = props.page,
    serialNo = props.serialNo,
    setDiagnosesWord = props.setDiagnosesWord,
    getHighriskDiagnosis = props.getHighriskDiagnosis;
  useEffect(function () {
    return function () {};
  }, []);
  function changeHeaderInfo() {
    return __awaiter(this, void 0, void 0, function () {
      var res;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            return [4, request.get('/api/doctor/getOutpatientHeaderInfo?id=' + _get(headerInfo, "id"))];
          case 1:
            res = _a.sent();
            saveHeaderInfo(res.data);
            return [2];
        }
      });
    });
  }
  var handleDelete = function handleDelete(item, i) {
    return __awaiter(_this, void 0, void 0, function () {
      var newList, delArr;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            newList = _cloneDeep(diagnosesList);
            delArr = newList.splice(i, 1);
            return [4, requestMethods_further.deleteDiagnosis(_get(delArr, "[0].id"))];
          case 1:
            _a.sent();
            _message.info('删除成功！');
            setDiagnosesList(newList);
            changeHeaderInfo();
            return [2];
        }
      });
    });
  };
  var handleBtnClick = function handleBtnClick() {
    setDiagnosesWord('');
    setVisible(true);
  };
  var addDiag = function addDiag(diagnosisObj) {
    return __awaiter(_this, void 0, void 0, function () {
      var diag, res, newList, data;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            if (serialNo) {
              diagnosisObj.serialNo = serialNo;
            }
            diag = _get(diagnosisObj, 'diagnosis');
            if (!(diagnosesList.filter(function (item) {
              return item.diagnosis === diag;
            }).length === 0)) return [3, 2];
            return [4, requestMethods_further.newAddDiagnosis(diagnosisObj)];
          case 1:
            res = _a.sent();
            _message.success('添加成功！');
            newList = _cloneDeep(diagnosesList);
            data = res || diagnosisObj;
            setDiagnosesList(__spreadArray(__spreadArray([], newList, true), [data], false));
            changeHeaderInfo();
            if (diag.indexOf('梅毒') > -1) changeSyphilis(true);
            return [3, 3];
          case 2:
            _message.warning('添加诊断重复！');
            _a.label = 3;
          case 3:
            return [2];
        }
      });
    });
  };
  var closeTemplate = function closeTemplate() {
    setDiagnosesWord('');
    setVisible(false);
  };
  function 诊断管理按钮() {
    return !isAllPregnancies && /*#__PURE__*/React__default.createElement("div", {
      className: "diag-btn",
      style: {
        display: 'flex',
        justifyContent: 'flex-end',
        padding: 4
      }
    }, /*#__PURE__*/React__default.createElement(_Button.Group, {
      size: "small"
    }, /*#__PURE__*/React__default.createElement(OkButton, {
      icon: /*#__PURE__*/React__default.createElement(BookOutlined, null),
      onClick: function onClick() {
        return mchcModal__.open('诊断历史', {
          modal_data: {
            pregnancyId: headerInfo === null || headerInfo === void 0 ? void 0 : headerInfo.id
          }
        });
      }
    }, "\u5386\u53F2"), mchcEnv["in"](['建瓯']) ? /*#__PURE__*/React__default.createElement(OkButton, {
      icon: /*#__PURE__*/React__default.createElement(SyncOutlined, null),
      onClick: function onClick() {
        return request.get('/api/syncDiagnosis', {
          params: __assign(__assign({}, getSearchParamsAll()), {
            id: headerInfo === null || headerInfo === void 0 ? void 0 : headerInfo.id
          }),
          successText: '同步成功'
        }).then(function (res) {
          var _a;
          var arr = (_a = res.data) !== null && _a !== void 0 ? _a : [];
          setDiagnosesList(__spreadArray(__spreadArray([], diagnosesList, true), arr, true));
        });
      }
    }, "\u540C\u6B65") : null, /*#__PURE__*/React__default.createElement(OkButton, {
      icon: /*#__PURE__*/React__default.createElement(SettingOutlined, null),
      onClick: handleBtnClick
    }, "\u7BA1\u7406")));
  }
  var renderDiagnoses = function renderDiagnoses() {
    return /*#__PURE__*/React__default.createElement("div", {
      className: "diagWrapper-new"
    }, 诊断管理按钮(), /*#__PURE__*/React__default.createElement(DiagnosesWeek, {
      first: page !== 'return',
      headerInfo: headerInfo
    }), (diagnosesList === null || diagnosesList === void 0 ? void 0 : diagnosesList.length) ? diagnosesList.map(function (item, index) {
      return /*#__PURE__*/React__default.createElement(DiagnosesItem, {
        edit: false,
        index: index,
        diagnose: item,
        key: "".concat(_get(item, 'id'), "-false"),
        handleDelete: handleDelete,
        headerInfo: headerInfo,
        diagnosesList: diagnosesList,
        saveHeaderInfo: saveHeaderInfo,
        setDiagnosesList: setDiagnosesList,
        isShowDiagnosesTemplate: false
      });
    }) : /*#__PURE__*/React__default.createElement(_Empty, null));
  };
  return /*#__PURE__*/React__default.createElement("div", null, !noshowlist && renderDiagnoses(), visible && /*#__PURE__*/React__default.createElement(DoctorEnd_DiagnosesTemplate, {
    isShowDiagnosesTemplate: visible,
    closeTemplate: closeTemplate,
    addDiag: addDiag,
    diagnosesWord: diagnosesWord,
    getHighriskDiagnosis: getHighriskDiagnosis,
    headerInfo: headerInfo,
    diagnosesList: diagnosesList,
    setDiagnosesList: setDiagnosesList,
    saveHeaderInfo: saveHeaderInfo
  }));
}
export { Diagnoses as default };
//# sourceMappingURL=prenatal-visit.pregnancy.doctor-end5.js.map
