From 97e45d1b9837dc1c9b46f531120b7f43ef53e378 Mon Sep 17 00:00:00 2001 From: Christopher Seven Phiri Date: Wed, 2 Oct 2024 09:48:07 +0200 Subject: [PATCH 1/3] update versions --- package.json | 2 +- pnpm-lock.yaml | 88 +++++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 4f38854..8745ee4 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "jsonwebtoken": "^9.0.2", "jwt-decode": "^3.1.2", "lucide-react": "^0.271.0", - "next": "14.2.5", + "next": "14.2.13", "next-auth": "beta", "nextjs-toploader": "^1.6.12", "postcss": "8.4.29", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ff3f60..6c3e542 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,14 +90,14 @@ dependencies: specifier: ^0.271.0 version: 0.271.0(react@18.3.1) next: - specifier: 14.2.5 - version: 14.2.5(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) + specifier: 14.2.13 + version: 14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) next-auth: specifier: beta - version: 5.0.0-beta.20(next@14.2.5)(react@18.3.1) + version: 5.0.0-beta.21(next@14.2.13)(react@18.3.1) nextjs-toploader: specifier: ^1.6.12 - version: 1.6.12(next@14.2.5)(react-dom@18.3.1)(react@18.3.1) + version: 1.6.12(next@14.2.13)(react-dom@18.3.1)(react@18.3.1) postcss: specifier: 8.4.29 version: 8.4.29 @@ -168,8 +168,8 @@ packages: '@jridgewell/trace-mapping': 0.3.19 dev: false - /@auth/core@0.34.2: - resolution: {integrity: sha512-KywHKRgLiF3l7PLyL73fjLSIBe1YNcA6sMeew4yMP6cfCWGXZrkkXd32AjRi1hlJ9nvovUBGZHvbn+LijO6ZeQ==} + /@auth/core@0.35.0: + resolution: {integrity: sha512-XvMALiYn5ZQd1hVeG1t+jCU89jRrc7ortl/05wkBrPHnRWZScxAK5jKuzBz+AOBQXewDjYcMpzeF5tTqg6rDhQ==} peerDependencies: '@simplewebauthn/browser': ^9.0.1 '@simplewebauthn/server': ^9.0.2 @@ -566,8 +566,8 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@next/env@14.2.5: - resolution: {integrity: sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==} + /@next/env@14.2.13: + resolution: {integrity: sha512-s3lh6K8cbW1h5Nga7NNeXrbe0+2jIIYK9YaA9T7IufDWnZpozdFUp6Hf0d5rNWUKu4fEuSX2rCKlGjCrtylfDw==} dev: false /@next/eslint-plugin-next@13.4.19: @@ -576,8 +576,8 @@ packages: glob: 7.1.7 dev: false - /@next/swc-darwin-arm64@14.2.5: - resolution: {integrity: sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==} + /@next/swc-darwin-arm64@14.2.13: + resolution: {integrity: sha512-IkAmQEa2Htq+wHACBxOsslt+jMoV3msvxCn0WFSfJSkv/scy+i/EukBKNad36grRxywaXUYJc9mxEGkeIs8Bzg==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -585,8 +585,8 @@ packages: dev: false optional: true - /@next/swc-darwin-x64@14.2.5: - resolution: {integrity: sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA==} + /@next/swc-darwin-x64@14.2.13: + resolution: {integrity: sha512-Dv1RBGs2TTjkwEnFMVL5XIfJEavnLqqwYSD6LXgTPdEy/u6FlSrLBSSfe1pcfqhFEXRAgVL3Wpjibe5wXJzWog==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -594,8 +594,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-gnu@14.2.5: - resolution: {integrity: sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA==} + /@next/swc-linux-arm64-gnu@14.2.13: + resolution: {integrity: sha512-yB1tYEFFqo4ZNWkwrJultbsw7NPAAxlPXURXioRl9SdW6aIefOLS+0TEsKrWBtbJ9moTDgU3HRILL6QBQnMevg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -603,8 +603,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-musl@14.2.5: - resolution: {integrity: sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA==} + /@next/swc-linux-arm64-musl@14.2.13: + resolution: {integrity: sha512-v5jZ/FV/eHGoWhMKYrsAweQ7CWb8xsWGM/8m1mwwZQ/sutJjoFaXchwK4pX8NqwImILEvQmZWyb8pPTcP7htWg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -612,8 +612,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-gnu@14.2.5: - resolution: {integrity: sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ==} + /@next/swc-linux-x64-gnu@14.2.13: + resolution: {integrity: sha512-aVc7m4YL7ViiRv7SOXK3RplXzOEe/qQzRA5R2vpXboHABs3w8vtFslGTz+5tKiQzWUmTmBNVW0UQdhkKRORmGA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -621,8 +621,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-musl@14.2.5: - resolution: {integrity: sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ==} + /@next/swc-linux-x64-musl@14.2.13: + resolution: {integrity: sha512-4wWY7/OsSaJOOKvMsu1Teylku7vKyTuocvDLTZQq0TYv9OjiYYWt63PiE1nTuZnqQ4RPvME7Xai+9enoiN0Wrg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -630,8 +630,8 @@ packages: dev: false optional: true - /@next/swc-win32-arm64-msvc@14.2.5: - resolution: {integrity: sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw==} + /@next/swc-win32-arm64-msvc@14.2.13: + resolution: {integrity: sha512-uP1XkqCqV2NVH9+g2sC7qIw+w2tRbcMiXFEbMihkQ8B1+V6m28sshBwAB0SDmOe0u44ne1vFU66+gx/28RsBVQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -639,8 +639,8 @@ packages: dev: false optional: true - /@next/swc-win32-ia32-msvc@14.2.5: - resolution: {integrity: sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==} + /@next/swc-win32-ia32-msvc@14.2.13: + resolution: {integrity: sha512-V26ezyjPqQpDBV4lcWIh8B/QICQ4v+M5Bo9ykLN+sqeKKBxJVDpEc6biDVyluTXTC40f5IqCU0ttth7Es2ZuMw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -648,8 +648,8 @@ packages: dev: false optional: true - /@next/swc-win32-x64-msvc@14.2.5: - resolution: {integrity: sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g==} + /@next/swc-win32-x64-msvc@14.2.13: + resolution: {integrity: sha512-WwzOEAFBGhlDHE5Z73mNU8CO8mqMNLqaG+AO9ETmzdCQlJhVtWZnOl2+rqgVQS+YHunjOWptdFmNfbpwcUuEsw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -3966,8 +3966,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: false - /next-auth@5.0.0-beta.20(next@14.2.5)(react@18.3.1): - resolution: {integrity: sha512-+48SjV9k9AtUU3JbEIa4PXNjKIewfFjVGL7Xs2RKkuQ5QqegDNIQiIG8sLk6/qo7RTScQYIGKgeQ5IuQRtrTQg==} + /next-auth@5.0.0-beta.21(next@14.2.13)(react@18.3.1): + resolution: {integrity: sha512-VrT6LV9u/o5tMuWxRDN5d/K1OgPskrMHy+aITTwasVfIrkIaU/8UVg3TXH8ynJgzhfzlDx/3hLWGhi+eXQw4qg==} peerDependencies: '@simplewebauthn/browser': ^9.0.1 '@simplewebauthn/server': ^9.0.2 @@ -3982,13 +3982,13 @@ packages: nodemailer: optional: true dependencies: - '@auth/core': 0.34.2 - next: 14.2.5(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) + '@auth/core': 0.35.0 + next: 14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) react: 18.3.1 dev: false - /next@14.2.5(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA==} + /next@14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-BseY9YNw8QJSwLYD7hlZzl6QVDoSFHL/URN5K64kVEVpCsSOWeyjbIGK+dZUaRViHTaMQX8aqmnn0PHBbGZezg==} engines: {node: '>=18.17.0'} hasBin: true peerDependencies: @@ -4005,7 +4005,7 @@ packages: sass: optional: true dependencies: - '@next/env': 14.2.5 + '@next/env': 14.2.13 '@swc/helpers': 0.5.5 busboy: 1.6.0 caniuse-lite: 1.0.30001620 @@ -4015,28 +4015,28 @@ packages: react-dom: 18.3.1(react@18.3.1) styled-jsx: 5.1.1(@babel/core@7.22.11)(react@18.3.1) optionalDependencies: - '@next/swc-darwin-arm64': 14.2.5 - '@next/swc-darwin-x64': 14.2.5 - '@next/swc-linux-arm64-gnu': 14.2.5 - '@next/swc-linux-arm64-musl': 14.2.5 - '@next/swc-linux-x64-gnu': 14.2.5 - '@next/swc-linux-x64-musl': 14.2.5 - '@next/swc-win32-arm64-msvc': 14.2.5 - '@next/swc-win32-ia32-msvc': 14.2.5 - '@next/swc-win32-x64-msvc': 14.2.5 + '@next/swc-darwin-arm64': 14.2.13 + '@next/swc-darwin-x64': 14.2.13 + '@next/swc-linux-arm64-gnu': 14.2.13 + '@next/swc-linux-arm64-musl': 14.2.13 + '@next/swc-linux-x64-gnu': 14.2.13 + '@next/swc-linux-x64-musl': 14.2.13 + '@next/swc-win32-arm64-msvc': 14.2.13 + '@next/swc-win32-ia32-msvc': 14.2.13 + '@next/swc-win32-x64-msvc': 14.2.13 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros dev: false - /nextjs-toploader@1.6.12(next@14.2.5)(react-dom@18.3.1)(react@18.3.1): + /nextjs-toploader@1.6.12(next@14.2.13)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-nbun5lvVjlKnxLQlahzZ55nELVEduqoEXT03KCHnsEYJnFpI/3BaIzpMyq/v8C7UGU2NfxQmjq6ldZ310rsDqA==} peerDependencies: next: '>= 6.0.0' react: '>= 16.0.0' react-dom: '>= 16.0.0' dependencies: - next: 14.2.5(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) + next: 14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) nprogress: 0.2.0 prop-types: 15.8.1 react: 18.3.1 From 5ceffe7edcb3df203c8b1cf7e208792d77619fb6 Mon Sep 17 00:00:00 2001 From: Christopher Seven Phiri Date: Wed, 2 Oct 2024 10:25:45 +0200 Subject: [PATCH 2/3] Fetch from api on facility page --- package.json | 1 + pnpm-lock.yaml | 27 +++++ src/app/(dashboard)/facilities/[id]/page.tsx | 119 +++++-------------- src/lib/api/axios.ts | 10 +- src/lib/models/helpers.ts | 18 +++ tailwind.config.js | 6 +- 6 files changed, 91 insertions(+), 90 deletions(-) create mode 100644 src/lib/models/helpers.ts diff --git a/package.json b/package.json index 8745ee4..aa07b94 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@smile-cdr/fhirts": "^2.0.7", + "@tailwindcss/typography": "^0.5.15", "@tanstack/react-query": "^4.33.0", "@types/node": "20.5.7", "@types/react": "18.2.21", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6c3e542..eb41d9b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ dependencies: '@smile-cdr/fhirts': specifier: ^2.0.7 version: 2.0.7 + '@tailwindcss/typography': + specifier: ^0.5.15 + version: 0.5.15(tailwindcss@3.3.3) '@tanstack/react-query': specifier: ^4.33.0 version: 4.33.0(react-dom@18.3.1)(react@18.3.1) @@ -1862,6 +1865,18 @@ packages: tslib: 2.6.2 dev: false + /@tailwindcss/typography@0.5.15(tailwindcss@3.3.3): + resolution: {integrity: sha512-AqhlCXl+8grUz8uqExv5OTtgpjuVIwFTSXTrh8y9/pw6q2ek7fJ+Y8ZEVw7EB2DCcuCOtEjf9w3+J3rzts01uA==} + peerDependencies: + tailwindcss: '>=3.0.0 || insiders || >=4.0.0-alpha.20' + dependencies: + lodash.castarray: 4.4.0 + lodash.isplainobject: 4.0.6 + lodash.merge: 4.6.2 + postcss-selector-parser: 6.0.10 + tailwindcss: 3.3.3 + dev: false + /@tanstack/query-core@4.33.0: resolution: {integrity: sha512-qYu73ptvnzRh6se2nyBIDHGBQvPY1XXl3yR769B7B6mIDD7s+EZhdlWHQ67JI6UOTFRaI7wupnTnwJ3gE0Mr/g==} dev: false @@ -3824,6 +3839,10 @@ packages: p-locate: 5.0.0 dev: false + /lodash.castarray@4.4.0: + resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==} + dev: false + /lodash.flattendeep@4.4.0: resolution: {integrity: sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==} dev: false @@ -4340,6 +4359,14 @@ packages: postcss: 8.4.29 postcss-selector-parser: 6.0.13 + /postcss-selector-parser@6.0.10: + resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==} + engines: {node: '>=4'} + dependencies: + cssesc: 3.0.0 + util-deprecate: 1.0.2 + dev: false + /postcss-selector-parser@6.0.13: resolution: {integrity: sha512-EaV1Gl4mUEV4ddhDnv/xtj7sxwrwxdetHdWUGnT4VJQf+4d05v6lHYZr8N573k5Z0BViss7BDhfWtKS3+sfAqQ==} engines: {node: '>=4'} diff --git a/src/app/(dashboard)/facilities/[id]/page.tsx b/src/app/(dashboard)/facilities/[id]/page.tsx index d637e64..f56c7f8 100644 --- a/src/app/(dashboard)/facilities/[id]/page.tsx +++ b/src/app/(dashboard)/facilities/[id]/page.tsx @@ -1,104 +1,47 @@ -import { fhirServer } from "@/lib/api/axios"; -import { BundleEntry } from "@/model/resources"; +import { fhirHelperServer } from "@/lib/api/axios"; +import { FacilityResultData } from "@/lib/models/helpers"; export default async function Page({ params }: { params: { id: string } }) { const data = await fetchData(params.id); return (
-
- {data.map((location) => { - return ( -
-

{location.title}

-

{location.count}

-
- ); - })} +
+
+ {data.groups.map((group) => { + return ( +
+

{group.groupTitle}

+
+
+ {group.summaries.map((summary) => { + return ( +
+

{summary.name}

+
+ {summary.value} +
+
+ ); + })} +
+
+
+ ); + })} +
); } -const fetchData: (id: string) => Promise = async (id) => { +const fetchData: (id: string) => Promise = async (id) => { try { - const entries: BundleEntry[] = []; - const titles = [ - "Exposed Infants", - "Clients Already on ART", - "Newly Diagnosed Client", - ]; - entries.push( - addFetch("/Patient", { - _tag: [ - `http://smartregister.org/fhir/location-tag|${id}`, - "https://d-tree.org/fhir/patient-meta-tag|exposed-infant", - ], - _summary: "count", - }) + const { data } = await fhirHelperServer.get( + `/stats/facility/${id}` ); - - entries.push( - addFetch("/Patient", { - _tag: [ - `http://smartregister.org/fhir/location-tag|${id}`, - "https://d-tree.org/fhir/patient-meta-tag|client-already-on-art", - ], - _summary: "count", - }) - ); - - entries.push( - addFetch("/Patient", { - _tag: [ - `http://smartregister.org/fhir/location-tag|${id}`, - "https://d-tree.org/fhir/patient-meta-tag|newly-diagnosed-client", - ], - _summary: "count", - }) - ); - - const { data } = await fhirServer.post(`/`, { - resourceType: "Bundle", - type: "transaction", - entry: entries, - }); - - if (data == null) { - return []; - } - - return data.entry.map((entry: any, index: number) => { - return { - id: entry.resource.id, - count: entry.resource.total, - title: titles[index], - }; - }); + return data; } catch (error) { console.log(error); + return { groups: [], date: "", generatedDate: "" }; } }; - -type CountSummary = { - id: string; - count: number; - title: string; -}; - -const addFetch = (path: string, params: Record): BundleEntry => { - let query = ""; - for (const key in params) { - const param = params[key]; - if (Array.isArray(param)) { - for (const p of param) { - query += `${key}=${p}&`; - } - } else { - query += `${key}=${param}&`; - } - } - const url = `${path}?${query}`; - console.log(url); - - return { request: { method: "GET", url: url } }; -}; diff --git a/src/lib/api/axios.ts b/src/lib/api/axios.ts index fa1bfe1..3414e75 100644 --- a/src/lib/api/axios.ts +++ b/src/lib/api/axios.ts @@ -9,10 +9,18 @@ export const fhirServer = axios.create({ }, }); +export const fhirHelperServer = axios.create({ + baseURL: process.env.FHIR_HELPER_SERVICE, + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, +}); + fhirServer.interceptors.request.use( async (config) => { const token = await getAccessToken(); - + config.headers.Authorization = `Bearer ${token}`.trim(); return config; }, diff --git a/src/lib/models/helpers.ts b/src/lib/models/helpers.ts new file mode 100644 index 0000000..f58ce72 --- /dev/null +++ b/src/lib/models/helpers.ts @@ -0,0 +1,18 @@ +export type FacilityResultData = { + groups: GroupedSummaryItem[]; + date: string; + generatedDate: string; +}; + +export type GroupedSummaryItem = { + groupKey: string; + groupTitle: string; + summaries: SummaryItem[]; + order: number; + startCollapsed: boolean; +}; + +export type SummaryItem = { + name: string; + value: number; +}; diff --git a/tailwind.config.js b/tailwind.config.js index ac8d8bb..f40a9c1 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -75,5 +75,9 @@ module.exports = { daisyui: { themes: ["light", "dark", "cupcake"], }, - plugins: [require("tailwindcss-animate"), require("daisyui")], + plugins: [ + require("@tailwindcss/typography"), + require("tailwindcss-animate"), + require("daisyui"), + ], }; From f2aa068e8ea76e9b87a85d80b86a92c8047e0bfe Mon Sep 17 00:00:00 2001 From: Christopher Seven Phiri Date: Tue, 8 Oct 2024 16:23:03 +0200 Subject: [PATCH 3/3] Add links indicator --- package.json | 3 +- pnpm-lock.yaml | 127 ++++++++++++------ .../patients/[id]/components/patientInfo.tsx | 89 ++++++++++-- src/components/ui/avatar.tsx | 50 +++++++ src/components/ui/dialog.tsx | 58 ++++---- src/lib/fhir/patient.ts | 37 +++-- src/lib/fhir/types.ts | 5 + 7 files changed, 271 insertions(+), 98 deletions(-) create mode 100644 src/components/ui/avatar.tsx diff --git a/package.json b/package.json index aa07b94..de9cca7 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@headlessui/react": "^2.0.4", "@hookform/resolvers": "^3.3.1", + "@radix-ui/react-avatar": "^1.1.1", "@radix-ui/react-collapsible": "^1.1.0", "@radix-ui/react-dialog": "^1.0.4", "@radix-ui/react-icons": "^1.3.0", @@ -38,7 +39,7 @@ "jsonwebtoken": "^9.0.2", "jwt-decode": "^3.1.2", "lucide-react": "^0.271.0", - "next": "14.2.13", + "next": "14.2.14", "next-auth": "beta", "nextjs-toploader": "^1.6.12", "postcss": "8.4.29", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eb41d9b..44db452 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@hookform/resolvers': specifier: ^3.3.1 version: 3.3.1(react-hook-form@7.45.4) + '@radix-ui/react-avatar': + specifier: ^1.1.1 + version: 1.1.1(@types/react-dom@18.2.7)(@types/react@18.2.21)(react-dom@18.3.1)(react@18.3.1) '@radix-ui/react-collapsible': specifier: ^1.1.0 version: 1.1.0(@types/react-dom@18.2.7)(@types/react@18.2.21)(react-dom@18.3.1)(react@18.3.1) @@ -93,14 +96,14 @@ dependencies: specifier: ^0.271.0 version: 0.271.0(react@18.3.1) next: - specifier: 14.2.13 - version: 14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) + specifier: 14.2.14 + version: 14.2.14(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) next-auth: specifier: beta - version: 5.0.0-beta.21(next@14.2.13)(react@18.3.1) + version: 5.0.0-beta.22(next@14.2.14)(react@18.3.1) nextjs-toploader: specifier: ^1.6.12 - version: 1.6.12(next@14.2.13)(react-dom@18.3.1)(react@18.3.1) + version: 1.6.12(next@14.2.14)(react-dom@18.3.1)(react@18.3.1) postcss: specifier: 8.4.29 version: 8.4.29 @@ -171,8 +174,8 @@ packages: '@jridgewell/trace-mapping': 0.3.19 dev: false - /@auth/core@0.35.0: - resolution: {integrity: sha512-XvMALiYn5ZQd1hVeG1t+jCU89jRrc7ortl/05wkBrPHnRWZScxAK5jKuzBz+AOBQXewDjYcMpzeF5tTqg6rDhQ==} + /@auth/core@0.35.3: + resolution: {integrity: sha512-g6qfiqU4OtyvIEZ8J7UoIwAxEnNnLJV0/f/DW41U+4G5nhBlaCrnKhawJIJpU0D3uavXLeDT3B0BkjtiimvMDA==} peerDependencies: '@simplewebauthn/browser': ^9.0.1 '@simplewebauthn/server': ^9.0.2 @@ -569,8 +572,8 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@next/env@14.2.13: - resolution: {integrity: sha512-s3lh6K8cbW1h5Nga7NNeXrbe0+2jIIYK9YaA9T7IufDWnZpozdFUp6Hf0d5rNWUKu4fEuSX2rCKlGjCrtylfDw==} + /@next/env@14.2.14: + resolution: {integrity: sha512-/0hWQfiaD5//LvGNgc8PjvyqV50vGK0cADYzaoOOGN8fxzBn3iAiaq3S0tCRnFBldq0LVveLcxCTi41ZoYgAgg==} dev: false /@next/eslint-plugin-next@13.4.19: @@ -579,8 +582,8 @@ packages: glob: 7.1.7 dev: false - /@next/swc-darwin-arm64@14.2.13: - resolution: {integrity: sha512-IkAmQEa2Htq+wHACBxOsslt+jMoV3msvxCn0WFSfJSkv/scy+i/EukBKNad36grRxywaXUYJc9mxEGkeIs8Bzg==} + /@next/swc-darwin-arm64@14.2.14: + resolution: {integrity: sha512-bsxbSAUodM1cjYeA4o6y7sp9wslvwjSkWw57t8DtC8Zig8aG8V6r+Yc05/9mDzLKcybb6EN85k1rJDnMKBd9Gw==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -588,8 +591,8 @@ packages: dev: false optional: true - /@next/swc-darwin-x64@14.2.13: - resolution: {integrity: sha512-Dv1RBGs2TTjkwEnFMVL5XIfJEavnLqqwYSD6LXgTPdEy/u6FlSrLBSSfe1pcfqhFEXRAgVL3Wpjibe5wXJzWog==} + /@next/swc-darwin-x64@14.2.14: + resolution: {integrity: sha512-cC9/I+0+SK5L1k9J8CInahduTVWGMXhQoXFeNvF0uNs3Bt1Ub0Azb8JzTU9vNCr0hnaMqiWu/Z0S1hfKc3+dww==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -597,8 +600,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-gnu@14.2.13: - resolution: {integrity: sha512-yB1tYEFFqo4ZNWkwrJultbsw7NPAAxlPXURXioRl9SdW6aIefOLS+0TEsKrWBtbJ9moTDgU3HRILL6QBQnMevg==} + /@next/swc-linux-arm64-gnu@14.2.14: + resolution: {integrity: sha512-RMLOdA2NU4O7w1PQ3Z9ft3PxD6Htl4uB2TJpocm+4jcllHySPkFaUIFacQ3Jekcg6w+LBaFvjSPthZHiPmiAUg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -606,8 +609,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-musl@14.2.13: - resolution: {integrity: sha512-v5jZ/FV/eHGoWhMKYrsAweQ7CWb8xsWGM/8m1mwwZQ/sutJjoFaXchwK4pX8NqwImILEvQmZWyb8pPTcP7htWg==} + /@next/swc-linux-arm64-musl@14.2.14: + resolution: {integrity: sha512-WgLOA4hT9EIP7jhlkPnvz49iSOMdZgDJVvbpb8WWzJv5wBD07M2wdJXLkDYIpZmCFfo/wPqFsFR4JS4V9KkQ2A==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -615,8 +618,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-gnu@14.2.13: - resolution: {integrity: sha512-aVc7m4YL7ViiRv7SOXK3RplXzOEe/qQzRA5R2vpXboHABs3w8vtFslGTz+5tKiQzWUmTmBNVW0UQdhkKRORmGA==} + /@next/swc-linux-x64-gnu@14.2.14: + resolution: {integrity: sha512-lbn7svjUps1kmCettV/R9oAvEW+eUI0lo0LJNFOXoQM5NGNxloAyFRNByYeZKL3+1bF5YE0h0irIJfzXBq9Y6w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -624,8 +627,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-musl@14.2.13: - resolution: {integrity: sha512-4wWY7/OsSaJOOKvMsu1Teylku7vKyTuocvDLTZQq0TYv9OjiYYWt63PiE1nTuZnqQ4RPvME7Xai+9enoiN0Wrg==} + /@next/swc-linux-x64-musl@14.2.14: + resolution: {integrity: sha512-7TcQCvLQ/hKfQRgjxMN4TZ2BRB0P7HwrGAYL+p+m3u3XcKTraUFerVbV3jkNZNwDeQDa8zdxkKkw2els/S5onQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -633,8 +636,8 @@ packages: dev: false optional: true - /@next/swc-win32-arm64-msvc@14.2.13: - resolution: {integrity: sha512-uP1XkqCqV2NVH9+g2sC7qIw+w2tRbcMiXFEbMihkQ8B1+V6m28sshBwAB0SDmOe0u44ne1vFU66+gx/28RsBVQ==} + /@next/swc-win32-arm64-msvc@14.2.14: + resolution: {integrity: sha512-8i0Ou5XjTLEje0oj0JiI0Xo9L/93ghFtAUYZ24jARSeTMXLUx8yFIdhS55mTExq5Tj4/dC2fJuaT4e3ySvXU1A==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -642,8 +645,8 @@ packages: dev: false optional: true - /@next/swc-win32-ia32-msvc@14.2.13: - resolution: {integrity: sha512-V26ezyjPqQpDBV4lcWIh8B/QICQ4v+M5Bo9ykLN+sqeKKBxJVDpEc6biDVyluTXTC40f5IqCU0ttth7Es2ZuMw==} + /@next/swc-win32-ia32-msvc@14.2.14: + resolution: {integrity: sha512-2u2XcSaDEOj+96eXpyjHjtVPLhkAFw2nlaz83EPeuK4obF+HmtDJHqgR1dZB7Gb6V/d55FL26/lYVd0TwMgcOQ==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -651,8 +654,8 @@ packages: dev: false optional: true - /@next/swc-win32-x64-msvc@14.2.13: - resolution: {integrity: sha512-WwzOEAFBGhlDHE5Z73mNU8CO8mqMNLqaG+AO9ETmzdCQlJhVtWZnOl2+rqgVQS+YHunjOWptdFmNfbpwcUuEsw==} + /@next/swc-win32-x64-msvc@14.2.14: + resolution: {integrity: sha512-MZom+OvZ1NZxuRovKt1ApevjiUJTcU2PmdJKL66xUPaJeRywnbGGRWUlaAOwunD6dX+pm83vj979NTC8QXjGWg==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -743,6 +746,29 @@ packages: react-dom: 18.3.1(react@18.3.1) dev: false + /@radix-ui/react-avatar@1.1.1(@types/react-dom@18.2.7)(@types/react@18.2.21)(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-eoOtThOmxeoizxpX6RiEsQZ2wj5r4+zoeqAwO0cBaFQGjJwIH3dIX0OCxNrCyrrdxG+vBweMETh3VziQG7c1kw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@radix-ui/react-context': 1.1.1(@types/react@18.2.21)(react@18.3.1) + '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.2.7)(@types/react@18.2.21)(react-dom@18.3.1)(react@18.3.1) + '@radix-ui/react-use-callback-ref': 1.1.0(@types/react@18.2.21)(react@18.3.1) + '@radix-ui/react-use-layout-effect': 1.1.0(@types/react@18.2.21)(react@18.3.1) + '@types/react': 18.2.21 + '@types/react-dom': 18.2.7 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + dev: false + /@radix-ui/react-collapsible@1.1.0(@types/react-dom@18.2.7)(@types/react@18.2.21)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-zQY7Epa8sTL0mq4ajSJpjgn2YmCgyrG7RsQgLp3C0LQVkG7+Tf6Pv1CeNWZLyqMjhdPkBa5Lx7wYBeSu7uCSTA==} peerDependencies: @@ -865,6 +891,19 @@ packages: react: 18.3.1 dev: false + /@radix-ui/react-context@1.1.1(@types/react@18.2.21)(react@18.3.1): + resolution: {integrity: sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@types/react': 18.2.21 + react: 18.3.1 + dev: false + /@radix-ui/react-dialog@1.0.0(@types/react@18.2.21)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-Yn9YU+QlHYLWwV1XfKiqnGVpWYWk6MeBVM6x/bcoyPvxgjQGoeT35482viLPctTMWoMw0PoHgqfSox7Ig+957Q==} peerDependencies: @@ -3985,8 +4024,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: false - /next-auth@5.0.0-beta.21(next@14.2.13)(react@18.3.1): - resolution: {integrity: sha512-VrT6LV9u/o5tMuWxRDN5d/K1OgPskrMHy+aITTwasVfIrkIaU/8UVg3TXH8ynJgzhfzlDx/3hLWGhi+eXQw4qg==} + /next-auth@5.0.0-beta.22(next@14.2.14)(react@18.3.1): + resolution: {integrity: sha512-QGBo9HGOjmnJBHGXvtFztl0tM5tL0porDlk74HVoCCzXd986ApOlIW3EmiCuho7YzEopgkFiwwmcXpoCrHAtYw==} peerDependencies: '@simplewebauthn/browser': ^9.0.1 '@simplewebauthn/server': ^9.0.2 @@ -4001,13 +4040,13 @@ packages: nodemailer: optional: true dependencies: - '@auth/core': 0.35.0 - next: 14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) + '@auth/core': 0.35.3 + next: 14.2.14(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) react: 18.3.1 dev: false - /next@14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-BseY9YNw8QJSwLYD7hlZzl6QVDoSFHL/URN5K64kVEVpCsSOWeyjbIGK+dZUaRViHTaMQX8aqmnn0PHBbGZezg==} + /next@14.2.14(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-Q1coZG17MW0Ly5x76shJ4dkC23woLAhhnDnw+DfTc7EpZSGuWrlsZ3bZaO8t6u1Yu8FVfhkqJE+U8GC7E0GLPQ==} engines: {node: '>=18.17.0'} hasBin: true peerDependencies: @@ -4024,7 +4063,7 @@ packages: sass: optional: true dependencies: - '@next/env': 14.2.13 + '@next/env': 14.2.14 '@swc/helpers': 0.5.5 busboy: 1.6.0 caniuse-lite: 1.0.30001620 @@ -4034,28 +4073,28 @@ packages: react-dom: 18.3.1(react@18.3.1) styled-jsx: 5.1.1(@babel/core@7.22.11)(react@18.3.1) optionalDependencies: - '@next/swc-darwin-arm64': 14.2.13 - '@next/swc-darwin-x64': 14.2.13 - '@next/swc-linux-arm64-gnu': 14.2.13 - '@next/swc-linux-arm64-musl': 14.2.13 - '@next/swc-linux-x64-gnu': 14.2.13 - '@next/swc-linux-x64-musl': 14.2.13 - '@next/swc-win32-arm64-msvc': 14.2.13 - '@next/swc-win32-ia32-msvc': 14.2.13 - '@next/swc-win32-x64-msvc': 14.2.13 + '@next/swc-darwin-arm64': 14.2.14 + '@next/swc-darwin-x64': 14.2.14 + '@next/swc-linux-arm64-gnu': 14.2.14 + '@next/swc-linux-arm64-musl': 14.2.14 + '@next/swc-linux-x64-gnu': 14.2.14 + '@next/swc-linux-x64-musl': 14.2.14 + '@next/swc-win32-arm64-msvc': 14.2.14 + '@next/swc-win32-ia32-msvc': 14.2.14 + '@next/swc-win32-x64-msvc': 14.2.14 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros dev: false - /nextjs-toploader@1.6.12(next@14.2.13)(react-dom@18.3.1)(react@18.3.1): + /nextjs-toploader@1.6.12(next@14.2.14)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-nbun5lvVjlKnxLQlahzZ55nELVEduqoEXT03KCHnsEYJnFpI/3BaIzpMyq/v8C7UGU2NfxQmjq6ldZ310rsDqA==} peerDependencies: next: '>= 6.0.0' react: '>= 16.0.0' react-dom: '>= 16.0.0' dependencies: - next: 14.2.13(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) + next: 14.2.14(@babel/core@7.22.11)(react-dom@18.3.1)(react@18.3.1) nprogress: 0.2.0 prop-types: 15.8.1 react: 18.3.1 diff --git a/src/app/(dashboard)/patients/[id]/components/patientInfo.tsx b/src/app/(dashboard)/patients/[id]/components/patientInfo.tsx index 682d05d..153cf9d 100644 --- a/src/app/(dashboard)/patients/[id]/components/patientInfo.tsx +++ b/src/app/(dashboard)/patients/[id]/components/patientInfo.tsx @@ -1,7 +1,20 @@ +import React from "react"; import HiddenText from "@/components/hidden.text"; +import { Button } from "@/components/ui/button"; import { Patient } from "@/lib/fhir/types"; import { CarePlanData } from "@/lib/models/types"; -import React from "react"; +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Card, CardContent } from "@/components/ui/card"; +import { Avatar, AvatarFallback } from "@/components/ui/avatar"; type Props = { patient: Patient; @@ -18,19 +31,67 @@ const PatientInfo = ({ patient, carePlan }: Props) => { {getAge(patient.birthDate)} years old
-
- {carePlan && ( -
- {carePlan.title && ( -

{carePlan.title}

- )} -
- )} - +
+
+ {carePlan && ( +
+ {carePlan.title && ( +

{carePlan.title}

+ )} +
+ )} + +
+
+ {patient.links.length > 0 && ( + + + + + + + Patient Links +
+ { +
    + {patient.links.map((link) => ( + + +
    + + + {link.initials} + + +
    +

    + {link.name} +

    +

    + {link.id} +

    +
    +
    +
    +
    + ))} +
+ } +
+
+
+
+ )} +
); diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx new file mode 100644 index 0000000..51e507b --- /dev/null +++ b/src/components/ui/avatar.tsx @@ -0,0 +1,50 @@ +"use client" + +import * as React from "react" +import * as AvatarPrimitive from "@radix-ui/react-avatar" + +import { cn } from "@/lib/utils" + +const Avatar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Avatar.displayName = AvatarPrimitive.Root.displayName + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarImage.displayName = AvatarPrimitive.Image.displayName + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName + +export { Avatar, AvatarImage, AvatarFallback } diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index 2f33766..69b2e62 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -1,22 +1,18 @@ -"use client" +"use client"; -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { X } from "lucide-react" +import * as React from "react"; +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { X } from "lucide-react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const Dialog = DialogPrimitive.Root +const Dialog = DialogPrimitive.Root; -const DialogTrigger = DialogPrimitive.Trigger +const DialogTrigger = DialogPrimitive.Trigger; -const DialogPortal = ({ - className, - ...props -}: DialogPrimitive.DialogPortalProps) => ( - -) -DialogPortal.displayName = DialogPrimitive.Portal.displayName +const DialogPortal = DialogPrimitive.Portal; + +const DialogClose = DialogPrimitive.Close; const DialogOverlay = React.forwardRef< React.ElementRef, @@ -25,13 +21,13 @@ const DialogOverlay = React.forwardRef< -)) -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName +)); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const DialogContent = React.forwardRef< React.ElementRef, @@ -42,7 +38,7 @@ const DialogContent = React.forwardRef< -)) -DialogContent.displayName = DialogPrimitive.Content.displayName +)); +DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({ className, @@ -68,8 +64,8 @@ const DialogHeader = ({ )} {...props} /> -) -DialogHeader.displayName = "DialogHeader" +); +DialogHeader.displayName = "DialogHeader"; const DialogFooter = ({ className, @@ -82,8 +78,8 @@ const DialogFooter = ({ )} {...props} /> -) -DialogFooter.displayName = "DialogFooter" +); +DialogFooter.displayName = "DialogFooter"; const DialogTitle = React.forwardRef< React.ElementRef, @@ -97,8 +93,8 @@ const DialogTitle = React.forwardRef< )} {...props} /> -)) -DialogTitle.displayName = DialogPrimitive.Title.displayName +)); +DialogTitle.displayName = DialogPrimitive.Title.displayName; const DialogDescription = React.forwardRef< React.ElementRef, @@ -109,15 +105,19 @@ const DialogDescription = React.forwardRef< className={cn("text-sm text-muted-foreground", className)} {...props} /> -)) -DialogDescription.displayName = DialogPrimitive.Description.displayName +)); +DialogDescription.displayName = DialogPrimitive.Description.displayName; export { Dialog, + DialogPortal, + DialogOverlay, + DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, -} +}; + diff --git a/src/lib/fhir/patient.ts b/src/lib/fhir/patient.ts index 72ff4c3..dc5d8e4 100644 --- a/src/lib/fhir/patient.ts +++ b/src/lib/fhir/patient.ts @@ -1,18 +1,35 @@ +import { fhirR4 } from "@smile-cdr/fhirts"; import { Patient } from "./types"; -export const createPatient = (data: any): Patient => { +export const createPatient = (data: fhirR4.Patient): Patient => { + const firstName = data.name?.[0]?.given?.[0] ?? ""; + const lastName = data?.name?.[0]?.family ?? ""; return { - id: data.id, + id: data.id ?? "NA", locationId: - data.meta.tag.find( + (data.meta?.tag ?? []).find( (e: any) => e.system === "http://smartregister.org/fhir/location-tag" )?.code ?? "NA", identifier: data.identifier?.[0]?.value ?? "NA", - name: data.name[0].given[0] + " " + data.name[0].family, - firstName: data.name[0].given[0], - lastName: data.name[0].family, - gender: data.gender, - birthDate: data.birthDate, + name: `${firstName} ${lastName}`, + firstName: firstName, + lastName: lastName, + gender: data.gender ?? "unknown", + birthDate: data.birthDate ?? "", + links: + (data.link ?? []).map((value) => { + const items = value.other.display?.split(",") ?? []; + const name = items[items.length > 3 ? 2 : 1] ?? "NA"; + const initials = name + .split(" ") + .map((e) => e[0]) + .join(""); + return { + id: items?.[0].trim() ?? "NA", + name: name, + initials: initials, + }; + }) ?? [], phoneNumbers: data.telecom?.map((value: any) => { var array = value.value?.split("|"); @@ -21,14 +38,14 @@ export const createPatient = (data: any): Patient => { owner: array[2], }; }) ?? [], - active: data.active, + active: data.active ?? true, address: data.address?.map((value: any) => ({ facility: value.district ?? "NA", physical: data.address?.[0]?.text ?? "NA", })) ?? [], registrationDate: - data.meta.tag.find( + (data?.meta?.tag ?? []).find( (e: any) => e.system === "https://d-tree.org/fhir/created-on-tag" )?.code ?? "NA", registratedBy: data.generalPractitioner?.[0]?.display ?? "NA", diff --git a/src/lib/fhir/types.ts b/src/lib/fhir/types.ts index 6fc0730..dee0154 100644 --- a/src/lib/fhir/types.ts +++ b/src/lib/fhir/types.ts @@ -15,4 +15,9 @@ export type Patient = { number: string, owner: string, }[], + links: { + name: string, + id: string, + initials: string; + }[] } \ No newline at end of file