{ "cells": [ { "cell_type": "markdown", "id": "4b3853d4-d30f-4b1d-99de-fa52777ce65c", "metadata": {}, "source": [ "## 体质指标问卷导入" ] }, { "cell_type": "code", "execution_count": 17, "id": "202a0266-f578-4d75-b04c-5ae9957391bf", "metadata": { "execution": { "iopub.execute_input": "2023-05-22T08:51:23.135343Z", "iopub.status.busy": "2023-05-22T08:51:23.134459Z", "iopub.status.idle": "2023-05-22T08:51:23.150352Z", "shell.execute_reply": "2023-05-22T08:51:23.149334Z", "shell.execute_reply.started": "2023-05-22T08:51:23.135304Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ok\n" ] } ], "source": [ "import json\n", "\n", "filename = 'data/淄博交警体质指标问卷.json'\n", "item = {}\n", "unit = {}\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "dict2 = {}\n", "for items in dict1['pages']:\n", " for item in items['elements']:\n", " #print(item)\n", " dict2.setdefault(item['name'],{})\n", " name = item['name']\n", " dict2[name]['type'] = item['type']\n", " dict2[name]['title'] = item['title']['zh-cn']\n", " if 'isRequired' in item.keys():\n", " dict2[name]['isRequired'] = item['isRequired']\n", " else:\n", " dict2[name]['isRequired'] = False\n", " if item['type'] == 'text':\n", " dict2[name]['inputType'] = item['inputType']\n", " else:\n", " dict2[name]['choices'] = item['choices']\n", "filename = 'data/淄博交警体质问卷参数.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(dict2, fl, ensure_ascii=False)\n", "print('ok')" ] }, { "cell_type": "markdown", "id": "5eed4886-a332-429f-9283-e109d48227fe", "metadata": {}, "source": [ "## 体质指标问卷整理" ] }, { "cell_type": "code", "execution_count": 41, "id": "857ca433-556a-4152-af7e-5f81434d11a7", "metadata": { "execution": { "iopub.execute_input": "2023-05-22T13:35:16.464666Z", "iopub.status.busy": "2023-05-22T13:35:16.463814Z", "iopub.status.idle": "2023-05-22T13:35:16.476027Z", "shell.execute_reply": "2023-05-22T13:35:16.474929Z", "shell.execute_reply.started": "2023-05-22T13:35:16.464626Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ok\n" ] } ], "source": [ "import json\n", "\n", "filename = 'data/淄博交警体质问卷参数.json'\n", "item = {}\n", "unit = {}\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", "for k, v in dict1.items():\n", " if 'choices' in v.keys():\n", " dict2 = {}\n", " for item in v['choices']:\n", " dict2[str(item['value'])] = item['text']\n", " dict1[k]['choices'] = dict2\n", "filename = 'data/淄博交警体质问卷参数.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(dict1, fl, ensure_ascii=False)\n", "print('ok')" ] }, { "cell_type": "markdown", "id": "d7ab7cfd-3448-45a6-abb4-04e7f317b843", "metadata": {}, "source": [ "## 问卷数据分析" ] }, { "cell_type": "code", "execution_count": 43, "id": "f5c6a39a-3e3e-4844-8ff8-b9ebb7e8f8af", "metadata": { "execution": { "iopub.execute_input": "2023-05-22T13:36:57.660765Z", "iopub.status.busy": "2023-05-22T13:36:57.660192Z", "iopub.status.idle": "2023-05-22T13:36:57.673702Z", "shell.execute_reply": "2023-05-22T13:36:57.672666Z", "shell.execute_reply.started": "2023-05-22T13:36:57.660720Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "13718887655\n", "您的性别 女性\n", "您的年龄 39\n", "您的身高(cm) 160\n", "您的体重(kg) 52\n", "您的血压(BP) 临界偏低(收缩压90-94mmHg和/或舒张压60-65mmHg)\n", "您的空腹血糖(FPG) 正常(3.89-6.1mmol/L)\n", "您的白细胞计数(WBC) 临界偏高(9.6-10×10^9/L)\n", "您的血红蛋白(HGB) 临界偏低(110-114g/L)\n", "您的血小板(PLT) 正常(125-350×10^9/L)\n", "您的低密度脂蛋白(LDL-C) 临界偏高(5.18-6.19mmol/L)\n", "您的甘油三酯(TG) 正常(0.45-1.69mmol/L)\n", "您的尿酸(UA) 正常(155.00- 350.00 μmol/L)\n", "您的肌酐(Cr) 正常(44.00- 73.00μmol/L)\n", "您的谷丙转氨酶(ALT) 正常(7.00- 19.00U/L)\n", "您的谷草转氨酶(AST) 正常(13.00- 35.00U/L)\n", "您的甲状腺功能 正常\n", "您的尿蛋白 阴性\n", "您的便潜血 阴性\n", "您的幽门螺旋杆菌 阴性\n", "囊肿(选做题,没有囊肿问题的请跳过) ['卵巢囊肿']\n", "结节(选做题,没有结节问题的请跳过) ['肺结节']\n", "息肉(选做题,没有息肉问题的请跳过) ['其他息肉']\n", "您的其他问题(选做题,没有这些问题的请跳过) ['过敏性鼻炎']\n", "您的饮食口味 ['清淡']\n", "您吸烟吗 不吸烟\n", "您喝酒吗 不喝\n", "您参加规律的体育锻炼吗 不参加\n", "您的睡眠状况如何 非常好\n", "您的排便频率如何 2天一次\n", "您的职业 管理人员\n", "您的父母或兄弟姐妹是否患有明确诊断的疾病?(选做题,没有遗传病史的请跳过) ['高血压', '冠心病', '脑卒中']\n", "15210715398\n", "您的性别 女性\n", "您的年龄 36\n", "您的身高(cm) 162\n", "您的体重(kg) 56\n", "您的血压(BP) 正常(收缩压95-130mmHg和舒张压65-85mmHg)\n", "您的空腹血糖(FPG) 正常(3.89-6.1mmol/L)\n", "您的白细胞计数(WBC) 正常(4-9.5×10^9/L)\n", "您的血红蛋白(HGB) 正常(115-145g/L)\n", "您的血小板(PLT) 正常(125-350×10^9/L)\n", "您的低密度脂蛋白(LDL-C) 正常(3.1-5.18mmol/L)\n", "您的甘油三酯(TG) 正常(0.45-1.69mmol/L)\n", "您的尿酸(UA) 正常(155.00- 350.00 μmol/L)\n", "您的肌酐(Cr) 正常(44.00- 73.00μmol/L)\n", "您的谷丙转氨酶(ALT) 正常(7.00- 19.00U/L)\n", "您的谷草转氨酶(AST) 正常(13.00- 35.00U/L)\n", "您的甲状腺功能 正常\n", "您的尿蛋白 阴性\n", "您的便潜血 阴性\n", "您的幽门螺旋杆菌 阴性\n", "您的心脏(选做题,没有心脏问题的请跳过) ['窦性心律不齐']\n", "您的饮食口味 ['辛辣']\n", "您吸烟吗 不吸烟\n", "您喝酒吗 不喝\n", "您参加规律的体育锻炼吗 经常参加(平均每周锻炼3次及以上,每次锻炼>30分钟)\n", "您的睡眠状况如何 非常好\n", "您的排便频率如何 2天一次\n", "您的职业 行政工作\n", "您的父母或兄弟姐妹是否患有明确诊断的疾病?(选做题,没有遗传病史的请跳过) ['高血压']\n" ] } ], "source": [ "import json\n", "filename = 'data/淄博交警体质问卷参数.json'\n", "item = {}\n", "unit = {}\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", "filename = 'data/Survey_20230522.json'\n", "\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl) \n", "for items in dict2['Survey']:\n", " #print(items)\n", " phone = items['phone']\n", " print(phone)\n", " data = json.loads(items['data'])\n", " for k, v in data.items():\n", " title = dict1[k]['title']\n", " if dict1[k]['type'] == 'radiogroup':\n", " value = dict1[k]['choices'][str(v)] \n", " if dict1[k]['type'] == 'text':\n", " value = v\n", " if dict1[k]['type'] == 'checkbox':\n", " value = []\n", " for choice in v:\n", " value.append(dict1[k]['choices'][str(choice)]) \n", " print(title,value) " ] }, { "cell_type": "code", "execution_count": null, "id": "2bb69139-b4be-4fd1-ae44-461f62b09503", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }