<?php


namespace app\controller;


use app\model\Bmy;
use app\model\CaseInfo;
use app\model\PatientInfo;
use app\model\Qtzd;
use app\model\SsInfo;
use app\model\Zyys;
use app\model\Zyzd;
use app\model\Zzzd;
use app\model\JmCdssInspection;
use think\facade\Request;

class QualityControl extends CommonTwoController
{

     public function yzEamine()
    {
        $XB = Request::post('XB'); // 性别
        $NL = Request::post('NL'); // 年龄
        $YZMC = Request::post('YZMC'); // 医嘱名称

        $yzbMapping = JmCdssInspection::where(["name" => $YZMC])->find();
        if ($yzbMapping && $yzbMapping['sex'] != $XB && $yzbMapping['sex'].'性' != $XB) {

            return $this->_json_error('', 1, [
                "name" => $YZMC,
                "content" => "仅限" . $yzbMapping['sex'] . "性，" . $yzbMapping["overview"]
            ]);
        }
        return $this->_json_succ();
    }
    public function initConfig()
    {
        $bmy = Bmy::order('id')->select()->toArray();
        $bmy = array_values(array_column($bmy, 'bmy', 'id'));
        $zyys = Zyys::order('id')->select()->toArray();
        $zyys = array_values(array_column($zyys, 'zyys', 'id'));
        $data = [
            'ylfkfs' => [
                0 => '城镇职工基本医疗保险',
                1 => '城镇居民基本医疗保险',
                2 => '新型农村合作医疗',
                3 => '贫困救助',
                4 => '贫困救助',
                5 => '商业医疗保险',
                6 => '全公费',
                7 => '全自费',
                8 => '其他社会保险',
                9 => '其他'
            ],
            'zyys' => $zyys,
            'cybf' => array_values(self::getKb('',2)),
            'CN_track' => [
                0 => '未入组病案',
                1 => '死亡病案',
                2 => '费用异常病案',
                3 => '无效病案',
            ],
            'CHS_DRG_track' => [
                0 => '未入组病案',
                1 => '死亡病案',
                2 => '费用异常病案',
                3 => '无效病案',
            ],
            'DIP_situation' => [
                0 => '未入组',
                1 => '核心病种',
                2 => '综合病种',
                3 => '床日病种',
                4 => '单病种',
                5 => '其他病种',
            ],
            'CN_level' => [
                0 => '低风险',
                1 => '中低风险',
                2 => '中高风险',
                3 => '高风险',
            ],
            'CHS_DRG_level' => [
                0 => '低风险',
                1 => '中低风险',
                2 => '中高风险',
                3 => '高风险',
            ],
            'problem' => [
                0 => '全部错误',
                1 => '强制错误',
                2 => '疑似错误',
            ],
            'bmy' => $bmy,
            'status' => [
                0 => '未编辑',
                1 => '已编辑'
            ]
        ];
        return $data;
    }

    public function getConfig()
    {
        return json(self::initConfig());
    }

    public function getQcList()
    {
        $data = self::initConfig();
        $where = [];
        $page = Request::post('page', 1);
        $department = Request::post('zyys', null);
        if (!empty($department)) {
            $where[] = ['zyys', '=', $data['zyys'][$department] ?? ''];
        }
        $case_id = Request::post('bah', null);
        if ($case_id !== null) {
            $where[] = ['bah', '=', $case_id];
        }
        $problem = Request::post('problem', null);
        if ($problem !== null) {
            if ($problem == 1){
                $where[] = ['code_error','!=',''] ;
            }elseif ($problem == 2){
                $where[] = ['no_code_error','!=',''];
            }
        }
        $pay_type = Request::post('ylfkfs', null);
        if ($pay_type !== null) {
            $where[] = ['ylfkfs', '=', $data['ylfkfs'][$pay_type] ?? ''];
        }

        $coder = Request::post('bmy', null);
        if ($coder !== null) {
            $where[] = ['bmy', '=', $data['bmy'][$coder] ?? ''];
        }
        $physician = Request::post('zyys', null);
        if ($physician !== null) {
            $where[] = ['zyys', '=', $data['zyys'][$physician] ?? ''];
        }
        $cybf = Request::post('cybf', null);
        if ($cybf !== null) {
            $where[] = ['cybf', '=', $data['cybf'][$cybf] ?? ''];
        }
        //CN
        $CN_level = Request::post('CN_level', null);
        if ($CN_level !== null) {
            $where[] = ['CN_level', '=', $data['CN_level'][$CN_level] ?? ''];
        }
        $CN_DRG = Request::post('CN_DNR', null);
        if ($CN_DRG !== null) {
            $where[] = ['CN_DNR', '=', $CN_DRG];
        }
        $CN_track = Request::post('CN_track', null);
        if ($CN_track !== null) {
            $where[] = ['CN_track', '=', $data['CN_track'][$CN_track] ?? ''];
        }
        $CN_magnification = Request::post('CN_magnification', null);
        if ($CN_magnification !== null) {
            $tempArr = explode(',', $CN_magnification);
            $where[] = ['CN_magnification', $tempArr[0], $tempArr[1]];
        }
        //DIP
        $DIP_diagnosis_code = Request::post('DIP_diagnosis_code', null);
        if ($DIP_diagnosis_code !== null) {
            $where[] = ['DIP_diagnosis_code', '=', $DIP_diagnosis_code];
        }
        $DIP_diagnosis_name = Request::post('DIP_diagnosis_name', null);
        if ($DIP_diagnosis_name !== null) {
            $where[] = ['DIP_diagnosis_name', '=', $DIP_diagnosis_name];
        }
        $DIP_situation = Request::post('DIP_situation', null);
        if ($DIP_situation !== null) {
            $where[] = ['DIP_situation', '=', $DIP_situation];
        }
        $DIP_magnification = Request::post('DIP_magnification', null);
        if ($DIP_magnification !== null) {
            $tempArr = explode(',', $DIP_magnification);
            $where[] = ['DIP_magnification', $tempArr[0], $tempArr[1]];
        }
        $DIP_value = Request::post('DIP_value', null);
        if ($DIP_value !== null) {
            $tempArr = explode(',', $DIP_value);
            $where[] = ['DIP_value', $tempArr[0], $tempArr[1]];
        }

        //CHS
        $CHS_DRG = Request::post('CHS_DRG', null);
        if ($CHS_DRG !== null) {
            $where[] = ['CHS_DRG', '=', $CHS_DRG];
        }
        $CHS_DRG_level = Request::post('CHS_DRG_level', null);
        if ($CHS_DRG_level !== null) {
            $where[] = ['CHS_DRG_level', '=', $data['CHS_DRG_level'][$CHS_DRG_level] ?? ''];
        }
        $CHS_DRG_track = Request::post('CHS_DRG_track', null);
        if ($CHS_DRG_track !== null) {
            $where[] = ['CHS_DRG_track', '=', $data['CHS_DRG_track'][$CHS_DRG_track] ?? ''];
        }
        $CHS_DRG_magnification = Request::post('CHS_DRG_magnification', null);
        if ($CHS_DRG_magnification !== null) {
            $tempArr = explode(',', $CHS_DRG_magnification);
            $where[] = ['CHS_DRG_magnification', $tempArr[0], $tempArr[1]];
        }

        $status = Request::post('status', null);
        if ($status !== null) {
            $where[] = ['status', '=', $status];
        }
        $list['list'] = CaseInfo::where($where)->page($page, 10)->select();
        $list['count'] = CaseInfo::where($where)->count('id');
        return json($list);
    }

    public function getInfo()
    {
        $fkfs = [
            "01" => "城镇职工基本医疗保险",
            "02" => "城镇居民基本医疗保险",
            "03" => "新型农村合作医疗",
            "04" => "贫困救助",
            "05" => "商业医疗保险",
            "06" => "全公费",
            "07" => "全自费",
            "08" => "其他社会保险",
            "99" => "其他"
        ];
        $must = [
            'ylfkfs' => ['tips' => '医疗付款方式缺失', 'title' => '医疗付款方式', 'id' => 'ylfkfs'],
            'bah' => ['tips' => '病案号缺失', 'title' => '病案号', 'id' => 'bah'],
            'zycs' => ['tips' => '住院次数缺失', 'title' => '住院次数', 'id' => 'zycs'],
            'xm' => ['tips' => '姓名缺失', 'title' => '姓名', 'id' => 'xm'],
            'xb' => ['tips' => '性别缺失', 'title' => '性别', 'id' => 'xb'],
            'sfzh' => ['tips' => '身份证号缺失', 'title' => '身份证号', 'id' => 'sfzh'],
            'csrq' => ['tips' => '出生日期缺失', 'title' => '出生日期', 'id' => 'csrq'],
            'nl' => ['tips' => '年龄缺失', 'title' => '年龄', 'id' => 'nl'],
            'gj' => ['tips' => '国籍缺失', 'title' => '国籍', 'id' => 'gj'],
            'mz' => ['tips' => '民族缺失', 'title' => '民族', 'id' => 'mz'],
            'zy' => ['tips' => '职业缺失', 'title' => '职业', 'id' => 'zy'],
            'hy' => ['tips' => '婚姻缺失', 'title' => '婚姻', 'id' => 'hy'],
            'gg' => ['tips' => '籍贯缺失', 'title' => '籍贯', 'id' => 'gg'],
            'csd' => ['tips' => '出生地址缺失', 'title' => '出生地址', 'id' => 'csd'],
            'hkdz' => ['tips' => '户口地址缺失', 'title' => '户口地址', 'id' => 'hkdz'],
            'xzz' => ['tips' => '现住地址缺失', 'title' => '现住地址', 'id' => 'xzz'],
            'gzdwjdz' => ['tips' => '工作单位地址缺失', 'title' => '工作单位地址', 'id' => 'gzdwjdz'],
            'lxrxm' => ['tips' => '联系人姓名缺失', 'title' => '联系人姓名', 'id' => 'lxrxm'],
            'gx' => ['tips' => '联系人关系缺失', 'title' => '联系人关系', 'id' => 'gx'],
            'rytj' => ['tips' => '入院途径缺失', 'title' => '入院途径', 'id' => 'rytj'],
            'zllb' => ['tips' => '治疗类别缺失', 'title' => '治疗类别', 'id' => 'zllb'],
            'rysj' => ['tips' => '入院时间缺失', 'title' => '入院时间', 'id' => 'rysj'],
            'rybf' => ['tips' => '入院院内科室缺失', 'title' => '入院院内科室', 'id' => 'rybf'],
            'cysj' => ['tips' => '出院时间缺失', 'title' => '出院时间', 'id' => 'cysj'],
            'cybf' => ['tips' => '出院院内科室缺失', 'title' => '出院院内科室', 'id' => 'cybf'],
            'sjzyts' => ['tips' => '住院天数缺失', 'title' => '住院天数', 'id' => 'sjzyts'],
            'kzr' => ['tips' => '科主任姓名缺失', 'title' => '科主任姓名', 'id' => 'kzr'],
            'zrys' => ['tips' => '主任医师姓名缺失', 'title' => '主任医师姓名', 'id' => 'zrys'],
            'zzys' => ['tips' => '主治医师姓名缺失', 'title' => '主治医师姓名', 'id' => 'zzys'],
            'zyys' => ['tips' => '住院医师姓名缺失', 'title' => '住院医师姓名', 'id' => 'zyys'],
            'zrhs' => ['tips' => '责任护士姓名缺失', 'title' => '责任护士姓名', 'id' => 'zrhs'],
            'bmy' => ['tips' => '编码员姓名缺失', 'title' => '编码员姓名', 'id' => 'bmy'],
            'zkys' => ['tips' => '质控医师姓名缺失', 'title' => '质控医师姓名', 'id' => 'zkys'],
            'lyfs' => ['tips' => '离院方式缺失', 'title' => '离院方式', 'id' => 'lyfs'],
            'sfzzyjh' => ['tips' => '再住院计划缺失', 'title' => '再住院计划', 'id' => 'sfzzyjh'],
            'md' => ['tips' => '目的缺失', 'title' => '目的', 'id' => 'md'],
        ];
        $case_id = Request::post('bah');
        $info = PatientInfo::where('bah', '=', $case_id)->find()->toArray();
        $zyzd = Zyzd::where('bah', '=', $case_id)->find()->toArray();
        $qtzd = Qtzd::where('bah', '=', $case_id)->select()->toArray();
        $ssInfo = SsInfo::where('bah', '=', $case_id)->select()->toArray();
        //检查必填项
        $myError = [];
        foreach ($must as $key => $item) {
            if (empty($info[$key])) {
                $myError[$key] = $item;
            }
        }
        //手术编码诊断编码
//        $QualityControl = self::getQualityControl($case_id, $info,$zd,$ssInfo,$zyzd);
        $QualityControl = self::getOmahaControl($ssInfo, $info, $zyzd, $qtzd);
        $value = 100;
        if ($QualityControl['code'] == 0) {
            $error = $QualityControl['result'];
            $count = count($error);
            $value = bcsub($value, bcmul($count, 0.5, 1), 1);
        }else{
            $error = [];
        }
        $errorData = [];
        foreach ($error as $key => $item){
            $data = preg_split('/[(\s]/',$item['source']);
            if (empty($data)){
                continue;
            }
            $test = [
                'tips' => $item['tips'],
                'title' => $data[0],
                'id' => ''
            ];
            if ($data[0] == '外因编码'){
                $test['id'] = 'h23';
            }
            if ($data[0] == '疾病编码'){
                $test['id'] = 'zyzd';
            }
            $errorData[$data[1]] = $test;
        }
        //分组
        $group = self::getQuality([
            "HOS_ID" => $info['hospitalId'],
            "DATE" => $info['rysj'],
            "YBLX" => array_search($info['ylfkfs'], $fkfs) ?? "310",
            "M_ID" => $info['bah'] ?? '',
            "ZYZD" => $zyzd['jbdm'] ?? '',
            "ZYZD_NAME" => $zyzd['zd_name'] ?? '',
            "QTZD" => array_column($qtzd, 'jbdm'),
            "QTZD_NAME" => array_column($qtzd, 'zd_name'),
            "SSCZ" => array_column($ssInfo, 'ssjczbm'),
            "SSCZ_NAME" => array_column($ssInfo, 'ssjczmc'),
            "NL" => $info['nl'],
            "XM" => $info['xm'],
            "XB" => $info['xb'] == 1 ? '男' : '女',
            "ZYTS" => $info['sjzyts'],
            "FY" => $info['zfy'],
            "XSETS" => $info['bzyzsnl'] ?? 0,
            "XSECSTZ" => $info['xsecstz'],
            "XSERYTZ" => $info['xserytz'],
            "HXJ" => $info['ycfxj'] ?? 0 + $info['wcfxj'] ?? 0,
            "CYZG" => $info['lyfs'],
            "KSBM" => $info['ryksbm'] ?? '',
            "KSMC" => $info['rybf'] ?? '',
            "YSBM" => $info['zzys_bh'] ?? '',
            "YSMC" => $info['zzys'] ?? ''
        ]);
        //处理编码数据
        $zyzd['text'] = '主要诊断';
        $zyzd['id'] = 'zyzd';
        $qtn = 0;
        //诊断信息
        foreach ($qtzd as &$item){
            $item['text'] = '其他诊断';
            $item['id'] = 'qtzd'.$qtn;
            $qtn++;
            if (isset($errorData[$item['jbdm']])){
                if ($errorData[$item['jbdm']]['id'] == ''){
                    $errorData[$item['jbdm']]['id'] = $item['id'];
                }
            }
        }
        $zd = array_merge([$zyzd], $qtzd);
        //手术信息
        $sn = 0;
        foreach ($ssInfo as &$item){
            $item['id'] = 'ssid'.$sn;
            if (isset($errorData[$item['ssjczbm']])){
                if ($errorData[$item['ssjczbm']]['id'] == ''){
                    $errorData[$item['ssjczbm']]['id'] = $item['id'];
                }
            }
        }
        //费用
        $xyf = $info['xyf'] ?? 0;
        $kjywf = $info['kjywf'] ?? 0;
        $zcyf = $info['zcyf'] ?? 0;
        $zyzjf = $info['zyzjf'] ?? 0;
        $zcyf1 = $info['zcyf1'] ?? 0;
        $zfy = $info['zfy'] ?? 0;
        $yaocaify = bcadd(bcadd(bcadd($xyf, $kjywf, 2), bcadd($zcyf, $zyzjf, 2)), $zcyf1, 2);
        if ($yaocaify == 0) {
            $yaocai = '0%';
        } else {
            $yaocai = bcmul(bcdiv($yaocaify, $zfy, 4), 100, 2) . '%';
        }
        $hcyyclf = $info['hcyyclf'] ?? 0;
        $yyclf = $info['yyclf'] ?? 0;
        $ycxyyclf = $info['ycxyyclf'] ?? 0;
        $haocaify = bcadd(bcadd($hcyyclf, $yyclf, 2), $ycxyyclf, 2);
        if ($haocaify == 0) {
            $haocai = '0%';
        } else {
            $haocai = bcmul(bcdiv($haocaify, $zfy, 4), 100, 2) . '%';
        }
        $fy = [
            'zfy' => $zfy,
            'yc' => $yaocai,
            'hc' => $haocai,
            'drgs' => $group['DRGS'],
            'rw' => $group['RW'],
            'zfbz' => $group['ZFBZ'],
            'zfjy' => $group['ZFJY'],
            'zkdf' => $value
        ];
        $infoData = [];
        foreach ($info as $key => $value) {
            $infoData[$key] = ['id' => $key, 'valaue' => $value];
        }
        //拼装数据
        $data = [
            'info' => $infoData,
            'zd' => $zd,
            'ssinfo' => $ssInfo,
            'drg' => $fy,
            'error' => array_merge($myError,$errorData)
        ];
        return json($data);
    }

    public static function getQuality(array $info)
    {
        $url = 'http://49.233.2.47:9006/drumpHTTP_YFZ.aspx';
        $post['Params'] = json_encode($info);
        $header = array('Content-Type: multipart/form-data');
        $result = CommonController::sendWebservice($url, $post, $header);
        $result = json_decode($result, true);
        if (!empty($result) && $result['RESULT'] == 1) {
            return [
                'DRGS' => $result['DRGS'],
                'RW' => $result['RW'],
                'ZFY' => $result['ZFY'],
                'ZFBZ' => $result['ZFBZ'],
                'ZFJY' => $result['ZFJY'],
            ];
        } else {
            return [
                'DRGS' => $result['DRGS'] ?? '',
                'RW' => $result['RW'] ?? 0,
                'ZFY' => $result['ZFY'] ?? 0,
                'ZFBZ' => $result['ZFBZ'] ?? 0,
                'ZFJY' => $result['ZFJY'] ?? 0,
            ];
        }
    }

    public static function getQualityControl($mid, $info, $zd, $ssInfo, $zyzd)
    {
        $diagnos = [];
        foreach ($zd as $key => $item) {
            $diagnos[] = [
                "hosId" => $info['hospitalId'],
                "icdCode" => $item['jbdm'],
                "icdName" => $item['zd_name'],
                "rybq" => $item['rybq'],
                "cyqk" => $item['cyqk'],
                "ord" => 2,
                "cysj" => $info['cysj'],
                "type" => "",
                "mid" => $info['bah']
            ];
        }
        $operation = [];
        foreach ($ssInfo as $item) {
            $operation[] = [
                "hosId" => $info['hospitalId'],
                "icdCode" => $item['ssjczbm'],
                "icdName" => $item['ssjczmc'],
                "ord" => 2,
                "ssjczrq" => $item['ssjczrq'],
                "ssjb" => $item['ssjb'],
                "sfzyss" => "0",
                "sscxsj" => null,
                "sz" => $item['sz'],
                "yz" => $item['yz'],
                "ez" => $item['ez'],
                "qkdj" => $item['qkdj'],
                "qkyhlb" => $item['qkyhlb'],
                "qkyhdj" => null,
                "mzfs" => $item['mzfs'],
                "mzfj" => null,
                "mzys" => $item['mzys'],
                "cysj" => $info['cysj'],
                "mid" => $info['bah']
            ];
        }
        //质控手术编码
        $QualityControlData = [
            "hosId" => $info['hospitalId'],
            "xm" => $info['xm'],
            "jkkh" => $info['jkkh'],
            "xb" => $info['xb'],
            "csrq" => $info['csrq'] . " 00=>00=>00",
            "nl" => $info['nl'],
            "gj" => $info['gj'],
            "csd" => $info['csd'],
            "gg" => $info['gg'],
            "mz" => $info['mz'],
            "zjlb" => "1",
            "sfzh" => $info['sfzh'],
            "zy" => $info['zy'],
            "hy" => $info['hy'],
            "xzz" => $info['xzz'],
            "dh" => $info['dh'],
            "yb1" => $info['yb1'],
            "hkdz" => $info['hkdz'],
            "yb2" => $info['yb2'],
            "gzdwjdz" => $info['gzdwjdz'],
            "dwdh" => $info['dwdh'],
            "yb3" => $info['yb3'],
            "lxrxm" => $info['lxrxm'],
            "gx" => $info['gx'],
            "dz" => $info['dz'],
            "dh2" => $info['dh2'],
            "zyh" => $info['rykb'],
            "ylfkfs" => $info['ylfkfs'],
            "zycs" => $info['zycs'],
            "bah" => $info['bah'],
            "bzyzsnl" => $info['bzyzsnl'],
            "xsecstz" => $info['xsecstz'],
            "xsecstz2" => null,
            "xsecstz3" => null,
            "xsecstz4" => null,
            "xsecstz5" => null,
            "xserytz" => $info['xserytz'],
            "rytj" => $info['rytj'],
            "rysj" => $info['rysj'],
            "rysjs" => $info['rysjs'],
            "rykb" => $info['rykb'],
            "rybf" => $info['rybf'],
            "zkkb" => $info['zkkb'],
            "cysj" => $info['cysj'],
            "cysjs" => $info['cysjs'],
            "cykb" => $info['cykb'],
            "cybf" => $info['cybf'],
            "sjzyts" => $info['sjzyts'],
            "mzzd" => $info['mzzd'],
            "jbbm" => $info['jbbm'],
            "zyzd" => $zyzd['zd_name'],
            "jbdm" => $zyzd['jbdm'],
            "zyzdcyqk" => $zyzd['cyqk'],
            "rybq" => $zyzd['rybq'],
            "rysqk" => $zyzd['rybq'],
            "ryzdbm" => $zyzd['jbdm'],
            "ryzdmc" => $zyzd['zd_name'],
            "qyhqzrq" => '',
            "lyfs" => $info['lyfs'],
            "sfzzyjh" => $info['sfzzyjh'],
            "md" => $info['md'],
            "zfy" => $info['zfy'],
            "zfje" => $info['zfje'],
            "hxjsj" => $info['ycfxj'] ?? 0 + $info['wcfxj'] ?? 0,
            "sfrjss" => null,
            "tjhlts" => null,
            "yjhlts" => null,
            "ejhlts" => null,
            "sjhlts" => null,
            "wbyy" => $info['wbyy'],
            "h23" => $info['h23'],
            "blzd" => $info['blzd'],
            "jbmm" => $info['jbmm'],
            "blh" => $info['blh'],
            "blzd1" => null,
            "jbmm1" => null,
            "blh1" => null,
            "blzd2" => null,
            "jbmm2" => null,
            "blh2" => null,
            "ywgm" => $info['ywgm'],
            "gmyw" => $info['gmyw'],
            "swhzsj" => $info['swhzsj'],
            "xx" => $info['xx'],
            "rh" => $info['rh'],
            "hbsag" => null,
            "hcvAb" => null,
            "hivAb" => null,
            "sxfy" => null,
            "hxb" => null,
            "xxb" => null,
            "xj" => null,
            "qx" => null,
            "ztxhs" => null,
            "ryqT" => null,
            "ryqXs" => null,
            "ryqF" => null,
            "ryhT" => null,
            "ryhXs" => null,
            "ryhF" => null,
            "kzrbm" => $info['kzr_bh'],
            "kzr" => $info['kzr'],
            "zrysbm" => $info['zrys_bh'],
            "zrys" => $info['zrys'],
            "zzysbm" => $info['zzys_bh'],
            "zzys" => $info['zzys'],
            "zyysbm" => $info['zyys_bh'],
            "zyys" => $info['zyys'],
            "zrhsbm" => $info['zrhs_bh'],
            "zrhs" => $info['zrhs'],
            "jxys" => $info['jxys'],
            "sxys" => $info['sxys'],
            "bmy" => $info['bmy'],
            "bazl" => $info['bazl'],
            "zkys" => $info['zkys'],
            "zkhs" => $info['zkhs'],
            "zkrq" => $info['zkrq'],
            "zzzbm" => '',
            "zzz" => '',
            "zzzysbm" => '',
            "zzzys" => '',
            "diagnos" => $diagnos,
            "fee" => [],
            "operation" => $operation
        ];
        $info = json_encode($info);
        $url = 'http://49.233.2.47:9000/drumpWS_QT.asmx?op=DrumpServices_ZK';
        $post = <<<EOT
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DrumpServices_ZK xmlns="http://tempuri.org/">
<strM_ID>$mid</strM_ID>
<Params>$info</Params>
</DrumpServices_ZK>
</soap:Body>
</soap:Envelope>
EOT;
        $header = array('Content-Type: text/xml;charset=utf-8');
        $result = CommonController::sendWebservice($url, $post, $header);
        $result = json_decode(preg_replace('/(|)|<.+?>/i', '', $result), true);
        return $result;
    }

    public static function getOmahaControl($ssInfo, $info, $zyzd, $qtzd)
    {
        $url = 'http://spark.omaha.org.cn/api/search?acctId=b9ffdc51784&key=JmvVQEdZ&prodId=P_Q_101&type=0&dataSet=H30051&icd10version=83&icd9cm3version=84';
        $data = [
            'A01' => $info['hospitalId'],    //字符	组织机构代码
            'A02' => $info['username'],    //字符	医疗机构名称
            'A46C' => self::getFffs($info['ylfkfs']), //	字符	医疗付费方式
            'A47' => $info['jkkh'],//	字符	健康卡号
            'A49' => $info['zycs'], //	数字	住院次数
            'A48' => $info['bah'], //	字符	病案号
            'A11' => $info['xm'], //	字符	姓名
            'A12C' => self::getXb($info['xb']),//	数字	性别（取值：未知、男、女、未说明）
            'A13' => $info['csrq'],//	日期	出生日期
            'A14' => $info['nl'], //	数字	年龄（岁）
            'A15C' => $info['gj'],//	字符	国籍
            'A16' => $info['bzyzsnl'],//	数字	年龄不足1周岁的年龄（天）
            'A18' => $info['xsecstz'],//	list	新生儿出生体重
            'A18x01' => $info['xsecstz'],//	数字	新生儿出生体重（克）
            'A17' => $info['xserytz'],//	数字	新生儿入院体重（克）
            'A22' => $info['csd'],//	字符	出生地址
            'A23C' => self::getGg($info['gg']),//	字符	籍贯省（自治区、直辖市）
            'A19C' => self::getMz($info['mz']),//	字符	民族
            'A20' => $info['sfzh'],//	字符	身份证号
            'A38C' => self::getZy($info['zy']),//	字符	职业
            'A21C' => self::getHy($info['hy']),//	字符	婚姻
            'A26' => $info['xzz'],//	字符	现住址
            'A27' => $info['dh'],//	字符	现住址电话
            'A28C' => $info['yb1'],//	字符	现住址邮政编码
            'A24' => $info['hkdz'],//	字符	户口地址
            'A25C' => $info['yb2'],//	字符	户口地址邮政编码
            'A29' => $info['gzdwjdz'],//	字符	工作单位及地址
            'A30' => $info['dwdh'],//	字符	工作单位电话
            'A31C' => $info['yb3'],//	字符	工作单位邮政编码
            'A32' => $info['lxrxm'],//	字符	联系人姓名
            'A33C' => self::getGx($info['gx']),//	字符	联系人关系
            'A34' => $info['dz'],//	字符	联系人地址
            'A35' => $info['dh2'],//	字符	联系人电话
            'B11C' => self::getRytj($info['rytj']),//	字符	入院途径（取值：急诊、门诊、其他医疗机构转入、其他）
            'B12' => $info['rysj'],//	日期时间	入院时间
            'B13C' => self::getKb($info['rykb']),//	字符	入院科别
            'B14' => $info['rybfmc'],//	字符	入院病房
            'B21C' => $info['zkkb'],//	集合	转科科别
            'B15' => $info['cysj'],//	日期时间	出院时间
            'B16C' => self::getKb($info['cykb']),//	字符	出院科别
            'B17' => $info['cybfmc'],//	字符	出院病房
            'B20' => $info['sjzyts'],//	数字	实际住院（天）
            'C01-C02' => '',//$info['mzzd']	list	门（急）诊诊断
            'C01C' => $info['jbbm'],//	字符	门（急）诊诊断编码
            'C02N' => $info['mzzd'],//	字符	门（急）诊诊断名称
            'C04N' => $zyzd['zd_name'],//	字符	出院主要诊断名称
            'C03C' => $zyzd['jbdm'],//	字符	出院主要诊断编码
            'C05C' => self::getBq($zyzd['rybq']),//	字符	出院主要诊断入院病情
            'C06_C08' => '',//$qtzd	list	出院其他诊断
            'C06C' =>  $qtzd[0]['jbdm'],//	字符	出院其他诊断编码
            'C07N' => $qtzd[0]['zd_name'] ?? '',//	字符	出院其他诊断名称
            'C08C' => self::getBq($qtzd[0]['rybq'] ?? ''),//	字符	出院其他诊断入院病情
            'C13N' => $info['wbyy'],//	字符	损伤、中毒外部原因名称
            'C12C' => 'C73.xA008',//$info['h23']	字符	损伤、中毒外部原因编码
            'C10N' => $info['blzd'],//	字符	病理诊断名称
            'C09C' => 'C73.xA008',//$info['jbmm']	字符	病理诊断编码
            'C11' => $info['blh'],//字符	病理号
            'C24C' => $info['ywgm'] == '有' ? 2 : 1,//	字符	有无药物过敏
            'C25' => $info['gmyw'],//字符	过敏药物名称
            'C34C' => $info['swhzsj'] == '是' ? 1 : 2,//	字符	死亡患者尸检
            'C26C' => self::getXx($info['xx']),//	字符	ABO血型
            'C27C' => self::getRh($info['rh']),//	字符	Rh血型
            'B22' => $info['kzr'],//	字符	科主任
            'B23' => $info['zrys'],//	字符	主（副主）任医师
            'B24' => $info['zzys'],//	字符	主治医师
            'B25' => $info['zyys'],//	字符	住院医师
            'B26' => $info['zrhs'],//	字符	责任护士
            'B27' => $info['jxys'],//	字符	进修医师
            'B28' => $info['sxys'],//	字符	实习医师
            'B29' => $info['bmy'],//	字符	编码员
            'B30C' => self::getBazl($info['bazl']),//	字符	病案质量
            'B31' => $info['zkys'],//	字符	质控医师
            'B32' => $info['zkhs'],//	字符	质控护师
            'B33' => $info['zkrq'],//	日期	质控日期
            'C15N' => $ssInfo[0]['ssjczmc'] ?? '',//	字符	主要手术操作名称
            'C14C' => $ssInfo[0]['ssjczbm'] ?? '',//$ssInfo[0]['ssjczbm'] ?? 	字符	主要手术操作编码
            'C16' => $ssInfo[0]['ssjczrq'] ?? '',//	日期时间	主要手术操作日期
            'C17' => self::getSsjb($ssInfo[0]['ssjb'] ?? ''),//	字符	主要手术操作级别
            'C18' => $ssInfo[0]['sz'] ?? '',//	字符	主要手术操作术者
            'C19' => $ssInfo[0]['yz'] ?? '',//	字符	主要手术操作Ⅰ助
            'C20' => $ssInfo[0]['ez'] ?? '',//	字符	主要手术操作Ⅱ助
            'C21C' => self::getYhdj($ssInfo[0]['qkdj'] ?? ''),//	字符	主要手术操作切口愈合等级
            'C22C' => self::getMzfs($ssInfo[0]['mzfs'] ?? ''),//	字符	主要手术操作麻醉方式
            'C23' => $ssInfo[0]['mzys'] ?? '',//	字符	主要手术操作麻醉医师
            'C35_C44' => '',//	$ssInfolist	其他手术操作
            'C35C' => $ssInfo[1]['ssjczbm'] ?? '',//$ssInfo[1]['ssjczbm'] ?? 	字符	其他手术操作编码
            'C36N' => $ssInfo[1]['ssjczmc'] ?? '',//	字符	其他手术操作名称
            'C37' => $ssInfo[1]['ssjczrq'] ?? '',//	日期时间	其他手术操作日期
            'C38' => self::getSsjb($ssInfo[1]['ssjb'] ?? ''),//	字符	其他手术操作级别
            'C39' => $ssInfo[1]['sz'] ?? '',//	字符	其他手术操作术者
            'C40' => $ssInfo[1]['yz'] ?? '',//	字符	其他手术操作Ⅰ助
            'C41' => $ssInfo[1]['ez'] ?? '',//	字符	其他手术操作Ⅱ助
            'C42C' => self::getYhdj($ssInfo[1]['qkdj'] ?? '') ?? '',//	字符	其他手术操作切口愈合等级
            'C43C' => self::getMzfs($ssInfo[1]['mzfs'] ?? '') ?? '',//	字符	其他手术操作麻醉方式
            'C44' => $ssInfo[1]['mzys'] ?? '',//	字符	其他手术操作麻醉医师
            'B34C' => self::getLyfs($info['lyfs']),//	字符	离院方式（取值：医嘱离院、医嘱转院、医嘱转社区卫生服务机构/乡镇卫生院、非医嘱离院、死亡、其他）
            'B35' => $info['yzzy_yljg'] ?? '',//	字符	医嘱转院、转社区卫生服务机构/乡镇卫生院名称
            'B36C' => $info['sfzzyjh'] == '无' ? 1 : 2,//	数字	是否有出院31日内再住院计划
            'B37' => $info['md'] ?? '',//	字符	出院31天再住院计划目的
            'C28' => $info['ryq_t'],//	数字	颅脑损伤患者入院前昏迷时间（天）
            'C29' => $info['ryq_xs'],//	数字	颅脑损伤患者入院前昏迷时间（小时）
            'C30' => $info['ryq_f'],//	数字	颅脑损伤患者入院前昏迷时间（分钟）
            'C31' => $info['ryh_t'],//	数字	颅脑损伤患者入院后昏迷时间（天）
            'C32' => $info['ryh_xs'],//	数字	颅脑损伤患者入院后昏迷时间（小时）
            'C33' => $info['ryh_f'],//	数字	颅脑损伤患者入院后昏迷时间（分钟）
            'D01' => $info['zfy'],//	数字	住院总费用
            'D09' => $info['zfje'],//	数字	住院总费用其中自付金额
            'D11' => $info['ylfuf'],//	数字	1.一般医疗服务费
            'D12' => $info['zlczf'],//	数字	2.一般治疗操作费
            'D13' => $info['hlf'],//	数字	3.护理费
            'D14' => $info['ylfuf'],//	数字	4.综合医疗服务类其他费用
            'D15' => $info['blzdf'],//	数字	5.病理诊断费
            'D16' => $info['syszdf'],//	数字	6.实验室诊断费
            'D17' => $info['yxzdf'],//	数字	7.影像学诊断费
            'D18' => $info['lczdxmf'],//	数字	8.临床诊断项目费
            'D19' => $info['fsszlxmf'],//	数字	9.非手术治疗项目费
            'D19x01' => $info['wlzlf'],//	数字	其中：临床物理治疗费
            'D20' => $info['sszlf'],//	数字	10.手术治疗费
            'D20x01' => $info['maf'],//	数字	其中：麻醉费
            'D20x02' => $info['ssf'],//	数字	其中：手术费
            'D21' => $info['kff'],//	数字	11.康复费
            'D22' => $info['zyzlf'],//	数字	12.中医治疗费
            'D23' => $info['xyf'],//	数字	13.西药费
            'D23x01' => $info['kjywf'],//	数字	其中：抗菌药物费
            'D24' => $info['zcyf'],//	数字	14.中成药费
            'D25' => $info['zcyf1'],//	数字	15.中草药费
            'D26' => $info['xf'],//	数字	16.血费
            'D27' => $info['bdblzpf'],//	数字	17.白蛋白类制品费
            'D28' => $info['qdblzpf'],//	数字	18.球蛋白类制品费
            'D29' => $info['nxyzlzpf'],//	数字	19.凝血因子类制品费
            'D30' => $info['xpyzlzpf'],//	数字	20.细胞因子类制品费
            'D31' => $info['hcyyclf'],//	数字	21.检查用一次性医用材料费
            'D32' => $info['yyclf'],//	数字	22.治疗用一次性医用材料费
            'D33' => $info['ycxyyclf'],//	数字	23.手术用一次性医用材料费
            'D34' => $info['qtf'],//	数字	24.其他费：
        ];
        $data = json_encode($data);
        $header = array('Content-Type: application/json;charset=utf-8');
        $result = CommonController::sendWebservice($url, $data, $header);
        $result = json_decode($result, true);
        return $result;
    }

    public static function getZy($zy)
    {
        $data = [
            11 => '国家公务员',
            13 => '专业技术人',
            17 => '职员',
            21 => '企业管理人',
            24 => '工人',
            27 => '农民',
            31 => '学生',
            37 => '现役军人',
            51 => '自由职业者',
            54 => '个体经营者',
            70 => '无业人员',
            80 => '退（离）休',
            90 => '其他'];
        return array_search($zy, $data) ?? 90;
    }

    public static function getGg($gg)
    {
        $data = [
            1 => '北京市',
            10 => '江苏省',
            11 => '浙江省',
            12 => '安徽省',
            13 => '福建省',
            14 => '江西省',
            15 => '山东省',
            16 => '河南省',
            17 => '湖北省',
            18 => '湖南省',
            19 => '广东省',
            2 => '天津市',
            20 => '广西省',
            21 => '海南省',
            22 => '四川省',
            23 => '重庆市',
            24 => '贵州省',
            25 => '云南省',
            26 => '西藏',
            27 => '陕西省',
            28 => '甘肃省',
            29 => '青海省',
            3 => '河北省',
            30 => '宁夏',
            31 => '新疆',
            32 => '台湾',
            33 => '香港特别行政区',
            34 => '澳门',
            35 => '外籍',
            4 => '山西省',
            5 => '内蒙古',
            6 => '辽宁省',
            7 => '吉林省',
            8 => '黑龙江省',
            9 => '上海市',
        ];
        return array_search($gg, $data) ?? 35;
    }

    public static function getMz($mz)
    {
        $data = [
            1 => '汉族',
            10 => '朝鲜族',
            11 => '满族',
            12 => '侗族',
            13 => '瑶族',
            14 => '白族',
            15 => '土家族',
            16 => '哈尼族',
            17 => '哈萨克族',
            18 => '傣族',
            19 => '黎族',
            2 => '蒙古族',
            20 => '傈僳族',
            21 => '佤族',
            22 => '畲族',
            23 => '高山族',
            24 => '拉祜族',
            25 => '水族',
            26 => '东乡族',
            27 => '纳西族',
            28 => '景颇族',
            29 => '柯尔克孜族',
            3 => '回族',
            30 => '土族',
            31 => '达斡尔族',
            32 => '仫佬族',
            33 => '羌族',
            34 => '布朗族',
            35 => '撒拉族',
            36 => '毛难族',
            37 => '仡佬族',
            38 => '锡伯族',
            39 => '阿昌族',
            4 => '藏族',
            40 => '普米族',
            41 => '塔吉克族',
            42 => '怒族',
            43 => '乌孜别克族',
            44 => '俄罗斯族',
            45 => '鄂温克族',
            46 => '德昂族',
            47 => '保安族',
            48 => '裕固族',
            49 => '京族',
            5 => '维吾尔族',
            50 => '塔塔尔族',
            51 => '独龙族',
            52 => '鄂伦春族',
            53 => '赫哲族',
            54 => '门巴族',
            55 => '珞巴族',
            56 => '基诺族',
            6 => '苗族',
            66 => '其他',
            7 => '彝族',
            8 => '壮族',
            9 => '布依族	',
            99 => '外籍人士',
        ];
        return array_search($mz, $data) ?? 99;
    }

    public static function getXb($xb)
    {
        $data = [
            0 => '未知',
            1 => '男',
            2 => '女',
            9 => '未说明',
        ];
        return isset($data[$xb]) ? $xb : 9;
    }

    public static function getFffs($fffs)
    {
        $data = [
            '1.1' => '本市城镇职工基本医疗保险',
            '1.2' => '外埠城镇职工基本医疗保险',
            '2.1' => '本市城乡居民基本医疗保险',
            '2.2' => '外埠城镇居民基本医疗保险',
            '3.1' => '本市新型农村合作医疗',
            '3.2' => '外埠新型农村合作医疗',
            '4' => '贫困救助',
            '5' => '商业医疗保险',
            '6' => '全公费',
            '7' => '全自费',
            '8' => '其他社会保险',
            '9' => '其他',
        ];
        return array_search($fffs, $data) ?? '9';
    }

    public static function getHy($hy)
    {
        $data = [
            1 => '未婚',
            2 => '已婚',
            3 => '丧偶',
            4 => '离婚',
            9 => '其他',
        ];
        return array_search($hy, $data) ?? 9;
    }

    public static function getGx($gx)
    {
        $data = [
            0 => '本人或户主',
            1 => '配偶',
            2 => '子',
            3 => '女',
            4 => '孙子、孙女或外孙子、外孙女',
            5 => '父母',
            6 => '祖父母或外祖父母',
            7 => '兄弟姐妹',
            8 => '同事同学',
            9 => '其他',
        ];
        return array_search($gx, $data) ?? 9;
    }

    public static function getRytj($rytj)
    {
        $data = [
            1 => '急诊',
            2 => '门诊',
            3 => '其他医疗机构转入',
            9 => '其他',
        ];
        return array_search($rytj, $data) ?? 9;
    }

    public static function getKb($kb,$type = 1)
    {
        $data = [
            1 => '预防保健科',
            10 => '眼科',
            11 => '耳鼻咽喉科',
            1101 => '耳科专业',
            1102 => '鼻科专业',
            1103 => '咽喉科专业',
            1104 => '其他',
            12 => '口腔科',
            1201 => '口腔内科专业',
            1202 => '口腔颌面外科专业',
            1203 => '正畸专业',
            1204 => '口腔修复专业',
            1205 => '口腔预防保健专业',
            1206 => '其他',
            13 => '皮肤科',
            1301 => '皮肤病专业',
            1302 => '性传播疾病专业',
            1303 => '其他',
            14 => '医疗美容科',
            15 => '精神科',
            1501 => '精神病专业',
            1502 => '精神卫生专业',
            1503 => '药物依赖专业',
            1504 => '精神康复专业',
            1505 => '社区防治专业',
            1506 => '临床心理专业',
            1507 => '司法精神专业',
            1508 => '其他',
            16 => '传染科',
            1601 => '肠道传染病专业',
            1602 => '呼吸道传染病专业',
            1603 => '肝炎专业',
            1604 => '虫媒传染病专业',
            1605 => '动物源性传染病专业',
            1606 => '蠕虫病专业',
            1607 => '其它',
            17 => '结核病科',
            18 => '地方病科',
            19 => '肿瘤科',
            2 => '全科医疗科',
            20 => '急诊医学科',
            21 => '康复医学科',
            22 => '运动医学科',
            23 => '职业病科',
            2301 => '职业中毒专业',
            2302 => '尘肺专业',
            2303 => '放射病专业',
            2304 => '物理因素损伤专业',
            2305 => '职业健康监护专业',
            2306 => '其他',
            24 => '临终关怀科',
            25 => '特种医学与军事医学科',
            26 => '麻醉科',
            27 => '疼痛科',
            28 => '重症医学科',
            3 => '内科',
            30 => '医学检验科',
            3001 => '临床体液、血液专业',
            3002 => '临床微生物学专业',
            3003 => '临床生化检验专业',
            3004 => '临床免疫、血清学专业',
            3005 => '临床细胞分子遗传学专业',
            3006 => '其他',
            301 => '呼吸内科专业',
            302 => '消化内科专业',
            303 => '神经内科专业',
            304 => '心血管内科专业',
            305 => '血液内科专业',
            306 => '肾病学专业',
            307 => '内分泌专业',
            308 => '免疫学专业',
            309 => '变态反应专业',
            31 => '病理科',
            310 => '老年病专业',
            311 => '其他',
            32 => '医学影像科',
            3201 => 'X线诊断专业',
            3202 => 'CT诊断专业',
            3203 => '磁共振成像诊断专业',
            3204 => '核医学专业',
            3205 => '超声诊断专业',
            3206 => '心电诊断专业',
            3207 => '脑电及脑血流图诊断专业',
            3208 => '神经肌肉电图专业',
            3209 => '介入放射学专业',
            3210 => '放射治疗专业',
            3211 => '其他',
            4 => '外科',
            401 => '普通外科专业',
            40101 => '肝脏移植项目',
            40102 => '胰腺移植项目',
            40103 => '小肠移植项目',
            402 => '神经外科专业',
            403 => '骨科专业',
            404 => '泌尿外科专业',
            40401 => '肾脏移植项目',
            405 => '胸外科专业',
            40501 => '肺脏移植项目',
            406 => '心脏大血管外科专业',
            40601 => '心脏移植项目',
            407 => '烧伤科专业',
            408 => '整形外科专业',
            409 => '其他',
            5 => '妇产科',
            50 => '中医科',
            5001 => '内科专业',
            5002 => '外科专业',
            5003 => '妇产科专业',
            5004 => '儿科专业',
            5005 => '皮肤科专业',
            5006 => '眼科专业',
            5007 => '耳鼻咽喉科专业',
            5008 => '口腔科专业',
            5009 => '肿瘤科专业',
            501 => '妇科专业',
            5010 => '骨伤科专业',
            5011 => '肛肠科专业',
            5012 => '老年病科专业',
            5013 => '针灸科专业',
            5014 => '推拿科专业',
            5015 => '康复医学专业',
            5016 => '急诊科专业',
            5017 => '预防保健科专业',
            5018 => '其他',
            502 => '产科专业',
            503 => '计划生育专业',
            504 => '优生学专业',
            505 => '生殖健康与不孕症专业',
            506 => '其他',
            51 => '民族医学科',
            5101 => '维吾尔医学',
            5102 => '藏医学',
            5103 => '蒙医学',
            5104 => '彝医学',
            5105 => '傣医学',
            5106 => '其他',
            52 => '中西医结合科',
            6 => '妇女保健科',
            601 => '青春期保健专业',
            602 => '围产期保健专业',
            603 => '更年期保健专业',
            604 => '妇女心理卫生专业',
            605 => '妇女营养专业',
            606 => '其他',
            69 => '其他业务科室',
            7 => '儿科',
            701 => '新生儿专业',
            702 => '小儿传染病专业',
            703 => '小儿消化专业',
            704 => '小儿呼吸专业',
            705 => '小儿心脏病专业',
            706 => '小儿肾病专业',
            707 => '小儿血液病专业',
            708 => '小儿神经病学专业',
            709 => '小儿内分泌专业',
            710 => '小儿遗传病专业',
            711 => '小儿免疫专业',
            712 => '其他',
            8 => '小儿外科',
            801 => '小儿普通外科专业',
            802 => '小儿骨科专业',
            803 => '小儿泌尿外科专业',
            804 => '小儿胸心外科专业',
            805 => '小儿神经外科专业',
            806 => '其他',
            9 => '儿童保健科',
            901 => '儿童生长发育专业',
            902 => '儿童营养专业',
            903 => '儿童心理卫生专业',
            904 => '儿童五官保健专业',
            905 => '儿童康复专业',
            906 => '其他',
        ];
        if ($type == 2){
            return $data;
        }
        return isset($data[$kb]) ?$kb : 906;
    }

    public static function getBq($bq)
    {
        $data = [
            1 => '有',
            2 => '临床未确定',
            3 => '情况不明',
            4 => '无',
        ];
        return array_search($bq, $data) ?? 3;
    }

    public static function getXx($xx)
    {
        $data = [
            1 => 'A型',
            2 => 'B型',
            3 => 'O型',
            4 => 'AB型',
            5 => '不详',
            6 => '未查',
        ];
        return array_search($xx, $data) ?? 6;
    }

    public static function getRh($rh)
    {
        $data = [
            1 => '阴性',
            2 => '阳性',
            3 => '不详',
            4 => '未查',
        ];
        return array_search($rh, $data) ?? 4;
    }

    public static function getBazl($bazl)
    {
        $data = [
            1 => '甲',
            2 => '乙',
            3 => '丙',
        ];
        return array_search($bazl, $data) ?? 1;
    }

    public static function getSsjb($ssjb)
    {
        $data = [
            1 => '一级手术',
            2 => '二级手术',
            3 => '三级手术',
            4 => '四级手术',
        ];
        return array_search($ssjb, $data) ?? 4;
    }

    public static function getYhdj($yhdj)
    {
        $data = [
            0 => '有手术，但体表无切口',
            1 => 'Ⅰ/甲',
            10 => 'Ⅰ/其他',
            2 => 'Ⅰ/乙',
            20 => 'Ⅱ/其他',
            3 => 'Ⅰ/丙',
            30 => 'Ⅲ/其他',
            4 => 'Ⅱ/甲',
            5 => 'Ⅱ/乙',
            6 => 'Ⅱ/丙',
            7 => 'Ⅲ/甲',
            8 => 'Ⅲ/乙',
            9 => 'Ⅲ/丙',
        ];
        return array_search($yhdj, $data) ?? 0;
    }

    public static function getMzfs($mzfs)
    {
        $data = [
            1 => '全身麻醉',
            101 => '吸入麻醉 （气管内插管、喉罩、面罩）',
            102 => '静脉麻醉 （全凭静脉麻醉）',
            103 => '静吸复合麻醉',
            104 => '基础麻醉 （直肠注入、肌肉注射）',
            2 => '区域麻醉',
            201 => '椎管内麻醉',
            20101 => '蛛网膜下腔阻滞',
            20102 => '硬膜外间隙阻滞（含骶管阻滞）',
            20103 => '蛛网膜下-硬膜外复合麻醉',
            202 => '神经及神经丛阻滞',
            20201 => '颈丛阻滞',
            20202 => '臂丛阻滞及上肢神经阻滞',
            20203 => '腰骶神经丛阻滞及下肢神经阻滞',
            20204 => '躯干神经阻滞：肋间神经阻滞	',
            20205 => '椎旁神经阻滞',
            20206 => '会阴神经阻滞',
            20207 => '交感神经阻滞：星状神经节阻滞',
            20208 => '胸腰交感神经阻滞',
            20209 => '脑神经阻滞：三叉神经阻滞、舌咽神经阻滞',
            3 => '局部麻醉',
            301 => '表面麻醉',
            302 => '局部浸润麻醉',
            303 => '局部阻滞麻醉',
            304 => '静脉局部麻醉',
            4 => '针刺镇痛与麻醉',
            5 => '复合麻醉',
            501 => '不同药物的复合：普鲁卡因静脉复合全麻，神经安定镇痛麻醉等',
            502 => '不同方法的复合：静吸复合全麻，针药复合麻醉，全身-硬膜外复合麻醉，脊髓-硬膜外复合麻醉等',
            503 => '特殊方法的复合：全麻复合全身降温（低温麻醉）， 控制性降压等',
            99 => '其他',
        ];
        return array_search($mzfs, $data) ?? 99;
    }
    public static function getLyfs($lyfs) {
        $data = [
            1 => '医嘱离院',
            2 => '医嘱转院',
            3 => '医嘱转社区卫生服务机构/乡镇卫生院',
            4 => '非医嘱离院',
            5 => '死亡',
            9 => '其他',
        ];
        return array_search($lyfs, $data) ?? 9;
    }
}
