Commit b5e48a89 authored by 陶书衡's avatar 陶书衡

init

parents
Pipeline #268 failed with stages
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@122.112.141.214" uuid="9e128027-e8b1-416f-a302-28144e029dfb">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://122.112.141.214:3306</jdbc-url>
<vm-options>&quot;-Djdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, DH keySize &lt; 1024, EC keySize &lt; 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves&quot;</vm-options>
<working-dir>$ProjectFileDir$</working-dir>
<driver-properties>
<property name="enabledTLSProtocols" value="TLSv1, TLSv1.1, TLSv1.2, TLSv1.3" />
</driver-properties>
</data-source>
<data-source source="LOCAL" name="@47.102.207.72" uuid="5454eab1-3548-4bfb-bf5e-936bf7fdae82">
<driver-ref>mongo</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.dbschema.MongoJdbcDriver</jdbc-driver>
<jdbc-url>mongodb://47.102.207.72:27017</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="147" name="Python" />
</Languages>
</inspection_tool>
<inspection_tool class="JupyterKernelInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JupyterPackageInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="47">
<item index="0" class="java.lang.String" itemvalue="h5py" />
<item index="1" class="java.lang.String" itemvalue="six" />
<item index="2" class="java.lang.String" itemvalue="keras-bert" />
<item index="3" class="java.lang.String" itemvalue="keras-transformer" />
<item index="4" class="java.lang.String" itemvalue="absl-py" />
<item index="5" class="java.lang.String" itemvalue="google-pasta" />
<item index="6" class="java.lang.String" itemvalue="protobuf" />
<item index="7" class="java.lang.String" itemvalue="decorator" />
<item index="8" class="java.lang.String" itemvalue="tensorflow-estimator" />
<item index="9" class="java.lang.String" itemvalue="joblib" />
<item index="10" class="java.lang.String" itemvalue="threadpoolctl" />
<item index="11" class="java.lang.String" itemvalue="opt-einsum" />
<item index="12" class="java.lang.String" itemvalue="scikit-learn" />
<item index="13" class="java.lang.String" itemvalue="PyYAML" />
<item index="14" class="java.lang.String" itemvalue="cycler" />
<item index="15" class="java.lang.String" itemvalue="gast" />
<item index="16" class="java.lang.String" itemvalue="numpy" />
<item index="17" class="java.lang.String" itemvalue="importlib-metadata" />
<item index="18" class="java.lang.String" itemvalue="Keras-Preprocessing" />
<item index="19" class="java.lang.String" itemvalue="tensorflow" />
<item index="20" class="java.lang.String" itemvalue="Pygments" />
<item index="21" class="java.lang.String" itemvalue="pyzmq" />
<item index="22" class="java.lang.String" itemvalue="certifi" />
<item index="23" class="java.lang.String" itemvalue="prompt-toolkit" />
<item index="24" class="java.lang.String" itemvalue="cached-property" />
<item index="25" class="java.lang.String" itemvalue="Markdown" />
<item index="26" class="java.lang.String" itemvalue="scipy" />
<item index="27" class="java.lang.String" itemvalue="Werkzeug" />
<item index="28" class="java.lang.String" itemvalue="opencv-python" />
<item index="29" class="java.lang.String" itemvalue="parso" />
<item index="30" class="java.lang.String" itemvalue="wrapt" />
<item index="31" class="java.lang.String" itemvalue="astor" />
<item index="32" class="java.lang.String" itemvalue="ipython" />
<item index="33" class="java.lang.String" itemvalue="kiwisolver" />
<item index="34" class="java.lang.String" itemvalue="typing-extensions" />
<item index="35" class="java.lang.String" itemvalue="jupyter-client" />
<item index="36" class="java.lang.String" itemvalue="ipykernel" />
<item index="37" class="java.lang.String" itemvalue="Keras-Applications" />
<item index="38" class="java.lang.String" itemvalue="appnope" />
<item index="39" class="java.lang.String" itemvalue="pandas" />
<item index="40" class="java.lang.String" itemvalue="termcolor" />
<item index="41" class="java.lang.String" itemvalue="tensorboard" />
<item index="42" class="java.lang.String" itemvalue="matplotlib" />
<item index="43" class="java.lang.String" itemvalue="grpcio" />
<item index="44" class="java.lang.String" itemvalue="Keras" />
<item index="45" class="java.lang.String" itemvalue="pytz" />
<item index="46" class="java.lang.String" itemvalue="Pillow" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E501" />
<option value="E122" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N803" />
</list>
</option>
</inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (DB-base)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mongodb2mysql.iml" filepath="$PROJECT_DIR$/.idea/mongodb2mysql.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.7 (DB-base)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlResolveMappings">
<file url="file://$PROJECT_DIR$/get_json.py" scope="{&quot;node&quot;:{ &quot;@negative&quot;:&quot;1&quot;, &quot;group&quot;:{ &quot;@kind&quot;:&quot;root&quot;, &quot;node&quot;:{ &quot;@negative&quot;:&quot;1&quot; } } }}" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
name: DB-base
channels:
- defaults
dependencies:
- ca-certificates=2021.7.5=hecd8cb5_1
- certifi=2021.5.30=py37hecd8cb5_0
- libcxx=12.0.0=h2f01273_0
- libffi=3.3=hb1e8313_2
- ncurses=6.2=h0a44026_1
- openssl=1.1.1l=h9ed2024_0
- pip=21.0.1=py37hecd8cb5_0
- python=3.7.11=h88f2d9e_0
- readline=8.1=h9ed2024_0
- setuptools=52.0.0=py37hecd8cb5_0
- sqlite=3.36.0=hce871da_0
- tk=8.6.10=hb0a8c7a_0
- wheel=0.37.0=pyhd3eb1b0_1
- xz=5.2.5=h1de35cc_0
- zlib=1.2.11=h1de35cc_3
- pip:
- pymongo==3.12.0
- pymysql==1.0.2
prefix: /Users/Bureaux/miniconda3/envs/DB-base
This diff is collapsed.
import json
import pymysql
import time
def save(filename, contents):
fh = open(filename, 'w', encoding = 'utf-8')
fh.write(contents)
fh.close()
mysqldb = pymysql.connect(host = '122.112.141.214', user = 'chyy_demo', passwd = 'Waw8DXh3fJJ-', port = 3306,
db = 'shchyy',
charset = 'utf8')
mysqlcur = mysqldb.cursor() # 生成游标对象
# SQL语句
sql = """
SELECT a.number,a.name,b.area FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省');
""" # id,name,ename
mysqlcur.execute(sql)
i = 0
rows = mysqlcur.fetchall()
timestamp = int(time.time())
hosp_list = []
for row in rows: # 循环处理所有记录
jsonS = ""
i = i + 1
jsonS = jsonS + "{\"_id\":{\"$oid\":\"" + str(timestamp) + str(i).rjust(14,
'0') + "\"}" # 5e,00,30,d0,/2b,85,a7,/76,e1,9c,50,98
jsonS = jsonS + ",\"_class\":\"com.ewell.bean.HospitalBean\"" #
jsonS = jsonS + ",\"hospitalId\":\"" + str(i).rjust(7, '0') + "-" + str(timestamp) + "\"" # 0000001-1577070800036
jsonS = jsonS + ",\"hospitalName\":\"" + row[1] + "\"" # 上海市浦东新区公利医院
jsonS = jsonS + ",\"shortName\":\"\"" #
jsonS = jsonS + ",\"hospitalNumber\":\"" + str(i).rjust(7, '0') + "\"" # 0000001
jsonS = jsonS + ",\"ownership\":\"公立\"" #
jsonS = jsonS + ",\"mechanismCategory\":\"综合\"" #
jsonS = jsonS + ",\"hospitalRank\":\"二级\"" #
jsonS = jsonS + ",\"hospitalHierarchy\":\"甲等\"" #
jsonS = jsonS + ",\"provinceId\":\"\"" #
jsonS = jsonS + ",\"provinceName\":\"\"" #
jsonS = jsonS + ",\"prefectureId\":\"\"" #
jsonS = jsonS + ",\"prefectureName\":\"\"" #
jsonS = jsonS + ",\"handler\":\"tsh\"" #
jsonS = jsonS + ",\"isUse\":{\"$numberInt\":\"1\"}" #
jsonS = jsonS + ",\"createTime\":\"" + time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(timestamp)) + "\"" # 2019-12-23 11:13:20
jsonS = jsonS + ",\"createUser\":{\"userId\":\"superadmin\",\"name\":\"超级管理员\"}}" #
data = json.loads(jsonS)
hosp_list.append(data)
print(data)
save('/Users/Bureaux/Documents/workspace/PyCharmProjects/mongodb2mysql/data/tb_hosp_shchyy/all.json',
json.dumps(hosp_list, ensure_ascii = False))
import time
import pymysql
import pymongo
from get_json import getsplit, get_json_str
from sql import user, hosp
import os
import json
def save(filename, contents):
fd = filename.strip(filename.split('/')[-1])
if not os.path.exists(fd):
os.makedirs(fd)
with open(filename, 'w', encoding = 'utf-8') as fh:
fh.write(contents)
fh.close()
mysqldb = pymysql.connect(host = '122.112.141.214', user = 'chyy_demo', passwd = 'Waw8DXh3fJJ-', port = 3306,
db = 'shchyy_dw',
charset = 'utf8')
mysqlcur = mysqldb.cursor() # 生成游标对象
mysqlcur.execute(user)
# # 创建mongodb数据库连接
# mongodb = pymongo.MongoClient(host='localhost', port=27017)
# # 获取数据库
# db = mongodb['cancer'] # 或者db=client.pp,相当于数据库中的use pp;
dinfo0 = [] # 定义一个函数来处理字段拆分
dinfo1 = [] # 定义一个函数来处理字段拆分
dinfo2 = [] # 定义一个函数来处理字段拆分
def handle_json_str(str, hos):
data = json.loads(str)
data['reportContent']['isPrivate'] = 0
data['hospitalBean'] = hos
data['progressStatus'] = 0
data['auditStatus'] = 4
data['auditRecords'] = [
{
"create_time": "2018-02-08 17:11:11",
"status": 1,
"auditUserId": "superadmin",
"auditUserName": "超级管理员"
}
]
data['noticeFlag'] = 0
data['dateSource'] = 1
data['isPrivate'] = 0
data['isDeleted'] = 0
data['handler'] = 'tsh'
# print(data)
return data
def get_hospital_bean(patient_id, hospitalId, hosp_list):
# print(patient_id)
qur2 = mysqldb.cursor()
qur2.execute(hosp(patient_id))
hos = qur2.fetchone()
# print(get_hos_oid(hosp_list, '上海长海医院'))
# print(get_hos_other_info(hosp_list, '上海长海医院', 'shortName'))
# print(get_hos_other_info(hosp_list, '上海长海医院', 'hospitalNumber').rjust(6, '0'))
return {
"hospitalId": get_hos_oid(hosp_list, hos[2]) if hos is not None else '',
"hospitalName": hos[2] if hos is not None else '',
"shortName": get_hos_other_info(hosp_list, hos[2], 'shortName') if hos is not None else '',
"hospitalNumber": get_hos_other_info(hosp_list, hos[2], 'hospitalNumber').rjust(6, '0') if hos is not None else hospitalId,
"ownership": get_hos_other_info(hosp_list, hos[2], 'ownership') if hos is not None else '',
"mechanismCategory": get_hos_other_info(hosp_list, hos[2], 'mechanismCategory') if hos is not None else '',
"hospitalRank": get_hos_other_info(hosp_list, hos[2], 'hospitalRank') if hos is not None else '',
"hospitalHierarchy": get_hos_other_info(hosp_list, hos[2], 'hospitalHierarchy') if hos is not None else '',
"provinceId": get_hos_other_info(hosp_list, hos[2], 'provinceId') if hos is not None else '',
"provinceName": get_hos_other_info(hosp_list, hos[2], 'provinceName') if hos is not None else '',
"prefectureId": get_hos_other_info(hosp_list, hos[2], 'prefectureId') if hos is not None else '',
"prefectureName": get_hos_other_info(hosp_list, hos[2], 'prefectureName') if hos is not None else '',
"roles": [
{
"roleId": "5db654b23bce1ecbbfc96dff",
"roleCode": "1001",
"roleName": "超级管理员"
}
]
}
def get_hos_oid(json_array, name):
try:
return [obj for obj in json_array if obj['hospitalName'] == name][0]['_id']['$oid']
except IndexError as e:
return None
def get_hos_other_info(json_array, name, rt_field):
try:
return [obj for obj in json_array if obj['hospitalName'] == name][0][rt_field]
except IndexError as e1:
return None
except KeyError as e2:
return ""
if __name__ == '__main__':
hosp_list = []
with open('./data/hospital.jsonl', 'r') as f:
for i in f.readlines():
hosp_list.append(json.loads(i.split('\n')[0]))
count = 0
err_num = 0
json_list = []
for row in mysqlcur.fetchall(): # 循环处理所有记录
count += 1
try:
diagnose_info0 = row[33] # 筛查
diagnose_info1 = row[53] # 第一次随访
diagnose_info2 = row[73] # 第二次随访
if diagnose_info0:
dinfo0 = getsplit(diagnose_info0) # 定义一个函数来处理字段拆分
if diagnose_info1:
dinfo1 = getsplit(diagnose_info1) # 定义一个函数来处理字段拆分
if diagnose_info2:
dinfo2 = getsplit(diagnose_info2) # 定义一个函数来处理字段拆分
patient_id = row[0]
hospitalId = row[2]
hos = get_hospital_bean(patient_id, hospitalId, hosp_list)
json_list.append(handle_json_str(get_json_str(row, dinfo0, dinfo1, dinfo2), hos))
# print(handle_json_str(get_json_str(row, dinfo0, dinfo1, dinfo2), hos))
print("\r%d : %s ✓" % (count, row[1]), end = "")
# save('/Users/Bureaux/Documents/workspace/PyCharmProjects/mongodb2mysql/data/tb_lab_inspect/' + row[1] + '.json',
# json.dumps(handle_json_str(get_json_str(row, dinfo0, dinfo1, dinfo2), hos), ensure_ascii = False))
except Exception as e:
print("%d : %s %s Error! msg: %s" % (count, row[0], row[1], str(e)))
err_num += 1
save('/Users/Bureaux/Documents/workspace/PyCharmProjects/mongodb2mysql/data/tb_lab_inspect/test.json',
json.dumps(json_list, ensure_ascii = False))
print('\nhandled: %d, success: %d, error: %d' % (count, count - err_num, err_num))
This diff is collapsed.
use shchyy;
SELECT * FROM
(SELECT id as patient_id,name,hosp_number,org_number,number,survey_time,if(sex = 1,"a","b") AS sex,birth,age,phone1,phone2,
if(gastric_cancer=0,"b","a") AS gastric_cancer,if(cancer_a = 0,"b","a") AS cancer_a,
cancer_b,if(orther_tumour=0,"b","a") AS orther_tumour,
if(tumour_a = 0,"b","a") AS tumour_a,tumour_b,step
FROM tb_patient WHERE step = 0
AND hosp_number IN (SELECT a.number FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省')
)
) AS a
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS b ON a.patient_id = b.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS c ON a.patient_id = c.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS d ON a.patient_id = d.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS e ON a.patient_id = e.patient_id
#第一次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS f ON a.patient_id = f.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS g ON a.patient_id = g.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS h ON a.patient_id = h.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS i ON a.patient_id = i.patient_id
#第二次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS j ON a.patient_id = j.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS k ON a.patient_id = k.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS l ON a.patient_id = l.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS m ON a.patient_id = m.patient_id
limit 12400,10;
select concat(round(sum(DATA_LENGTH / 1024 / 1024), 2), 'MB') as data
from information_schema.TABLES;
select concat(round(sum(DATA_LENGTH / 1024 / 1024), 2), 'MB') as data
from information_schema.TABLES
where table_schema = 'shchyy';
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'shchyy'
and table_name = 'tb_hosp_shchyy';
select * from ((SELECT id as patient_id,name,survey_time,if(sex = 1,"a","b") AS sex,birth,age,phone1,phone2,
if(gastric_cancer=0,"b","a") AS gastric_cancer,if(cancer_a = 0,"b","a") AS cancer_a,
cancer_b,if(orther_tumour=0,"b","a") AS orther_tumour,
if(tumour_a = 0,"b","a") AS tumour_a,tumour_b,step
FROM tb_patient WHERE step = 0) AS a
join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 1) AS f ON a.patient_id = f.patient_id);
select tb_patient.id,tb_patient.hosp_number,tmp_tb_hosp_apply.hosp_name,tmp_tb_hosp_area.area from shchyy_dw.tb_patient join shchyy.tmp_tb_hosp_apply join shchyy.tmp_tb_hosp_area on right(shchyy_dw.tb_patient.hosp_number,4)=shchyy.tmp_tb_hosp_apply.hosp_number and shchyy.tmp_tb_hosp_apply.hosp_name=shchyy.tmp_tb_hosp_area.name where shchyy_dw.tb_patient.id='101207';
select count(*) from tb_patient join tmp_tb_hosp_apply join tmp_tb_hosp_area on tb_patient.hosp_number=tmp_tb_hosp_apply.hosp_number and tmp_tb_hosp_apply.hosp_name=tmp_tb_hosp_area.name;
select count(*) from tb_patient;
SELECT a.number,a.name,b.area FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省');
SELECT * FROM tb_hosp_shchyy;
SELECT * FROM
(SELECT id as patient_id,name,hosp_number,org_number,number,survey_time,if(sex = 1,"a","b") AS sex,birth,age,phone1,phone2,
if(gastric_cancer=0,"b","a") AS gastric_cancer,if(cancer_a = 0,"b","a") AS cancer_a,
cancer_b,if(orther_tumour=0,"b","a") AS orther_tumour,
if(tumour_a = 0,"b","a") AS tumour_a,tumour_b,step
FROM tb_patient WHERE step = 0
AND hosp_number IN (SELECT a.number FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省')
)
) AS a
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS b ON a.patient_id = b.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS c ON a.patient_id = c.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS d ON a.patient_id = d.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS e ON a.patient_id = e.patient_id
#第一次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS f ON a.patient_id = f.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS g ON a.patient_id = g.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS h ON a.patient_id = h.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS i ON a.patient_id = i.patient_id
#第二次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS j ON a.patient_id = j.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS k ON a.patient_id = k.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS l ON a.patient_id = l.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS m ON a.patient_id = m.patient_id where a.patient_id=101207;
\ No newline at end of file
SELECT * FROM
(SELECT id as patient_id,name,hosp_number,org_number,number,survey_time,if(sex = 1,"a","b") AS sex,birth,age,phone1,phone2,
if(gastric_cancer=0,"b","a") AS gastric_cancer,if(cancer_a = 0,"b","a") AS cancer_a,
cancer_b,if(orther_tumour=0,"b","a") AS orther_tumour,
if(tumour_a = 0,"b","a") AS tumour_a,tumour_b,step
FROM tb_patient WHERE step = 0 AND hosp_number IN (
SELECT a.number FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省')
)) AS a
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS b ON a.patient_id = b.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS c ON a.patient_id = c.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS d ON a.patient_id = d.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS e ON a.patient_id = e.patient_id
#第一次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS f ON a.patient_id = f.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS g ON a.patient_id = g.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS h ON a.patient_id = h.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS i ON a.patient_id = i.patient_id
#第二次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS j ON a.patient_id = j.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS k ON a.patient_id = k.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS l ON a.patient_id = l.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS m ON a.patient_id = m.patient_id;
\ No newline at end of file
SELECT * FROM
(SELECT id as patient_id,name,hosp_number,org_number,number,survey_time,if(sex = 1,"a","b") AS sex,birth,age,phone1,phone2,
if(gastric_cancer=0,"b","a") AS gastric_cancer,if(cancer_a = 0,"b","a") AS cancer_a,
cancer_b,if(orther_tumour=0,"b","a") AS orther_tumour,
if(tumour_a = 0,"b","a") AS tumour_a,tumour_b,step
FROM tb_patient WHERE step = 0
AND hosp_number IN (SELECT a.number FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省')
)
) AS a
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS b ON a.patient_id = b.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS c ON a.patient_id = c.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS d ON a.patient_id = d.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS e ON a.patient_id = e.patient_id
#第一次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS f ON a.patient_id = f.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS g ON a.patient_id = g.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS h ON a.patient_id = h.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS i ON a.patient_id = i.patient_id
#第二次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS j ON a.patient_id = j.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS k ON a.patient_id = k.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS l ON a.patient_id = l.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS m ON a.patient_id = m.patient_id;
\ No newline at end of file
import os
import pymongo
import json
host = '10.16.1.60'
port = 27017
user_name = 'root'
user_pwd = 'huangheruhailiu8431&*@ewell'
conn = pymongo.MongoClient(host, port)
db_admin = conn.admin
db_admin.authenticate(user_name, user_pwd)
db = conn.get_database('gastric-cancer-global') # 直接写库名
gastric_cancer_report_data = db.get_collection("myCollection")
k = db.collection_names(include_system_collections=True)
print(k)
path = "./data/tb_lab_inspect" # 文件夹目录
files = os.listdir(path) # 得到文件夹下的所有文件名称
s = []
for file in files: # 遍历文件夹
if not os.path.isdir(file): # 判断是否是文件夹,不是文件夹才打开
f = open(path + "/" + file) # 打开文件
iter_f = iter(f) # 创建迭代器
str = ""
for line in iter_f: # 遍历文件,一行行遍历,读取文本
str = str + line
post_data = json.loads(str)
result = gastric_cancer_report_data.insert_one(post_data)
print(result)
{
"_id": {
"$oid": "5e074ccceb67ee03ec8921a2"
},
"_class": "com.ewell.bean.report.ReportDataBean",
"sampleId": "20191228-2033-267",
"diseaseTypes": "gc_yq",
"userId": "superadmin",
"name": "王13",
"version": "1.1",
"reportTime": "2018-02-08",
"lastUpdateTime": "2018-02-08",
"riskRank": "14",
"reportContent": {
"diseaseType": "gc_yq",
"data": {
"sampleId": "20191228-2033-267",
"sex": "a",
"birthday": "1970-01-01",
"age": "50",
"agree": "a",
"gc-1-2-1": "b",
"gc-1-2-1-1": "b",
"gc-1-2-2": "b",
"gc-1-2-3": "b",
"gc-1-2-4": "b",
"gc-1-2-5": "b",
"gc-1-2-6": "b",
"name": "王13",
"sex-1": "a",
"birthday-1": "1970-01-01",
"weight": {
"$numberInt": "0"
},
"height": {
"$numberInt": "0"
},
"IDCard": "",
"medicalCard": "",
"cellPhone": "13813580525",
"telephone": "",
"address": "",
"checkTime": "2018-02-08",
"relativesGastric": "b",
"relativesGastricCount": "b",
"relativesGastricAge": {
"$numberInt": ""
},
"relativesCancer": "b",
"relativesCancerCount": "b",
"relativesCancerAge": "",
"inspectionsTime": "2018-02-08",
"g17": {
"$numberInt": "3.01"
},
"pgi": {
"$numberInt": "4.01"
},
"pgii": {
"$numberInt": "5.01"
},
"HPScore": "0",
"caga": "",
"vaca": "",
"urea": "",
"ureb": "",
"pgr": {
"$numberInt": "1.249376558603491271820448878"
},
"file": "",
"labImages": "5e074ca5bbc96666667d65b5,5e074cb472c3d50b5f2c64e6,5e074cfcbbc96666667d65b6,5e074d19bbc96666667d65b7,5e0751fc72c3d50b5f2c64e9",
"riskScore": "14",
"riskLevel": "b",
"gc-3-4-3": "b",
"inspectionsChecked": "a",
"gastroscopeTime": "2018-02-11",
"gastroscopeWay": "a",
"gc-4-2-3": "a",
"finalDiagnose": [],
"gc-4-4-0": "i",
"gc-4-4-2": [
"",
"",
""
],
"refluxEsophagealCancer": "a",
"atrophicGastritis": "a",
"atrophicGastritisPart": [
"",
"a",
"",
"",
""
],
"duodenalBulbarUlcer": "a",
"otherLesions": "胃角轻度肠上皮化生,中度活动伴糜烂",
"otherDiseases": "胃角轻度肠上皮化生,中度活动伴糜烂",
"gc-4-3-14": "5e074f4772c3d50b5f2c64e7,5e0751e472c3d50b5f2c64e8",
"gc-5-1-1": "1",
"gc-5-2-1": "a",
"followUpPlanDate": "2019-02-11",
"followUpContent": [
"b"
]
},
"isPrivate": 0
},
"hospitalBean": {
"hospitalId": "00000091631868051",
"hospitalName": "上海长海医院",
"shortName": "早癌筛查联盟",
"hospitalNumber": "00000009",
"ownership": "计算所",
"mechanismCategory": "综合",
"hospitalRank": "二级",
"hospitalHierarchy": "甲等",
"provinceId": "",
"provinceName": "上海市",
"prefectureId": "",
"prefectureName": "",
"roles": [
{
"roleId": "5db654b23bce1ecbbfc96dff",
"roleCode": "1001",
"roleName": "超级管理员"
}
]
},
"progressStatus": 0,
"auditStatus": 4,
"auditRecords": [
{
"create_time": "2018-02-08 17:11:11",
"status": 1,
"auditUserId": "superadmin",
"auditUserName": "超级管理员"
}
],
"noticeFlag": 0,
"dateSource": 1,
"isPrivate": 0,
"isDeleted": 0
}
{
"_id": {
"$oid": "5e074ccceb67ee03ec8921a2"
},
"_class": "com.ewell.bean.report.ReportDataBean",
"sampleId": "20200313-1223-385",
"diseaseTypes": "gc_yq",
"userId": "superadmin",
"name": "人才",
"hospitalBean": {
"hospitalId": "5e66135f7df7b41838c0d35e",
"hospitalName": "早期胃癌筛查全流程管理平台",
"shortName": "早癌筛查联盟",
"hospitalNumber": "00000001",
"ownership": "计算所",
"mechanismCategory": "综合",
"hospitalRank": "二级",
"hospitalHierarchy": "甲等",
"provinceId": "31",
"provinceName": "上海",
"prefectureId": "310117",
"prefectureName": "松江区",
"roles": [
{
"roleId": "5db654b23bce1ecbbfc96dff",
"roleCode": "1001",
"roleName": "超级管理员"
}
]
},
"version": "1.1",
"reportTime": "2020-03-13 12:24:17",
"lastUpdateTime": "2020-03-13 17:11:36",
"reportContent": {
"isPrivate": 0,
"diseaseType": "gc_yq",
"data": {
"birthday": "1978-12-04",
"sex-1": "a",
"birthday-1": "1978-12-04",
"medicalCard": "",
"withinOneYear": "b",
"habit": "b",
"gastricChecked": "b",
"subtotalGastrectomy": "b",
"gaisticDiseaseHistory": "b",
"address": "",
"IDCard": "",
"sampleId": "20200313-1223-385",
"seriousIllness": "b",
"hpInfection": "b",
"sex": "a",
"ppi": "b",
"telephone": "",
"agree": "a",
"possibilityOfCancer": "b",
"symptom": "b",
"checkTime": "2020-02-04",
"name": "人才",
"diseasesHistory": "b",
"relativesCancer": "b",
"age": "42",
"cellPhone": "18212345678",
"relativesGastric": "b"
}
},
"progressStatus": 0,
"auditStatus": 4,
"auditRecords": [
{
"create_time": "2020-03-13 17:11:11",
"status": 1,
"auditUserId": "superadmin",
"auditUserName": "超级管理员"
}
],
"noticeFlag": 0,
"dateSource": 1,
"isPrivate": 0,
"isDeleted": 0
}
\ No newline at end of file
gastric_cancer_article
gastric_cancer_enumerate
gastric_cancer_favorite
gastric_cancer_hosp_en
gastric_cancer_hospital
gastric_cancer_import_file
gastric_cancer_import_result
gastric_cancer_informed_consent
gastric_cancer_mini_program_notice_template
gastric_cancer_mini_program_notification
gastric_cancer_permission
gastric_cancer_province
gastric_cancer_report_data
gastric_cancer_report_img
gastric_cancer_resource
gastric_cancer_role
gastric_cancer_sms_notice
gastric_cancer_sms_notice_template
gastric_cancer_sys_announcement
gastric_cancer_sys_op_log
gastric_cancer_template
gastric_cancer_user
gastric_cancer_wechat_user
nanjing_disease_icd
nanjing_operation_icd
nanjing_report_data
songjiang_schedule_date
\ No newline at end of file
This diff is collapsed.
MongoDB shell version v3.6.14
connecting to: mongodb://10.16.1.60:27017/gastric-cancer-global?authSource=admin&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("03fea62e-a2c9-4c19-9f72-ff846d9522d0") }
MongoDB server version: 3.6.14
Variety: A MongoDB Schema Analyzer
Version 1.5.1, released 02 October 2017
Using collection of "gastric_cancer_hospital"
Using query of { }
Using limit of 24
Using maxDepth of 99
Using sort of { "_id" : -1 }
Using outputFormat of "ascii"
Using persistResults of false
Using resultsDatabase of "varietyResults"
Using resultsCollection of "gastric_cancer_hospitalKeys"
Using resultsUser of null
Using resultsPass of null
Using logKeysContinuously of false
Using excludeSubkeys of [ ]
Using arrayEscape of "XX"
Using lastValue of false
Using plugins of [ ]
+-------------------------------------------------------------------------------+
| key | types | occurrences | percents |
| ------------------------------ | -------- | ----------- | ------------------- |
| _class | String | 24 | 100.000000000000000 |
| _id | ObjectId | 24 | 100.000000000000000 |
| hospitalName | String | 24 | 100.000000000000000 |
| hospitalNumber | String | 24 | 100.000000000000000 |
| isUse | Number | 24 | 100.000000000000000 |
| ownership | String | 24 | 100.000000000000000 |
| provinceId | String | 24 | 100.000000000000000 |
| provinceName | String | 24 | 100.000000000000000 |
| shortName | String | 24 | 100.000000000000000 |
| hospitalHierarchy | String | 22 | 91.666666666666671 |
| hospitalRank | String | 22 | 91.666666666666671 |
| mechanismCategory | String | 22 | 91.666666666666671 |
| prefectureId | String | 22 | 91.666666666666671 |
| prefectureName | String | 22 | 91.666666666666671 |
| auditStatus | Number | 21 | 87.500000000000000 |
| isAlliance | Number | 21 | 87.500000000000000 |
| address | String | 19 | 79.166666666666671 |
| annualGastric | Number | 19 | 79.166666666666671 |
| annualOutpatient | Number | 19 | 79.166666666666671 |
| applyDate | String | 19 | 79.166666666666671 |
| applyReason | String | 19 | 79.166666666666671 |
| deptContactEmail | String | 19 | 79.166666666666671 |
| deptContactName | String | 19 | 79.166666666666671 |
| deptContactPhone | String | 19 | 79.166666666666671 |
| gastricDevices | Array | 19 | 79.166666666666671 |
| gastricDevices.XX.deviceName | String | 19 | 79.166666666666671 |
| leadDepartment | String | 19 | 79.166666666666671 |
| legalRepresentative | String | 19 | 79.166666666666671 |
| legalRepresentativePhone | String | 19 | 79.166666666666671 |
| postalCode | String | 19 | 79.166666666666671 |
| seraDiagnosis | Number | 19 | 79.166666666666671 |
| annualScanningPlan | Number | 18 | 75.000000000000000 |
| haveCooperativeSerum | Number | 18 | 75.000000000000000 |
| haveCooperativeUnion | Number | 18 | 75.000000000000000 |
| haveFollowUpPlan | Number | 18 | 75.000000000000000 |
| haveGovernmentGastric | Number | 18 | 75.000000000000000 |
| havePathologist | Number | 18 | 75.000000000000000 |
| haveRecorders | Number | 18 | 75.000000000000000 |
| haveScreeningMobilize | Number | 18 | 75.000000000000000 |
| haveScreeningOutpatient | Number | 18 | 75.000000000000000 |
| haveScreeningPhysician | Number | 18 | 75.000000000000000 |
| haveSeniorGastricDoctors | Number | 18 | 75.000000000000000 |
| haveSupportPlan | Number | 18 | 75.000000000000000 |
| isTeachingHospital | Number | 17 | 70.833333333333329 |
| updateTime | String | 17 | 70.833333333333329 |
| updateUser | Object | 17 | 70.833333333333329 |
| updateUser.name | String | 17 | 70.833333333333329 |
| updateUser.userId | String | 17 | 70.833333333333329 |
| permissionIds | Array | 12 | 50.000000000000000 |
| recorders | String | 11 | 45.833333333333336 |
| seniorGastricDoctors | String | 11 | 45.833333333333336 |
| whichScreening | String | 11 | 45.833333333333336 |
| canningPlan | String | 10 | 41.666666666666664 |
| cooperativeUnion | String | 10 | 41.666666666666664 |
| followUpPlan | String | 10 | 41.666666666666664 |
| gastricDevices.XX.deviceCount | Number | 10 | 41.666666666666664 |
| governmentGastric | String | 10 | 41.666666666666664 |
| haveMiniProgram | Number | 10 | 41.666666666666664 |
| pathologist | String | 10 | 41.666666666666664 |
| screeningMobilize | String | 10 | 41.666666666666664 |
| screeningOutpatient | String | 10 | 41.666666666666664 |
| screeningPhysician | String | 10 | 41.666666666666664 |
| supportPlan | String | 10 | 41.666666666666664 |
| version | String | 10 | 41.666666666666664 |
| auditRecords | Array | 9 | 37.500000000000000 |
| auditRecords.XX.auditStatus | Number | 9 | 37.500000000000000 |
| auditRecords.XX.auditTime | String | 9 | 37.500000000000000 |
| auditRecords.XX.auditUserId | String | 9 | 37.500000000000000 |
| auditRecords.XX.auditUserName | String | 9 | 37.500000000000000 |
| cooperativeSerum | String | 9 | 37.500000000000000 |
| annualGastric | Number | 2 | 8.333333333333334 |
| annualOutpatient | Number | 2 | 8.333333333333334 |
| annualScanningPlan | Number | 2 | 8.333333333333334 |
| gastricDevices | Array | 2 | 8.333333333333334 |
| gastricDevices.XX._class | String | 2 | 8.333333333333334 |
| gastricDevices.XX.deviceCount | Number | 2 | 8.333333333333334 |
| gastricDevices.XX.deviceName | String | 2 | 8.333333333333334 |
| haveCooperativeSerum | Number | 2 | 8.333333333333334 |
| haveCooperativeUnion | Number | 2 | 8.333333333333334 |
| haveFollowUpPlan | Number | 2 | 8.333333333333334 |
| haveGovernmentGastric | Number | 2 | 8.333333333333334 |
| havePathologist | Number | 2 | 8.333333333333334 |
| haveRecorders | Number | 2 | 8.333333333333334 |
| haveScreeningMobilize | Number | 2 | 8.333333333333334 |
| haveScreeningOutpatient | Number | 2 | 8.333333333333334 |
| haveScreeningPhysician | Number | 2 | 8.333333333333334 |
| haveSeniorGastricDoctors | Number | 2 | 8.333333333333334 |
| haveSupportPlan | Number | 2 | 8.333333333333334 |
| seraDiagnosis | Number | 2 | 8.333333333333334 |
| deptAnnualDischarge | Number | 2 | 8.333333333333334 |
| deptAnnualIncome | String | 2 | 8.333333333333334 |
| deptBedCount | Number | 2 | 8.333333333333334 |
| deptMemberCount | Number | 2 | 8.333333333333334 |
| examAnnualCheck | Number | 2 | 8.333333333333334 |
| examAnnualIncome | String | 2 | 8.333333333333334 |
| examAverageCost | String | 2 | 8.333333333333334 |
| fax | String | 2 | 8.333333333333334 |
| mobileResources | Array | 2 | 8.333333333333334 |
| researchParticipants | Array | 2 | 8.333333333333334 |
| researchParticipants.XX.email | String | 2 | 8.333333333333334 |
| researchParticipants.XX.name | String | 2 | 8.333333333333334 |
| researchParticipants.XX.phone | String | 2 | 8.333333333333334 |
| telephone | String | 2 | 8.333333333333334 |
| auditRecords.XX.refuseReason | String | 1 | 4.166666666666667 |
| hospitalId | String | 1 | 4.166666666666667 |
+-------------------------------------------------------------------------------+
This diff is collapsed.
user = """
SELECT * FROM
(SELECT id as patient_id,name,hosp_number,org_number,number,survey_time,if(sex = 1,"a","b") AS sex,birth,age,phone1,phone2,
if(gastric_cancer=0,"b","a") AS gastric_cancer,if(cancer_a = 0,"b","a") AS cancer_a,
cancer_b,if(orther_tumour=0,"b","a") AS orther_tumour,
if(tumour_a = 0,"b","a") AS tumour_a,tumour_b,step
FROM tb_patient WHERE step = 0
AND hosp_number IN (SELECT a.number FROM (
SELECT number,name FROM shchyy4dw_geca.tb_hosp
UNION
SELECT number,name FROM shchyy4dw.tb_hosp
UNION
SELECT number,name FROM shchyy4dw_qg.tb_hosp) a
left JOIN
shchyy_dw.tmp_tb_hosp_area b
ON a.name=b.name
WHERE a.NAME IS NOT null and b.area in ('上海市','浙江省','江苏省','安徽省')
)
) AS a
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS b ON a.patient_id = b.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS c ON a.patient_id = c.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS d ON a.patient_id = d.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS e ON a.patient_id = e.patient_id
#第一次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS f ON a.patient_id = f.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS g ON a.patient_id = g.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS h ON a.patient_id = h.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS i ON a.patient_id = i.patient_id
#第二次随访
LEFT join
(SELECT patient_id,g17,pg1,pg2,igg
FROM tb_lab_inspect
WHERE step = 0) AS j ON a.patient_id = j.patient_id
LEFT JOIN
(select patient_id,score,(case grade when 1 then "a" when 2 then "b" when 3 then "c" end) AS grade
from tb_risk_assess WHERE step = 0) AS k ON a.patient_id = k.patient_id
LEFT JOIN
(select patient_id, if(is_inspect=1,"a","b") AS is_inspect,inspect_time,
(case inspect_way when 1 then "a" when 2 then "b" when 3 then "c" end) AS inspect_way,
if(capsule=1,"a","b") AS capsule,
precise_way,if(diagnose_result=1,"a","b") AS diagnose_result,diagnose_info
from tb_gastro_inspect where step = 0) AS l ON a.patient_id = l.patient_id
LEFT JOIN
(select patient_id,continue_flup,flup_time,if(content_type,"a","b") as content_type
from tb_flup_plan WHERE step = 1) AS m ON a.patient_id = m.patient_id
# limit 12400,100
;
"""
def hosp(id):
return "select tb_patient.id,tb_patient.hosp_number,tmp_tb_hosp_apply.hosp_name,tmp_tb_hosp_area.area from shchyy_dw.tb_patient join shchyy.tmp_tb_hosp_apply join shchyy.tmp_tb_hosp_area on right(shchyy_dw.tb_patient.hosp_number,4)=shchyy.tmp_tb_hosp_apply.hosp_number and shchyy.tmp_tb_hosp_apply.hosp_name=shchyy.tmp_tb_hosp_area.name where shchyy_dw.tb_patient.id=%s" % id;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment