|
@@ -45,8 +45,9 @@ class InstitutionModel extends ZskkDefaultModel {
|
|
|
|
|
|
|
|
public function getRemoteIns($id)
|
|
public function getRemoteIns($id)
|
|
|
{
|
|
{
|
|
|
- $info = RcontactModel::where('hospital_id',$id)->column('super_hospital_id');
|
|
|
|
|
- return $info;
|
|
|
|
|
|
|
+ $info = RcontactModel::where('hospital_id',$id)->select();
|
|
|
|
|
+ $data = array_column($info,'super_hospital_id');
|
|
|
|
|
+ return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getSpecialIns()
|
|
public function getSpecialIns()
|
|
@@ -60,19 +61,44 @@ class InstitutionModel extends ZskkDefaultModel {
|
|
|
|
|
|
|
|
public function getDoctor($id,$class,$remote)
|
|
public function getDoctor($id,$class,$remote)
|
|
|
{
|
|
{
|
|
|
|
|
+// $info = DoctorModel::alias('d')
|
|
|
|
|
+// ->join('doctor_class dc','dc.doctor_id=d.id and find_in_set("7", dc.doctor_class)')
|
|
|
|
|
+// ->join('remote_cost rc',"rc.super_doctor_id=d.id and rc.exam_class='".$class."' and super_hospital_id=d.institution_id and hospital_id='".$remote."'")
|
|
|
|
|
+// ->where('d.institution_id',$id)
|
|
|
|
|
+// ->where('d.is_admin','1')
|
|
|
|
|
+// ->field('d.id,d.institution_id AS hid,d.realname,convert(rc.money/100,decimal(10,2)) AS cost,introduce,null AS scid,null AS sid')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+// if(empty(json_decode(json_encode($info),true))){
|
|
|
|
|
+// $info = DoctorModel::alias('d')
|
|
|
|
|
+// ->join('doctor_class dc','dc.doctor_id=d.id and find_in_set("7", dc.doctor_class)')
|
|
|
|
|
+// ->join('remote_cost rc',"rc.super_doctor_id=d.id and rc.exam_class='".$class."' and super_hospital_id=d.institution_id and hospital_id='".$remote."'")
|
|
|
|
|
+// ->where('d.institution_id',$id)
|
|
|
|
|
+// ->field('d.id,d.institution_id AS hid,realname,d.introduce,convert(rc.money/100,decimal(10,2)) AS cost,null AS scid,null AS sid')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+// }
|
|
|
$info = DoctorModel::alias('d')
|
|
$info = DoctorModel::alias('d')
|
|
|
- ->join('doctor_class dc','dc.doctor_id=d.id and find_in_set("7", dc.doctor_class)')
|
|
|
|
|
- ->join('remote_cost rc',"rc.super_doctor_id=d.id and rc.exam_class='".$class."' and super_hospital_id=d.institution_id and hospital_id='".$remote."'")
|
|
|
|
|
- ->where('d.institution_id',$id)
|
|
|
|
|
- ->where('d.is_admin','1')
|
|
|
|
|
- ->field('d.id,d.institution_id AS hid,d.realname,convert(rc.money/100,decimal(10,2)) AS cost,introduce,null AS scid,null AS sid')
|
|
|
|
|
|
|
+ // 达梦没有 FIND_IN_SET,改用 POSITION 或 LIKE,或提前创建自定义函数
|
|
|
|
|
+ // 方案1:用 POSITION 替代(推荐,无需创建函数)
|
|
|
|
|
+ ->join('doctor_class dc', "dc.doctor_id = d.id AND (',' || dc.doctor_class || ',') LIKE '%,7,%'", 'inner')
|
|
|
|
|
+
|
|
|
|
|
+ ->join('remote_cost rc', "rc.super_doctor_id = d.id AND rc.exam_class = '" . $class . "' AND rc.super_hospital_id = d.institution_id AND rc.hospital_id = '" . $remote . "'", 'inner')
|
|
|
|
|
+
|
|
|
|
|
+ ->where('d.institution_id', $id)
|
|
|
|
|
+ ->where('d.is_admin', '1')
|
|
|
|
|
+
|
|
|
|
|
+ // 达梦 CAST 语法:CAST(value AS DECIMAL(10,2))
|
|
|
|
|
+ // 注意:达梦整数相除默认取整,需要把分母写成 100.0
|
|
|
|
|
+ ->field("d.id, d.INSTITUTION_ID AS hid, d.realname, CAST(rc.money / 100.0 AS DECIMAL(10,2)) AS cost, introduce, null AS scid, null AS sid")
|
|
|
|
|
+
|
|
|
->select();
|
|
->select();
|
|
|
- if(empty(json_decode(json_encode($info),true))){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (empty(json_decode(json_encode($info), true))) {
|
|
|
$info = DoctorModel::alias('d')
|
|
$info = DoctorModel::alias('d')
|
|
|
- ->join('doctor_class dc','dc.doctor_id=d.id and find_in_set("7", dc.doctor_class)')
|
|
|
|
|
- ->join('remote_cost rc',"rc.super_doctor_id=d.id and rc.exam_class='".$class."' and super_hospital_id=d.institution_id and hospital_id='".$remote."'")
|
|
|
|
|
- ->where('d.institution_id',$id)
|
|
|
|
|
- ->field('d.id,d.institution_id AS hid,realname,d.introduce,convert(rc.money/100,decimal(10,2)) AS cost,null AS scid,null AS sid')
|
|
|
|
|
|
|
+ ->join('doctor_class dc', "dc.doctor_id = d.id AND (',' || dc.doctor_class || ',') LIKE '%,7,%'", 'inner')
|
|
|
|
|
+ ->join('remote_cost rc', "rc.super_doctor_id = d.id AND rc.exam_class = '" . $class . "' AND rc.super_hospital_id = d.institution_id AND rc.hospital_id = '" . $remote . "'", 'inner')
|
|
|
|
|
+ ->where('d.institution_id', $id)
|
|
|
|
|
+ // 达梦 CAST 语法,整数除法用 100.0
|
|
|
|
|
+ ->field("d.id, d.INSTITUTION_ID AS hid, realname, d.introduce, CAST(rc.money / 100.0 AS DECIMAL(10,2)) AS cost, null AS scid, null AS sid")
|
|
|
->select();
|
|
->select();
|
|
|
}
|
|
}
|
|
|
return $info;
|
|
return $info;
|