Skip to content

Commit

Permalink
Merge pull request #2 from IntelliSOFT-Consulting/refactor/code-smell…
Browse files Browse the repository at this point in the history
…s-clean-up

Refactor/code smells clean up
  • Loading branch information
PiusKariuki authored Oct 2, 2024
2 parents 24dabfe + 91d0ad3 commit bc8eac4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 26 deletions.
4 changes: 0 additions & 4 deletions src/modules/auth/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
<script setup>
import MazInput from 'maz-ui/components/MazInput'
import MazBtn from 'maz-ui/components/MazBtn'
import {ref} from "vue";
import {useRouter} from "vue-router";
import axios from "axios";
import {useToast} from "maz-ui";
import MazSpinner from "maz-ui/components/MazSpinner";
import {useLogin} from "../hooks/useLogin.js";
Expand Down
20 changes: 17 additions & 3 deletions src/modules/facilities/hooks/usePatients.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const usePatients = () => {
}

const clearFilters = () => {
gender.value=""
surname.value=""
gender.value = ""
surname.value = ""
}

const getCBDId = (array) => {
Expand All @@ -54,8 +54,22 @@ export const usePatients = () => {
const csvHeaders = ['Name', 'Gender', 'Registration Date', 'CB-ID', 'Phone']

let csvData = data.value.map(item => {
const name = (item.resource.name[0].family || "") + " " + (item?.resource?.name[0]?.given || "");
const gender = item.resource.gender;
const registrationDate = new Date(item.resource.meta.lastUpdated).toLocaleDateString();
const cbID = getCBDId(item.resource.identifier);

let phone = '';

if (item.resource.contact && item?.resource?.contact[0]?.telecom[0]?.value) {
phone = item?.resource?.contact[0]?.telecom[0]?.value;
} else if (item?.resource?.telecom && item?.resource?.telecom[0]?.value) {
phone = item.resource.telecom[0].value
}


return [
`${item.resource.name[0].family}`, `${item.resource.gender}`, `${new Date(item.resource.meta.lastUpdated).toLocaleDateString()}`, `${getCBDId(item.resource.identifier)}`, `${item.resource.contact ? item?.resource?.contact[0]?.telecom[0]?.value : item?.resource?.telecom ? item?.resource?.telecom[0]?.value : ''}`
name, gender, registrationDate, cbID, phone
]
})

Expand Down
2 changes: 0 additions & 2 deletions src/modules/facilities/hooks/useProfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {useAuthStore} from "../../../shared/store/authStore.js";
import {useAxios} from "../../../shared/hooks/useAxios.js";
import {ref} from "vue";
import {useToast} from "maz-ui";

export const useProfile = () => {

const authStore = useAuthStore()

const firstName = ref("")
const lastName = ref("")
Expand Down
23 changes: 22 additions & 1 deletion src/modules/facilities/hooks/useReferrals.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,28 @@ export const useReferrals = () => {
const print = () => {
const csvHeaders = ["Name", "Gender", "Registration Date", "Referred From", "Referred To", "Reason For Referral", "Referral Received"];

let csvData = filteredReferrals.value.map(item => [`${item?.patient?.name[0]?.text}`, `${item?.patient?.gender}`, `${new Date(item.service.occurrenceDateTime).toDateString()}`, `${(item?.service?.supportingInfo?.find(item => item?.display === "REFERRING_FROM"))?.reference.split("/")[1]}`, `${(item?.service?.supportingInfo?.find(item => item?.display === "REFERRING_TO"))?.reference?.split("/")[1]}`, `${item?.service?.reasonCode[0].text}`, `${item?.service?.status == 'draft' ? 'Pending' : item?.service?.status == 'active' ? 'Recieved' : ''}`])


let csvData = filteredReferrals.value.map(item => {
const name = item?.patient?.name[0]?.text;
const gender = item?.patient?.gender;
const registrationDate = new Date(item.service.occurrenceDateTime).toDateString();
const referredFrom = (item?.service?.supportingInfo?.find(item => item?.display === "REFERRING_FROM"))?.reference.split("/")[1];
const referredTo = (item?.service?.supportingInfo?.find(item => item?.display === "REFERRING_TO"))?.reference?.split("/")[1];
const reasonForReferral = item?.service?.reasonCode[0].text;

let referralStatus = "";

if (item?.service?.status == 'draft') {
referralStatus = "pending"
} else if (item?.service?.status == 'active') {
referralStatus = "received"
} else {
referralStatus = "unknown"
}

return [name, gender, registrationDate, referredFrom, referredTo, reasonForReferral, referralStatus]
})

csvData = [csvHeaders, ...csvData]

Expand Down
4 changes: 0 additions & 4 deletions src/modules/facilities/hooks/useRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ export const useRegistration = () => {

const isOpen = ref(false)
const loading = ref(false)
const name = ref("")
const level = ref("")
const district = ref("")
const listOfFacilities = ref([])
const searchString = ref("")
const selectedFacility = ref({
Expand All @@ -34,7 +31,6 @@ export const useRegistration = () => {


const submit = async (evt) => {
console.log("selected facility", selectedFacility.value)
evt.preventDefault()
loading.value = true;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/facilities/views/RegisterFacility.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import MazIcon from 'maz-ui/components/MazIcon'
import MazDialog from 'maz-ui/components/MazDialog'
import MazSpinner from 'maz-ui/components/MazSpinner'
import MazBtn from 'maz-ui/components/MazBtn'
import {computed, onMounted, watch,} from "vue";
import { onMounted, watch,} from "vue";
import {useRegistration} from "../hooks/useRegistration.js";
import {useRouter} from "vue-router";
Expand Down
2 changes: 0 additions & 2 deletions src/modules/facilities/views/RegisterUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ import {useRouter} from "vue-router";
import {onMounted, watch} from "vue";
import MazDialog from "maz-ui/components/MazDialog";
import MazBtn from "maz-ui/components/MazBtn";
import {useLocationStore} from "../../../shared/store/locationStore.js";
import {useAllFacilities} from "../hooks/useAllFacilities.js";
const router = useRouter()
Expand Down
18 changes: 12 additions & 6 deletions src/shared/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ const router = createRouter({
routes
})

router.beforeEach((to) => {
const authStore = useAuthStore(pinia)
if (to.meta.requiresAuth && !authStore.accessToken) {
// return {name: "login"}
}
})

/**
* return this line of code when the authentication is fixed
*
* router.beforeEach((to) => {
* const authStore = useAuthStore(pinia)
* return
* })
* if (to.meta.requiresAuth && !authStore.accessToken) {
* // return {name: "login"}
* }
*/


router.beforeEach((to) => {
Expand Down
3 changes: 0 additions & 3 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ body {
--easy-table-body-row-font-size: 12px;
}
}

@layer components {
}

0 comments on commit bc8eac4

Please sign in to comment.