Compare commits

...

3 Commits

6 changed files with 49 additions and 15 deletions

View File

@@ -22,7 +22,7 @@ class SttMedicalHistoryResource extends JsonResource
'dateextract' => Carbon::parse($this->DateExtract)->format('d.m.Y'),
'card_num' => $this->archiveInfo->num ?? null,
'status' => $this->archiveInfo->status ?? null,
'datearhiv' => $this->archiveInfo?->post_at ? Carbon::parse($this->archiveInfo->post_at)->format('d.m.Y') : null,
'datearhiv' => $this->whenLoaded('archiveInfo') ? Carbon::parse($this->archiveInfo->post_in)->format('d.m.Y') : null,
'medcardnum' => $this->MedCardNum,
'dr' => Carbon::parse($this->BD)->format('d.m.Y'),
'can_be_issue' => $this->canBeIssued()

View File

@@ -22,7 +22,7 @@ class SttMedicalHistoryResource extends JsonResource
'dateextract' => Carbon::parse($this->dateextract)->format('d.m.Y'),
'card_num' => $this->archiveInfo->num ?? null,
'status' => $this->archiveInfo->status ?? null,
'datearhiv' => $this->archiveInfo?->post_at ? Carbon::parse($this->archiveInfo->post_at)->format('d.m.Y') : null,
'datearhiv' => $this->whenLoaded('archiveInfo') ? Carbon::parse($this->archiveInfo->post_in)->format('d.m.Y') : null,
'medcardnum' => $this->medcardnum,
'dr' => Carbon::parse($this->dr)->format('d.m.Y'),
'can_be_issue' => $this->canBeIssued()

View File

@@ -24,7 +24,8 @@ class MedicalHistoryRepository
'ot',
'daterecipient',
'dateextract',
'medcardnum'
'medcardnum',
'dr'
];
protected array $defaultFieldsMis = [
@@ -34,7 +35,8 @@ class MedicalHistoryRepository
'OT',
'DateRecipient',
'DateExtract',
'MedCardNum'
'MedCardNum',
'BD'
];
public function __construct(
@@ -66,6 +68,7 @@ class MedicalHistoryRepository
return $query->select($this->defaultFieldsSI)
->orderBy($sortBy, $sortDir)
->with(['archiveInfo'])
->paginate($pageSize)
->through(function ($item) {
$item->database_source = 'postgresql';
@@ -94,6 +97,7 @@ class MedicalHistoryRepository
return $query->select($this->defaultFieldsMis)
->orderBy($sortBy, $sortDir)
->with(['archiveInfo'])
->paginate($pageSize)
->through(function ($item) {
$item->database_source = 'mssql';

View File

@@ -45,7 +45,7 @@ const loadPatientData = async () => {
loading.value = true
try {
axios.get(`/api/si/patients/${props.patientId}?view_type=${filtersRef.value.view_type}`).then(res => {
await axios.get(`/api/si/patients/${props.patientId}?view_type=${filtersRef.value.view_type}`).then(res => {
patient.value = res.data
patientData.value = res.data.info
archiveInfo.value = res.data.archiveInfo ?? {
@@ -109,8 +109,15 @@ const rowProps = (row) => ({
}
})
const onUpdateHistory = (updatedData) => {
loadPatientData()
const onUpdateHistory = async ({data}) => {
await loadPatientData()
const updatedData = {
status: archiveInfo.value.status,
}
emits('historyUpdated', {
data: updatedData,
patientId: props.patientId
})
}
const hasCreateNew = computed(() => archiveInfo.value === null)
@@ -119,11 +126,14 @@ const onSubmit = async () => {
try {
await axios.post(`/api/archive/histories/info/${props.patientId}`, archiveInfo.value).then(res => {
// onCloseWithoutSave()
const updatedData = {
status: archiveInfo.value.status,
}
emits('historyUpdated', {
type: hasCreateNew.value ? 'created' : 'updated',
data: res.data,
data: updatedData,
patientId: props.patientId
})
open.value = false
})
} catch (error) {
@@ -134,9 +144,9 @@ const onSubmit = async () => {
}
// Наблюдаем за изменением patientId
watch(() => props.patientId, (newId) => {
watch(() => props.patientId, async (newId) => {
if (newId) {
loadPatientData()
await loadPatientData()
}
}, { immediate: true })
</script>

View File

@@ -73,12 +73,12 @@ const submit = () => {
: `/api/archive/histories/move/${archiveHistory.value.id}`
axios.post(url, archiveHistory.value).then(res => {
onCloseWithoutSave()
emits('historyUpdated', {
type: props.isCreateNew ? 'created' : 'updated',
data: res.data,
historyId: archiveHistory.value.id
})
onCloseWithoutSave()
})
} catch (error) {

View File

@@ -1,6 +1,6 @@
<script setup>
import {NDataTable, NEllipsis, NTag} from "naive-ui"
import {computed, h, reactive, ref} from "vue"
import {computed, h, reactive, ref, watch} from "vue"
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
import ArchiveHistoryModal from '../ArchiveHistoryModal/Index.vue'
@@ -24,6 +24,7 @@ const props = defineProps({
})
const { isLoading, handlePageChange, handlePageSizeChange, meta, filtersRef } = useMedicalHistoryFilter(props.filters)
const dataTable = ref(props.data ?? [])
const archiveStatusColumn = (status) => {
const tagType = status?.variant ?? 'error'
@@ -132,11 +133,30 @@ const pagination = computed(() => {
}
}
})
const onCloseWithoutSave = () => {
selectedPatientId.value = null
}
const onUpdateHistory = ({data, patientId}) => {
console.log(data)
if (dataTable.value.length > 0) {
let needUpdateItem = dataTable.value.findIndex(itm => itm.id === patientId)
dataTable.value[needUpdateItem] = {
...dataTable.value[needUpdateItem],
status: data.status
}
}
}
watch(() => props.data, (newData) => {
dataTable.value = newData
})
</script>
<template>
<NDataTable remote striped :loading="isLoading" :row-props="rowProps" :columns="columns" :pagination="pagination" :max-height="maxHeight" size="small" :min-height="minHeight" :data="data" />
<ArchiveHistoryModal v-model:open="showArchiveHistoryModal" :patient-id="selectedPatientId" />
<NDataTable remote striped :loading="isLoading" :row-props="rowProps" :columns="columns" :pagination="pagination" :max-height="maxHeight" size="small" :min-height="minHeight" :data="dataTable" />
<ArchiveHistoryModal v-model:open="showArchiveHistoryModal" :patient-id="selectedPatientId" @history-updated="onUpdateHistory" @close-without-save="onCloseWithoutSave" />
</template>
<style scoped>