Browse Source

feat: 更新患者信息含code, 查下个节点信息

main
wally 2 years ago
parent
commit
7425658e02
  1. 9
      api/modules/service.ts
  2. 9
      components/CodeFormItem/CodeFormItem.vue
  3. 88
      components/DetailBase/DetailBase.vue
  4. 54
      hooks/useNextNode.ts
  5. 29
      pages/detail2/detail2.vue
  6. 1
      store/modules/service.ts

9
api/modules/service.ts

@ -24,4 +24,13 @@ export const serviceApi = {
// 查病历数据
getAidInfo: (firstAidId: string, codeList = []) => post('/firstAid/queryAidRecord', { param: { firstAidId, codeList } }),
// 更新急救基本信息
updateAidBase: param => post('/firstAid/update', { param }),
// 更新急救code信息
updateAidCode: param => post('/firstAid/saveAidRecord', { param }),
// 查 下一个节点
getNextNode: (firstAidId: string) => post('/firstAid/next', { param: { firstAidId } }),
}

9
components/CodeFormItem/CodeFormItem.vue

@ -2,9 +2,14 @@
<view>
<uni-easyinput :value="value" type="text" placeholder="请输入" @input="$emit('on-change', $event)" v-if="config.type === 'input'" />
<uni-datetime-picker type="datetime" :value="value" @change="$emit('on-change', $event)" v-else-if="config.type === 'datetime'" />
<uni-datetime-picker type="datetime" :value="value" :modelValue="value" @change="$emit('on-change', $event)"
v-else-if="config.type === 'datetime'" />
<uni-data-checkbox :value="value" :localdata="config.range" @change="$emit('on-change', $event.detail.value)" />
<uni-data-checkbox :value="value" :localdata="config.range" @change="$emit('on-change', $event.detail.value)"
v-else-if="config.type === 'radio'" />
<uni-data-select :value="value" :modelValue="value" :localdata="config.range" @change="$emit('on-change', $event)"
v-else-if="config.type === 'select'"></uni-data-select>
</view>
</template>

88
components/DetailBase/DetailBase.vue

@ -7,17 +7,24 @@
<uni-icons type="scan" color="#70798C" size="24" />
</view>
</uni-forms-item>
<uni-forms-item label="姓名" name="patientName">
<uni-easyinput type="text" v-model="baseInfo.patientName" placeholder="请输入姓名" />
<uni-easyinput type="text" v-model="baseInfo.patientName" placeholder="请输入姓名" @change="onBaseChange('patientName', $event)" />
</uni-forms-item>
<uni-forms-item name="patientGender" label="性别">
<uni-data-checkbox v-model="baseInfo.patientGender" :localdata="GENDER_LIST" />
<uni-data-checkbox v-model="baseInfo.patientGender" :localdata="GENDER_LIST"
@change="onBaseChange('patientGender', $event.detail.value)" />
</uni-forms-item>
<uni-forms-item label="民族" name="patientNation">
<uni-data-select :localdata="nationList" v-model="baseInfo.patientNation" :clear="false" />
<uni-data-select :localdata="nationList" v-model="baseInfo.patientNation" :clear="false"
@change="onBaseChange('patientNation', $event)" />
</uni-forms-item>
<uni-forms-item label="身份证号" name="patientIdCardNo">
<uni-easyinput type="idcard" v-model="baseInfo.patientIdCardNo" placeholder="请输入身份证号" />
<uni-easyinput type="idcard" v-model="baseInfo.patientIdCardNo" placeholder="请输入身份证号"
@change="onBaseChange('patientIdCardNo', $event)" />
</uni-forms-item>
<template v-for="(item, key) in codeForm" :key="key">
@ -28,17 +35,23 @@
</uni-forms>
<uni-section type="line" title="疑似诊断" titleFontSize="16px"> </uni-section>
<uni-data-checkbox mode="list" v-model="baseInfo.firstAidZlType" :localdata="FIRST_AID_ZL_TYPE" class="white uni-radius-lg uni-pa-6">
<uni-data-checkbox mode="list" v-model="baseInfo.firstAidZlType" :localdata="FIRST_AID_ZL_TYPE" class="white uni-radius-lg uni-pa-6"
@change="onBaseChange('firstAidZlType', $event.detail.value)">
</uni-data-checkbox>
</view>
</template>
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { reactive, ref, computed, inject } from 'vue';
import type { Ref } from 'vue'
import { useUserStore } from '@/store/modules/user'
import { GENDER_LIST, FIRST_AID_ZL_TYPE } from '@/config/service'
import { computed } from 'vue';
import { CODE_DICT } from '@/config/code';
import { useServiceStore } from '@/store/modules/service';
const firstAidId = inject<Ref<string>>('firstAidId')
const userStore = useUserStore()
const serviceStore = useServiceStore()
const baseInfo = reactive({
patientName: '张三',
@ -61,9 +74,8 @@ const codeForm = reactive({
const nationList = ref([])
const userStore = useUserStore()
const token = computed(() => userStore.token)
const currentPatient = computed(() => serviceStore.currentPatient)
//
async function onSubmit() {
@ -124,9 +136,41 @@ function upload(tempPath: string) {
});
}
/**
* 基础信息更新
* @param {string} type 字段名
* @param {string} event 值信息
*/
async function onBaseChange(type: string, event: string) {
console.log(firstAidId?.value);
if (!firstAidId?.value) {
uni.$u.alertError('缺少急救id参数')
return
}
const param = { [type]: event, firstAidId: firstAidId?.value }
try {
await uni.$u.api.updateAidBase(param)
uni.$u.toast('更新成功')
} catch (error) {
uni.$u.alertError(error)
}
}
// code form item change
function onChange(code: string, value: string) {
async function onChange(code: string, value: string) {
codeForm[code] = value
try {
if (!firstAidId?.value) {
uni.$u.alertError('缺少急救id参数')
return
}
const param = { codeAndAnswerList: [{ questionCode: code, answer: [value], time: '' }], firstAidId: firstAidId?.value, sourceId: '', sourceType: '' }
await uni.$u.api.updateAidCode(param)
uni.$u.toast('更新成功')
} catch (error) {
uni.$u.alertError(error)
}
}
// code form
@ -145,6 +189,26 @@ async function getNationList() {
uni.$u.alertError(error)
}
}
//
getNationList()
function init() {
//
getNationList()
// store
if (!currentPatient.value) return
for (const key in baseInfo) {
baseInfo[key] = currentPatient.value[key]
}
// code
const { recordValDict } = currentPatient.value
if (!recordValDict) return
for (const key in codeForm) {
if (!recordValDict[key]) continue
codeForm[key] = recordValDict[key][0]?.answer[0] || ''
}
}
init()
</script>

54
hooks/useNextNode.ts

@ -0,0 +1,54 @@
import { computed, onUnmounted, ref } from 'vue'
import { onUnload } from '@dcloudio/uni-app'
import { useServiceStore } from '@/store/modules/service'
export interface INextNode {
countDownInSeconds: string
firstAidId: number
nextStepCode: string
nextStepName: string
nextStepType: string // 0 仅显示 1 弹窗询问是否进入下个环节
}
export function useNextNode() {
const serviceStore = useServiceStore()
const nextNode = ref<null | INextNode>(null)
const currentFirstAidId = computed(() => serviceStore.currentFirstAidId)
let timer: number
async function getNextNode() {
if (!currentFirstAidId.value) {
uni.$u.alertError('没有急救id信息')
return
}
try {
nextNode.value = await uni.$u.api.getNextNode(currentFirstAidId.value)
} catch (error) {
nextNode.value = null
uni.$u.alertError(error)
}
}
// 循环查下个节点
function intervalGetNextCode() {
timer && clearInterval(timer)
timer = setInterval(() => {
getNextNode()
}, 1000)
}
onUnmounted(() => {
console.log('on unmounted')
timer && clearInterval(timer)
timer = 0
})
onUnload(() => {
console.log('on unload')
timer && clearInterval(timer)
timer = 0
})
return { nextNode, getNextNode, intervalGetNextCode }
}

29
pages/detail2/detail2.vue

@ -39,8 +39,8 @@
</view>
<view class="item-card u-m-r-20 u-m-t-30 bg-primary">
<view class="flex count-wrap">
NIHSS评分
<view class="flex count-wrap" v-if="nextNode?.nextStepName">
{{ nextNode.nextStepName }}
<view class="flex-1 flex justify-end">
<view class="time-item">00</view> :
@ -68,41 +68,37 @@
</view>
</view>
</view>
<!-- right -->
<view class="flex-3">
<DetailBase />
</view>
</view>
<!-- float button -->
<FloatButton />
</view>
</template>
<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { useServiceStore } from '@/store/modules/service';
import { computed } from 'vue';
import { computed, ref, provide } from 'vue';
import { GET_GENDER_TEXT_BY_CODE } from '@/config/service';
import { useNextNode } from '@/hooks/useNextNode'
const serviceStore = useServiceStore()
const { nextNode, intervalGetNextCode } = useNextNode()
const firstAidId = ref('')
const currentPatient = computed(() => serviceStore.currentPatient)
function onClickRight() {
}
provide('firstAidId', firstAidId)
onLoad((option) => {
console.log(option);
if (option?.firstAidId) {
firstAidId.value = option.firstAidId
//
getAidInfo(option.firstAidId)
} else {
firstAidId.value = ''
}
})
@ -116,6 +112,13 @@ async function getAidInfo(firstAidId: string) {
uni.$u.alertError(error)
}
}
function onClickRight() {
}
intervalGetNextCode()
</script>
<style lang="scss" scoped>

1
store/modules/service.ts

@ -14,6 +14,7 @@ export interface IPatient {
patientNation: string
sourceId: string
sourceType: number
recordValDict: any
}
// 平车信息

Loading…
Cancel
Save