Skip to content

Commit

Permalink
GOK-367 | Add. Query param to getAllPatient api based on user input v…
Browse files Browse the repository at this point in the history
…alue | [Sweety/Riya]
  • Loading branch information
riyaTw committed Sep 20, 2023
1 parent 2d7d1bd commit 22ea4af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/inventory/dispense/add-inventory-item/add-item-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@ import styles from './add-item-modal.module.scss';
const AddItemModal = (props) => {
const { itemStock } = useItemStockContext();
const [cookies] = useCookies();

const locationUuid = cookies[locationCookieName].uuid;

const [inventoryItem, setInventoryItem] = useState([]);

const { data: allPatientList, error: allPatientListError } = useSWR(
getAllPatient(locationUuid),
fetcher,
);

const [rows, setRows] = useState([{ id: 1, drugName: '', avlQty: 0, dispQty: 0 }]);
const [inputValue, setInputValue] = useState('');

const { data: allPatientList } = useSWR(inputValue.length > 1 ? getAllPatient(locationUuid, inputValue) : null, fetcher);

useEffect(() => {
if (itemStock) {
Expand Down Expand Up @@ -164,6 +159,9 @@ const AddItemModal = (props) => {
shouldFilterItem={filterPatient}
itemToString={(item) => getPatientName(item) ?? ''}
onChange={(selectedItem) => props.setPatient(selectedItem?.selectedItem)}
onInputChange={(inputValue) => {
setInputValue(inputValue);
}}
invalid={!props.patient}
invalidText='Please select a patient'
style={{ fontWeight: 'bolder' }}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ export const stockOperationURL = "/openmrs/ws/rest/v2/inventory/stockOperation"
export const stockOperationTypeURL = (stockOperationType) => `/openmrs/ws/rest/v2/inventory/stockOperationType?v=full&q=${stockOperationType}`
export const inventoryItemByNameURL = (itemName) => `/openmrs/ws/rest/v2/inventory/item?v=full&q=${itemName}`
export const sessionURL = '/openmrs/ws/rest/v1/session?v=custom:(uuid)'
export const getAllPatient = (locationUuid) => `/openmrs/ws/rest/v1/bahmni/search/patient/lucene?filterOnAllIdentifiers=true&loginLocationUuid=${locationUuid}`
export const getAllPatient = (locationUuid,inputValue) => `/openmrs/ws/rest/v1/bahmni/search/patient/lucene?filterOnAllIdentifiers=true&loginLocationUuid=${locationUuid}&q=${inputValue}`

0 comments on commit 22ea4af

Please sign in to comment.