患者信息SQL v1
select
CASE 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.id
WHERE 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 docname
FROM thc_warehouse.staff_record u
LEFT 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, -- 部门ID
a.orderId, -- 订单ID
a.order_item_id, -- 订单明细id
a.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.id left join
(
select
aa.id,
round((ff.preFee - ff.discountFee - ff.promotionBenefitFee - ff.couponFee - ff.itemBenefitFee - ff.memberCardBenefitFee - ff.itemComInvBenefitFee) * ff.discount,2) AS realFee
from `thc_arrange`.`bpm_appointment` aa
inner join `thc_sob`.`bpm_service_order` b on aa.orderId = b.id
inner 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 = 0
inner join `thc_rcm`.`Cs_AccountBillDetail` ee on dd.id = ee.AccountBillId and ee.itemClass = 1 and ee.returnFlag is NULL
inner join `thc_rcm`.`Cs_SettlementDetail` ff on ff.accountBillID = dd.id and ff.accountBillDetailID = ee.id
inner 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.id left 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星期日晚
select
CASE 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.id
WHERE 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 docname
FROM thc_warehouse.staff_record u
LEFT 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, -- 部门ID
a.orderId, -- 订单ID
a.order_item_id, -- 订单明细id
a.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.id left join
(
select
aa.id,
round((ff.preFee - ff.discountFee - ff.promotionBenefitFee - ff.couponFee - ff.itemBenefitFee - ff.memberCardBenefitFee - ff.itemComInvBenefitFee) * ff.discount,2) AS realFee
from `thc_arrange`.`bpm_appointment` aa
inner join `thc_sob`.`bpm_service_order` b on aa.orderId = b.id
inner 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 = 0
inner join `thc_rcm`.`Cs_AccountBillDetail` ee on dd.id = ee.AccountBillId and ee.itemClass = 1 and ee.returnFlag is NULL
inner join `thc_rcm`.`Cs_SettlementDetail` ff on ff.accountBillID = dd.id and ff.accountBillDetailID = ee.id
inner 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.id left 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
患者信息SQL v1的更多相关文章
- PHP基础示例:商品信息管理系统v1.1
实现目标:使用php和mysql写一个商品信息管理系统,并带有购物车功能 一.创建数据库和表 1.创建数据库和表:demodb 2.创建表格:goods 字段:商品编号,商品名称,商品类型,商品图片, ...
- 获取客户信息SQL
/*取客户信息SQL*/ --客户信息 SELECT hou.name 业务实体, hca.account_number 客户编号, hp.party_name 客户名称, arp_addr_pkg. ...
- DedeCMS版权信息SQL命令删除
dedecms织梦系统底部会自动带有官方链接power by dedecms字样,很多新用户想去除官方的链接,底部调用标签为{dede:global.cfg_poweby/},方法很多,但不鼓励大家删 ...
- PHP基础示例:商品信息管理系统v1.1[转]
实现目标:使用php和mysql写一个商品信息管理系统,并带有购物车功能 一.创建数据库和表 1.创建数据库和表:demodb 2.创建表格:goods 字段:商品编号,商品名称,商品类型,商品图 ...
- 供应商和管理员查看供应商地址簿信息SQL
--管理员查看地址簿 SELECT hps.party_site_id, hps.party_site_name AS address_name, 'CURRENT' AS status, hzl.a ...
- 学生信息管理系统v1.0
昨天一个教师朋友找到我,告诉我现在学期末他工作比较忙.需要统计处理很多学生信息,想让我帮他做一个管理系统.实现的功能就是把WPS表格转化成Word文档,将每一个学生的信息都能够分开,并且要根据名字找到 ...
- Oracle EBS-SQL (SYS-13):查询DBA在系统中的打Patch的信息.SQL
查询DBA在系统中的打补丁信息 1. select * from ad_patch_drivers /*查看已经打了哪些Patch*/ 2. select * from ad_pat ...
- SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享
1. 查询所有存储过程 1 select Pr_Name as [存储过程], [参数]=stuff((select ','+[Parameter] 2 from ( 3 select Pr.Name ...
- mysql查看锁等信息SQL
查看锁等信息,包括锁信息: select "HOLD:",ph.id h_processid,trh.trx_id h_trx_id,trh.trx_started h_start ...
随机推荐
- ubuntu配置mysql
1.安装mysql: sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install ...
- Python3 与 C# 基础语法对比(String专栏)
Code:https://github.com/lotapp/BaseCode 多图旧排版:https://www.cnblogs.com/dunitian/p/9119986.html 在线编程 ...
- PHP选择排序算法
说明: 通过假设一个最小数的key,来逐个比较后面的值,如果假设的值大于后面的值,则互换位置. 示例: <?php $a = array(2,13,42,34,56,23,67,365,8766 ...
- js怎么获取微信浏览器内容的高度
通过window对象来得到窗口相关的内外款高度信息,如下: outerHeight属性设置或返回一个窗口的外部高度,包括所有界面元素(如工具栏/滚动条).outerWidth属性设置或返回窗口的外部宽 ...
- 大型游戏案例UI开发总结_1
Canvas(画布)中选择Render Mode----Screen Space Camera,为了在摄像机和UI画布之间放置3D物体. Camera中的Projection选择Orthographi ...
- nginx搭建分布式简单配置
1.下载安装nginx 2.编辑nginx.conf文件 upstream 172.100.10.52 { ip_hash; #保证每一个用户访问同一个网站 server 172.100.10.21: ...
- 点赞功能与redis
转:https://edu.aliyun.com/a/20538 摘要: 前言点赞其实是一个很有意思的功能.基本的设计思路有大致两种, 一种自然是用mysql等数据库直接落地存储, 另外一种就是利用点 ...
- (Prim算法)codeVs 1078 最小生成树
题目描述 Description 农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场.当然,他需要你的帮助. 约翰已经给他的农场安排了一条高速的网络线路,他想把这 ...
- node.js(node.js+mongoose小案例)_实现简单的注册登录退出
一.前言 通过node.js基本知识对node.js基本知识的一个简单应用 1.注册 2.登录 3.退出 二.基本内容 1.项目结构搭建如图所示 2.这个小案列中用到了art-template子模板以 ...
- vue购物车和地址选配(三)
参考资料:vue.js官网 项目演示: 项目源代码: 核心代码及踩坑 删除: new Vue({ el:'#app', data:{ productlist:[], totalMoney:0, che ...