forked from wishonia/wishonia
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConditionSearchAutocomplete, searchConditions library
- Loading branch information
Showing
11 changed files
with
326 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import { Input } from "@/components/ui/input" | ||
import { searchConditions } from "@/lib/clinicaltables" | ||
|
||
interface ConditionSearchAutocompleteProps { | ||
onConditionSelect: (condition: string) => void | ||
placeholder?: string | ||
} | ||
|
||
export default function ConditionSearchAutocomplete({ onConditionSelect, placeholder = "Enter medical condition" }: ConditionSearchAutocompleteProps) { | ||
const [condition, setCondition] = useState('') | ||
const [suggestions, setSuggestions] = useState<string[]>([]) | ||
const [showDropdown, setShowDropdown] = useState(false) | ||
|
||
useEffect(() => { | ||
if (condition.length > 2) { | ||
searchConditions(condition).then(extractedSuggestions => { | ||
setSuggestions(extractedSuggestions) | ||
setShowDropdown(true) | ||
}) | ||
} else { | ||
setSuggestions([]) | ||
setShowDropdown(false) | ||
} | ||
}, [condition]) | ||
|
||
const handleSuggestionClick = (suggestion: string) => { | ||
setCondition(suggestion) | ||
setShowDropdown(false) | ||
onConditionSelect(suggestion) | ||
} | ||
|
||
return ( | ||
<div className="relative"> | ||
<Input | ||
type="text" | ||
placeholder={placeholder} | ||
value={condition} | ||
onChange={(e) => setCondition(e.target.value)} | ||
className="w-full" | ||
/> | ||
{showDropdown && suggestions.length > 0 && ( | ||
<ul className="absolute z-10 w-full border border-gray-300 mt-1 max-h-60 overflow-auto bg-background"> | ||
{suggestions.map((suggestion, index) => ( | ||
<li | ||
key={index} | ||
className="px-4 py-2 hover:bg-accent hover:text-accent-foreground cursor-pointer" | ||
onClick={() => handleSuggestionClick(suggestion)} | ||
> | ||
{suggestion} | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
"use client" | ||
import React from 'react' | ||
import FindTreatments from './components/FindTreatments' | ||
import HealthTracking from './components/HealthTracking' | ||
import HealthTrackingLinkBoxes from './components/HealthTrackingLinkBoxes' | ||
import CostBenefitAnalysis from './components/CostBenefitAnalysis' | ||
import TopTreatments from './components/TopTreatments' | ||
|
||
export default function DFDAPage() { | ||
return ( | ||
<div className="container mx-auto px-4 py-8 space-y-8"> | ||
<FindTreatments /> | ||
<HealthTracking /> | ||
<CostBenefitAnalysis /> | ||
<TopTreatments /> | ||
<FindTreatments /> | ||
<HealthTrackingLinkBoxes /> | ||
<CostBenefitAnalysis /> | ||
<TopTreatments /> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.