fix: 优化需求开发
This commit is contained in:
parent
e7e0a9d422
commit
998d95125a
@ -5,10 +5,10 @@ export default function useUser() {
|
|||||||
const store = userStore();
|
const store = userStore();
|
||||||
|
|
||||||
const { drugStore, familyProfile, logined, myProfile, patientList, storeId, userInfo } = storeToRefs(store);
|
const { drugStore, familyProfile, logined, myProfile, patientList, storeId, userInfo } = storeToRefs(store);
|
||||||
const { getAuthCode, getFamilyProfile, getStore, loadPatientList, login, loginout, getProfileData, setTemporaryPatient } = store;
|
const { getAuthCode, getFamilyProfile, getStore, loadPatientList, login, loginout, getProfileData } = store;
|
||||||
return {
|
return {
|
||||||
drugStore, familyProfile, logined, myProfile, patientList, storeId, userInfo,
|
drugStore, familyProfile, logined, myProfile, patientList, storeId, userInfo,
|
||||||
getAuthCode, getFamilyProfile, getStore, loadPatientList, login, loginout, getProfileData, setTemporaryPatient
|
getAuthCode, getFamilyProfile, getStore, loadPatientList, login, loginout, getProfileData
|
||||||
};
|
};
|
||||||
// const { userInfo, logined, maskName, maskMobile, maskCertNo, cards, card, idCardInfo, storeId, drugStore, getFamilyProfile, familyProfile } = storeToRefs(store);
|
// const { userInfo, logined, maskName, maskMobile, maskCertNo, cards, card, idCardInfo, storeId, drugStore, getFamilyProfile, familyProfile } = storeToRefs(store);
|
||||||
// const { login, loginout, getAuthCode, getStore } = store;
|
// const { login, loginout, getAuthCode, getStore } = store;
|
||||||
|
|||||||
@ -307,6 +307,9 @@ function upload(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
|
uni.setNavigationBarTitle({
|
||||||
|
title: titleMap[options.feeType] || ''
|
||||||
|
})
|
||||||
if (options.reEdit === '1') {
|
if (options.reEdit === '1') {
|
||||||
const record = get('re-edit-consult-order');
|
const record = get('re-edit-consult-order');
|
||||||
remove('re-edit-consult-order');
|
remove('re-edit-consult-order');
|
||||||
@ -316,13 +319,10 @@ onLoad((options) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const hisArchive = get("current-his-archive");
|
const patientProfile = get("consult-patient-profile");
|
||||||
remove("current-his-archive");
|
remove("consult-patient-profile");
|
||||||
initOrder({ feeType: options.feeType, socialno: options.socialno, hisArchive });
|
initOrder({ feeType: options.feeType, patientProfile });
|
||||||
}
|
}
|
||||||
uni.setNavigationBarTitle({
|
|
||||||
title: titleMap[options.feeType] || ''
|
|
||||||
})
|
|
||||||
uni.$on('on-disease-selected', onDiseaseSelected);
|
uni.$on('on-disease-selected', onDiseaseSelected);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<full-page :pageStyle="`background: ${themeBg};`">
|
<full-page :pageStyle="`background: ${themeBg};`">
|
||||||
<view v-if="logined" class="container">
|
<view class="container">
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<text class="title">选择就诊人</text>
|
<text class="title">选择就诊人</text>
|
||||||
<button class="scan-button rounded-sm" :disabled="scanning" @click="scanInsuranceCode">扫医保码</button>
|
<button class="scan-button rounded-sm" :disabled="scanning" @click="scanInsuranceCode">扫医保码</button>
|
||||||
@ -25,10 +25,7 @@
|
|||||||
<view v-if="!patientList.length" class="empty-text">暂无就诊人</view>
|
<view v-if="!patientList.length" class="empty-text">暂无就诊人</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<template #footer>
|
||||||
<re-login v-else height="80vh" />
|
|
||||||
|
|
||||||
<template v-if="logined" #footer>
|
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
<view class="button-group">
|
<view class="button-group">
|
||||||
<button class="action-button add-button rounded" @click="toAddPatient">
|
<button class="action-button add-button rounded" @click="toAddPatient">
|
||||||
@ -48,14 +45,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||||
import useElder from "@/hooks/useElder";
|
|
||||||
import useUser from "@/hooks/useUser";
|
import useUser from "@/hooks/useUser";
|
||||||
import { bindHisPatient, createSelfAuthRequest, getHisCustomer, getScannedCard } from "@/utils/api";
|
import { bindHisPatient, createSelfAuthRequest, addHisCustomer } from "@/utils/api";
|
||||||
import { set } from "@/utils/cache";
|
import { set } from "@/utils/cache";
|
||||||
import { toast } from "@/utils/widget";
|
import { toast } from "@/utils/widget";
|
||||||
import { themeBg, themeColor, themeSecondary } from "@/utils/theme-config";
|
import { themeBg, themeColor, themeSecondary } from "@/utils/theme-config";
|
||||||
|
|
||||||
import reLogin from "@/components/re-login.vue";
|
|
||||||
import ybPlugin from "@/utils/insurance-plugin";
|
import ybPlugin from "@/utils/insurance-plugin";
|
||||||
import fullPage from "@/components/full-page.vue";
|
import fullPage from "@/components/full-page.vue";
|
||||||
|
|
||||||
@ -63,8 +58,7 @@ const {
|
|||||||
logined,
|
logined,
|
||||||
getAuthCode,
|
getAuthCode,
|
||||||
userInfo,
|
userInfo,
|
||||||
storeId,
|
patientList,
|
||||||
patientList: storePatientList,
|
|
||||||
loadPatientList,
|
loadPatientList,
|
||||||
} = useUser();
|
} = useUser();
|
||||||
|
|
||||||
@ -78,59 +72,10 @@ const preferredCertNo = ref("");
|
|||||||
const feeType = ref("");
|
const feeType = ref("");
|
||||||
const scanning = ref(false);
|
const scanning = ref(false);
|
||||||
|
|
||||||
const patientList = computed(() => {
|
|
||||||
return storePatientList.value
|
|
||||||
.filter(patient => !patient.isTemporary)
|
|
||||||
.sort((a, b) => {
|
|
||||||
return new Date(a.createTime).getTime() - new Date(b.createTime).getTime();
|
|
||||||
});
|
|
||||||
// return feeType.value === "YB" ? list.filter(patient => patient.isSelf) : list;
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentProfile = computed(() => {
|
const currentProfile = computed(() => {
|
||||||
return patientList.value.find(patient => patient.id === selectedPatientId.value);
|
return patientList.value.find(patient => patient.id === selectedPatientId.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
onLoad(options => {
|
|
||||||
feeType.value = options.feeType;
|
|
||||||
preferredCertNo.value = options.socialno || "";
|
|
||||||
|
|
||||||
uni.setNavigationBarTitle({
|
|
||||||
title: titleMap[options.feeType] || "",
|
|
||||||
});
|
|
||||||
|
|
||||||
ybPlugin.init({
|
|
||||||
archiveTokenCallback: () => {
|
|
||||||
const certNo = currentProfile.value ? currentProfile.value.certNo : "";
|
|
||||||
uni.redirectTo({
|
|
||||||
url: `/pages/consult/index?socialno=${certNo}&feeType=${feeType.value}`,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
onShow(async () => {
|
|
||||||
if (logined.value) {
|
|
||||||
await loadPatientList();
|
|
||||||
selectDefaultPatient();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(logined, value => {
|
|
||||||
if (value) loadPatientList();
|
|
||||||
});
|
|
||||||
|
|
||||||
function selectDefaultPatient() {
|
|
||||||
const selectedExists = patientList.value.some(patient => patient.id === selectedPatientId.value);
|
|
||||||
if (selectedExists) return;
|
|
||||||
|
|
||||||
const preferred = patientList.value.find(patient => patient.certNo === preferredCertNo.value);
|
|
||||||
const self = patientList.value.find(patient => patient.isSelf);
|
|
||||||
selectedPatientId.value = (preferred || self || patientList.value[0] || {}).id || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(patientList, selectDefaultPatient, { immediate: true });
|
|
||||||
|
|
||||||
function scanCode() {
|
function scanCode() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
@ -142,6 +87,120 @@ function scanCode() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectDefaultPatient() {
|
||||||
|
const selectedExists = patientList.value.some(patient => patient.id === selectedPatientId.value);
|
||||||
|
if (selectedExists) return;
|
||||||
|
const preferred = patientList.value.find(patient => patient.certNo === preferredCertNo.value && preferredCertNo.value);
|
||||||
|
const self = patientList.value.find(patient => patient.isSelf);
|
||||||
|
selectedPatientId.value = (preferred || self || patientList.value[0] || {}).id || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function toAddPatient() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/member/detail`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle(patientId) {
|
||||||
|
selectedPatientId.value = patientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toPatientManagement() {
|
||||||
|
uni.navigateTo({ url: "/pages/member/list" });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function bindInsurance(psnToken, idCard, name, mobile) {
|
||||||
|
const { success, list, tmbxx, message } = await bindHisPatient({ idCard, name, mobile, psnToken });
|
||||||
|
const patients = Array.isArray(list) ? list : [];
|
||||||
|
const patient = patients.find(item => item.socialno === idCard) || patients[0] || null;
|
||||||
|
if (!success || !patient) {
|
||||||
|
toast(message || "医保建档失败");
|
||||||
|
return Promise.reject(message || "医保建档失败");
|
||||||
|
}
|
||||||
|
if (patient.isyb !== "1") {
|
||||||
|
toast("医保建档失败");
|
||||||
|
return Promise.reject("医保建档失败");
|
||||||
|
}
|
||||||
|
patient.tmbxx = tmbxx;
|
||||||
|
return patient;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getHisArchive(profile) {
|
||||||
|
const params = {
|
||||||
|
name: profile.name,
|
||||||
|
idCard: profile.certNo,
|
||||||
|
mobile: profile.mobile,
|
||||||
|
birthday: profile.birthday,
|
||||||
|
sex: profile.sex,
|
||||||
|
address: profile.address
|
||||||
|
}
|
||||||
|
const { success, list, tmbxx, message } = await addHisCustomer(params);
|
||||||
|
const patient = Array.isArray(list) ? list[0] : null;
|
||||||
|
if (!success || !patient) {
|
||||||
|
toast(message || "获取档案信息失败");
|
||||||
|
return Promise.reject(message || "获取档案信息失败");
|
||||||
|
}
|
||||||
|
patient.tmbxx = tmbxx;
|
||||||
|
return patient;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function nextStep() {
|
||||||
|
if (!currentProfile.value) {
|
||||||
|
toast("请选择就诊人");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let hisArchive = null;
|
||||||
|
if (feeType.value === 'YB') {
|
||||||
|
if (!currentProfile.value.certNo) {
|
||||||
|
toast("就诊人未填写证件号,暂不支持医保处方");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (currentProfile.value.isSelf) {
|
||||||
|
const authCode = await getAuthCode("nhsamp");
|
||||||
|
const psnToken = await ybPlugin.getArchiveToken(authCode);
|
||||||
|
if (psnToken) {
|
||||||
|
hisArchive = await bindInsurance(psnToken, currentProfile.value.certNo, currentProfile.value.name, currentProfile.value.mobile);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const { success, data, message } = await createSelfAuthRequest(
|
||||||
|
currentProfile.value.id,
|
||||||
|
userInfo.value.userId,
|
||||||
|
);
|
||||||
|
if (!success || !data || !data.id) {
|
||||||
|
toast(message || "创建授权请求失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
set("auth-hlw-patient", {
|
||||||
|
id: currentProfile.value.id,
|
||||||
|
name: currentProfile.value.name,
|
||||||
|
certNo: currentProfile.value.certNo,
|
||||||
|
feeType: feeType.value,
|
||||||
|
}, 10 * 60);
|
||||||
|
uni.navigateTo({ url: `/pages/consult/self-auth/auth-qrcode?id=${data.id}` });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hisArchive = await getHisArchive(currentProfile.value);
|
||||||
|
}
|
||||||
|
const consultPatientProfile = {
|
||||||
|
patientId: hisArchive.patientId,
|
||||||
|
blhno: hisArchive.blhno,
|
||||||
|
name: hisArchive.name,
|
||||||
|
mobile: hisArchive.tel,
|
||||||
|
sex: hisArchive.sex == 1 ? '男' : '女',
|
||||||
|
age: parseInt(hisArchive.age) > 0 ? parseInt(hisArchive.age) : '',
|
||||||
|
address: hisArchive.address,
|
||||||
|
socialno: hisArchive.socialno,
|
||||||
|
tmbxx: Array.isArray(hisArchive.tmbxx) ? hisArchive.tmbxx : []
|
||||||
|
}
|
||||||
|
set("consult-patient-profile", consultPatientProfile);
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/consult/disease-description?feeType=${feeType.value}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function scanInsuranceCode() {
|
async function scanInsuranceCode() {
|
||||||
if (scanning.value) return;
|
if (scanning.value) return;
|
||||||
scanning.value = true;
|
scanning.value = true;
|
||||||
@ -176,89 +235,33 @@ async function scanInsuranceCode() {
|
|||||||
scanning.value = false;
|
scanning.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function nextStep() {
|
onLoad(options => {
|
||||||
if (!currentProfile.value) {
|
feeType.value = options.feeType;
|
||||||
toast("请选择就诊人");
|
preferredCertNo.value = options.socialno || "";
|
||||||
return;
|
|
||||||
}
|
uni.setNavigationBarTitle({
|
||||||
let hisArchive = null;
|
title: titleMap[options.feeType] || "",
|
||||||
if (feeType.value === 'YB') {
|
|
||||||
if (currentProfile.value.isSelf) {
|
|
||||||
const authCode = await getAuthCode("nhsamp");
|
|
||||||
const psnToken = await ybPlugin.getArchiveToken(authCode);
|
|
||||||
if (psnToken) {
|
|
||||||
hisArchive = await bindInsurance(psnToken, currentProfile.value.certNo, currentProfile.value.name, currentProfile.value.mobile);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const { success, data, message } = await createSelfAuthRequest(
|
|
||||||
currentProfile.value._id,
|
|
||||||
userInfo.value.userId,
|
|
||||||
);
|
|
||||||
if (!success || !data || !data.id) {
|
|
||||||
toast(message || "创建授权请求失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
set("auth-hlw-patient", {
|
|
||||||
id: currentProfile.value._id,
|
|
||||||
name: currentProfile.value.name,
|
|
||||||
certNo: currentProfile.value.certNo,
|
|
||||||
feeType: feeType.value,
|
|
||||||
}, 10 * 60);
|
|
||||||
uni.navigateTo({ url: `/pages/consult/self-auth/auth-qrcode?id=${data.id}` });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hisArchive = await getHisArchive(currentProfile.value.certNo);
|
|
||||||
}
|
|
||||||
set("current-his-archive", hisArchive);
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/consult/disease-description?socialno=${currentProfile.value.certNo}&feeType=${feeType.value}`,
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
async function bindInsurance(psnToken, idCard, name, mobile) {
|
ybPlugin.init({
|
||||||
const { success, list, tmbxx, message } = await bindHisPatient({ idCard, name, mobile, psnToken });
|
archiveTokenCallback: () => {
|
||||||
const patients = Array.isArray(list) ? list : [];
|
const certNo = currentProfile.value ? currentProfile.value.certNo : "";
|
||||||
const patient = patients.find(item => item.socialno === idCard) || patients[0] || null;
|
uni.redirectTo({
|
||||||
if (!success || !patient) {
|
url: `/pages/consult/index?socialno=${certNo}&feeType=${feeType.value}`,
|
||||||
toast(message || "医保建档失败");
|
});
|
||||||
return Promise.reject(message || "医保建档失败");
|
},
|
||||||
}
|
|
||||||
if (patient.isyb !== "1") {
|
|
||||||
toast("医保建档失败");
|
|
||||||
return Promise.reject("医保建档失败");
|
|
||||||
}
|
|
||||||
patient.tmbxx = tmbxx;
|
|
||||||
return patient;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getHisArchive(idCard) {
|
|
||||||
const { success, list, tmbxx, message } = await getHisCustomer(idCard);
|
|
||||||
const patients = Array.isArray(list) ? list : [];
|
|
||||||
const patient = patients.find(item => item.socialno === idCard);
|
|
||||||
if (!success || !patient) {
|
|
||||||
toast(message || "获取档案信息失败");
|
|
||||||
return Promise.reject(message || "获取档案信息失败");
|
|
||||||
}
|
|
||||||
patient.tmbxx = tmbxx;
|
|
||||||
return patient;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggle(patientId) {
|
|
||||||
selectedPatientId.value = patientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toAddPatient() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/member/detail`,
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
|
onShow(async () => {
|
||||||
|
if (logined.value) {
|
||||||
|
await loadPatientList();
|
||||||
|
selectDefaultPatient();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(patientList, selectDefaultPatient, { immediate: true });
|
||||||
|
|
||||||
function toPatientManagement() {
|
|
||||||
uni.navigateTo({ url: "/pages/member/list" });
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@ -89,11 +89,24 @@ async function hasAuthed() {
|
|||||||
toast(message || "查询授权结果失败");
|
toast(message || "查询授权结果失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.status === "success" && data.hisArchive) {
|
console.log(data)
|
||||||
set("current-his-archive", data.hisArchive);
|
if (data.status === "success" && data.hisArchive && data.hisArchive.patientId) {
|
||||||
|
const hisArchive = data.hisArchive;
|
||||||
|
const consultPatientProfile = {
|
||||||
|
patientId: hisArchive.patientId,
|
||||||
|
blhno: hisArchive.blhno,
|
||||||
|
name: hisArchive.name,
|
||||||
|
mobile: hisArchive.tel,
|
||||||
|
sex: hisArchive.sex == '1' ? '男' : '女',
|
||||||
|
age: parseInt(hisArchive.age) > 0 ? parseInt(hisArchive.age) : '',
|
||||||
|
address: hisArchive.address,
|
||||||
|
socialno: hisArchive.socialno,
|
||||||
|
tmbxx: Array.isArray(hisArchive.tmbxx) ? hisArchive.tmbxx : []
|
||||||
|
}
|
||||||
|
set("consult-patient-profile", consultPatientProfile);
|
||||||
remove("auth-hlw-patient");
|
remove("auth-hlw-patient");
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/consult/disease-description?socialno=${patient.value.certNo}&feeType=YB`,
|
url: `/pages/consult/disease-description?feeType=YB`,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -157,6 +170,4 @@ onReady(() => {
|
|||||||
color: #333;
|
color: #333;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -24,6 +24,22 @@
|
|||||||
<input v-model="form.certNo" :maxlength="18" class="item-value" type="idcard"
|
<input v-model="form.certNo" :maxlength="18" class="item-value" type="idcard"
|
||||||
placeholder="请输入证件号" />
|
placeholder="请输入证件号" />
|
||||||
</view>
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="item-label">出生日期</text>
|
||||||
|
<picker mode="date" :value="form.birthday" @change="onBirthdayChange">
|
||||||
|
<view class="item-value picker-value" :class="{ 'placeholder-value': !form.birthday }">
|
||||||
|
{{ form.birthday || '请选择出生日期' }}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="item-label">性别</text>
|
||||||
|
<picker :range="sexOptions" :value="sexIndex" @change="onSexChange">
|
||||||
|
<view class="item-value picker-value" :class="{ 'placeholder-value': !form.sex }">
|
||||||
|
{{ form.sex || '请选择性别' }}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<text class="item-label">手机号</text>
|
<text class="item-label">手机号</text>
|
||||||
<input v-model="form.mobile" :maxlength="11" class="item-value" type="number"
|
<input v-model="form.mobile" :maxlength="11" class="item-value" type="number"
|
||||||
@ -78,6 +94,7 @@ import { get, remove, set } from '@/utils/cache';
|
|||||||
import { isChinaId } from '@/utils/validator';
|
import { isChinaId } from '@/utils/validator';
|
||||||
import { toast } from '@/utils/widget';
|
import { toast } from '@/utils/widget';
|
||||||
import reLogin from '@/components/re-login.vue';
|
import reLogin from '@/components/re-login.vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
const id = ref('');
|
const id = ref('');
|
||||||
const type = ref('');
|
const type = ref('');
|
||||||
@ -91,9 +108,12 @@ const scannedCard = ref(null);
|
|||||||
const form = ref({
|
const form = ref({
|
||||||
name: '',
|
name: '',
|
||||||
certNo: '',
|
certNo: '',
|
||||||
|
birthday: '',
|
||||||
|
sex: '',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
address: '',
|
address: '',
|
||||||
});
|
});
|
||||||
|
const sexOptions = ['男', '女'];
|
||||||
|
|
||||||
const { userInfo, logined, setTemporaryPatient } = useUser();
|
const { userInfo, logined, setTemporaryPatient } = useUser();
|
||||||
const accountId = computed(() => userInfo.value && userInfo.value.userId ? userInfo.value.userId : '');
|
const accountId = computed(() => userInfo.value && userInfo.value.userId ? userInfo.value.userId : '');
|
||||||
@ -111,19 +131,39 @@ const maskCertNo = computed(() => {
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
|
const sexIndex = computed(() => sexOptions.indexOf(form.value.sex));
|
||||||
|
|
||||||
|
function getIdCardInfo(certNo) {
|
||||||
|
const [valid, birthday, gender] = isChinaId(certNo);
|
||||||
|
if (!valid) return null;
|
||||||
|
return { birthday, sex: gender === 'MALE' ? '男' : '女' };
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillPersonInfoFromCertNo(onlyWhenEmpty = false) {
|
||||||
|
const info = getIdCardInfo(form.value.certNo.trim());
|
||||||
|
if (!info) return;
|
||||||
|
if (!onlyWhenEmpty || !form.value.birthday) form.value.birthday = info.birthday;
|
||||||
|
if (!onlyWhenEmpty || !form.value.sex) form.value.sex = info.sex;
|
||||||
|
}
|
||||||
|
|
||||||
function validateForm() {
|
function validateForm() {
|
||||||
if (!form.value.name.trim()) {
|
if (!form.value.name.trim()) {
|
||||||
toast('姓名不能为空');
|
toast('姓名不能为空');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!form.value.certNo.trim()) {
|
const certNo = form.value.certNo.trim();
|
||||||
toast('证件号不能为空');
|
const certInfo = certNo ? getIdCardInfo(certNo) : null;
|
||||||
|
if (certNo && !certInfo) {
|
||||||
|
toast('请输入有效的身份证号');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!isChinaId(form.value.certNo.trim())[0]) {
|
if (certInfo) {
|
||||||
toast('请输入有效的身份证号');
|
if (form.value.birthday !== certInfo.birthday || form.value.sex !== certInfo.sex) {
|
||||||
|
toast('出生日期或性别与证件号信息不一致');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!form.value.birthday || !form.value.sex) {
|
||||||
|
toast('未填写证件号时,请补充出生日期和性别');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!/^1[3-9]\d{9}$/.test(form.value.mobile.trim())) {
|
if (!/^1[3-9]\d{9}$/.test(form.value.mobile.trim())) {
|
||||||
@ -133,6 +173,14 @@ function validateForm() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onBirthdayChange(event) {
|
||||||
|
form.value.birthday = dayjs(event.detail.value).format('YYYY-MM-DD');
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSexChange(event) {
|
||||||
|
form.value.sex = sexOptions[Number(event.detail.value)] || '';
|
||||||
|
}
|
||||||
|
|
||||||
function chooseAddress() {
|
function chooseAddress() {
|
||||||
uni.chooseLocation({
|
uni.chooseLocation({
|
||||||
success: location => {
|
success: location => {
|
||||||
@ -168,6 +216,8 @@ async function confirm() {
|
|||||||
accountId: accountId.value,
|
accountId: accountId.value,
|
||||||
name: form.value.name.trim(),
|
name: form.value.name.trim(),
|
||||||
certNo: form.value.certNo.trim(),
|
certNo: form.value.certNo.trim(),
|
||||||
|
birthday: form.value.birthday,
|
||||||
|
sex: form.value.sex,
|
||||||
mobile: form.value.mobile.trim(),
|
mobile: form.value.mobile.trim(),
|
||||||
address: form.value.address.trim(),
|
address: form.value.address.trim(),
|
||||||
};
|
};
|
||||||
@ -247,9 +297,13 @@ async function saveYbQrcodePatient() {
|
|||||||
name: form.value.name.trim(),
|
name: form.value.name.trim(),
|
||||||
mobile: form.value.mobile.trim(),
|
mobile: form.value.mobile.trim(),
|
||||||
address: form.value.address.trim(),
|
address: form.value.address.trim(),
|
||||||
mdtrt_cert_type: '03',
|
...(scannedCard.value.Source === 'EC'
|
||||||
mdtrt_cert_no: scannedCard.value.CardNum,
|
? { ecToken: scannedCard.value.ECToken }
|
||||||
card_sn: scannedCard.value.CardIDCode,
|
: {
|
||||||
|
mdtrt_cert_type: '03',
|
||||||
|
mdtrt_cert_no: scannedCard.value.CardNum,
|
||||||
|
card_sn: scannedCard.value.CardIDCode,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
const patients = Array.isArray(res && res.list) ? res.list : [];
|
const patients = Array.isArray(res && res.list) ? res.list : [];
|
||||||
const hisArchive = patients.find(patient => patient.socialno === idCard) || patients[0] || null;
|
const hisArchive = patients.find(patient => patient.socialno === idCard) || patients[0] || null;
|
||||||
@ -258,24 +312,27 @@ async function saveYbQrcodePatient() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hisArchive.socialno = hisArchive.socialno || idCard;
|
const consultPatientProfile = {
|
||||||
hisArchive.tmbxx = Array.isArray(res.tmbxx) ? res.tmbxx : [];
|
patientId: hisArchive.patientId,
|
||||||
set('current-his-archive', hisArchive);
|
blhno: hisArchive.blhno,
|
||||||
setTemporaryPatient({
|
name: hisArchive.name,
|
||||||
name: form.value.name.trim(),
|
mobile: hisArchive.tel,
|
||||||
certNo: idCard,
|
sex: hisArchive.sex == 1 ? '男' : '女',
|
||||||
mobile: form.value.mobile.trim(),
|
age: parseInt(hisArchive.age) > 0 ? parseInt(hisArchive.age) : '',
|
||||||
address: form.value.address.trim(),
|
address: hisArchive.address,
|
||||||
});
|
socialno: hisArchive.socialno,
|
||||||
|
tmbxx: Array.isArray(hisArchive.tmbxx) ? hisArchive.tmbxx : []
|
||||||
|
}
|
||||||
|
set("consult-patient-profile", consultPatientProfile);
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/consult/disease-description?socialno=${idCard}&feeType=${feeType.value}`,
|
url: `/pages/consult/disease-description?feeType=${feeType.value}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadScannedCard() {
|
async function loadScannedCard() {
|
||||||
const card = get('current-scanned-card');
|
const card = get('current-scanned-card');
|
||||||
remove('current-scanned-card');
|
remove('current-scanned-card');
|
||||||
if (!card || !card.Name || !card.IDNum) {
|
if (!card || !['SC', 'EC'].includes(card.Source) || !card.Name || !card.IDNum) {
|
||||||
toast('医保扫码信息已失效,请重新扫码');
|
toast('医保扫码信息已失效,请重新扫码');
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
return;
|
return;
|
||||||
@ -317,9 +374,12 @@ async function loadPatient() {
|
|||||||
form.value = {
|
form.value = {
|
||||||
name: res.data.name || '',
|
name: res.data.name || '',
|
||||||
certNo: res.data.certNo || '',
|
certNo: res.data.certNo || '',
|
||||||
|
birthday: res.data.birthday || '',
|
||||||
|
sex: res.data.sex || '',
|
||||||
mobile: res.data.mobile || '',
|
mobile: res.data.mobile || '',
|
||||||
address: res.data.address || '',
|
address: res.data.address || '',
|
||||||
};
|
};
|
||||||
|
fillPersonInfoFromCertNo(true);
|
||||||
const patientCertNo = typeof res.data.certNo === 'string' ? res.data.certNo.trim() : '';
|
const patientCertNo = typeof res.data.certNo === 'string' ? res.data.certNo.trim() : '';
|
||||||
const userCertNo = typeof userInfo.value.certNo === 'string' ? userInfo.value.certNo.trim() : '';
|
const userCertNo = typeof userInfo.value.certNo === 'string' ? userInfo.value.certNo.trim() : '';
|
||||||
loadedPatientIsSelf.value = userCertNo ? patientCertNo === userCertNo : null;
|
loadedPatientIsSelf.value = userCertNo ? patientCertNo === userCertNo : null;
|
||||||
@ -356,6 +416,7 @@ onLoad(options => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch([id, accountId], loadPatient, { immediate: true });
|
watch([id, accountId], loadPatient, { immediate: true });
|
||||||
|
watch(() => form.value.certNo, () => fillPersonInfoFromCertNo());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@ -458,6 +519,18 @@ watch([id, accountId], loadPatient, { immediate: true });
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
picker {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.picker-value {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder-value {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
.save-footer {
|
.save-footer {
|
||||||
padding: calc(24rpx * var(--spacing-scale)) calc(30rpx * var(--spacing-scale));
|
padding: calc(24rpx * var(--spacing-scale)) calc(30rpx * var(--spacing-scale));
|
||||||
background: white;
|
background: white;
|
||||||
|
|||||||
@ -155,21 +155,21 @@ export default defineStore("orderStore", () => {
|
|||||||
|
|
||||||
const recommondDiseases = ref([]);
|
const recommondDiseases = ref([]);
|
||||||
|
|
||||||
function init({ feeType, socialno, hisArchive }) {
|
function init({ feeType, patientProfile }) {
|
||||||
recommondDiseases.value = [];
|
recommondDiseases.value = [];
|
||||||
if (!FeeType.includes(feeType)) {
|
if (!FeeType.includes(feeType)) {
|
||||||
toast('不支持的费用类型');
|
toast('不支持的费用类型');
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!hisArchive || hisArchive.socialno !== socialno) {
|
if (!patientProfile || !patientProfile.patientId) {
|
||||||
toast('档案与就诊人不匹配');
|
toast('患者信息有误, 请重试');
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tmbxx = Array.isArray(hisArchive.tmbxx) ? hisArchive.tmbxx : [];
|
|
||||||
|
const tmbxx = Array.isArray(patientProfile.tmbxx) ? patientProfile.tmbxx : [];
|
||||||
medTypeList.value = [outpatientMedType, ...tmbxx];
|
medTypeList.value = [outpatientMedType, ...tmbxx];
|
||||||
const profile = patientList.value.find((i) => i.socialno === socialno);
|
|
||||||
regFee.value = 0;
|
regFee.value = 0;
|
||||||
order.value = {
|
order.value = {
|
||||||
accountId: userInfo.value.userId,
|
accountId: userInfo.value.userId,
|
||||||
@ -178,18 +178,17 @@ export default defineStore("orderStore", () => {
|
|||||||
description: "",
|
description: "",
|
||||||
images: [],
|
images: [],
|
||||||
drugs: [],
|
drugs: [],
|
||||||
patientId: hisArchive.patientId,
|
patientId: patientProfile.patientId,
|
||||||
idCard: profile.socialno,
|
idCard: patientProfile.socialno,
|
||||||
name: profile.name,
|
name: patientProfile.name,
|
||||||
mobile: profile.tel,
|
mobile: patientProfile.tel,
|
||||||
blhno: hisArchive.blhno,
|
blhno: patientProfile.blhno,
|
||||||
age: profile.age,
|
age: patientProfile.age,
|
||||||
sex: profile.sex,
|
sex: patientProfile.sex,
|
||||||
address: profile.address,
|
address: patientProfile.address,
|
||||||
orderSource,
|
orderSource,
|
||||||
feeType,
|
feeType,
|
||||||
medInfo: { ...outpatientMedType },
|
medInfo: { ...outpatientMedType },
|
||||||
// consultType: ConsultTypeByFeeType[feeType],
|
|
||||||
};
|
};
|
||||||
histories.forEach((item) => (order.value[item.prop] = item.options[1]));
|
histories.forEach((item) => (order.value[item.prop] = item.options[1]));
|
||||||
order.value.pastHistoryStr = pastHistoryStr.value;
|
order.value.pastHistoryStr = pastHistoryStr.value;
|
||||||
|
|||||||
108
store/user.js
108
store/user.js
@ -11,7 +11,6 @@ import {
|
|||||||
} from "@/utils/api";
|
} from "@/utils/api";
|
||||||
import authStore from "./auth";
|
import authStore from "./auth";
|
||||||
|
|
||||||
import { isChinaId } from "@/utils/validator";
|
|
||||||
import { confirm, toast } from "@/utils/widget";
|
import { confirm, toast } from "@/utils/widget";
|
||||||
|
|
||||||
export default defineStore("userStore", () => {
|
export default defineStore("userStore", () => {
|
||||||
@ -26,42 +25,20 @@ export default defineStore("userStore", () => {
|
|||||||
const userInfo = ref({}); // { avatar, certNo, mobile, userName, userId }
|
const userInfo = ref({}); // { avatar, certNo, mobile, userName, userId }
|
||||||
// his档案信息
|
// his档案信息
|
||||||
const patients = ref([]); // 就诊人档案
|
const patients = ref([]); // 就诊人档案
|
||||||
const temporaryPatient = ref(null);
|
const patientList = computed(() => patients.value.map(i => {
|
||||||
const patientList = computed(() => {
|
const maskInfo = getMaskInfo({
|
||||||
const source = temporaryPatient.value && temporaryPatient.value.certNo
|
name: i.name,
|
||||||
? [
|
socialno: i.certNo,
|
||||||
...patients.value.filter(i => i.certNo !== temporaryPatient.value.certNo),
|
tel: i.mobile,
|
||||||
temporaryPatient.value,
|
});
|
||||||
]
|
return { ...i, ...maskInfo, isSelf: i.certNo && i.certNo === userInfo.value.certNo }
|
||||||
: patients.value;
|
}))
|
||||||
return source.map(i => {
|
|
||||||
const { birthday, age, sex } = getInfoFromIdNo({ socialno: i.certNo });
|
|
||||||
const maskInfo = getMaskInfo({
|
|
||||||
name: i.name,
|
|
||||||
socialno: i.certNo,
|
|
||||||
tel: i.mobile,
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
...i,
|
|
||||||
...maskInfo,
|
|
||||||
birthday,
|
|
||||||
age,
|
|
||||||
sex,
|
|
||||||
_id: i.id,
|
|
||||||
socialno: i.certNo,
|
|
||||||
tel: i.mobile,
|
|
||||||
isSelf: i.certNo === userInfo.value.certNo,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
async function login() {
|
async function login() {
|
||||||
if (!userInfo.value.certNo) {
|
if (!userInfo.value.certNo) {
|
||||||
const authCode = await getAuthCode();
|
const authCode = await getAuthCode();
|
||||||
const auth = authStore();
|
const auth = authStore();
|
||||||
await auth.login({
|
await auth.login({ authCode });
|
||||||
authCode,
|
|
||||||
});
|
|
||||||
const data = await getUserByAuthCode(authCode);
|
const data = await getUserByAuthCode(authCode);
|
||||||
uni.setStorageSync("hasAuthed", "hasAuthed");
|
uni.setStorageSync("hasAuthed", "hasAuthed");
|
||||||
const maskData = {
|
const maskData = {
|
||||||
@ -72,16 +49,6 @@ export default defineStore("userStore", () => {
|
|||||||
userInfo.value = { ...data, ...getMaskInfo(maskData) };
|
userInfo.value = { ...data, ...getMaskInfo(maskData) };
|
||||||
}
|
}
|
||||||
logined.value = true;
|
logined.value = true;
|
||||||
|
|
||||||
// const patients = await queryHisPatients(userInfo.value.certNo);
|
|
||||||
// const profile = patients.find((i) => i.socialno === userInfo.value.certNo);
|
|
||||||
// if (profile) {
|
|
||||||
// myProfile.value = getProfileData(profile);
|
|
||||||
// logined.value = true;
|
|
||||||
// addLaunchLog()
|
|
||||||
// } else if (remindTobind) {
|
|
||||||
// toBuild();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addLaunchLog() {
|
async function addLaunchLog() {
|
||||||
@ -101,7 +68,6 @@ export default defineStore("userStore", () => {
|
|||||||
logined.value = false;
|
logined.value = false;
|
||||||
userInfo.value = {};
|
userInfo.value = {};
|
||||||
patients.value = [];
|
patients.value = [];
|
||||||
temporaryPatient.value = null;
|
|
||||||
uni.removeStorageSync("hasAuthed");
|
uni.removeStorageSync("hasAuthed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,19 +80,6 @@ export default defineStore("userStore", () => {
|
|||||||
return loginPromise.value;
|
return loginPromise.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInfoFromIdNo({ socialno: idNo }) {
|
|
||||||
const [isIdCard, birthday, gender] = isChinaId(idNo);
|
|
||||||
if (isIdCard) {
|
|
||||||
const age = dayjs().diff(dayjs(birthday), "year");
|
|
||||||
return {
|
|
||||||
birthday,
|
|
||||||
age: Math.max(1, age),
|
|
||||||
sex: gender === "MALE" ? "男" : "女",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return { birthday: "", age: "", sex: "" };
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMaskInfo(profile) {
|
function getMaskInfo(profile) {
|
||||||
const name = typeof profile.name == "string" ? profile.name : "";
|
const name = typeof profile.name == "string" ? profile.name : "";
|
||||||
const maskName = name.length
|
const maskName = name.length
|
||||||
@ -168,25 +121,9 @@ export default defineStore("userStore", () => {
|
|||||||
return Promise.reject(message);
|
return Promise.reject(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过 身份证号查询 his 的 患者信息
|
|
||||||
* @param {*} idCard
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async function queryHisPatients(idCard) {
|
|
||||||
const { success, message, list } = await getHisCustomer(idCard);
|
|
||||||
if (success) {
|
|
||||||
return Array.isArray(list) ? list : [];
|
|
||||||
}
|
|
||||||
return Promise.reject(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function getStore() {
|
async function getStore() {
|
||||||
if (!storeId.value) {
|
if (!storeId.value) {
|
||||||
await confirm("请支付宝扫一扫所在店铺二维码重新进入小程序!", {
|
await confirm("请支付宝扫一扫所在店铺二维码重新进入小程序!", { showCancel: false });
|
||||||
showCancel: false,
|
|
||||||
});
|
|
||||||
return Promise.reject("未选择药房");
|
return Promise.reject("未选择药房");
|
||||||
}
|
}
|
||||||
const { success, list, message } = await getDrugStoreList(storeId.value);
|
const { success, list, message } = await getDrugStoreList(storeId.value);
|
||||||
@ -210,12 +147,14 @@ export default defineStore("userStore", () => {
|
|||||||
|
|
||||||
async function loadPatientList() {
|
async function loadPatientList() {
|
||||||
const accountId = userInfo.value && userInfo.value.userId;
|
const accountId = userInfo.value && userInfo.value.userId;
|
||||||
if (!accountId) return;
|
if (!accountId) {
|
||||||
|
patients.value = [];
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getHlwPatientList(accountId);
|
const res = await getHlwPatientList(accountId);
|
||||||
if (!res || !res.success) {
|
if (!res || !res.success) {
|
||||||
patients.value = [];
|
|
||||||
toast((res && res.message) || "查询就诊人失败");
|
toast((res && res.message) || "查询就诊人失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -226,19 +165,6 @@ export default defineStore("userStore", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTemporaryPatient(patient) {
|
|
||||||
if (!patient || !patient.certNo) {
|
|
||||||
temporaryPatient.value = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
temporaryPatient.value = {
|
|
||||||
id: patient.id || `yb-qrcode-${patient.certNo}`,
|
|
||||||
createTime: patient.createTime || new Date().toISOString(),
|
|
||||||
...patient,
|
|
||||||
isTemporary: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(storeId, (n) => {
|
watch(storeId, (n) => {
|
||||||
uni.setStorageSync("storeId", n);
|
uni.setStorageSync("storeId", n);
|
||||||
});
|
});
|
||||||
@ -249,7 +175,6 @@ export default defineStore("userStore", () => {
|
|||||||
storeId,
|
storeId,
|
||||||
userInfo,
|
userInfo,
|
||||||
patients,
|
patients,
|
||||||
temporaryPatient,
|
|
||||||
launchOptions,
|
launchOptions,
|
||||||
patientList,
|
patientList,
|
||||||
|
|
||||||
@ -257,7 +182,6 @@ export default defineStore("userStore", () => {
|
|||||||
getStore,
|
getStore,
|
||||||
login,
|
login,
|
||||||
loginout,
|
loginout,
|
||||||
loadPatientList,
|
loadPatientList
|
||||||
setTemporaryPatient
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user