PatientHealthRecordPreview.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <script setup lang="ts">
  2. import { h, ref } from 'vue';
  3. import { VxeUI } from 'vxe-pc-ui';
  4. import { ArrowDownOutlined, ArrowUpOutlined, EditOutlined } from '@ant-design/icons-vue';
  5. import { useWatcher } from 'alova/client';
  6. import { getPatientTagsMethod, patientMethod } from '@/request/api/patient.api';
  7. import { getPatientDiagnosisReportMethod, getPatientHealthIndicatorMethod, getPatientHealthRecordMethod } from '@/request/api/report.api';
  8. import type { PatientModel, PatientTagVO, ReportModel } from '@/model';
  9. import UseDict from '@/core/dictionary/component';
  10. import HealthReportAnalysisWidget from '@/widgets/HealthReportAnalysisWidget.vue';
  11. const props = defineProps<{
  12. patient: Partial<PatientModel>;
  13. report: Partial<ReportModel>;
  14. source?: string;
  15. sourceInsName?: string;
  16. }>();
  17. const emits = defineEmits<{
  18. refresh: [];
  19. destroy: [];
  20. }>();
  21. // 患者基本信息
  22. const { data: patient } = useWatcher(() => patientMethod(props.patient?.id!), [() => props.patient.id], {
  23. initialData: { ...props.patient },
  24. immediate: true,
  25. middleware: (_, next) => {
  26. if (props.patient.id) next();
  27. },
  28. });
  29. const { data: patientTags, loading: loadPatientTagsPending } = useWatcher(() => getPatientTagsMethod(props.patient?.id!), [() => props.patient.id], {
  30. initialData: [],
  31. immediate: true,
  32. middleware: (_, next) => {
  33. if (props.patient.id) next();
  34. },
  35. });
  36. // 患者最后一次就诊记录
  37. const { data: diagnosisRecord } = useWatcher(() => getPatientDiagnosisReportMethod(0, props.patient?.id!), [() => props.patient.id], {
  38. initialData: { disease: {}, symptom: {} },
  39. immediate: true,
  40. middleware: (_, next) => {
  41. if (props.patient.id) next();
  42. },
  43. });
  44. // 患者最后一次健康分析报告
  45. const { data: healthRecord } = useWatcher(() => getPatientHealthRecordMethod(props.report?.id!), [() => props.report.id], {
  46. initialData: {},
  47. immediate: true,
  48. middleware: (_, next) => {
  49. if (props.report.id) next();
  50. },
  51. });
  52. const { data: indicator } = useWatcher(() => getPatientHealthIndicatorMethod(props.patient?.id!), [() => props.patient.id], {
  53. initialData: [],
  54. immediate: true,
  55. middleware: (_, next) => {
  56. if (props.patient.id) next();
  57. },
  58. });
  59. const panels = shallowReactive([
  60. {
  61. id: 'patient-diagnosis-records',
  62. title: '就诊记录',
  63. component: defineAsyncComponent(() => import('@/widgets/PatientDiagnosisRecordsWidget.vue')),
  64. },
  65. {
  66. id: 'patient-followUp-records',
  67. title: '就诊随访',
  68. component: defineAsyncComponent(() => import('@/widgets/PatientFollowUpRecordsWidget.vue')),
  69. },
  70. {
  71. id: 'patient-service-records',
  72. title: '调养记录',
  73. component: defineAsyncComponent(() => import('@/widgets/PatientCareRecordsWidget.vue')),
  74. },
  75. {
  76. id: 'patient-health-records',
  77. title: '健康分析记录',
  78. component: defineAsyncComponent(() => import('@/widgets/PatientHealthRecordsWidget.vue')),
  79. },
  80. {
  81. id: 'patient-physicalSign-records',
  82. title: '生理指标',
  83. component: defineAsyncComponent(() => import('@/widgets/PatientPhysicalSignRecordsWidget.vue')),
  84. },
  85. ]);
  86. const activePanel = ref(panels[0].id);
  87. const activePanelChange = (event: Event) => {
  88. (event.target as HTMLElement)?.scrollIntoView({ block: 'start', behavior: 'smooth' });
  89. };
  90. function openPatientTagEdit(event: MouseEvent) {
  91. const width = 500;
  92. const offset = 32;
  93. const component = defineAsyncComponent(() => import('@/components/PatientTagEdit.vue'));
  94. const id = `PatientTagEdit`;
  95. VxeUI.modal.open({
  96. id,
  97. title: '标签',
  98. type: 'modal',
  99. position: {
  100. top: event.pageY + offset,
  101. left: event.pageX - width,
  102. },
  103. escClosable: true,
  104. resize: true,
  105. width,
  106. minWidth: width,
  107. mask: false,
  108. slots: {
  109. default() {
  110. return h(component, {
  111. id: patient.value.id,
  112. tags: patientTags.value,
  113. onDestroy(values?: PatientTagVO[]) {
  114. if (values) {
  115. patientTags.value = values;
  116. emits('refresh');
  117. }
  118. VxeUI.modal.close(id);
  119. },
  120. });
  121. },
  122. },
  123. });
  124. }
  125. function openPatientRecordsPreview() {
  126. const component = defineAsyncComponent(() => import('@/components/RecordsPatientPreview.vue'));
  127. const id = `modal:record-patient:preview`;
  128. const onDestroy = () => {
  129. VxeUI.modal.close(id);
  130. };
  131. onDestroy();
  132. VxeUI.modal.open({
  133. id,
  134. remember: true,
  135. showMaximize: true,
  136. mask: false,
  137. lockView: false,
  138. padding: false,
  139. resize: true,
  140. width: Math.floor(window.innerWidth * 0.5),
  141. height: Math.floor(window.innerHeight * 0.5),
  142. escClosable: true,
  143. maskClosable: true,
  144. title: `基础信息更新记录`,
  145. slots: {
  146. default() {
  147. return h(component, {
  148. patient: patient.value,
  149. onDestroy,
  150. });
  151. },
  152. },
  153. });
  154. }
  155. function openIndicatorRecordsPreview() {
  156. const component = defineAsyncComponent(() => import('@/components/RecordsIndicatorPreview.vue'));
  157. const id = `modal:record-indicator:preview`;
  158. console.log(patient.value, 'patient======');
  159. const onDestroy = () => {
  160. VxeUI.modal.close(id);
  161. };
  162. onDestroy();
  163. VxeUI.modal.open({
  164. id,
  165. remember: true,
  166. showMaximize: true,
  167. mask: false,
  168. lockView: false,
  169. padding: false,
  170. resize: true,
  171. width: Math.floor(window.innerWidth * 0.5),
  172. height: Math.floor(window.innerHeight * 0.5),
  173. escClosable: true,
  174. maskClosable: true,
  175. title: `指标信息更新记录`,
  176. slots: {
  177. default() {
  178. return h(component, {
  179. patient: patient.value,
  180. records: indicator.value,
  181. onDestroy,
  182. });
  183. },
  184. },
  185. });
  186. }
  187. </script>
  188. <template>
  189. <div class="p-6">
  190. <div class="flex">
  191. <section class="flex-auto">
  192. <div class="row mb-5" v-if="source || sourceInsName">
  193. <span class="text-lg mr-12 font-bold">来源</span>
  194. <a-tag color="pink">{{ source }}</a-tag>
  195. <a-tag color="red">{{ sourceInsName }}</a-tag>
  196. </div>
  197. <header class="flex items-center">
  198. <div class="title">基本信息</div>
  199. <a-button type="link" @click="openPatientRecordsPreview">更新记录</a-button>
  200. </header>
  201. <main>
  202. <div class="row">
  203. <a-space class="separate" :size="0">
  204. <span>{{ patient.name }}</span>
  205. <UseDict v-slot="{ value }" sign="sys_user_sex" :raw="patient.gender">
  206. <span v-if="value">{{ value }}</span>
  207. </UseDict>
  208. <span v-if="patient.age">{{ patient.age }} 岁</span>
  209. <UseDict v-slot="{ value }" sign="women_special_period" :raw="patient.womenSpecialPeriod">
  210. <span v-if="value && value !== '无'">{{ value }}</span>
  211. </UseDict>
  212. <UseDict v-slot="{ value }" sign="job" :raw="patient.job">
  213. <span v-if="value && value !== '无'">{{ value }}</span>
  214. </UseDict>
  215. <span v-if="patient.phone"><label>手机号</label> {{ patient.phone }}</span>
  216. <span v-if="patient.cardno"><label>身份证号</label> {{ patient.cardno }}</span>
  217. </a-space>
  218. </div>
  219. <div class="row">
  220. <a-space :size="40">
  221. <span v-if="patient.height"><label>身高</label> {{ patient.height }} cm</span>
  222. <span v-if="patient.weight"><label>体重</label> {{ patient.weight }} kg</span>
  223. <UseDict v-slot="{ value }" sign="sys_yes_no" :raw="patient.drinkState">
  224. <span v-if="value"><label>饮酒</label> {{ value }}</span>
  225. </UseDict>
  226. <UseDict v-slot="{ value }" sign="sys_yes_no" :raw="patient.smokeState">
  227. <span v-if="value"><label>抽烟</label> {{ value }}</span>
  228. </UseDict>
  229. <UseDict v-slot="{ value }" sign="food_allergy" :raw="patient.foodAllergy2" :multiple="true" :separator="[',', '、']">
  230. <span v-if="value"><label>食物过敏</label> {{ value }}</span>
  231. </UseDict>
  232. <UseDict v-slot="{ value }" sign="hobby_flavor" :raw="patient.hobbyFlavor" :multiple="true" :separator="[',', '、']">
  233. <span v-if="value"><label>喜好口味</label> {{ value }}</span>
  234. </UseDict>
  235. </a-space>
  236. </div>
  237. </main>
  238. </section>
  239. <section class="flex-none min-w-100px max-w-400px">
  240. <label>标签:</label>
  241. <a-spin v-if="loadPatientTagsPending"></a-spin>
  242. <template v-else>
  243. <a-tag v-for="tag in patientTags" :key="tag.id" :color="tag.color">{{ tag.name }}</a-tag>
  244. <a-button type="link" @click="openPatientTagEdit($event)">
  245. <template #icon>
  246. <EditOutlined />
  247. </template>
  248. </a-button>
  249. </template>
  250. </section>
  251. </div>
  252. <section class="mt-4">
  253. <header class="flex items-center">
  254. <div class="title">健康状况</div>
  255. </header>
  256. <main>
  257. <div class="row" v-if="diagnosisRecord">
  258. <header>
  259. <label>诊断</label>
  260. <span>{{ diagnosisRecord.disease?.name }} - {{ diagnosisRecord.symptom?.name }}</span>
  261. <span v-if="diagnosisRecord.date">({{ diagnosisRecord.date }})</span>
  262. </header>
  263. </div>
  264. <div class="row">
  265. <header>
  266. <label>健康状态</label>
  267. <span>{{ healthRecord.result?.status }}</span>
  268. <span v-if="healthRecord.date">({{ healthRecord.date }})</span>
  269. </header>
  270. <main>
  271. <div class="row">
  272. <a-space :size="24">
  273. <a-space direction="vertical" :size="12">
  274. <span><label>程度</label>{{ healthRecord.result?.level }}</span>
  275. <span><label>表现</label>{{ healthRecord.result?.description }}</span>
  276. <span><label>症素</label>{{ healthRecord.syndromeElement?.label }}</span>
  277. </a-space>
  278. <a-space direction="vertical" :size="12">
  279. <span><label>类型</label>{{ healthRecord.result?.category }}</span>
  280. <span><label>体质</label>{{ healthRecord.physique?.label }}</span>
  281. <span><label>证型</label>{{ healthRecord.syndrome?.label }}</span>
  282. </a-space>
  283. </a-space>
  284. </div>
  285. </main>
  286. </div>
  287. <div class="row">
  288. <header>
  289. <label>症状</label>
  290. <span>{{ healthRecord.symptom?.value || ' - ' }}</span>
  291. <span v-if="healthRecord.symptom?.duration">,{{ healthRecord.symptom?.duration }}</span>
  292. <span v-if="healthRecord.symptom?.influence">,{{ healthRecord.symptom?.influence }}</span>
  293. </header>
  294. </div>
  295. <HealthReportAnalysisWidget class="row" category="tongue" :analysis="healthRecord.analysis"></HealthReportAnalysisWidget>
  296. <HealthReportAnalysisWidget class="row" category="face" :analysis="healthRecord.analysis"></HealthReportAnalysisWidget>
  297. <div class="row" v-if="indicator.length">
  298. <header>
  299. <label>生理指标</label>
  300. <a-button type="link" @click="openIndicatorRecordsPreview">更新记录</a-button>
  301. </header>
  302. <main>
  303. <div class="flex flex-wrap">
  304. <div class="text-center w-260px row" v-for="item in indicator" :key="item.id">
  305. <div class="flex justify-center">
  306. <span
  307. ><label>{{ item.name }}</label
  308. >{{ item.value }}{{ item.unit }}</span
  309. >
  310. <div class="inline-block ml-2 size-24px">
  311. <a-button v-if="item.trend > 0" :icon="h(ArrowUpOutlined)" shape="circle" size="small" class="trend-up" />
  312. <a-button v-else-if="item.trend < 0" :icon="h(ArrowDownOutlined)" shape="circle" size="small" class="trend-down" />
  313. </div>
  314. </div>
  315. <div class="text-center mt-1" style="font-size: 14px; color: rgba(0, 0, 0, 0.45)">{{ item.date }}</div>
  316. </div>
  317. </div>
  318. </main>
  319. </div>
  320. </main>
  321. </section>
  322. <a-tabs class="panel-wrapper" v-model:activeKey="activePanel">
  323. <a-tab-pane v-for="panel in panels" :key="panel.id">
  324. <component :is="panel.component" :patient="patient"></component>
  325. </a-tab-pane>
  326. <template #renderTabBar>
  327. <a-radio-group v-model:value="activePanel" @change="activePanelChange($event.nativeEvent)">
  328. <a-radio-button v-for="panel in panels" :key="panel.id" :value="panel.id" :disabled="panel.disabled">
  329. {{ panel.title }}
  330. </a-radio-button>
  331. </a-radio-group>
  332. </template>
  333. </a-tabs>
  334. </div>
  335. </template>
  336. <style scoped lang="scss">
  337. .title-text {
  338. font-size: 16px;
  339. color: rgba(0, 0, 0, 0.45);
  340. }
  341. section {
  342. color: rgba(0, 0, 0, 0.85);
  343. > header {
  344. font-size: 18px;
  345. font-weight: 700;
  346. :deep(.ant-btn-link) {
  347. padding-block: 0;
  348. font-size: 18px;
  349. border: none;
  350. }
  351. }
  352. > main {
  353. margin-left: 18px * 4;
  354. padding: 0 15px;
  355. font-size: 16px;
  356. color: rgba(0, 0, 0, 0.85);
  357. > .row > .ant-space {
  358. font-size: 16px;
  359. }
  360. .row {
  361. padding: 12px 0;
  362. span > label {
  363. color: rgba(0, 0, 0, 0.45);
  364. }
  365. label::after {
  366. margin-left: 2px;
  367. margin-right: 8px;
  368. content: ':';
  369. }
  370. > header::before {
  371. $size: 10px;
  372. content: '';
  373. display: inline-block;
  374. margin-right: 12px;
  375. width: $size;
  376. height: $size;
  377. border: 2px solid #1d6ff6;
  378. border-radius: 50%;
  379. }
  380. > main {
  381. margin-left: 18px * 2;
  382. }
  383. }
  384. }
  385. .ant-tag {
  386. margin-top: 6px;
  387. }
  388. }
  389. .separate {
  390. :deep(.ant-space-item) {
  391. & + .ant-space-item::before {
  392. content: ',';
  393. margin-right: 2px;
  394. }
  395. }
  396. span + span::before {
  397. content: ',';
  398. margin-right: 2px;
  399. }
  400. }
  401. .panel-wrapper {
  402. :deep(.ant-tabs-content-holder) {
  403. padding-top: 12px;
  404. height: calc(100vh - 60px - 24px - 32px);
  405. .ant-tabs-content {
  406. height: 100%;
  407. }
  408. }
  409. }
  410. .trend-up {
  411. color: #ff4d4f;
  412. border-color: #ff4d4f;
  413. }
  414. .trend-down {
  415. color: #87d068;
  416. border-color: #87d068;
  417. }
  418. </style>