日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

患者信息SQL v1

發布時間:2025/3/20 数据库 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 患者信息SQL v1 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

selectCASE a.appointment_state WHEN -1 THEN '' ELSE '' END AS returnFlag, -- 是否退號CASE a.is_appoint_resource WHEN 0 THEN '' WHEN 1 THEN '' END as isAppointResource, -- 是否指定醫生a.create_time as guaHaoTime, -- 掛號時間p.create_time as createDocTime, -- '建檔時間'-- 掛號實收金額round((f.preFee - f.discountFee - f.promotionBenefitFee - f.couponFee - f.itemBenefitFee - f.memberCardBenefitFee - f.itemComInvBenefitFee) * f.discount,2) AS realFee, round(t1.realFee,2) as menZenRealMoney, -- 門診實收金額j.outpatient_number as blNumber, -- 病歷號p.name as patientName, -- 患者姓名a.dept_name, -- 科室名稱a.appointment_doctor_name as doctorName, -- 醫生CASE a.subsequent_visit -- 初復診WHEN 0 THEN '初診' WHEN 1 THEN '復診' WHEN 2 THEN '轉診' WHEN 3 THEN '急診' WHEN 4 THEN '體檢'WHEN 5 THEN '簡易'WHEN 6 THEN '疫苗' END AS isReVisit, -- 初復診channel.name as sourceName, -- 信息(渠道)來源p.birthday, -- 出生日期if(i.id_no is null, if(i.other_type is null, null,(select e.name from `thc_warehouse`.`sys_type_info` e JOIN `thc_warehouse`.`sys_type` f ON e.sys_type_id = f.idWHERE f.`code` = 'THC_WH_PERSON_CARD' and e.value = i.other_type)), '身份證') as cardType, -- 證件類型if(i.id_no is null,i.other_no,i.id_no) as cardNo, -- 證件號碼 p.address, -- 住址p.household, -- 戶籍p.household_address, -- 區(戶口所在地) a.patient_phone, -- 患者電話號a.creator, -- 掛號員(select t.docname from (SELECT u.clinic_id AS clinicid, u.id AS docid,u1.property_value AS docnameFROM thc_warehouse.staff_record uLEFT JOIN thc_warehouse.staff_record_property u1 ON u1.property_code = 'SXX000083' AND u.id = u1.staff_record_id) t where t.docid = a.creator and a.dept_id = t.clinicid) AS creater2,a.appointment_starttime, -- 預約時間CONCAT(a.`appointment_date`," ",a.appointment_starttime) as startTime,CONCAT(a.`appointment_date`," ",a.appointment_endtime) as endTime,a.dept_id, -- 部門IDa.orderId, -- 訂單IDa.order_item_id, -- 訂單明細ida.medical_card_number, -- 社保卡號 a.description, -- 備注CASE a.data_source WHEN 1 THEN '網站' WHEN 2 THEN 'APP' END as dataSource -- 數據來源 from `thc_arrange`.`bpm_appointment` a inner join `thc_sob`.`bpm_service_order` b on a.orderId = b.id inner join `thc_sob`.`bpm_service_order_item` c on c.service_order_id = b.id and c.id = a.order_item_id inner join `thc_rcm`.`Cs_AccountBill` d on d.orderID = b.id and d.`isDelete` = 0 and d.orderSource = 1 and d.orderType = 3 and d.returnFlag = 0 inner join `thc_rcm`.`Cs_AccountBillDetail` e on d.id = e.AccountBillId and e.itemClass = 1 and e.returnFlag is NULL inner join `thc_rcm`.`Cs_SettlementDetail` f on f.accountBillID = d.id and f.accountBillDetailID = e.id inner join `thc_rcm`.`Cs_Settlement` g on g.id = f.settlementID and g.settlementType=2 and g.`isDelete` = 0 and g.returnFlag = 0 -- 門診掛號 inner join `thc_passport`.`patient` p on a.patient_id = p.idleft join (select aa.id,round((ff.preFee - ff.discountFee - ff.promotionBenefitFee - ff.couponFee - ff.itemBenefitFee - ff.memberCardBenefitFee - ff.itemComInvBenefitFee) * ff.discount,2) AS realFeefrom `thc_arrange`.`bpm_appointment` aainner join `thc_sob`.`bpm_service_order` b on aa.orderId = b.idinner join `thc_sob`.`bpm_service_order_item` cc on cc.service_order_id = b.id and cc.id = aa.`order_item_id`inner join `thc_rcm`.`Cs_AccountBill` dd on dd.orderID = b.id and dd.`isDelete` = 0 and dd.orderSource = 1 and dd.orderType = 3 and dd.returnFlag = 0inner join `thc_rcm`.`Cs_AccountBillDetail` ee on dd.id = ee.AccountBillId and ee.itemClass = 1 and ee.returnFlag is NULLinner join `thc_rcm`.`Cs_SettlementDetail` ff on ff.accountBillID = dd.id and ff.accountBillDetailID = ee.idinner join `thc_rcm`.`Cs_Settlement` gg on gg.id = ff.settlementID and gg.`isDelete` = 0 and gg.returnFlag = 0 -- 門診掛號and gg.settlementType=1 -- 非掛號消費類型where 1=1 and aa.del_flag = 0 ) t1 on a.id = t1.idleft join `thc_c_union`.`member_channel` channel on a.channel_id = channel.id left join `thc_passport`.`contact` i on a.patient_id = i.patient_id left join `thc_passport`.`patient_org` j on a.patient_id = j.patient_id

?

?

?

?

SQLV2.0 20181223星期日晚

selectCASE a.appointment_state WHEN -1 THEN '' ELSE '' END AS returnFlag, -- 是否退號CASE a.is_appoint_resource WHEN 0 THEN '' WHEN 1 THEN '' END as isAppointResource, -- 是否指定醫生a.create_time as guaHaoTime, -- 掛號時間p.create_time as createDocTime, -- '建檔時間'-- 掛號實收金額round((f.preFee - f.discountFee - f.promotionBenefitFee - f.couponFee - f.itemBenefitFee - f.memberCardBenefitFee - f.itemComInvBenefitFee) * f.discount,2) AS realFee, round(t1.realFee,2) as menZenRealMoney, -- 門診實收金額j.outpatient_number as blNumber, -- 病歷號p.name as patientName, -- 患者姓名a.dept_name, -- 科室名稱a.appointment_doctor_name as doctorName, -- 醫生CASE a.subsequent_visit -- 初復診WHEN 0 THEN '初診' WHEN 1 THEN '復診' WHEN 2 THEN '轉診' WHEN 3 THEN '急診' WHEN 4 THEN '體檢'WHEN 5 THEN '簡易'WHEN 6 THEN '疫苗' END AS isReVisit, -- 初復診channel.name as sourceName, -- 信息(渠道)來源p.birthday, -- 出生日期if(i.id_no is null, if(i.other_type is null, null,(select e.name from `thc_warehouse`.`sys_type_info` e JOIN `thc_warehouse`.`sys_type` f ON e.sys_type_id = f.idWHERE f.`code` = 'THC_WH_PERSON_CARD' and e.value = i.other_type)), '身份證') as cardType, -- 證件類型if(i.id_no is null,i.other_no,i.id_no) as cardNo, -- 證件號碼 p.address, -- 住址if(p.address is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.address,'$.province'))) as province,if(p.address is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.address,'$.city'))) as city,if(p.address is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.address,'$.county'))) as county,if(p.address is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.address,'$.addressDetail'))) as addressDetail,-- 戶籍if(p.household is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.household,'$.province'))) as province2,if(p.household is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.household,'$.city'))) as city2,if(p.household is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.household,'$.county'))) as county2,if(p.household is null,null, TRIM(BOTH '"' FROM JSON_EXTRACT(p.household,'$.addressDetail'))) as addressDetail2,p.household, -- 戶籍 p.household_address, -- 區(戶口所在地) a.patient_phone, -- 患者電話號a.creator, -- 掛號員(select t.docname from (SELECT u.clinic_id AS clinicid, u.id AS docid,u1.property_value AS docnameFROM thc_warehouse.staff_record uLEFT JOIN thc_warehouse.staff_record_property u1 ON u1.property_code = 'SXX000083' AND u.id = u1.staff_record_id) t where t.docid = a.creator and a.dept_id = t.clinicid) AS creater2,a.appointment_starttime, -- 預約時間CONCAT(a.`appointment_date`," ",a.appointment_starttime) as startTime,CONCAT(a.`appointment_date`," ",a.appointment_endtime) as endTime,a.dept_id, -- 部門IDa.orderId, -- 訂單IDa.order_item_id, -- 訂單明細ida.medical_card_number, -- 社保卡號 a.description, -- 備注CASE a.data_source WHEN 1 THEN '網站' WHEN 2 THEN 'APP' END as dataSource -- 數據來源 from `thc_arrange`.`bpm_appointment` a inner join `thc_sob`.`bpm_service_order` b on a.orderId = b.id inner join `thc_sob`.`bpm_service_order_item` c on c.service_order_id = b.id and c.id = a.order_item_id inner join `thc_rcm`.`Cs_AccountBill` d on d.orderID = b.id and d.`isDelete` = 0 and d.orderSource = 1 and d.orderType = 3 and d.returnFlag = 0 inner join `thc_rcm`.`Cs_AccountBillDetail` e on d.id = e.AccountBillId and e.itemClass = 1 and e.returnFlag is NULL inner join `thc_rcm`.`Cs_SettlementDetail` f on f.accountBillID = d.id and f.accountBillDetailID = e.id inner join `thc_rcm`.`Cs_Settlement` g on g.id = f.settlementID and g.settlementType=2 and g.`isDelete` = 0 and g.returnFlag = 0 -- 門診掛號 inner join `thc_passport`.`patient` p on a.patient_id = p.idleft join (select aa.id,round((ff.preFee - ff.discountFee - ff.promotionBenefitFee - ff.couponFee - ff.itemBenefitFee - ff.memberCardBenefitFee - ff.itemComInvBenefitFee) * ff.discount,2) AS realFeefrom `thc_arrange`.`bpm_appointment` aainner join `thc_sob`.`bpm_service_order` b on aa.orderId = b.idinner join `thc_sob`.`bpm_service_order_item` cc on cc.service_order_id = b.id and cc.id = aa.`order_item_id`inner join `thc_rcm`.`Cs_AccountBill` dd on dd.orderID = b.id and dd.`isDelete` = 0 and dd.orderSource = 1 and dd.orderType = 3 and dd.returnFlag = 0inner join `thc_rcm`.`Cs_AccountBillDetail` ee on dd.id = ee.AccountBillId and ee.itemClass = 1 and ee.returnFlag is NULLinner join `thc_rcm`.`Cs_SettlementDetail` ff on ff.accountBillID = dd.id and ff.accountBillDetailID = ee.idinner join `thc_rcm`.`Cs_Settlement` gg on gg.id = ff.settlementID and gg.`isDelete` = 0 and gg.returnFlag = 0 -- 門診掛號and gg.settlementType=1 -- 非掛號消費類型where 1=1 and aa.del_flag = 0 ) t1 on a.id = t1.idleft join `thc_c_union`.`member_channel` channel on a.channel_id = channel.id left join `thc_passport`.`contact` i on a.patient_id = i.patient_id left join `thc_passport`.`patient_org` j on a.patient_id = j.patient_id

?

轉載于:https://www.cnblogs.com/guchunchao/p/10164925.html

總結

以上是生活随笔為你收集整理的患者信息SQL v1的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。