Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add base for fhir forms #9262

Merged
merged 379 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
379 commits
Select commit Hold shift + click to select a range
c464e63
Clean up unused type references
bodhish Dec 15, 2024
c47a541
Merge branch 'cleanup-facility' into form-field-v1
bodhish Dec 15, 2024
d2a6e12
Appointments flow: adjustments
Jacobjeevan Dec 15, 2024
6c8cd61
Switch to QR code for Appointment Card; Add care logo
rithviknishad Dec 15, 2024
6fa3520
hide things not planned for now and remove redundant fields
rithviknishad Dec 15, 2024
9da93aa
Add viewer for symptoms and diagnosis
bodhish Dec 15, 2024
cfa055d
minor fixes/styling changes
Jacobjeevan Dec 15, 2024
20cc9b2
Merge branch 'form-field-v1' into rithviknishad/feat/scheduling
rithviknishad Dec 15, 2024
f775e6f
Cleanup Questionnaire Renderers
gigincg Dec 15, 2024
e82126c
Add list for allergy
bodhish Dec 15, 2024
2c57ce9
Integrate Schedule APIs
rithviknishad Dec 15, 2024
c9726a9
slots for a day; partial.
rithviknishad Dec 15, 2024
9624078
Merge branch 'rithviknishad/feat/scheduling' into form-field-v1
rithviknishad Dec 15, 2024
0a7a133
landing flow; some more updates
Jacobjeevan Dec 15, 2024
fcd9ac2
form error fix
Jacobjeevan Dec 15, 2024
d4b94c2
appointment create APIs
rithviknishad Dec 15, 2024
1b60519
Add support for styling
bodhish Dec 15, 2024
1a82817
Rebuild landing page
bodhish Dec 15, 2024
754a479
appointment token; and other fixes
rithviknishad Dec 15, 2024
40dc5b0
appointments list page
rithviknishad Dec 15, 2024
062dd94
Add phone number login
bodhish Dec 15, 2024
e5a2a28
landing flow: fix errors, adjust to match api changes
Jacobjeevan Dec 16, 2024
44405be
Lets show all users in the facility homepage
bodhish Dec 16, 2024
1e0eb39
More styling changes
Jacobjeevan Dec 16, 2024
dd12b34
Disable error message for 404
bodhish Dec 16, 2024
86e58a7
Fix overflow
bodhish Dec 16, 2024
402aa2c
scheduling: gracefully handle no home facility linked
rithviknishad Dec 16, 2024
2401e2f
OTP access token in createAppointment call; minor styling changes
Jacobjeevan Dec 16, 2024
19e035e
Merge remote-tracking branch 'origin' into form-field-v1
rithviknishad Dec 17, 2024
d5bfef9
OTP flow/API fixes
Jacobjeevan Dec 17, 2024
abfbc61
fix scroll in appointments page
rithviknishad Dec 17, 2024
4f2cbf4
Support Questionnaire with Encounter Creation
gigincg Dec 17, 2024
9f3637b
Removed/cleaned up mock data; switched to using tanstack, translation…
Jacobjeevan Dec 17, 2024
9833569
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
Jacobjeevan Dec 17, 2024
547edd4
Changes to Public Appointment
bodhish Dec 17, 2024
bcf1970
Add udpates tab in patients
bodhish Dec 17, 2024
47ee165
Support Patient Questionnaires
gigincg Dec 17, 2024
5dea3a9
Add filter for patient forms
bodhish Dec 17, 2024
e23cff7
Fix Patient Link for Volunteer
gigincg Dec 17, 2024
04cb300
Update QuestionnaireForm
bodhish Dec 17, 2024
770f991
Hide logs in prod
bodhish Dec 17, 2024
04d3ea7
Remove linkId from questions
bodhish Dec 17, 2024
ee3b941
Use encounterId as resourceId when available
gigincg Dec 17, 2024
912ee9a
Add support for custom logo in landing page
bodhish Dec 17, 2024
ed2d5e3
Update package lock
bodhish Dec 17, 2024
f9d7fbd
Reduce height for the logo
bodhish Dec 17, 2024
cdb3558
Enhance logo handling in Login and LandingPage components.
bodhish Dec 17, 2024
5d3c719
Fix logos in login page
bodhish Dec 18, 2024
ba16ea2
Hide occupancy
bodhish Dec 18, 2024
6691441
Add Appointments Tab
gigincg Dec 18, 2024
1a21311
minor: paste support for OTP, skip verification for valid token with …
Jacobjeevan Dec 19, 2024
b0ecc62
debounce valueset searches; correct wordings and scroll issues; depre…
rithviknishad Dec 20, 2024
f12a27e
medication request enhancement
rithviknishad Dec 20, 2024
6a859c8
WIP: OTPPatient Router, switch otp to react form etc
Jacobjeevan Dec 20, 2024
6a41e31
Replace consultation form
bodhish Dec 20, 2024
2a2c09b
appointments misc. cleanups
rithviknishad Dec 20, 2024
3e926ab
integrate schedule exceptions API
rithviknishad Dec 20, 2024
16f1331
Clean up encounter form
bodhish Dec 21, 2024
b50cbcf
Add encounter route
bodhish Dec 21, 2024
b79daaf
WIP v2: OTP appointments flow
Jacobjeevan Dec 21, 2024
7f6fe60
minor tweaks
Jacobjeevan Dec 21, 2024
d29b13c
Hide options when encounter class is not selected
bodhish Dec 21, 2024
bf6330a
fix issues with schedule exceptions listing and deletes
rithviknishad Dec 21, 2024
1b118f7
added patient switcher support
Jacobjeevan Dec 21, 2024
457da44
Rename resource request to request #9525
bodhish Dec 21, 2024
ef30f7a
Appointments: switch to card, styling, clean up
Jacobjeevan Dec 21, 2024
25b3aec
Rename resource request to request #9525
bodhish Dec 21, 2024
2582637
WIP: OTP Appointments flow
Jacobjeevan Dec 21, 2024
e2d02b6
Cleanup unsed assets
bodhish Dec 22, 2024
5b83a6e
appointments: fix issue with timezone; board height when empty; i18n
rithviknishad Dec 22, 2024
e3c8571
appointments: availability heatmap, slots group by name, and other im…
rithviknishad Dec 22, 2024
595450d
fix UserSpec's avatar url attribute key, cleanup appointment routes, …
rithviknishad Dec 22, 2024
dbba8da
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
Jacobjeevan Dec 23, 2024
698befa
appointments: sort slots and slot groups by their start time
rithviknishad Dec 23, 2024
26dc260
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
Jacobjeevan Dec 23, 2024
e0c8889
appointments: cleanup routes; fix born undefined issue; wip: show det…
rithviknishad Dec 23, 2024
47b21d1
wip: minor fixes, additions
Jacobjeevan Dec 23, 2024
46bf5ed
Add a description field to facility
bodhish Dec 23, 2024
f5411d8
Add NGO and CBO to Facility Type; Fixes #9529
rithviknishad Dec 24, 2024
22eee90
Appointments: (WIP) filter by slots
rithviknishad Dec 24, 2024
67b6d03
medication request: add site
rithviknishad Dec 24, 2024
9bbaed4
minor fixes: otp flow
Jacobjeevan Dec 24, 2024
2203a25
appointments filters and kill switch; wip; checkpoint before deleting…
rithviknishad Dec 24, 2024
35e0725
New Patient Search and Register UI (#9400)
shivankacker Dec 24, 2024
d2c94a0
Styles fixes
bodhish Dec 24, 2024
b6103b1
Resource form adjustments; translations
Jacobjeevan Dec 24, 2024
572cdae
scheduling: remove `resource_type` as per recent API changes
rithviknishad Dec 24, 2024
a370cfe
Fix filters
bodhish Dec 24, 2024
7bf3bca
Add organisation page
bodhish Dec 25, 2024
421bfa2
fix icon usage causing build to fail
rithviknishad Dec 25, 2024
cc737e4
Clena up org
bodhish Dec 25, 2024
52956f5
Add a OrganisationSelector
bodhish Dec 25, 2024
2acd106
Appointments: Save token as image
rithviknishad Dec 25, 2024
6a56d9b
Org Selector for Patient Registration
gigincg Dec 25, 2024
fb5407e
Appointments: Support for changing status
rithviknishad Dec 25, 2024
b196362
Add geo_org to Request
gigincg Dec 25, 2024
8ca7a57
fix edge case showing 0 hours for slot duration, improve action butto…
rithviknishad Dec 25, 2024
157e523
Change type for organisation
bodhish Dec 25, 2024
664b217
appointments: wire filter by practicioner, date, search, improved slo…
rithviknishad Dec 25, 2024
9a28652
fix schedule appointment link and scrollable section for too many slo…
rithviknishad Dec 25, 2024
1f5cd90
Style organisation selector
bodhish Dec 25, 2024
9d1fc9a
List parents in org
bodhish Dec 25, 2024
03a5ca0
Remove create org button
bodhish Dec 25, 2024
bf64f6f
Fix export button styling on shifting and resource page and facility …
shivankacker Dec 25, 2024
9295643
Add support to add and remove organisation roles
bodhish Dec 25, 2024
2594908
schedule: prevent creation of schedules without weekdays or sessions
rithviknishad Dec 26, 2024
4517cf0
Add support DateTime in Questionnaire
gigincg Dec 26, 2024
9b7f390
Clean up
bodhish Dec 25, 2024
3b746f4
Add org form to otp flow
bodhish Dec 26, 2024
46e9ef3
Appointments list view
Jacobjeevan Dec 26, 2024
57f7c0e
Patient registration form: react hook forms, and minor tweaks
Jacobjeevan Dec 26, 2024
4dcd431
Added medication statement question (#9528)
khavinshankar Dec 27, 2024
e042651
Clean up facility create and remove kasp
bodhish Dec 27, 2024
79afe4e
otp patient registration: switching backing to dateformfield
Jacobjeevan Dec 27, 2024
c297b92
file renaming and some tweaks
Jacobjeevan Dec 27, 2024
e4a9060
minor fixes/tweaks
Jacobjeevan Dec 27, 2024
317e792
more tweaks, renaming, added dialog for patient appointments
Jacobjeevan Dec 27, 2024
b075970
Add observation plots
bodhish Dec 27, 2024
96cd29e
Clean up patient create
bodhish Dec 27, 2024
85a80bc
Replace sidebar
bodhish Dec 27, 2024
eb249fd
Wire new api for encounter
bodhish Dec 28, 2024
92202c5
configurable plots
rithviknishad Dec 28, 2024
27a064c
Add an option to verify
bodhish Dec 28, 2024
55636a6
Merge branch 'form-field-v1' into rithviknishad/plots
rithviknishad Dec 28, 2024
37757af
Merge branch 'rithviknishad/plots' into form-field-v1
rithviknishad Dec 28, 2024
3e89df5
Clean up patient transfer
bodhish Dec 28, 2024
38e0dfa
Fix sidebar logic
bodhish Dec 28, 2024
95a5107
add plots: abg, resp support, nutrition, dialysis
rithviknishad Dec 28, 2024
c01598d
remove invesgtigations and dialysis tab
rithviknishad Dec 28, 2024
bb745c2
fixed facility sidebar redirection
nihal467 Dec 28, 2024
896d6b5
fixed facility sidebar redirection
nihal467 Dec 28, 2024
ffa11d4
Merge branch 'form-field-v1' of https://github.com/ohcnetwork/care_fe…
nihal467 Dec 28, 2024
988570c
Remove setSelectedFacility prop from FacilitySwitcher in AppSidebar c…
rithviknishad Dec 28, 2024
4e53924
Add new encounter page
bodhish Dec 28, 2024
45483b6
fix encounter not getting created
rithviknishad Dec 28, 2024
8236465
remove unused files
rithviknishad Dec 28, 2024
531abb2
fix profile redirect not working from sidebar
rithviknishad Dec 28, 2024
efbbe48
Wire active encounters in verify page
bodhish Dec 28, 2024
894bfb6
fix asset route
rithviknishad Dec 28, 2024
11e9d0a
WIP: new sidebar integration for patient
Jacobjeevan Dec 28, 2024
b744ce4
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
rithviknishad Dec 28, 2024
dd98155
fix facility view patients
rithviknishad Dec 28, 2024
3c869f4
Add encounter create page
bodhish Dec 28, 2024
adbab3c
add tabs to encounter show
rithviknishad Dec 28, 2024
bb0d545
fix nav link
rithviknishad Dec 28, 2024
25426fe
Add facility organisation page
bodhish Dec 28, 2024
5980ee1
fix things in updates
rithviknishad Dec 28, 2024
5dd612c
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
rithviknishad Dec 28, 2024
7cd29ca
Update url for encounter
bodhish Dec 28, 2024
3b19fde
sidebar and router tweaks
Jacobjeevan Dec 28, 2024
0dedb10
nav mobile adjustments
Jacobjeevan Dec 28, 2024
bd2a3bc
Add organisation create
bodhish Dec 28, 2024
e923e43
Change api for facility users
bodhish Dec 28, 2024
a6c11e1
Fix file uplaods
bodhish Dec 28, 2024
7d01e4e
Fix encounter form buttons
bodhish Dec 28, 2024
fcc808f
Wire encounterId to encounter question
bodhish Dec 28, 2024
cfcdfc8
Add encounter update form to form builder
bodhish Dec 28, 2024
8a8ba38
Add status history to encounterQgst
bodhish Dec 28, 2024
ca75575
Render encounter form in encounter update tab
bodhish Dec 28, 2024
213777b
fixed selection issue in the autocomplete popover
khavinshankar Dec 29, 2024
27f663f
Update the query key for cache invalidation
bodhish Dec 29, 2024
3cdbfad
Add encounters page
bodhish Dec 29, 2024
b40a676
Add facility switcher
bodhish Dec 29, 2024
bb81159
Hide border color in sidebar
bodhish Dec 29, 2024
147fb3e
Rebuild sidebar to suport org switching
bodhish Dec 29, 2024
cc7b3f7
Clean up patient search page
bodhish Dec 29, 2024
8ad3e86
Style fixes for title
bodhish Dec 29, 2024
9b8e634
Improve styles for verify patient page
bodhish Dec 29, 2024
b21c5ed
Update redirect in patient create
bodhish Dec 29, 2024
44e1a97
Clean up api request for loading question responses
bodhish Dec 29, 2024
a7b76e9
Remove sidebar close trigger
bodhish Dec 29, 2024
91eb525
Clean up patients
bodhish Dec 29, 2024
27b1a4b
encounter files
Jacobjeevan Dec 29, 2024
1f11a16
Add discharged status to encounter list
bodhish Dec 29, 2024
d903755
Add option to link organization to encounter
bodhish Dec 29, 2024
67635f7
Add option to add and remove oganizations from encounter
bodhish Dec 29, 2024
4fd5c2b
Hide more routes
bodhish Dec 29, 2024
1d014dd
Clean up facility index
bodhish Dec 29, 2024
1552609
Update types for resource request
bodhish Dec 29, 2024
e9385c1
add missing package and fixed type error
rithviknishad Dec 30, 2024
23eb6e9
Revert "add missing package and fixed type error"
rithviknishad Dec 30, 2024
51957a7
Wired the components in Consultation Medication Tab with latest FHIR …
khavinshankar Dec 30, 2024
f23241e
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
rithviknishad Dec 30, 2024
216730e
update dob fields
rithviknishad Dec 30, 2024
65ea0c5
add sign out button in user dashboard
rithviknishad Dec 30, 2024
f6e58ef
file styling tweaks
Jacobjeevan Dec 30, 2024
fc5599b
remove old sidebar
rithviknishad Dec 30, 2024
5cfd511
fix imports
rithviknishad Dec 30, 2024
7fb179c
hide neuro, pressure sore and nursing
rithviknishad Dec 30, 2024
00b1e8a
switch to sonner for notifications
rithviknishad Dec 30, 2024
f636e93
updated the type of medication_request's dosage_instruction
khavinshankar Dec 30, 2024
d66c8db
Wire patient user apis
bodhish Dec 30, 2024
5bf7d38
Add phonenumber to patient users
bodhish Dec 30, 2024
6da2d4f
use sonner notification
rithviknishad Dec 30, 2024
9c1e72c
missing translation in encounter
nihal467 Dec 30, 2024
7ad89a4
Merge branch 'form-field-v1' of https://github.com/ohcnetwork/care_fe…
nihal467 Dec 30, 2024
322953d
Let users create facilites
bodhish Dec 30, 2024
0f1c906
Add facility list
bodhish Dec 30, 2024
82c434a
fix click issue in user sheet
rithviknishad Dec 30, 2024
1602e79
Added more priority options in the encounters tab dropdown
nihal467 Dec 30, 2024
c7a2167
Merge branch 'form-field-v1' of https://github.com/ohcnetwork/care_fe…
nihal467 Dec 30, 2024
266507a
update lockfile
rithviknishad Dec 30, 2024
aae2eca
Change user type
bodhish Dec 30, 2024
f5445bd
Update package lock
bodhish Dec 30, 2024
5e30050
Use outline variant (#9611)
yash-learner Dec 30, 2024
7592bcd
Add Facility Type
gigincg Dec 30, 2024
3eceb3a
Change user type in add users
bodhish Dec 30, 2024
d9e7d79
use `UserSelect`
rithviknishad Dec 30, 2024
5187082
Facility create: switch to react hook form, mobile styling
Jacobjeevan Dec 30, 2024
ea06ea4
schedule no longer requires home facility
rithviknishad Dec 30, 2024
2567f4d
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
rithviknishad Dec 30, 2024
c1a17ae
make UserSelector handle data fetching
rithviknishad Dec 30, 2024
4b9d333
uninstall pnotify
rithviknishad Dec 30, 2024
3d59158
Contains Hacks; User Types
gigincg Dec 30, 2024
59728cc
Add user selector to link user sheet
rithviknishad Dec 30, 2024
3f2d28f
Add organization patient page
bodhish Dec 30, 2024
a38cda0
fix search filter in user selector
rithviknishad Dec 30, 2024
090cff9
Make encounter responsive on mobile (#9614)
yash-learner Dec 30, 2024
0dd1b2d
add missing translation for class history
nihal467 Dec 30, 2024
0356c13
choice question: handle repeats
rithviknishad Dec 30, 2024
b8bdfa5
fixed medication statement creation and improved the list table with …
khavinshankar Dec 30, 2024
aa5de89
Create Add Edit Form
gigincg Dec 30, 2024
62b60b4
Add facility pages for organisation
bodhish Dec 30, 2024
0a48b25
scheduleable users
Jacobjeevan Dec 30, 2024
3fa6e45
scheduleable user
Jacobjeevan Dec 30, 2024
402f965
Merge branch 'develop' into form-field-v1
rithviknishad Dec 30, 2024
40b7faf
Merge branch 'form-field-v1' of github.com:ohcnetwork/care_fe into fo…
rithviknishad Dec 30, 2024
e324cf6
fix build failures
rithviknishad Dec 30, 2024
e840ff2
Refactor facility routes and update cover image handling
bodhish Dec 30, 2024
a237805
Update lock
bodhish Dec 30, 2024
ac52bfe
Add Facility Form
gigincg Dec 30, 2024
65574a7
switching to userbase for user list and user detail; rrm useraddEditform
Jacobjeevan Dec 30, 2024
035d294
undo createuserform changes
Jacobjeevan Dec 30, 2024
d672cad
seamlessly open link user post add user
rithviknishad Dec 30, 2024
d5856fd
add create user for facility org; open link user post create
rithviknishad Dec 30, 2024
e11b6a6
blood group unknown and patient age registration fix
Jacobjeevan Dec 30, 2024
f5d654b
Refactor OrganizationFacilities component layout and add Note type de…
bodhish Dec 30, 2024
f2916b3
Create a new facility show page
bodhish Dec 30, 2024
872d667
Reduce height for cards in facility page
bodhish Dec 30, 2024
293e715
Refactor FacilityHome component layout by replacing Page with a div a…
bodhish Dec 30, 2024
534df8c
Clean up types
bodhish Dec 30, 2024
ad84046
Add search and pagination to organization
bodhish Dec 30, 2024
8abffc9
Enhance sidebar navigation and improve FacilityOrganizationView with …
bodhish Dec 30, 2024
8ac481f
fix profile pic not shown in link user to org
rithviknishad Dec 31, 2024
4f1b74b
add profile pic to missing avatar components
rithviknishad Dec 31, 2024
f012942
fix signout and auth state management
rithviknishad Dec 31, 2024
587e5ca
landing page and facilities listing
Jacobjeevan Dec 31, 2024
e23edce
Remove weekly working hours and video connect link fields from Create…
bodhish Dec 31, 2024
b20e167
make users page responsive
rithviknishad Dec 31, 2024
ea19afa
fix login redirect for app router
rithviknishad Dec 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ General Guidelines

- Care uses a custom useQuery hook to fetch data from the API. (Docs @ /Utils/request/useQuery)
- APIs are defined in the api.tsx file.
- Use raviger for routing.
- Use care icons for icons.
4,451 changes: 307 additions & 4,144 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@
"@pnotify/mobile": "^5.2.0",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Warning: Cannot remove @radix-ui/react-icons as it's actively used

The package is currently imported in multiple UI components:

  • src/components/ui/select.tsx (CheckIcon, ChevronDownIcon, ChevronUpIcon)
  • src/components/ui/dialog.tsx (Cross2Icon)
  • src/components/ui/command.tsx (MagnifyingGlassIcon)
  • src/components/ui/toast.tsx (Cross2Icon)
  • src/components/ui/dropdown-menu.tsx

Removing this package will break these components. Either keep the dependency or replace these icon imports with alternatives before removal.

🔗 Analysis chain

Verify icon usage after removing @radix-ui/react-icons

The removal of @radix-ui/react-icons might impact existing icon usage in the codebase. Let's verify there are no remaining dependencies on this package.

Also applies to: 67-67, 69-69

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of @radix-ui/react-icons
rg "@radix-ui/react-icons" --type ts --type tsx

Length of output: 75


Script:

#!/bin/bash
# Search for any remaining usage of @radix-ui/react-icons with correct file extensions
rg "@radix-ui/react-icons" -t js -t jsx -t ts

Length of output: 73


Script:

#!/bin/bash
# Search for any remaining usage of @radix-ui/react-icons without file type restrictions
rg "@radix-ui/react-icons"

Length of output: 1567

"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-scroll-area": "^1.2.0",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-tooltip": "^1.1.4",
"@sentry/browser": "^8.42.0",
Expand Down
7 changes: 7 additions & 0 deletions src/Routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import SampleRoutes from "@/Routers/routes/SampleRoutes";
import ShiftingRoutes from "@/Routers/routes/ShiftingRoutes";
import UserRoutes from "@/Routers/routes/UserRoutes";

import { QuestionnaireList } from "../components/Questionnaire";
import { QuestionnaireShow } from "../components/Questionnaire/show";

export type RouteParams<T extends string> =
T extends `${string}:${infer Param}/${infer Rest}`
? { [K in Param | keyof RouteParams<Rest>]: string }
Expand Down Expand Up @@ -64,6 +67,10 @@ const Routes: AppRoutes = {

// Only include the icon route in development environment
...(import.meta.env.PROD ? { "/icons": () => <IconIndex /> } : {}),

// Questionnaire Routes
"/questionnaire": () => <QuestionnaireList />,
"/questionnaire/:id": ({ id }) => <QuestionnaireShow id={id} />,
};

export default function AppRouter() {
Expand Down
18 changes: 18 additions & 0 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ManagePrescriptions from "@/components/Medicine/ManagePrescriptions";
import PrescriptionsPrintPreview from "@/components/Medicine/PrintPreview";
import { DailyRoundListDetails } from "@/components/Patient/DailyRoundListDetails";
import { DailyRounds } from "@/components/Patient/DailyRounds";
import EncounterQuestionnaire from "@/components/Patient/EncounterQuestionnaire";
import FileUploadPage from "@/components/Patient/FileUploadPage";
import PatientConsentRecords from "@/components/Patient/PatientConsentRecords";

Expand Down Expand Up @@ -159,6 +160,23 @@ const consultationRoutes: AppRoutes = {
consultationId={consultationId}
/>
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/questionnaire":
({ facilityId, patientId, consultationId }) => (
<EncounterQuestionnaire
facilityId={facilityId}
patientId={patientId}
consultationId={consultationId}
/>
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/questionnaire/:slug":
({ facilityId, patientId, consultationId, slug }) => (
<EncounterQuestionnaire
facilityId={facilityId}
patientId={patientId}
consultationId={consultationId}
questionnaireSlug={slug}
/>
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/:tab":
({ facilityId, patientId, consultationId, tab }) => (
<ConsultationDetails
Expand Down
76 changes: 76 additions & 0 deletions src/Utils/request/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ import {
} from "@/components/Users/models";

import { PaginatedResponse } from "@/Utils/request/types";
import {
BatchRequestBody,
BatchSubmissionResult,
} from "@/types/questionnaire/batch";
import type {
QuestionnaireDetail,
QuestionnaireResponse,
} from "@/types/questionnaire/questionnaire";

/**
* A fake function that returns an empty object casted to type T
Expand Down Expand Up @@ -1399,6 +1407,74 @@ const routes = {
},
},
},

// Questionnaire Routes
questionnaire: {
list: {
path: "/api/v1/questionnaire/",
method: "GET",
TRes: Type<PaginatedResponse<QuestionnaireDetail>>(),
},

detail: {
path: "/api/v1/questionnaire/{id}/",
method: "GET",
TRes: Type<QuestionnaireDetail>(),
},

create: {
path: "/api/v1/questionnaire/",
method: "POST",
TRes: Type<QuestionnaireDetail>(),
TBody: Type<Partial<QuestionnaireDetail>>(),
},

update: {
path: "/api/v1/questionnaire/{id}/",
method: "PUT",
TRes: Type<QuestionnaireDetail>(),
TBody: Type<QuestionnaireDetail>(),
},

partialUpdate: {
path: "/api/v1/questionnaire/{id}/",
method: "PATCH",
TRes: Type<QuestionnaireDetail>(),
TBody: Type<Partial<QuestionnaireDetail>>(),
},

delete: {
path: "/api/v1/questionnaire/{id}/",
method: "DELETE",
TRes: Type<Record<string, never>>(),
},

submit: {
path: "/api/v1/questionnaire/{id}/submit/",
method: "POST",
TRes: Type<Record<string, never>>(),
TBody: Type<{
resource_id: string;
encounter: string;
responses: Array<{
question_id: string;
value: string | number | boolean;
note?: string;
bodysite?: string;
method?: string;
}>;
}>(),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Add validation for questionnaire response values

The questionnaire.submit endpoint accepts complex response data without explicit validation. To ensure data integrity and prevent potential errors, consider adding runtime validation for the request body. This includes:

  • Ensuring required fields (resource_id, encounter, and responses) are present.
  • Validating that responses array contains items with correct types for question_id and value.
  • Confirming that optional fields (note, bodysite, method) are properly typed when present.

Would you like assistance in implementing validation using a library like zod or yup?

As a follow-up, you can verify the presence of validation by searching the codebase:

#!/bin/bash
# Description: Search for validation in the questionnaire submission process.

# Check for validation schemas or functions related to questionnaire submission.
rg -g '*.{ts,tsx}' -A 5 'questionnaire.*validate|questionnaire.*schema|questionnaire.*validation'

},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Based on the searches performed, I can now generate the final response since we've thoroughly checked for:

  1. Existing validation code for questionnaire responses
  2. Validation schemas in the questionnaire types directory
  3. Response handling in components

The lack of results from these searches indicates there's no existing validation for questionnaire responses, confirming the review comment's concern.

Add validation for questionnaire response values

The questionnaire submit endpoint accepts complex response data without any validation. Add runtime validation to ensure:

  • Required fields are present
  • Response values match their expected types (string/number/boolean)
  • Optional fields (note, bodysite, method) are properly typed when present

Example locations that need validation:

  • src/types/questionnaire/form.ts: Add Zod/Yup schema for response validation
  • src/components/Questionnaire/QuestionnaireForm.tsx: Implement validation before submission
🔗 Analysis chain

Consider adding validation for questionnaire responses

The submit endpoint accepts complex response data but doesn't specify validation requirements in the type definition.

Consider adding:

  1. Response validation using Zod/Yup schemas
  2. Type guards for response values since they can be string/number/boolean
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if validation types/schemas exist for questionnaire responses
rg -g '*.{ts,tsx}' -A 5 'questionnaire.*validation|questionnaire.*schema|questionnaire.*validate'

Length of output: 99


Script:

#!/bin/bash
# Let's check for any validation related code in the codebase, particularly around questionnaires
rg -g '*.{ts,tsx}' -B 2 -A 5 'interface.*Questionnaire|type.*Questionnaire'

# Also search for any validation utilities or schemas in the codebase
rg -g '*.{ts,tsx}' -B 2 -A 5 'zod|yup|validate|schema'

# Let's also check how questionnaire responses are handled
ast-grep --pattern 'function $FUNC($$$) {
  $$$
  questionnaire$$$submit($$$)
  $$$
}'

Length of output: 66387


Script:

#!/bin/bash
# Let's check for any validation related code specifically for questionnaire responses
rg -g '*.{ts,tsx}' -B 2 -A 5 'QuestionnaireResponse.*validate|QuestionnaireResponse.*schema'

# Let's also check the types/questionnaire directory for any validation related code
rg -g '*.{ts,tsx}' -B 2 -A 5 'validate|schema' src/types/questionnaire/

# Let's look at how questionnaire responses are handled in the form component
ast-grep --pattern 'function $FUNC($$$) {
  $$$
  responses: QuestionnaireResponse$$$
  $$$
}'

Length of output: 265


batchRequest: {
path: "/api/v1/batch_requests/",
method: "POST",
TRes: Type<{
results: BatchSubmissionResult[];
}>(),
TBody: Type<BatchRequestBody>(),
},
} as const;

export default routes;
2 changes: 1 addition & 1 deletion src/Utils/request/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default async function request<TData, TBody>(
result = {
res,
data: res.ok ? data : undefined,
error: res.ok ? undefined : (data as Record<string, unknown>),
error: res.ok ? undefined : (data as Record<any, unknown>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid using 'any' type for error records

The change from Record<string, unknown> to Record<any, unknown> weakens TypeScript's type safety. Consider using a more specific type or maintaining the original string key type.

-        error: res.ok ? undefined : (data as Record<any, unknown>),
+        error: res.ok ? undefined : (data as Record<string, unknown>),

If specific non-string keys are needed, consider creating a union type of allowed key types:

type ErrorKey = string | number;
// Then use: Record<ErrorKey, unknown>

};

onResponse?.(result);
Expand Down
20 changes: 7 additions & 13 deletions src/components/Common/SearchByMultipleFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ interface SearchByMultipleFieldsProps {
clearSearch?: { value: boolean; params?: string[] };
}

type EventType = {
value: string;
target?: { value: string };
};
type EventType = React.ChangeEvent<HTMLInputElement> | { value: string };

const SearchByMultipleFields: React.FC<SearchByMultipleFieldsProps> = ({
id,
Expand Down Expand Up @@ -161,24 +158,21 @@ const SearchByMultipleFields: React.FC<SearchByMultipleFieldsProps> = ({
return () => clearTimeout(timeout);
}, [searchValue]);

const handleSearchChange = useCallback(
(value: string) => {
setSearchValue(value);
},
[selectedOption, onSearch],
);
const handleSearchChange = useCallback((event: EventType) => {
const value = "target" in event ? event.target.value : event.value;
setSearchValue(value);
}, []);

const renderSearchInput = useMemo(() => {
const commonProps = {
ref: inputRef,
value: searchValue,
onChange: (e: EventType) =>
handleSearchChange(e.target ? e.target.value : e.value),
onChange: handleSearchChange,
className: cn(
"flex-grow border-none shadow-none focus-visible:ring-0 h-10",
inputClassName,
),
};
} as const;

switch (selectedOption.type) {
case "phone":
Expand Down
82 changes: 82 additions & 0 deletions src/components/Patient/EncounterQuestionnaire.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Card, CardContent } from "@/components/ui/card";

import Loading from "@/components/Common/Loading";
import Page from "@/components/Common/Page";
import { QuestionnaireForm } from "@/components/Questionnaire/QuestionnaireForm";

import routes from "@/Utils/request/api";
import useQuery from "@/Utils/request/useQuery";

interface Props {
facilityId: string;
patientId: string;
consultationId: string;
questionnaireSlug?: string;
}

export default function EncounterQuestionnaire({
facilityId,
patientId,
consultationId,
questionnaireSlug,
}: Props) {
const {
data: consultation,
loading,
error,
} = useQuery(routes.getConsultation, {
pathParams: { id: consultationId },
});

const { data: patient } = useQuery(routes.getPatient, {
pathParams: { id: patientId },
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for patient data fetch

While the consultation fetch has error handling, the patient fetch doesn't handle errors which could lead to runtime errors when accessing patient?.facility_object?.name or patient?.name.

-  const { data: patient } = useQuery(routes.getPatient, {
+  const { data: patient, error: patientError } = useQuery(routes.getPatient, {
     pathParams: { id: patientId },
   });

+  if (patientError) {
+    return (
+      <Alert variant="destructive">
+        <AlertTitle>Error</AlertTitle>
+        <AlertDescription>
+          Failed to load patient details. Please try again later.
+        </AlertDescription>
+      </Alert>
+    );
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { data: patient } = useQuery(routes.getPatient, {
pathParams: { id: patientId },
});
const { data: patient, error: patientError } = useQuery(routes.getPatient, {
pathParams: { id: patientId },
});
if (patientError) {
return (
<Alert variant="destructive">
<AlertTitle>Error</AlertTitle>
<AlertDescription>
Failed to load patient details. Please try again later.
</AlertDescription>
</Alert>
);
}


if (loading) {
return <Loading />;
}

if (error) {
return (
<Alert variant="destructive">
<AlertTitle>Error</AlertTitle>
<AlertDescription>
Failed to load consultation details. Please try again later.
</AlertDescription>
</Alert>
);
}

return (
<Page
title="Questionnaire"
crumbsReplacements={{
[facilityId]: { name: patient?.facility_object?.name },
[patientId]: { name: patient?.name },
consultation: {
name: "Consultation",
uri: `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`,
},
[consultationId]: {
name: consultation?.encounter_date
? `Admitted on ${consultation.encounter_date}`
: consultation?.suggestion_text,
},
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add fallback text for missing facility/patient names

The crumbs replacement logic should handle cases where facility or patient names are undefined.

   crumbsReplacements={{
     [facilityId]: { name: patient?.facility_object?.name },
     [patientId]: { name: patient?.name },
     consultation: {
       name: "Consultation",
       uri: `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`,
     },
     [consultationId]: {
-      name: consultation?.encounter_date
-        ? `Admitted on ${consultation.encounter_date}`
-        : consultation?.suggestion_text,
+      name: consultation?.encounter_date
+        ? `Admitted on ${consultation.encounter_date}`
+        : consultation?.suggestion_text ?? 'Consultation Details',
     },
   }}

Committable suggestion skipped: line range outside the PR's diff.

backUrl={`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`}
>
<div className="container mx-auto p-4">
<Card>
<CardContent className="pt-6">
<QuestionnaireForm
resourceId={patientId}
encounterId={consultationId}
questionnaireSlug={questionnaireSlug}
/>
</CardContent>
</Card>
</div>
</Page>
);
}
72 changes: 72 additions & 0 deletions src/components/Questionnaire/QuestionRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useEffect, useRef } from "react";

import { QuestionValidationError } from "@/types/questionnaire/batch";
import { QuestionnaireResponse } from "@/types/questionnaire/form";
import { Question } from "@/types/questionnaire/question";

import { QuestionGroup } from "./QuestionTypes/QuestionGroup";

interface QuestionRendererProps {
questions: Question[];
responses: QuestionnaireResponse[];
onResponseChange: (responses: QuestionnaireResponse[]) => void;
errors: QuestionValidationError[];
clearError: (questionId: string) => void;
disabled?: boolean;
activeGroupId?: string;
}

export function QuestionRenderer({
questions,
responses,
onResponseChange,
errors,
clearError,
disabled,
activeGroupId,
}: QuestionRendererProps) {
const questionRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});

useEffect(() => {
if (activeGroupId && questionRefs.current[activeGroupId]) {
questionRefs.current[activeGroupId]?.scrollIntoView({
behavior: "smooth",
block: "start",
});
}
}, [activeGroupId]);

const handleResponseChange = (updatedResponse: QuestionnaireResponse) => {
const newResponses = [...responses];
const index = newResponses.findIndex(
(r) => r.question_id === updatedResponse.question_id,
);
if (index !== -1) {
newResponses[index] = updatedResponse;
} else {
newResponses.push(updatedResponse);
}
onResponseChange(newResponses);
};

return (
<div className="space-y-4">
{questions.map((question) => (
<div
key={question.id}
ref={(el) => (questionRefs.current[question.id] = el)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor ref assignment to improve code clarity

The ref assignment in the JSX expression makes the code harder to read and is flagged by static analysis.

Move the ref assignment to a separate function:

+ const setQuestionRef = (id: string) => (el: HTMLDivElement | null) => {
+   questionRefs.current[id] = el;
+ };

  <div
    key={question.id}
-   ref={(el) => (questionRefs.current[question.id] = el)}
+   ref={setQuestionRef(question.id)}
  >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ref={(el) => (questionRefs.current[question.id] = el)}
const setQuestionRef = (id: string) => (el: HTMLDivElement | null) => {
questionRefs.current[id] = el;
};
<div
key={question.id}
ref={setQuestionRef(question.id)}
>
🧰 Tools
🪛 Biome (1.9.4)

[error] 57-57: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

>
<QuestionGroup
question={question}
questionnaireResponses={responses}
updateQuestionnaireResponseCB={handleResponseChange}
errors={errors}
clearError={clearError}
disabled={disabled}
activeGroupId={activeGroupId}
/>
</div>
))}
</div>
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for invalid questions

The component should handle cases where questions array might contain invalid data.

Add validation and error handling:

  return (
    <div className="space-y-4">
-     {questions.map((question) => (
+     {questions.filter(Boolean).map((question) => (
+       question.id ? (
          <div
            key={question.id}
            ref={setQuestionRef(question.id)}
          >
            <QuestionGroup
              question={question}
              questionnaireResponses={responses}
              updateQuestionnaireResponseCB={handleResponseChange}
              errors={errors}
              clearError={clearError}
              disabled={disabled}
              activeGroupId={activeGroupId}
            />
          </div>
+       ) : null
      ))}
    </div>
  );

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 57-57: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

}
22 changes: 22 additions & 0 deletions src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Label } from "@/components/ui/label";

import { QuestionnaireResponse } from "@/types/questionnaire/form";
import { Question } from "@/types/questionnaire/question";

interface AllergyQuestionProps {
question: Question;
questionnaireResponse: QuestionnaireResponse;
updateQuestionnaireResponseCB: (response: QuestionnaireResponse) => void;
disabled?: boolean;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation prop and error handling to interface

The props interface could be enhanced to handle validation and errors.

Consider adding these props:

interface AllergyQuestionProps {
  question: Question;
  questionnaireResponse: QuestionnaireResponse;
  updateQuestionnaireResponseCB: (response: QuestionnaireResponse) => void;
  disabled?: boolean;
+ validation?: {
+   required?: boolean;
+   minAnswers?: number;
+   maxAnswers?: number;
+ };
+ error?: string;
+ onError?: (error: string) => void;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
interface AllergyQuestionProps {
question: Question;
questionnaireResponse: QuestionnaireResponse;
updateQuestionnaireResponseCB: (response: QuestionnaireResponse) => void;
disabled?: boolean;
}
interface AllergyQuestionProps {
question: Question;
questionnaireResponse: QuestionnaireResponse;
updateQuestionnaireResponseCB: (response: QuestionnaireResponse) => void;
disabled?: boolean;
validation?: {
required?: boolean;
minAnswers?: number;
maxAnswers?: number;
};
error?: string;
onError?: (error: string) => void;
}


export function AllergyQuestion({ question }: AllergyQuestionProps) {
return (
<div className="space-y-4">
<Label>{question.text}</Label>
<div className="rounded-lg border border-dashed border-gray-300 bg-gray-50 p-4 text-center text-sm text-gray-500">
Allergy component to be implemented
</div>
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Implement proper FHIR AllergyIntolerance structure

The current implementation is a placeholder and needs to be updated to handle FHIR AllergyIntolerance resources properly.

The component should:

  1. Handle FHIR AllergyIntolerance fields (type, category, criticality, etc.)
  2. Implement proper error handling
  3. Support multiple allergies
  4. Include proper validation

Would you like me to provide a complete implementation that follows FHIR specifications?

Also, consider adding proper aria labels for accessibility:

- <div className="space-y-4">
+ <div className="space-y-4" role="group" aria-labelledby={`allergy-question-${question.id}`}>
-   <Label>{question.text}</Label>
+   <Label id={`allergy-question-${question.id}`}>{question.text}</Label>

Committable suggestion skipped: line range outside the PR's diff.

Loading
Loading