diff --git a/.cursor/rules/Api-Response.mdc b/.cursor/rules/Api-Response.mdc new file mode 100644 index 0000000..1a51882 --- /dev/null +++ b/.cursor/rules/Api-Response.mdc @@ -0,0 +1,49 @@ +--- +description: Yii 与 xk-api 接口响应取值规范(按后端固定写死,禁止混取) +alwaysApply: true +--- + +# 接口响应取值(Yii vs xk-api) + +写请求代码时**先确认该接口走哪个后端**,再按对应字段固定取值。 +**禁止**运行时猜测(如「有 code 就取 result」),**禁止** `result || data` / `code ?? errcode` 混写兼容。 + +## 形态对照 + +| | Yii(oldApi) | xk-api(Laravel jok) | +|---|---|---| +| 成功码 | `errcode: 0` | `code: 0` | +| 业务数据 | `data` | `result` | +| 提示文案 | `msg` | `message` | + +## 强制用法 + +统一用 `@/utils/api-response.js`,按后端选方法: + +```js +// 该接口是 xk-api +import { unwrapXkApi } from '@/utils/api-response.js' +const { ok, payload, message } = unwrapXkApi(res) + +// 该接口是 Yii +import { unwrapYiiApi } from '@/utils/api-response.js' +const { ok, payload, message } = unwrapYiiApi(res) +``` + +也可直接写死(患者端完整响应在 `res.data`): + +```js +// xk-api +if (res.data.code == 0) { const data = res.data.result } + +// Yii +if (res.data.errcode == 0) { const data = res.data.data } +``` + +API 封装文件注释里标明后端,例如:`// xk-api POST /patient/list`。 + +## 禁止 + +- 禁止 `unwrapApi` 一类「自动识别后端再取值」 +- 禁止 `res.data.result || res.data.data` +- 禁止把 xk-api 再 `normalize` 成 errcode/data 后按 Yii 读 diff --git a/.cursor/rules/Code-Standards.mdc b/.cursor/rules/Code-Standards.mdc index 4e74dd2..600712f 100644 --- a/.cursor/rules/Code-Standards.mdc +++ b/.cursor/rules/Code-Standards.mdc @@ -10,3 +10,4 @@ alwaysApply: true 5. 数据库的(created_at、updated_at、deleted_at)统一使用时间戳,不要使用字符串,并且我在查询器中一级格式化成字符串了,无需再次格式化 6. 微信小程序 `.vue` 模板(会编译成 WXML)禁止使用 `??`、`?.` 等现代运算符,否则会报 `unexpected token '?'`;模板里用 `||` / 显式判断,脚本里可用 `??`/`?.` 7. 微信小程序模板里 `:class` / `:style` 禁止写 `fn(arg)` 方法调用(如 `:class="sexClass(p)"` 会编译失败);用对象/数组字面量(如 `:class="{ male: p.sex == 1 }"`),或把结果先算进 data/computed 再绑定 +8. 接口取值:写代码时先确认接口是 xk-api 还是 Yii,再固定用 `code/result/message` 或 `errcode/data/msg`(可用 `unwrapXkApi` / `unwrapYiiApi`);禁止运行时猜测、禁止 `result || data`(详见 Api-Response.mdc) diff --git a/mixins/patientTabList.js b/mixins/patientTabList.js new file mode 100644 index 0000000..7f302e0 --- /dev/null +++ b/mixins/patientTabList.js @@ -0,0 +1,181 @@ +/** + * 就诊人 Tab + swiper 列表公共逻辑(处方/挂号/病历复用) + * 页面需实现:fetchPatientList(patientId, page) → Promise 返回完整接口 res + */ +import { getPatientListApi } from '@/request/api/patient.js' +import { unwrapXkApi } from '@/utils/api-response.js' + +export default { + data() { + return { + patientList: [], + patientTabs: [], + current: 0, + tabChanging: false, + infoList: [], + page: 1, + totalPage: 1, + total: 0, + loadMoreStatus: 'nomore', + isRefreshing: false, + scrollTop: 0, + emptyPatient: false, + } + }, + computed: { + currentPatientId() { + const p = this.patientList[this.current] + return p ? Number(p.id) : 0 + }, + }, + methods: { + /** + * 拉取就诊人并加载当前 Tab 列表 + */ + async bootstrapPatientTabs() { + try { + const res = await getPatientListApi({}) + // getPatientListApi → xk-api + const { ok, payload } = unwrapXkApi(res) + if (!ok) { + this.patientList = [] + this.patientTabs = [] + this.emptyPatient = true + this.infoList = [] + return + } + // xk-api:{ list, latest_register_user_patient_id };兼容旧版纯数组 + const list = Array.isArray(payload) ? payload : (payload && payload.list) || [] + const latestId = Array.isArray(payload) + ? 0 + : Number((payload && payload.latest_register_user_patient_id) || 0) + this.patientList = list + this.patientTabs = list.map((p) => ({ name: p.name || '就诊人' })) + this.emptyPatient = list.length === 0 + if (list.length === 0) { + this.infoList = [] + return + } + // 优先最近挂号就诊人,其次默认就诊人,否则第一个 + let idx = -1 + if (latestId > 0) { + idx = list.findIndex((p) => Number(p.id) === latestId) + } + if (idx < 0) { + idx = list.findIndex((p) => Number(p.is_default) === 1) + } + if (idx < 0) { + idx = 0 + } + if (this.current >= list.length) { + this.current = idx + } else if (!this._tabsBootstrapped) { + this.current = idx + } + this._tabsBootstrapped = true + this.reloadCurrentTab() + } catch (e) { + console.error('bootstrapPatientTabs', e) + this.emptyPatient = true + } + }, + onTabChange(index) { + if (this.tabChanging) { + return + } + this.tabChanging = true + this.changePatientTab(index) + this.$nextTick(() => { + this.tabChanging = false + }) + }, + onSwiperChange(e) { + if (this.tabChanging) { + return + } + this.tabChanging = true + this.changePatientTab(e.detail.current) + this.$nextTick(() => { + this.tabChanging = false + }) + }, + changePatientTab(index) { + const tabIndex = Number(index) || 0 + this.current = tabIndex + this.reloadCurrentTab() + }, + reloadCurrentTab() { + this.page = 1 + this.infoList = [] + this.loadMoreStatus = 'loading' + this.fetchCurrentList() + }, + /** + * 页面实现:return getXxxListApi({...}) + */ + fetchPatientList() { + return Promise.reject(new Error('请实现 fetchPatientList')) + }, + fetchCurrentList(callback) { + const patientId = this.currentPatientId + if (!patientId) { + this.infoList = [] + this.loadMoreStatus = 'nomore' + if (typeof callback === 'function') { + callback() + } + return + } + this.fetchPatientList(patientId, this.page) + .then((res) => { + // fetchPatientList 约定走 xk-api(处方/挂号/病历) + const { ok, payload } = unwrapXkApi(res) + if (!ok || !payload) { + this.loadMoreStatus = 'nomore' + return + } + const list = payload.list || [] + const pagination = payload.pagination || {} + this.totalPage = Number(pagination.totalPage) || 1 + this.total = Number(pagination.total) || 0 + if (this.page > 1) { + this.infoList = this.infoList.concat(list) + } else { + this.infoList = list + } + this.loadMoreStatus = this.page >= this.totalPage ? 'nomore' : 'loadmore' + }) + .catch((e) => { + console.error('fetchCurrentList', e) + this.loadMoreStatus = 'nomore' + }) + .finally(() => { + if (typeof callback === 'function') { + callback() + } + }) + }, + onRefresherRefresh() { + this.isRefreshing = true + this.page = 1 + this.infoList = [] + this.fetchCurrentList(() => { + this.isRefreshing = false + }) + }, + onOrderScrollToLower() { + if (this.page >= this.totalPage) { + this.loadMoreStatus = 'nomore' + return + } + this.page += 1 + this.loadMoreStatus = 'loading' + this.fetchCurrentList() + }, + goAddPatient() { + uni.navigateTo({ + url: '/subPackages/my/myinfo-add', + }) + }, + }, +} diff --git a/pages.json b/pages.json index 1e2a681..f4627d4 100644 --- a/pages.json +++ b/pages.json @@ -313,18 +313,32 @@ "enablePullDownRefresh": false } }, + { + "path": "my/mymedical", + "style": { + "navigationBarTitleText": "我的病历", + "enablePullDownRefresh": false + } + }, + { + "path": "my/mymedical-detail", + "style": { + "navigationBarTitleText": "病历详情", + "enablePullDownRefresh": false + } + }, { "path": "my/myrecord", "style": { - "navigationBarTitleText": "处方记录", - "enablePullDownRefresh": true + "navigationBarTitleText": "我的处方", + "enablePullDownRefresh": false } }, { "path": "my/myappiont", "style": { - "navigationBarTitleText": "挂号记录", - "enablePullDownRefresh": true + "navigationBarTitleText": "我的挂号", + "enablePullDownRefresh": false } }, { diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue index 6ee0caf..99d0e77 100644 --- a/pages/mine/mine.vue +++ b/pages/mine/mine.vue @@ -63,17 +63,17 @@ - + 我的病历 + - 处方记录 + 我的处方 - 挂号记录 + 我的挂号 @@ -108,6 +108,7 @@ import { getUserInfoApi } from '../../request/api/user' + import { unwrapXkApi } from '@/utils/api-response.js' export default { data() { return { @@ -140,9 +141,10 @@ getUserInfoApi({ store_id: uni.getStorageSync('store_id') || 11001 }).then((res) => { - // console.log(res, 'ingo'); - if (res.data.code == 0) { - this.infoList = res.data.result + // getUserInfoApi → xk-api + const { ok, payload } = unwrapXkApi(res) + if (ok) { + this.infoList = payload } }) }, diff --git a/request/api/medicalRecord.js b/request/api/medicalRecord.js new file mode 100644 index 0000000..43a8a7b --- /dev/null +++ b/request/api/medicalRecord.js @@ -0,0 +1,19 @@ +import { post, get } from './http' + +/** + * 我的病历列表(xk-api POST /medical-record/list) + * 取值:unwrapXkApi → code/result/message + * @param {{ user_patient_id: number, page?: number, pageSize?: number }} params + */ +export async function getMedicalRecordListApi(params) { + return await post('/medical-record/list', params, 3) +} + +/** + * 我的病历详情(xk-api GET /medical-record/detail) + * 取值:unwrapXkApi → code/result/message + * @param {{ id: number }} params + */ +export async function getMedicalRecordDetailApi(params) { + return await get('/medical-record/detail', params, 3) +} diff --git a/request/api/patient.js b/request/api/patient.js new file mode 100644 index 0000000..2e9766a --- /dev/null +++ b/request/api/patient.js @@ -0,0 +1,41 @@ +import { post, get } from './http' + +/** + * 就诊人相关接口统一走 xk-api(type=3) + * 取值:unwrapXkApi → code / result / message + */ + +/** 就诊人列表 POST /patient/list → { list, latest_register_user_patient_id } */ +export async function getPatientListApi(params = {}) { + return await post('/patient/list', params, 3) +} + +/** 就诊人保存(新增/编辑)POST /patient/save */ +export async function savePatientApi(params = {}) { + return await post('/patient/save', params, 3) +} + +/** 删除就诊人 POST /patient/delete */ +export async function deletePatientApi(params = {}) { + return await post('/patient/delete', params, 3) +} + +/** 监护人信息 GET /patient/guardian-info */ +export async function getPatientGuardianInfoApi(params = {}) { + return await get('/patient/guardian-info', params, 3) +} + +/** 关系枚举 GET /patient/relation */ +export async function getPatientRelationApi(params = {}) { + return await get('/patient/relation', params, 3) +} + +/** 设为默认就诊人 POST /patient/change-default,传 up_id */ +export async function changePatientDefaultApi(params = {}) { + return await post('/patient/change-default', params, 3) +} + +/** 健康问诊详情 POST /patient/health-info,传 user_patient_id */ +export async function getPatientHealthInfoApi(params = {}) { + return await post('/patient/health-info', params, 3) +} diff --git a/request/api/register.js b/request/api/register.js index 979a120..6e4fc31 100644 --- a/request/api/register.js +++ b/request/api/register.js @@ -1,4 +1,5 @@ import {post} from './http' +import { unwrapXkApi } from '@/utils/api-response.js' /** * 获取挂号记录列表 @@ -21,9 +22,11 @@ export async function fetchUnpaidRegisterListApi(params = {}) { page: 1, ...params, }, 3); - if (res.data?.code !== 0 && res.data?.code !== '0') { + // /register/list → xk-api + const { ok, payload } = unwrapXkApi(res) + if (!ok) { return []; } - const list = res.data?.result?.list || []; + const list = (payload && payload.list) || []; return list.filter((item) => item.status === 0 && item.is_cancel !== 1); } diff --git a/subPackages/my/myappiont.vue b/subPackages/my/myappiont.vue index 12cacea..1fc3dcf 100644 --- a/subPackages/my/myappiont.vue +++ b/subPackages/my/myappiont.vue @@ -1,432 +1,241 @@ \ No newline at end of file + diff --git a/subPackages/my/myinfo-add.vue b/subPackages/my/myinfo-add.vue index a88aed7..6aac0bd 100644 --- a/subPackages/my/myinfo-add.vue +++ b/subPackages/my/myinfo-add.vue @@ -155,10 +155,29 @@ +添加 - + - 个人病史 + 现病史 + + + {{item.name}} + + + + + + +添加 + + + + + + 既往史 @@ -173,15 +192,15 @@ +添加 - + - 家族病史 + 家族史 - {{item.name}} - + @@ -191,6 +210,82 @@ +添加 + + + + 流行病学史 + + + {{item.name}} + + + + + + +添加 + + + + + + 个人史 + + + {{item.name}} + + + + + + +添加 + + + + + + 月经史 + + + {{item.name}} + + + + + + +添加 + + + + + + 婚育史 + + + {{item.name}} + + + + + + +添加 + + @@ -356,7 +451,7 @@ name: '阿司匹林' } ], - person: "无", // 个人病史 + person: "无", // 既往史 personList: [{ name: '先天性心脏病' }, @@ -379,7 +474,7 @@ name: '哮喘' } ], - family: "无", // 家庭病史 + family: "无", // 家族史 familyList: [{ name: '高血压' }, @@ -411,12 +506,84 @@ name: '结核病' } ], + // 以下与病历字段对齐,默认「无」,挂号时写入病历 + present: "无", + presentList: [{ + name: '起病急' + }, + { + name: '病程迁延' + }, + { + name: '反复发作' + }, + { + name: '自行用药' + }, + { + name: '症状加重' + } + ], + epidemic: "无", + epidemicList: [{ + name: '疫区旅居' + }, + { + name: '确诊病例接触' + }, + { + name: '发热病例接触' + } + ], + personal: "无", + personalList: [{ + name: '吸烟' + }, + { + name: '饮酒' + }, + { + name: '熬夜' + } + ], + menstrual: "无", + menstrualList: [{ + name: '月经规律' + }, + { + name: '痛经' + }, + { + name: '月经不调' + } + ], + marital: "无", + maritalList: [{ + name: '未婚' + }, + { + name: '已婚' + }, + { + name: '已育' + } + ], rSelect: [], rSelects: [], rSelec: [], + rSelectPresent: [], + rSelectEpidemic: [], + rSelectPersonal: [], + rSelectMenstrual: [], + rSelectMarital: [], allergic_history: [], person_history: [], family_history: [], + present_history: [], + epidemic_history: [], + personal_history: [], + menstrual_history: [], + marital_history: [], // 内容安全 baseline:新增页为空对象,仅提交变动字段 _securityBaseline: {}, is_default: 0, @@ -440,6 +607,17 @@ const age = Number(this.form.age); return this.form.age !== '' && !isNaN(age) && age <= 6; }, + // 月经史仅女性展示(与病历面板规则一致) + showMenstrualHistory() { + return this.form.sex == '女' || this.form.sex == '2' || this.form.sex == 2; + }, + // 婚育史:男>22 或 女>20 + showMaritalHistory() { + const age = Number(this.form.age) || 0; + const isMale = this.form.sex == '男' || this.form.sex == '1' || this.form.sex == 1; + const isFemale = this.form.sex == '女' || this.form.sex == '2' || this.form.sex == 2; + return (isMale && age > 22) || (isFemale && age > 20); + }, guardianPickerList() { const currentId = Number(this.addid) || 0; return this.patientList @@ -689,8 +867,13 @@ name: this.names, visitDesc: this.visitDesc, allergic_history: this.allergic_history, + present_history: this.present_history, person_history: this.person_history, family_history: this.family_history, + epidemic_history: this.epidemic_history, + personal_history: this.personal_history, + menstrual_history: this.menstrual_history, + marital_history: this.marital_history, }, this._securityBaseline, SCENE_PROFILE); } catch (e) { handleSecurityError(e); @@ -710,11 +893,21 @@ liver_function: this.liver == '正常' ? '0' : '1', renal_function: this.renal == '正常' ? '0' : '1', allergic_status: this.allergic == '无' ? '0' : '1', + present_status: this.present == '无' ? '0' : '1', person_status: this.person == '无' ? '0' : '1', family_status: this.family == '无' ? '0' : '1', + epidemic_status: this.epidemic == '无' ? '0' : '1', + personal_status: this.personal == '无' ? '0' : '1', + menstrual_status: (!this.showMenstrualHistory || this.menstrual == '无') ? '0' : '1', + marital_status: (!this.showMaritalHistory || this.marital == '无') ? '0' : '1', allergic_history: this.allergic_history, + present_history: this.present_history, person_history: this.person_history, family_history: this.family_history, + epidemic_history: this.epidemic_history, + personal_history: this.personal_history, + menstrual_history: this.showMenstrualHistory ? this.menstrual_history : [], + marital_history: this.showMaritalHistory ? this.marital_history : [], }); userAdd({ method: "post", @@ -751,76 +944,96 @@ this.show = true this.addNum = 1 }, - // 个人病史 + // 既往史 addPer() { this.show = true this.addNum = 2 }, - // 家庭病史 + // 家族史 addFmaily() { this.show = true this.addNum = 3 }, - // 添加病情 + addEpidemic() { + this.show = true + this.addNum = 4 + }, + addPersonal() { + this.show = true + this.addNum = 5 + }, + addMenstrual() { + this.show = true + this.addNum = 6 + }, + addMarital() { + this.show = true + this.addNum = 7 + }, + // 现病史自定义标签 + addPresent() { + this.show = true + this.addNum = 8 + }, + // 添加自定义史标签 addTag() { this.show = false - - if (this.addNum == 3 && this.addtext != "") { - let obj = { - name: this.addtext - } - this.$set(this.familyList.push(obj)) - this.addtext = "" - } else if (this.addNum == 1 && this.addtext != "") { - let obj = { - name: this.addtext - } - this.$set(this.allergicList.push(obj)) - this.addtext = "" - - } else if (this.addNum == 2 && this.addtext != "") { - let obj = { - name: this.addtext - } - this.$set(this.personList.push(obj)) - this.addtext = "" + if (this.addtext == "") { + return + } + const obj = { name: this.addtext } + if (this.addNum == 3) { + this.familyList.push(obj) + } else if (this.addNum == 1) { + this.allergicList.push(obj) + } else if (this.addNum == 2) { + this.personList.push(obj) + } else if (this.addNum == 4) { + this.epidemicList.push(obj) + } else if (this.addNum == 5) { + this.personalList.push(obj) + } else if (this.addNum == 6) { + this.menstrualList.push(obj) + } else if (this.addNum == 7) { + this.maritalList.push(obj) + } else if (this.addNum == 8) { + this.presentList.push(obj) } this.addtext = "" }, - // 过敏史 + // 切换史标签选中(通用) + toggleHistoryTag(selectKey, historyKey, index, item) { + if (this[selectKey].indexOf(index) == -1) { + this[selectKey].push(index) + this[historyKey].push(item.name) + } else { + this[selectKey].splice(this[selectKey].indexOf(index), 1) + this[historyKey].splice(this[historyKey].indexOf(item.name), 1) + } + }, tapInfo(e, item) { - // console.log(item); - if (this.rSelect.indexOf(e) == -1) { - // console.log(e) //打印下标 - this.rSelect.push(e); //选中添加到数组里 - this.allergic_history.push(item.name) - } else { - this.rSelect.splice(this.rSelect.indexOf(e), 1); //取消 - this.allergic_history.splice(this.allergic_history.indexOf(item.name), 1) - } - + this.toggleHistoryTag('rSelect', 'allergic_history', e, item) }, - // 个人病史 tapInfos(e, item) { - if (this.rSelects.indexOf(e) == -1) { - // console.log(e) //打印下标 - this.rSelects.push(e); //选中添加到数组里 - this.person_history.push(item.name) - } else { - this.rSelects.splice(this.rSelects.indexOf(e), 1); //取消 - this.person_history.splice(this.person_history.indexOf(item.name), 1) - } + this.toggleHistoryTag('rSelects', 'person_history', e, item) }, - // 家庭病史 taps(e, item) { - if (this.rSelec.indexOf(e) == -1) { - // console.log(e) //打印下标 - this.rSelec.push(e); //选中添加到数组里 - this.family_history.push(item.name) - } else { - this.rSelec.splice(this.rSelec.indexOf(e), 1); //取消 - this.family_history.splice(this.family_history.indexOf(item.name), 1) - } + this.toggleHistoryTag('rSelec', 'family_history', e, item) + }, + tapEpidemic(e, item) { + this.toggleHistoryTag('rSelectEpidemic', 'epidemic_history', e, item) + }, + tapPersonal(e, item) { + this.toggleHistoryTag('rSelectPersonal', 'personal_history', e, item) + }, + tapMenstrual(e, item) { + this.toggleHistoryTag('rSelectMenstrual', 'menstrual_history', e, item) + }, + tapMarital(e, item) { + this.toggleHistoryTag('rSelectMarital', 'marital_history', e, item) + }, + tapPresent(e, item) { + this.toggleHistoryTag('rSelectPresent', 'present_history', e, item) }, // 身份证号码 diff --git a/subPackages/my/myinfo-edit.vue b/subPackages/my/myinfo-edit.vue index 0d06777..8ad913f 100644 --- a/subPackages/my/myinfo-edit.vue +++ b/subPackages/my/myinfo-edit.vue @@ -144,10 +144,29 @@ +添加 - + - 个人病史 + 现病史 + + + {{item.name}} + + + + + + +添加 + + + + + + 既往史 @@ -162,15 +181,15 @@ +添加 - + - 家族病史 + 家族史 - {{item.name}} - + @@ -180,6 +199,82 @@ +添加 + + + + 流行病学史 + + + {{item.name}} + + + + + + +添加 + + + + + + 个人史 + + + {{item.name}} + + + + + + +添加 + + + + + + 月经史 + + + {{item.name}} + + + + + + +添加 + + + + + + 婚育史 + + + {{item.name}} + + + + + + +添加 + + @@ -334,7 +429,7 @@ name: '阿司匹林' } ], - person: "无", // 个人病史 + person: "无", // 既往史 personList: [{ name: '先天性心脏病' }, @@ -357,7 +452,7 @@ name: '哮喘' } ], - family: "无", // 家庭病史 + family: "无", // 家族史 familyList: [{ name: '高血压' }, @@ -389,12 +484,83 @@ name: '结核病' } ], + present: "无", + presentList: [{ + name: '起病急' + }, + { + name: '病程迁延' + }, + { + name: '反复发作' + }, + { + name: '自行用药' + }, + { + name: '症状加重' + } + ], + epidemic: "无", + epidemicList: [{ + name: '疫区旅居' + }, + { + name: '确诊病例接触' + }, + { + name: '发热病例接触' + } + ], + personal: "无", + personalList: [{ + name: '吸烟' + }, + { + name: '饮酒' + }, + { + name: '熬夜' + } + ], + menstrual: "无", + menstrualList: [{ + name: '月经规律' + }, + { + name: '痛经' + }, + { + name: '月经不调' + } + ], + marital: "无", + maritalList: [{ + name: '未婚' + }, + { + name: '已婚' + }, + { + name: '已育' + } + ], rSelect: [], rSelects: [], rSelec: [], + rSelectPresent: [], + rSelectEpidemic: [], + rSelectPersonal: [], + rSelectMenstrual: [], + rSelectMarital: [], allergic_history: [], person_history: [], family_history: [], + present_history: [], + epidemic_history: [], + personal_history: [], + menstrual_history: [], + marital_history: [], // 内容安全 baseline:详情加载完成后快照 _securityBaseline: {}, heathList: [], // 健康信息 @@ -418,6 +584,15 @@ const age = Number(this.form.age); return this.form.age !== '' && !isNaN(age) && age <= 6; }, + showMenstrualHistory() { + return this.form.sex == '女' || this.form.sex == '2' || this.form.sex == 2; + }, + showMaritalHistory() { + const age = Number(this.form.age) || 0; + const isMale = this.form.sex == '男' || this.form.sex == '1' || this.form.sex == 1; + const isFemale = this.form.sex == '女' || this.form.sex == '2' || this.form.sex == 2; + return (isMale && age > 22) || (isFemale && age > 20); + }, guardianPickerList() { const currentId = Number(this.addid) || 0; return this.allPatientList @@ -480,83 +655,131 @@ // console.log(this.family, 'is'); }, - // 过敏史 addAller() { - this.addtext = '' + this.addtext = '' this.show = true this.addNum = 1 }, - // 个人病史 addPer() { - this.addtext = '' + this.addtext = '' this.show = true this.addNum = 2 }, - // 家庭病史 addFmaily() { - this.addtext = '' + this.addtext = '' this.show = true this.addNum = 3 }, - // 添加病情 + addEpidemic() { + this.addtext = '' + this.show = true + this.addNum = 4 + }, + addPersonal() { + this.addtext = '' + this.show = true + this.addNum = 5 + }, + addMenstrual() { + this.addtext = '' + this.show = true + this.addNum = 6 + }, + addMarital() { + this.addtext = '' + this.show = true + this.addNum = 7 + }, + addPresent() { + this.addtext = '' + this.show = true + this.addNum = 8 + }, + // 添加自定义史标签 addTag() { this.show = false - if (this.addNum == 3 && this.addtext != "") { - let obj = { - name: this.addtext - } - this.$set(this.familyList.push(obj)) - } else if (this.addNum == 1 && this.addtext != "") { - let obj = { - name: this.addtext - } - this.$set(this.allergicList.push(obj)) - } else if (this.addNum == 2 && this.addtext != "") { - let obj = { - name: this.addtext - } - this.$set(this.personList.push(obj)) + if (this.addtext == "") { + return + } + const obj = { name: this.addtext } + if (this.addNum == 3) { + this.familyList.push(obj) + } else if (this.addNum == 1) { + this.allergicList.push(obj) + } else if (this.addNum == 2) { + this.personList.push(obj) + } else if (this.addNum == 4) { + this.epidemicList.push(obj) + } else if (this.addNum == 5) { + this.personalList.push(obj) + } else if (this.addNum == 6) { + this.menstrualList.push(obj) + } else if (this.addNum == 7) { + this.maritalList.push(obj) + } else if (this.addNum == 8) { + this.presentList.push(obj) + } + this.addtext = "" + }, + toggleHistoryTag(selectKey, historyKey, index, item) { + if (this[selectKey].indexOf(index) == -1) { + this[selectKey].push(index) + this[historyKey].push(item.name) + } else { + this[selectKey].splice(this[selectKey].indexOf(index), 1) + this[historyKey].splice(this[historyKey].indexOf(item.name), 1) } - this.addtext = "" }, - // 过敏史 tapInfo(e, item) { - - if (this.rSelect.indexOf(e) == -1) { - // console.log(e) //打印下标 - this.rSelect.push(e); //选中添加到数组里 - this.allergic_history.push(item.name) - } else { - this.rSelect.splice(this.rSelect.indexOf(e), 1); //取消 - this.allergic_history.splice(this.allergic_history.indexOf(item.name), 1) - } - + this.toggleHistoryTag('rSelect', 'allergic_history', e, item) }, - // 个人病史 tapInfos(e, item) { - console.log(e, item, 'daaaaaaaaaaaaaaaaaaa') - // 如果当前选项不在已选中项的数组中 - if (this.rSelects.indexOf(e) == -1) { - // console.log(e) // 打印当前选项的下标 - this.rSelects.push(e); // 将选中的选项添加到数组中 - this.person_history.push(item.name); // 同时将选项的名称添加到历史记录中 - } else { - // 如果当前选项已经在已选中项的数组中,则移除它 - this.rSelects.splice(this.rSelects.indexOf(e), 1); // 取消选中 - // 同时从历史记录中移除该选项的名称 - this.person_history.splice(this.person_history.indexOf(item.name), 1); - } + this.toggleHistoryTag('rSelects', 'person_history', e, item) }, - // 家庭病史 taps(e, item) { - if (this.rSelec.indexOf(e) == -1) { - // console.log(e) //打印下标 - this.rSelec.push(e); //选中添加到数组里 - this.family_history.push(item.name) - } else { - this.rSelec.splice(this.rSelec.indexOf(e), 1); //取消 - this.family_history.splice(this.family_history.indexOf(item.name), 1) - } + this.toggleHistoryTag('rSelec', 'family_history', e, item) + }, + tapEpidemic(e, item) { + this.toggleHistoryTag('rSelectEpidemic', 'epidemic_history', e, item) + }, + tapPersonal(e, item) { + this.toggleHistoryTag('rSelectPersonal', 'personal_history', e, item) + }, + tapMenstrual(e, item) { + this.toggleHistoryTag('rSelectMenstrual', 'menstrual_history', e, item) + }, + tapMarital(e, item) { + this.toggleHistoryTag('rSelectMarital', 'marital_history', e, item) + }, + tapPresent(e, item) { + this.toggleHistoryTag('rSelectPresent', 'present_history', e, item) + }, + /** + * 回显史标签:已有选项勾选;自定义项追加到列表并勾选 + */ + applyHistoryEcho(listKey, selectKey, historyKey, names) { + const that = this + const arr = Array.isArray(names) ? names : [] + arr.forEach(function (name) { + if (!name) { + return + } + let idx = that[listKey].findIndex(function (it) { + return it.name == name + }) + if (idx < 0) { + that[listKey].push({ name: name, checked: true }) + idx = that[listKey].length - 1 + } else { + that.$set(that[listKey][idx], 'checked', true) + } + if (that[selectKey].indexOf(idx) == -1) { + that[selectKey].push(idx) + } + if (that[historyKey].indexOf(name) == -1) { + that[historyKey].push(name) + } + }) }, // 身份证号码 @@ -829,8 +1052,13 @@ name: this.names, visitDesc: this.visitDesc, allergic_history: this.allergic_history, + present_history: this.present_history, person_history: this.person_history, family_history: this.family_history, + epidemic_history: this.epidemic_history, + personal_history: this.personal_history, + menstrual_history: this.menstrual_history, + marital_history: this.marital_history, }, this._securityBaseline, SCENE_PROFILE); } catch (e) { handleSecurityError(e); @@ -849,11 +1077,21 @@ liver_function: this.liver == '正常' ? '0' : '1', renal_function: this.renal == '正常' ? '0' : '1', allergic_status: this.allergic == '无' ? '0' : '1', + present_status: this.present == '无' ? '0' : '1', person_status: this.person == '无' ? '0' : '1', family_status: this.family == '无' ? '0' : '1', + epidemic_status: this.epidemic == '无' ? '0' : '1', + personal_status: this.personal == '无' ? '0' : '1', + menstrual_status: (!this.showMenstrualHistory || this.menstrual == '无') ? '0' : '1', + marital_status: (!this.showMaritalHistory || this.marital == '无') ? '0' : '1', allergic_history: this.allergic_history, + present_history: this.present_history, person_history: this.person_history, family_history: this.family_history, + epidemic_history: this.epidemic_history, + personal_history: this.personal_history, + menstrual_history: this.showMenstrualHistory ? this.menstrual_history : [], + marital_history: this.showMaritalHistory ? this.marital_history : [], }); userAdd({ method: "post", @@ -898,49 +1136,40 @@ // console.log(res, 'heath'); if (res.data.errcode == 0) { this.heathList = res.data.data - this.liver = (this.heathList.liver_function) % 2 == 0 ? '正常' : '异常' this.renal = (this.heathList.renal_function) % 2 == 0 ? '正常' : '异常' - this.allergic = (this.heathList.allergic_status) % 2 == 0 ? '无' : '有' - this.allergicList = (this.heathList.allergic_history) == 'Array' ? [] : (this.heathList - .allergic_history).map(function (item, index) { - console.log(index, 'sssssssssssssssssssssssssss') - that.tapInfo(index, { - name: item, - checked: true - }) - return { - name: item, - checked: true - } - }) - this.person = (this.heathList.person_status) % 2 == 0 ? '无' : '有' - this.personList = (this.heathList.person_history != '') == 'Array' ? [] : (this.heathList - .person_history).map(function (item, index) { - that.tapInfos(index, { - name: item, - checked: true - }) - return { - name: item, - checked: true - } - }) - this.family = (this.heathList.family_status) % 2 == 0 ? '无' : '有' - this.familyList = (this.heathList.family_history != '') == 'Array' ? [] : (this.heathList - .family_history).map(function (item, index) { - that.taps(index, { - name: item, - checked: true - }) - return { - name: item, - checked: true - } - }) + this.present = (this.heathList.present_status || 0) % 2 == 0 ? '无' : '有' + this.epidemic = (this.heathList.epidemic_status || 0) % 2 == 0 ? '无' : '有' + this.personal = (this.heathList.personal_status || 0) % 2 == 0 ? '无' : '有' + this.menstrual = (this.heathList.menstrual_status || 0) % 2 == 0 ? '无' : '有' + this.marital = (this.heathList.marital_status || 0) % 2 == 0 ? '无' : '有' + this.rSelect = [] + this.rSelects = [] + this.rSelec = [] + this.rSelectPresent = [] + this.rSelectEpidemic = [] + this.rSelectPersonal = [] + this.rSelectMenstrual = [] + this.rSelectMarital = [] + this.allergic_history = [] + this.present_history = [] + this.person_history = [] + this.family_history = [] + this.epidemic_history = [] + this.personal_history = [] + this.menstrual_history = [] + this.marital_history = [] + that.applyHistoryEcho('allergicList', 'rSelect', 'allergic_history', this.heathList.allergic_history) + that.applyHistoryEcho('presentList', 'rSelectPresent', 'present_history', this.heathList.present_history) + that.applyHistoryEcho('personList', 'rSelects', 'person_history', this.heathList.person_history) + that.applyHistoryEcho('familyList', 'rSelec', 'family_history', this.heathList.family_history) + that.applyHistoryEcho('epidemicList', 'rSelectEpidemic', 'epidemic_history', this.heathList.epidemic_history) + that.applyHistoryEcho('personalList', 'rSelectPersonal', 'personal_history', this.heathList.personal_history) + that.applyHistoryEcho('menstrualList', 'rSelectMenstrual', 'menstrual_history', this.heathList.menstrual_history) + that.applyHistoryEcho('maritalList', 'rSelectMarital', 'marital_history', this.heathList.marital_history) } this.updateSecurityBaseline() }) @@ -951,8 +1180,13 @@ name: this.names, visitDesc: this.visitDesc, allergic_history: [...(this.allergic_history || [])], + present_history: [...(this.present_history || [])], person_history: [...(this.person_history || [])], family_history: [...(this.family_history || [])], + epidemic_history: [...(this.epidemic_history || [])], + personal_history: [...(this.personal_history || [])], + menstrual_history: [...(this.menstrual_history || [])], + marital_history: [...(this.marital_history || [])], }; } }, diff --git a/subPackages/my/mymedical-detail.vue b/subPackages/my/mymedical-detail.vue new file mode 100644 index 0000000..f264816 --- /dev/null +++ b/subPackages/my/mymedical-detail.vue @@ -0,0 +1,188 @@ + + + + + diff --git a/subPackages/my/mymedical.vue b/subPackages/my/mymedical.vue new file mode 100644 index 0000000..34f1cd2 --- /dev/null +++ b/subPackages/my/mymedical.vue @@ -0,0 +1,218 @@ + + + + + diff --git a/subPackages/my/myrecord.vue b/subPackages/my/myrecord.vue index 211b480..b8e4493 100644 --- a/subPackages/my/myrecord.vue +++ b/subPackages/my/myrecord.vue @@ -1,366 +1,237 @@ diff --git a/subPackages/register/components/RegisterPatientStep.vue b/subPackages/register/components/RegisterPatientStep.vue index 80132f8..1965fae 100644 --- a/subPackages/register/components/RegisterPatientStep.vue +++ b/subPackages/register/components/RegisterPatientStep.vue @@ -87,7 +87,19 @@ - 个人病史 + 现病史 + + {{present}} + + + + + + + + + 既往史 {{person}} @@ -99,7 +111,7 @@ - 家族病史 + 家族史 {{family}} @@ -109,6 +121,54 @@ :text="item" mode="dark" /> + + + 流行病学史 + + {{epidemic}} + + + + + + + + + 个人史 + + {{personal}} + + + + + + + + + 月经史 + + {{menstrual}} + + + + + + + + + 婚育史 + + {{marital}} + + + + + + @@ -160,10 +220,20 @@ export default { renal: '', allergic: '', allergicList: [], + present: '无', + presentList: [], person: '', personList: [], family: '', familyList: [], + epidemic: '无', + epidemicList: [], + personal: '无', + personalList: [], + menstrual: '无', + menstrualList: [], + marital: '无', + maritalList: [], heathList: [], rInfo: {}, registerType: '0', @@ -204,6 +274,23 @@ export default { && !!this.actived && this.infoList.some((p) => p.id === this.actived); }, + // 当前选中就诊人(用于月经史/婚育史展示规则) + activePatient() { + return this.infoList.find((p) => p.id === this.actived) || null; + }, + showMenstrualHistory() { + const p = this.activePatient; + return !!(p && Number(p.sex) === 2); + }, + showMaritalHistory() { + const p = this.activePatient; + if (!p) { + return false; + } + const sex = Number(p.sex); + const age = Number(p.age) || 0; + return (sex === 1 && age > 22) || (sex === 2 && age > 20); + }, }, watch: { doctorId: { @@ -500,11 +587,21 @@ export default { this.liver = (this.heathList.liver_function) % 2 == 0 ? '正常' : '异常'; this.renal = (this.heathList.renal_function) % 2 == 0 ? '正常' : '异常'; this.allergic = (this.heathList.allergic_status) % 2 == 0 ? '无' : '有'; - this.allergicList = (this.heathList.allergic_history) == 'Array' ? [] : (this.heathList.allergic_history); + this.allergicList = (this.heathList.allergic_history) == 'Array' ? [] : (this.heathList.allergic_history || []); + this.present = (this.heathList.present_status || 0) % 2 == 0 ? '无' : '有'; + this.presentList = this.heathList.present_history || []; this.person = (this.heathList.person_status) % 2 == 0 ? '无' : '有'; - this.personList = (this.heathList.person_history) == 'Array' ? [] : (this.heathList.person_history); + this.personList = (this.heathList.person_history) == 'Array' ? [] : (this.heathList.person_history || []); this.family = (this.heathList.family_status) % 2 == 0 ? '无' : '有'; - this.familyList = (this.heathList.family_history) == 'Array' ? [] : (this.heathList.family_history); + this.familyList = (this.heathList.family_history) == 'Array' ? [] : (this.heathList.family_history || []); + this.epidemic = (this.heathList.epidemic_status || 0) % 2 == 0 ? '无' : '有'; + this.epidemicList = this.heathList.epidemic_history || []; + this.personal = (this.heathList.personal_status || 0) % 2 == 0 ? '无' : '有'; + this.personalList = this.heathList.personal_history || []; + this.menstrual = (this.heathList.menstrual_status || 0) % 2 == 0 ? '无' : '有'; + this.menstrualList = this.heathList.menstrual_history || []; + this.marital = (this.heathList.marital_status || 0) % 2 == 0 ? '无' : '有'; + this.maritalList = this.heathList.marital_history || []; } }); }, diff --git a/utils/api-response.js b/utils/api-response.js new file mode 100644 index 0000000..64fa61b --- /dev/null +++ b/utils/api-response.js @@ -0,0 +1,78 @@ +/** + * 按「接口所属后端」固定取值,禁止运行时猜测 / result||data 混取 + * + * 写代码时先确认该请求打的是 xk-api 还是 Yii,再选用对应方法: + * - xk-api:unwrapXkApi / xkOk / xkPayload / xkMessage → code / result / message + * - Yii: unwrapYiiApi / yiiOk / yiiPayload / yiiMessage → errcode / data / msg + * + * 患者端 request 返回完整 uni 响应,业务包在 res.data + */ + +/** 取出业务 body(uni 完整响应 → res.data;已是 body 则原样) */ +export function getApiBody(res) { + if (res == null || typeof res !== 'object') { + return res + } + if ('statusCode' in res || 'errMsg' in res) { + return res.data + } + return res +} + +/** xk-api 是否成功(code === 0) */ +export function xkOk(res) { + const body = getApiBody(res) + return !!(body && Number(body.code) === 0) +} + +/** xk-api 业务数据(固定取 result) */ +export function xkPayload(res) { + const body = getApiBody(res) + return body ? body.result : undefined +} + +/** xk-api 提示文案(固定取 message) */ +export function xkMessage(res) { + const body = getApiBody(res) + return (body && body.message) || '' +} + +/** xk-api 一次解包 */ +export function unwrapXkApi(res) { + const body = getApiBody(res) + return { + ok: xkOk(res), + payload: xkPayload(res), + message: xkMessage(res), + body: body, + } +} + +/** Yii 是否成功(errcode === 0) */ +export function yiiOk(res) { + const body = getApiBody(res) + return !!(body && Number(body.errcode) === 0) +} + +/** Yii 业务数据(固定取 data) */ +export function yiiPayload(res) { + const body = getApiBody(res) + return body ? body.data : undefined +} + +/** Yii 提示文案(固定取 msg) */ +export function yiiMessage(res) { + const body = getApiBody(res) + return (body && body.msg) || '' +} + +/** Yii 一次解包 */ +export function unwrapYiiApi(res) { + const body = getApiBody(res) + return { + ok: yiiOk(res), + payload: yiiPayload(res), + message: yiiMessage(res), + body: body, + } +}