[WIP] Update Claim

This commit is contained in:
R
2023-03-06 02:10:08 +07:00
parent 91ba718a50
commit 35119ee8ec
18 changed files with 1066 additions and 18 deletions

View File

@@ -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}
</>
),
}}
/>
)}
/>
)
}