[WIP] Update Claim
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import axios from "@/utils/axios";
|
||||
import { Autocomplete, TextField, CircularProgress } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function AutocompleteDiagnosis({ onChange, textLabel, currentValue = null })
|
||||
{
|
||||
const [options, setOptions] = useState([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
return (<Autocomplete
|
||||
defaultValue={currentValue ?? null}
|
||||
onChange={(event, value) => {onChange(value)}}
|
||||
isOptionEqualToValue={(option, value) => option.title === value.title}
|
||||
getOptionLabel={(option) => option.title}
|
||||
options={options}
|
||||
loading={loading}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label={textLabel != null ? textLabel : "Diagnosa ICD-X"}
|
||||
onChange={(event) => {
|
||||
setLoading(true);
|
||||
axios.get('options?type=diagnosis&search='+event.target.value)
|
||||
.then((res) => {
|
||||
setOptions(res.data.map(function(icd) {
|
||||
return {
|
||||
title: icd.code + '-' + icd.name,
|
||||
value: icd.id
|
||||
}
|
||||
}))
|
||||
})
|
||||
.then(() => {
|
||||
setLoading(false);
|
||||
})
|
||||
}}
|
||||
InputProps={{
|
||||
...params.InputProps,
|
||||
endAdornment: (
|
||||
<>
|
||||
{loading ? <CircularProgress color="inherit" size={20} /> : null}
|
||||
{params.InputProps.endAdornment}
|
||||
</>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user