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'), 'dateextract' => Carbon::parse($this->DateExtract)->format('d.m.Y'),
'card_num' => $this->archiveInfo->num ?? null, 'card_num' => $this->archiveInfo->num ?? null,
'status' => $this->archiveInfo->status ?? 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, 'medcardnum' => $this->MedCardNum,
'dr' => Carbon::parse($this->BD)->format('d.m.Y'), 'dr' => Carbon::parse($this->BD)->format('d.m.Y'),
'can_be_issue' => $this->canBeIssued() 'can_be_issue' => $this->canBeIssued()

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
<script setup> <script setup>
import {NDataTable, NEllipsis, NTag} from "naive-ui" 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 {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
import ArchiveHistoryModal from '../ArchiveHistoryModal/Index.vue' import ArchiveHistoryModal from '../ArchiveHistoryModal/Index.vue'
@@ -24,6 +24,7 @@ const props = defineProps({
}) })
const { isLoading, handlePageChange, handlePageSizeChange, meta, filtersRef } = useMedicalHistoryFilter(props.filters) const { isLoading, handlePageChange, handlePageSizeChange, meta, filtersRef } = useMedicalHistoryFilter(props.filters)
const dataTable = ref(props.data ?? [])
const archiveStatusColumn = (status) => { const archiveStatusColumn = (status) => {
const tagType = status?.variant ?? 'error' 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> </script>
<template> <template>
<NDataTable remote striped :loading="isLoading" :row-props="rowProps" :columns="columns" :pagination="pagination" :max-height="maxHeight" size="small" :min-height="minHeight" :data="data" /> <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" /> <ArchiveHistoryModal v-model:open="showArchiveHistoryModal" :patient-id="selectedPatientId" @history-updated="onUpdateHistory" @close-without-save="onCloseWithoutSave" />
</template> </template>
<style scoped> <style scoped>