Compare commits
2 Commits
e7e0a9d422
...
9ab5190405
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ab5190405 | ||
|
|
998d95125a |
@ -5,10 +5,10 @@ export default function useUser() {
|
||||
const store = userStore();
|
||||
|
||||
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 {
|
||||
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 { login, loginout, getAuthCode, getStore } = store;
|
||||
|
||||
@ -307,6 +307,9 @@ function upload(path) {
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
uni.setNavigationBarTitle({
|
||||
title: titleMap[options.feeType] || ''
|
||||
})
|
||||
if (options.reEdit === '1') {
|
||||
const record = get('re-edit-consult-order');
|
||||
remove('re-edit-consult-order');
|
||||
@ -316,13 +319,10 @@ onLoad((options) => {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const hisArchive = get("current-his-archive");
|
||||
remove("current-his-archive");
|
||||
initOrder({ feeType: options.feeType, socialno: options.socialno, hisArchive });
|
||||
const patientProfile = get("consult-patient-profile");
|
||||
remove("consult-patient-profile");
|
||||
initOrder({ feeType: options.feeType, patientProfile });
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: titleMap[options.feeType] || ''
|
||||
})
|
||||
uni.$on('on-disease-selected', onDiseaseSelected);
|
||||
})
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<full-page :pageStyle="`background: ${themeBg};`">
|
||||
<view v-if="logined" class="container">
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<text class="title">选择就诊人</text>
|
||||
<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>
|
||||
</view>
|
||||
|
||||
<re-login v-else height="80vh" />
|
||||
|
||||
<template v-if="logined" #footer>
|
||||
<template #footer>
|
||||
<view class="footer">
|
||||
<view class="button-group">
|
||||
<button class="action-button add-button rounded" @click="toAddPatient">
|
||||
@ -48,14 +45,12 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import useElder from "@/hooks/useElder";
|
||||
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 { toast } from "@/utils/widget";
|
||||
import { themeBg, themeColor, themeSecondary } from "@/utils/theme-config";
|
||||
|
||||
import reLogin from "@/components/re-login.vue";
|
||||
import ybPlugin from "@/utils/insurance-plugin";
|
||||
import fullPage from "@/components/full-page.vue";
|
||||
|
||||
@ -63,8 +58,7 @@ const {
|
||||
logined,
|
||||
getAuthCode,
|
||||
userInfo,
|
||||
storeId,
|
||||
patientList: storePatientList,
|
||||
patientList,
|
||||
loadPatientList,
|
||||
} = useUser();
|
||||
|
||||
@ -78,59 +72,10 @@ const preferredCertNo = ref("");
|
||||
const feeType = ref("");
|
||||
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(() => {
|
||||
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() {
|
||||
return new Promise((resolve, reject) => {
|
||||
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() {
|
||||
if (scanning.value) return;
|
||||
scanning.value = true;
|
||||
@ -176,89 +235,33 @@ async function scanInsuranceCode() {
|
||||
scanning.value = false;
|
||||
}
|
||||
|
||||
async function nextStep() {
|
||||
if (!currentProfile.value) {
|
||||
toast("请选择就诊人");
|
||||
return;
|
||||
}
|
||||
let hisArchive = null;
|
||||
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}`,
|
||||
onLoad(options => {
|
||||
feeType.value = options.feeType;
|
||||
preferredCertNo.value = options.socialno || "";
|
||||
|
||||
uni.setNavigationBarTitle({
|
||||
title: titleMap[options.feeType] || "",
|
||||
});
|
||||
}
|
||||
|
||||
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(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`,
|
||||
ybPlugin.init({
|
||||
archiveTokenCallback: () => {
|
||||
const certNo = currentProfile.value ? currentProfile.value.certNo : "";
|
||||
uni.redirectTo({
|
||||
url: `/pages/consult/index?socialno=${certNo}&feeType=${feeType.value}`,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function toPatientManagement() {
|
||||
uni.navigateTo({ url: "/pages/member/list" });
|
||||
onShow(async () => {
|
||||
if (logined.value) {
|
||||
await loadPatientList();
|
||||
selectDefaultPatient();
|
||||
}
|
||||
});
|
||||
|
||||
watch(patientList, selectDefaultPatient, { immediate: true });
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -145,9 +145,9 @@ function confirm() {
|
||||
if (!(frequencyIndex.value >= 0)) {
|
||||
return toast('请选择用药频率', { mask: false })
|
||||
}
|
||||
if (!(timeIndex.value >= 0)) {
|
||||
return toast('请选择用药时机', { mask: false })
|
||||
}
|
||||
// if (!(timeIndex.value >= 0)) {
|
||||
// return toast('请选择用药时机', { mask: false })
|
||||
// }
|
||||
const days = Number(current.value.days);
|
||||
console.log('current: ', current.value.days)
|
||||
console.log('days: ', days)
|
||||
|
||||
@ -89,11 +89,24 @@ async function hasAuthed() {
|
||||
toast(message || "查询授权结果失败");
|
||||
return;
|
||||
}
|
||||
if (data.status === "success" && data.hisArchive) {
|
||||
set("current-his-archive", data.hisArchive);
|
||||
console.log(data)
|
||||
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");
|
||||
uni.redirectTo({
|
||||
url: `/pages/consult/disease-description?socialno=${patient.value.certNo}&feeType=YB`,
|
||||
url: `/pages/consult/disease-description?feeType=YB`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -157,6 +170,4 @@ onReady(() => {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
@ -24,6 +24,22 @@
|
||||
<input v-model="form.certNo" :maxlength="18" class="item-value" type="idcard"
|
||||
placeholder="请输入证件号" />
|
||||
</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">
|
||||
<text class="item-label">手机号</text>
|
||||
<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 { toast } from '@/utils/widget';
|
||||
import reLogin from '@/components/re-login.vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const id = ref('');
|
||||
const type = ref('');
|
||||
@ -91,9 +108,12 @@ const scannedCard = ref(null);
|
||||
const form = ref({
|
||||
name: '',
|
||||
certNo: '',
|
||||
birthday: '',
|
||||
sex: '',
|
||||
mobile: '',
|
||||
address: '',
|
||||
});
|
||||
const sexOptions = ['男', '女'];
|
||||
|
||||
const { userInfo, logined, setTemporaryPatient } = useUser();
|
||||
const accountId = computed(() => userInfo.value && userInfo.value.userId ? userInfo.value.userId : '');
|
||||
@ -111,19 +131,39 @@ const maskCertNo = computed(() => {
|
||||
}
|
||||
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() {
|
||||
if (!form.value.name.trim()) {
|
||||
toast('姓名不能为空');
|
||||
return false;
|
||||
}
|
||||
if (!form.value.certNo.trim()) {
|
||||
toast('证件号不能为空');
|
||||
const certNo = form.value.certNo.trim();
|
||||
const certInfo = certNo ? getIdCardInfo(certNo) : null;
|
||||
if (certNo && !certInfo) {
|
||||
toast('请输入有效的身份证号');
|
||||
return false;
|
||||
}
|
||||
if (!isChinaId(form.value.certNo.trim())[0]) {
|
||||
toast('请输入有效的身份证号');
|
||||
if (certInfo) {
|
||||
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;
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(form.value.mobile.trim())) {
|
||||
@ -133,6 +173,14 @@ function validateForm() {
|
||||
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() {
|
||||
uni.chooseLocation({
|
||||
success: location => {
|
||||
@ -168,6 +216,8 @@ async function confirm() {
|
||||
accountId: accountId.value,
|
||||
name: form.value.name.trim(),
|
||||
certNo: form.value.certNo.trim(),
|
||||
birthday: form.value.birthday,
|
||||
sex: form.value.sex,
|
||||
mobile: form.value.mobile.trim(),
|
||||
address: form.value.address.trim(),
|
||||
};
|
||||
@ -247,9 +297,13 @@ async function saveYbQrcodePatient() {
|
||||
name: form.value.name.trim(),
|
||||
mobile: form.value.mobile.trim(),
|
||||
address: form.value.address.trim(),
|
||||
...(scannedCard.value.Source === 'EC'
|
||||
? { ecToken: scannedCard.value.ECToken }
|
||||
: {
|
||||
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 hisArchive = patients.find(patient => patient.socialno === idCard) || patients[0] || null;
|
||||
@ -258,24 +312,27 @@ async function saveYbQrcodePatient() {
|
||||
return;
|
||||
}
|
||||
|
||||
hisArchive.socialno = hisArchive.socialno || idCard;
|
||||
hisArchive.tmbxx = Array.isArray(res.tmbxx) ? res.tmbxx : [];
|
||||
set('current-his-archive', hisArchive);
|
||||
setTemporaryPatient({
|
||||
name: form.value.name.trim(),
|
||||
certNo: idCard,
|
||||
mobile: form.value.mobile.trim(),
|
||||
address: form.value.address.trim(),
|
||||
});
|
||||
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.redirectTo({
|
||||
url: `/pages/consult/disease-description?socialno=${idCard}&feeType=${feeType.value}`,
|
||||
url: `/pages/consult/disease-description?feeType=${feeType.value}`,
|
||||
});
|
||||
}
|
||||
|
||||
async function loadScannedCard() {
|
||||
const card = get('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('医保扫码信息已失效,请重新扫码');
|
||||
uni.navigateBack();
|
||||
return;
|
||||
@ -317,9 +374,12 @@ async function loadPatient() {
|
||||
form.value = {
|
||||
name: res.data.name || '',
|
||||
certNo: res.data.certNo || '',
|
||||
birthday: res.data.birthday || '',
|
||||
sex: res.data.sex || '',
|
||||
mobile: res.data.mobile || '',
|
||||
address: res.data.address || '',
|
||||
};
|
||||
fillPersonInfoFromCertNo(true);
|
||||
const patientCertNo = typeof res.data.certNo === 'string' ? res.data.certNo.trim() : '';
|
||||
const userCertNo = typeof userInfo.value.certNo === 'string' ? userInfo.value.certNo.trim() : '';
|
||||
loadedPatientIsSelf.value = userCertNo ? patientCertNo === userCertNo : null;
|
||||
@ -356,6 +416,7 @@ onLoad(options => {
|
||||
});
|
||||
|
||||
watch([id, accountId], loadPatient, { immediate: true });
|
||||
watch(() => form.value.certNo, () => fillPersonInfoFromCertNo());
|
||||
</script>
|
||||
|
||||
<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 {
|
||||
padding: calc(24rpx * var(--spacing-scale)) calc(30rpx * var(--spacing-scale));
|
||||
background: white;
|
||||
|
||||
@ -155,21 +155,21 @@ export default defineStore("orderStore", () => {
|
||||
|
||||
const recommondDiseases = ref([]);
|
||||
|
||||
function init({ feeType, socialno, hisArchive }) {
|
||||
function init({ feeType, patientProfile }) {
|
||||
recommondDiseases.value = [];
|
||||
if (!FeeType.includes(feeType)) {
|
||||
toast('不支持的费用类型');
|
||||
uni.navigateBack();
|
||||
return;
|
||||
}
|
||||
if (!hisArchive || hisArchive.socialno !== socialno) {
|
||||
toast('档案与就诊人不匹配');
|
||||
if (!patientProfile || !patientProfile.patientId) {
|
||||
toast('患者信息有误, 请重试');
|
||||
uni.navigateBack();
|
||||
return;
|
||||
}
|
||||
const tmbxx = Array.isArray(hisArchive.tmbxx) ? hisArchive.tmbxx : [];
|
||||
|
||||
const tmbxx = Array.isArray(patientProfile.tmbxx) ? patientProfile.tmbxx : [];
|
||||
medTypeList.value = [outpatientMedType, ...tmbxx];
|
||||
const profile = patientList.value.find((i) => i.socialno === socialno);
|
||||
regFee.value = 0;
|
||||
order.value = {
|
||||
accountId: userInfo.value.userId,
|
||||
@ -178,18 +178,17 @@ export default defineStore("orderStore", () => {
|
||||
description: "",
|
||||
images: [],
|
||||
drugs: [],
|
||||
patientId: hisArchive.patientId,
|
||||
idCard: profile.socialno,
|
||||
name: profile.name,
|
||||
mobile: profile.tel,
|
||||
blhno: hisArchive.blhno,
|
||||
age: profile.age,
|
||||
sex: profile.sex,
|
||||
address: profile.address,
|
||||
patientId: patientProfile.patientId,
|
||||
idCard: patientProfile.socialno,
|
||||
name: patientProfile.name,
|
||||
mobile: patientProfile.tel,
|
||||
blhno: patientProfile.blhno,
|
||||
age: patientProfile.age,
|
||||
sex: patientProfile.sex,
|
||||
address: patientProfile.address,
|
||||
orderSource,
|
||||
feeType,
|
||||
medInfo: { ...outpatientMedType },
|
||||
// consultType: ConsultTypeByFeeType[feeType],
|
||||
};
|
||||
histories.forEach((item) => (order.value[item.prop] = item.options[1]));
|
||||
order.value.pastHistoryStr = pastHistoryStr.value;
|
||||
|
||||
@ -11,7 +11,6 @@ import {
|
||||
} from "@/utils/api";
|
||||
import authStore from "./auth";
|
||||
|
||||
import { isChinaId } from "@/utils/validator";
|
||||
import { confirm, toast } from "@/utils/widget";
|
||||
|
||||
export default defineStore("userStore", () => {
|
||||
@ -26,42 +25,20 @@ export default defineStore("userStore", () => {
|
||||
const userInfo = ref({}); // { avatar, certNo, mobile, userName, userId }
|
||||
// his档案信息
|
||||
const patients = ref([]); // 就诊人档案
|
||||
const temporaryPatient = ref(null);
|
||||
const patientList = computed(() => {
|
||||
const source = temporaryPatient.value && temporaryPatient.value.certNo
|
||||
? [
|
||||
...patients.value.filter(i => i.certNo !== temporaryPatient.value.certNo),
|
||||
temporaryPatient.value,
|
||||
]
|
||||
: patients.value;
|
||||
return source.map(i => {
|
||||
const { birthday, age, sex } = getInfoFromIdNo({ socialno: i.certNo });
|
||||
const patientList = computed(() => patients.value.map(i => {
|
||||
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,
|
||||
}
|
||||
})
|
||||
})
|
||||
return { ...i, ...maskInfo, isSelf: i.certNo && i.certNo === userInfo.value.certNo }
|
||||
}))
|
||||
|
||||
async function login() {
|
||||
if (!userInfo.value.certNo) {
|
||||
const authCode = await getAuthCode();
|
||||
const auth = authStore();
|
||||
await auth.login({
|
||||
authCode,
|
||||
});
|
||||
await auth.login({ authCode });
|
||||
const data = await getUserByAuthCode(authCode);
|
||||
uni.setStorageSync("hasAuthed", "hasAuthed");
|
||||
const maskData = {
|
||||
@ -72,16 +49,6 @@ export default defineStore("userStore", () => {
|
||||
userInfo.value = { ...data, ...getMaskInfo(maskData) };
|
||||
}
|
||||
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() {
|
||||
@ -101,7 +68,6 @@ export default defineStore("userStore", () => {
|
||||
logined.value = false;
|
||||
userInfo.value = {};
|
||||
patients.value = [];
|
||||
temporaryPatient.value = null;
|
||||
uni.removeStorageSync("hasAuthed");
|
||||
}
|
||||
|
||||
@ -114,19 +80,6 @@ export default defineStore("userStore", () => {
|
||||
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) {
|
||||
const name = typeof profile.name == "string" ? profile.name : "";
|
||||
const maskName = name.length
|
||||
@ -168,25 +121,9 @@ export default defineStore("userStore", () => {
|
||||
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() {
|
||||
if (!storeId.value) {
|
||||
await confirm("请支付宝扫一扫所在店铺二维码重新进入小程序!", {
|
||||
showCancel: false,
|
||||
});
|
||||
await confirm("请支付宝扫一扫所在店铺二维码重新进入小程序!", { showCancel: false });
|
||||
return Promise.reject("未选择药房");
|
||||
}
|
||||
const { success, list, message } = await getDrugStoreList(storeId.value);
|
||||
@ -210,12 +147,14 @@ export default defineStore("userStore", () => {
|
||||
|
||||
async function loadPatientList() {
|
||||
const accountId = userInfo.value && userInfo.value.userId;
|
||||
if (!accountId) return;
|
||||
|
||||
if (!accountId) {
|
||||
patients.value = [];
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await getHlwPatientList(accountId);
|
||||
if (!res || !res.success) {
|
||||
patients.value = [];
|
||||
|
||||
toast((res && res.message) || "查询就诊人失败");
|
||||
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) => {
|
||||
uni.setStorageSync("storeId", n);
|
||||
});
|
||||
@ -249,7 +175,6 @@ export default defineStore("userStore", () => {
|
||||
storeId,
|
||||
userInfo,
|
||||
patients,
|
||||
temporaryPatient,
|
||||
launchOptions,
|
||||
patientList,
|
||||
|
||||
@ -257,7 +182,6 @@ export default defineStore("userStore", () => {
|
||||
getStore,
|
||||
login,
|
||||
loginout,
|
||||
loadPatientList,
|
||||
setTemporaryPatient
|
||||
loadPatientList
|
||||
};
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user