<?php

namespace app\common\api;

use think\facade\Db;

/**
 * Description of Nhc
 * 卫健相关数据接口
 * @author sgq
 */
class Nhc {

    /**
     * 获取医共体列表，按正序排
     * @return type
     */
    public static function getMedicalCommunityList() {
        $where = [];
        $where[] = ["status", "<>", 3];
        $list = Db::table("nhc_medical_community")->where($where)->order("num asc,createTime asc")->select()->toArray();
        return $list;
    }

    /**
     * 获取医共体键值对id,name
     * @return type
     */
    public static function getMedicalCommunityMap() {
        $list = Db::table("nhc_medical_community")->column("name", "id");
        return $list;
    }

    public static function hasGeneralHospital($medicalCommunityId) {
        $where = [];
        $where[] = ["type", "=", \app\common\state\CommonConst::ENTERPRISE_WJ];
        $where[] = ["medicalCommunityId", "=", $medicalCommunityId];
        $where[] = ["isGeneral", "=", 1];
        $where[] = ["checkState", "=", 3];
        $where[] = ["active", "=", 1];
        $where[] = ["delete", "=", 0];
        return \app\admin\model\Enterprise::where($where)->findOrEmpty()->toArray();
    }

}
