2022-04-04 02:54:31 +08:00
|
|
|
<script setup lang="ts">
|
2023-02-24 08:44:14 +08:00
|
|
|
import { ref, reactive, computed, h } from "vue";
|
|
|
|
import DataTable from "../../components/datatable/DataTable.vue";
|
2022-12-28 05:29:14 +08:00
|
|
|
import { storeToRefs } from "pinia";
|
2023-02-24 08:44:14 +08:00
|
|
|
import { RouterLink } from "vue-router";
|
|
|
|
import { usePatientStore, useLocationStore } from "../../stores";
|
2022-12-28 05:29:14 +08:00
|
|
|
import { IPatient } from "../../models/patient";
|
|
|
|
|
|
|
|
import * as shield from "../../guards";
|
|
|
|
|
|
|
|
let patientStore = usePatientStore();
|
|
|
|
let locationsStore = useLocationStore();
|
|
|
|
|
2023-02-24 08:44:14 +08:00
|
|
|
const { patients, fetchingPatients, patientPageInfo } = storeToRefs(patientStore);
|
|
|
|
|
|
|
|
const tableColumns = ref([
|
|
|
|
{
|
|
|
|
name: "UID",
|
|
|
|
value: "uid",
|
|
|
|
sortable: true,
|
|
|
|
sortBy: "asc",
|
|
|
|
defaultSort: true,
|
|
|
|
showInToggler: false,
|
|
|
|
hidden: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Patient Id",
|
|
|
|
value: "patientId",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
customRender: function (patient, _) {
|
|
|
|
return h(RouterLink, {
|
|
|
|
to: {
|
|
|
|
name: "patient-detail",
|
|
|
|
params: {
|
|
|
|
patientUid: patient?.uid,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
innerHTML: patient?.patientId,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Full Name",
|
|
|
|
value: "",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
customRender: function (patient, _) {
|
|
|
|
return h(RouterLink, {
|
|
|
|
to: {
|
|
|
|
name: "patient-detail",
|
|
|
|
params: {
|
|
|
|
patientUid: patient?.uid,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
innerHTML: getPatientFullName(patient),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Age",
|
|
|
|
value: "age",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Gender",
|
|
|
|
value: "gender",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Client Patient ID",
|
|
|
|
value: "clientPatientId",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Province",
|
|
|
|
value: "client.district.province.name",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "District",
|
|
|
|
value: "client.district.name",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Client",
|
|
|
|
value: "client.name",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
hidden: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "",
|
|
|
|
value: "",
|
|
|
|
sortable: false,
|
|
|
|
sortBy: "asc",
|
|
|
|
showInToggler: false,
|
|
|
|
hidden: false,
|
|
|
|
customRender: function (patient, _) {
|
|
|
|
return h(RouterLink, {
|
|
|
|
to: {
|
|
|
|
name: "samples-add",
|
|
|
|
params: {
|
|
|
|
patientUid: patient?.uid,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
class:
|
2023-04-09 21:13:46 +08:00
|
|
|
"px-2 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none",
|
|
|
|
innerHTML: "+ Analysis Request",
|
2023-02-24 08:44:14 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]);
|
2022-12-28 05:29:14 +08:00
|
|
|
|
|
|
|
locationsStore.fetchCountries();
|
|
|
|
let patientParams = reactive({
|
2023-02-24 08:44:14 +08:00
|
|
|
first: 50,
|
2022-12-28 05:29:14 +08:00
|
|
|
before: "",
|
|
|
|
text: "",
|
|
|
|
sortBy: ["-uid"],
|
|
|
|
filterAction: false,
|
|
|
|
});
|
|
|
|
patientStore.fetchPatients(patientParams);
|
|
|
|
|
2023-02-24 08:44:14 +08:00
|
|
|
let patientSearch = ref<string>("");
|
|
|
|
function searchPatients(opts: any): void {
|
2022-12-28 05:29:14 +08:00
|
|
|
patientParams.first = 100;
|
2023-02-24 08:44:14 +08:00
|
|
|
patientParams.before = patientPageInfo?.value?.endCursor ?? "";
|
|
|
|
patientParams.text = opts.filterText;
|
2022-12-28 05:29:14 +08:00
|
|
|
patientParams.filterAction = true;
|
2023-02-24 08:44:14 +08:00
|
|
|
patientSearch.value = opts.filterText;
|
2022-04-04 02:54:31 +08:00
|
|
|
patientStore.fetchPatients(patientParams);
|
2022-12-28 05:29:14 +08:00
|
|
|
}
|
2022-04-04 02:54:31 +08:00
|
|
|
|
2023-02-24 08:44:14 +08:00
|
|
|
const countNone = computed(
|
|
|
|
() => patients?.value?.length + " of " + patientStore.getPatientCount + " patients"
|
|
|
|
);
|
2022-04-04 02:54:31 +08:00
|
|
|
|
2023-02-24 08:44:14 +08:00
|
|
|
function showMorePatients(opts: any): void {
|
|
|
|
patientParams.first = opts.fetchCount;
|
|
|
|
patientParams.before = patientPageInfo?.value?.endCursor ?? "";
|
|
|
|
patientParams.text = opts.filterText;
|
2022-12-28 05:29:14 +08:00
|
|
|
patientParams.filterAction = false;
|
|
|
|
patientStore.fetchPatients(patientParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
let getPatientFullName = (pt: IPatient) => {
|
|
|
|
return pt.firstName + " " + pt.lastName;
|
|
|
|
};
|
2022-04-04 02:54:31 +08:00
|
|
|
</script>
|
|
|
|
|
2023-02-24 08:44:14 +08:00
|
|
|
<style lang="postcss" scoped></style>
|
2022-12-28 05:29:14 +08:00
|
|
|
|
2023-02-24 08:44:14 +08:00
|
|
|
<template>
|
2023-04-09 21:13:46 +08:00
|
|
|
<DataTable :columns="tableColumns" :data="patients" :toggleColumns="true" :loading="fetchingPatients" :paginable="true"
|
2023-02-24 08:44:14 +08:00
|
|
|
:pageMeta="{
|
|
|
|
fetchCount: patientParams.first,
|
|
|
|
hasNextPage: patientPageInfo?.hasNextPage,
|
|
|
|
countNone,
|
2023-04-09 21:13:46 +08:00
|
|
|
}" :searchable="true" :filterable="false" @onSearch="searchPatients" @onPaginate="showMorePatients"
|
|
|
|
:selectable="false">
|
2023-02-24 08:44:14 +08:00
|
|
|
<template v-slot:footer>
|
|
|
|
<div>
|
|
|
|
<div class="flex content-start items-center">
|
|
|
|
<span class="text-sky-800"><i class="fas fa-info-circle"></i></span>
|
|
|
|
<p class="ml-2 italic text-orange-600">
|
|
|
|
Click register when you dont find your patient during search*
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<hr class="my-2" />
|
2022-12-28 05:29:14 +08:00
|
|
|
|
2023-04-09 21:13:46 +08:00
|
|
|
<router-link v-show="shield.hasRights(shield.actions.CREATE, shield.objects.PATIENT)"
|
2023-02-24 08:44:14 +08:00
|
|
|
:to="{ name: 'patients-register', query: { cpid: patientSearch } }"
|
2023-04-09 21:13:46 +08:00
|
|
|
class="px-4 p-1 text-sm border-sky-800 border text-dark-700 transition-colors duration-150 rounded-sm focus:outline-none hover:bg-sky-800 hover:text-gray-100">
|
2023-02-24 08:44:14 +08:00
|
|
|
Register New Patiet
|
|
|
|
</router-link>
|
2022-12-28 05:29:14 +08:00
|
|
|
</div>
|
2023-02-24 08:44:14 +08:00
|
|
|
</template>
|
|
|
|
</DataTable>
|
2021-04-09 06:37:58 +08:00
|
|
|
</template>
|