©
Code by
Mateus
Paula
Loading...
ROLE / SERVICES
development
COMPANY RELATED
The Casely Group
YEAR
2023

Injury Institute is a full-featured medical directory web application connecting personal injury attorneys and patients with healthcare providers across California. The platform features a powerful CMS-driven architecture using Sanity, server-side rendered listings with geographic search capabilities, and a sophisticated filtering system using URL query parameters.
The platform uses a polymorphic content model where a single "Item" document type dynamically changes its form based on the selected type (Clinic or Doctor).

Key Implementation Details:
clinic.ts and doctor.tshidden property with document contextcomputedString type for geocoding city names
The listing page uses getServerSideProps for server-side rendering with dynamic GROQ query construction based on filter parameters.
Key Implementation Details:
geo::distance() functionbuildArrayFilter helper
A comprehensive filtering system using Jotai atoms for state management, synchronized with URL query parameters.
Key Implementation Details:
The listing page features a side-by-side layout with virtualized list and Google Maps integration.
Key Implementation Details:
next/dynamic to avoid SSR issuesClinic and doctor detail pages use getStaticPaths with ISR (Incremental Static Regeneration) for optimal performance.
A clever URL pattern allows doctors to be viewed both independently and within their clinic context.
Key Implementation Details:
The listing page uses virtualization for smooth scrolling with large datasets.
Automatic city extraction from coordinates using Google Geocoding API in Sanity Studio.
getServerSideProps parses query params and builds GROQ queryProblem: Need to support both Clinics and Doctors as first-class items while sharing common fields.
Solution: Created a base "Item" schema that conditionally shows nested clinic or doctor fields based on a type selector:
Problem: Filtering results by proximity to user location using Sanity's GROQ.
Solution: Leveraged Sanity's built-in geo::distance() function with geopoint fields and converted user-friendly miles to meters:
Problem: Maintaining filter state across page refreshes and enabling shareable URLs.
Solution: Implemented bidirectional sync between Jotai atoms and Next.js router query params, with SSR reading params directly in getServerSideProps.
Problem: Doctors can exist both as standalone items AND as team members within clinics.
Solution: Created a special URL pattern (doctor-slug___clinic=clinic-slug) that encodes the relationship, with GROQ using array filtering to find the doctor within the clinic's team array.


getServerSideProps) for dynamic listings with ISR (getStaticProps + revalidate) for detail pages