refactor: change props to encounter data

This commit is contained in:
riefive
2025-11-25 13:15:37 +07:00
parent 0ceaa9c222
commit d0ca67386f
2 changed files with 17 additions and 23 deletions
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, defineAsyncComponent } from 'vue'
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
// Components
@@ -10,6 +10,9 @@ import SubMenu from '~/components/pub/my-ui/menus/submenu.vue'
// Libraries
import { getPositionAs } from '~/lib/roles'
// Models
import { genEncounter } from '~/models/encounter'
// Types
import type { EncounterProps } from '~/handlers/encounter-init.handler'
@@ -37,15 +40,13 @@ const activeMenu = computed({
})
const id = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
const data = ref<any>(null)
const data = ref<any>(genEncounter())
const isShowPatient = computed(() => data.value && data.value?.patient?.person)
if (activePosition.value === 'none') { // if user position is none, redirect to home page
router.push('/')
}
console.log(JSON.stringify(user, null, 4))
// Dummy rows for ProtocolList (matches keys expected by list-cfg.protocol)
const protocolRows = [
{
@@ -83,16 +84,8 @@ function handleClick(type: string) {
function initMenus() {
menus.value = getMenuItems(id, props, user, {
status: data.value,
medicalAssessment: data.value,
medicalAssessmentRehab: data.value,
functionAssessment: data.value,
protocolTheraphy: data.value,
protocolChemotherapy: data.value,
medicineProtocolChemotherapy: data.value,
consultation: data.value,
letterOfControl: data.value,
}, {
encounter: data.value
} as any, {
protocolTheraphy: paginationMeta,
protocolChemotherapy: paginationMeta,
medicineProtocolChemotherapy: paginationMeta,
+10 -9
View File
@@ -17,6 +17,7 @@ export interface EncounterProps {
}
export interface EncounterListData {
encounter?: any
status?: any
medicalAssessment?: any
medicalAssessmentRehab: any
@@ -233,12 +234,12 @@ export function injectComponents(id: string | number, data: EncounterListData, m
const currentKeys = { ...defaultKeys }
if (currentKeys?.status) {
currentKeys.status['component'] = StatusAsync
currentKeys.status['props'] = { encounter: data?.status }
currentKeys.status['props'] = { encounter: data?.encounter }
}
if (currentKeys?.earlyMedicalAssessment) {
currentKeys.earlyMedicalAssessment['component'] = EarlyMedicalAssesmentListAsync
currentKeys.earlyMedicalAssessment['props'] = {
encounter: data?.medicalAssessment,
encounter: data?.encounter,
type: 'early-medic',
label: currentKeys.earlyMedicalAssessment['title'],
}
@@ -246,7 +247,7 @@ export function injectComponents(id: string | number, data: EncounterListData, m
if (currentKeys?.rehabMedicalAssessment) {
currentKeys.rehabMedicalAssessment['component'] = EarlyMedicalRehabListAsync
currentKeys.rehabMedicalAssessment['props'] = {
encounter: data?.medicalAssessmentRehab,
encounter: data?.encounter,
type: 'early-rehab',
label: currentKeys.rehabMedicalAssessment['title'],
}
@@ -254,7 +255,7 @@ export function injectComponents(id: string | number, data: EncounterListData, m
if (currentKeys?.functionAssessment) {
currentKeys.functionAssessment['component'] = AssesmentFunctionListAsync
currentKeys.functionAssessment['props'] = {
encounter: data?.functionAssessment,
encounter: data?.encounter,
type: 'function',
label: currentKeys.functionAssessment['title'],
}
@@ -263,13 +264,13 @@ export function injectComponents(id: string | number, data: EncounterListData, m
// TODO: add component for therapyProtocol
currentKeys.therapyProtocol['component'] = null
currentKeys.therapyProtocol['props'] = {
data: data?.protocolTheraphy,
data: data?.encounter,
paginationMeta: meta?.protocolTheraphy,
}
}
if (currentKeys?.chemotherapyProtocol) {
currentKeys.chemotherapyProtocol['component'] = ChemoProtocolListAsync
currentKeys.chemotherapyProtocol['props'] = {
currentKeys.encounter['props'] = {
data: data?.protocolChemotherapy,
paginationMeta: meta?.protocolChemotherapy,
}
@@ -277,7 +278,7 @@ export function injectComponents(id: string | number, data: EncounterListData, m
if (currentKeys?.chemotherapyMedicine) {
currentKeys.chemotherapyMedicine['component'] = ChemoMedicineProtocolListAsync
currentKeys.chemotherapyMedicine['props'] = {
data: data?.medicineProtocolChemotherapy,
data: data?.encounter,
paginationMeta: meta?.medicineProtocolChemotherapy,
}
}
@@ -332,7 +333,7 @@ export function injectComponents(id: string | number, data: EncounterListData, m
}
if (currentKeys?.consultation) {
currentKeys.consultation['component'] = ConsultationAsync
currentKeys.consultation['props'] = { encounter: data?.consultation }
currentKeys.consultation['props'] = { encounter: data?.encounter }
}
if (currentKeys?.resume) {
currentKeys.resume['component'] = ResumeListAsync
@@ -340,7 +341,7 @@ export function injectComponents(id: string | number, data: EncounterListData, m
}
if (currentKeys?.control) {
currentKeys.control['component'] = ControlLetterListAsync
currentKeys.control['props'] = { encounter: data?.letterOfControl }
currentKeys.control['props'] = { encounter: data?.encounter }
}
if (currentKeys?.screening) {
// TODO: add component for screening