Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bulk creating beds inside a location #10585

Open
rithviknishad opened this issue Feb 13, 2025 · 12 comments · May be fixed by #10815
Open

Support for bulk creating beds inside a location #10585

rithviknishad opened this issue Feb 13, 2025 · 12 comments · May be fixed by #10815
Assignees

Comments

@rithviknishad
Copy link
Member

rithviknishad commented Feb 13, 2025

issues will be assigned once the solution to solve this is approved

Is your feature request related to a problem? Please describe.
When setting up locations of a facility, there'd be multiple beds inside a location. To ease data entry effort, we should be able to bulk create beds (eg. Bed 1, Bed 2, Bed 3, etc...).

Describe the solution you'd like
We could either ask the prefix name from the user and call the API.

Describe alternatives you've considered
We def. can/should explore more better ways to approach this

@tellmeY18 tellmeY18 added this to Care Feb 13, 2025
@tellmeY18 tellmeY18 moved this to Triage in Care Feb 13, 2025
@rajku-dev
Copy link
Contributor

i would like to work on this.

@rithviknishad
Copy link
Member Author

issues will be assigned once the solution to solve this is approved; do share your thoughts on how to solve this.

@AdityaJ2305
Copy link
Contributor

Hmm, as much as I understood, we can have the prefix name from user and also starting and ending numbering label for example A1 to A10. And prefix 'Bed' and push the array from Bed A1 to Bed A10
It could be just number as well

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 13, 2025
@Rustix69
Copy link
Contributor

Approach for Dynamic Bed Naming & Optimized API Request

1. User Input Fields in Location Form

  • Bed Type Selection: User can select the type of bed (e.g., ICU, Standard, etc.).
  • Number of Beds: A field to specify how many beds to add (defaults to 1 for each type).
  • Real-Time Preview: Dynamically generate a preview of bed names based on existing beds (e.g., ICU-1, ICU-2, ICU-3).

2. Real-Time Bed Name Preview

  • Before submitting, users see a preview of the beds that will be created.
  • If 3 ICU beds already exist (ICU-1, ICU-2, ICU-3), adding 3 more will show:
  • If no beds exist, the preview will start from ICU-1.

3. Optimized API Request Structure

  • Do not send the entire list of generated bed names to avoid memory overhead.
  • Only send bed type and count in the payload.
  • Example API Payload:
{
  "location_id": "12345",
  "bed_type": "ICU",
  "count": 3
}

4. Backend Processing & Database Update

  • Backend fetches the existing beds of the selected type for that location.
  • Determines the next available bed number.
  • Generates and inserts new beds dynamically.
  • Updates the parent location records accordingly.

5. Validation Rules

  • Ensure bed numbers are sequential and unique.
  • Restrict the maximum number of beds per location (if applicable).
  • Prevent duplicate names from being created.

@hrit2773
Copy link
Contributor

@rithviknishad is the backend open for contributions now

@hrit2773
Copy link
Contributor

@rithviknishad we can ask the user to add multiple beds once the user selects location form as bed. We can create a separate model for Bed in the backend with fields bed_type, number_of_units, location referencing to existing facilityLocation model or we can also create a JSON field of beds in FacilityLocation Model anything can be preferred. And it will be better to create a separate model for Bed Types also which would allow admin to add default bed types. In frontend we can show a select field with all those bed types as choices.

@vishwansh01
Copy link
Contributor

vishwansh01 commented Feb 16, 2025

@rithviknishad Could you assign this issue to me.

Approach

We can add an option where the user can select the number of beds.

For example, the user types the name of the location as bed and selects 10 beds. After clicking "Create," the API is called, which checks if there are already entries in the database labeled as bed.

If no such entries exist, the beds are created starting from bed 1 (then bed 2, bed 3, and so on up to bed 10).
If entries named bed already exist in the database, new entries will be added with numbering starting after the highest existing bed number.
For example, if entries up to bed 5 already exist, the new entries will start from bed 6 and go up to bed 15.

@rithviknishad rithviknishad marked this as a duplicate of #10685 Feb 19, 2025
@rithviknishad
Copy link
Member Author

rithviknishad commented Feb 19, 2025

Checkout batch_requests API.

We can achieve this without modifying the backend.

@rithviknishad rithviknishad removed question Further information is requested needs-triage labels Feb 19, 2025
@rithviknishad rithviknishad moved this from Triage to Up Next in Care Feb 19, 2025
@AdityaJ2305
Copy link
Contributor

Image
@rithviknishad , do you mean we should pass it in description?

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 19, 2025
@vishwansh01
Copy link
Contributor

vishwansh01 commented Feb 19, 2025

@rithviknishad

Approach1

We can add an option where the user can select the number of beds and then push the stringified details of all the beds in an array then send this array to backend.

For example, the user types the name of the location as bed and selects 10 beds. After clicking, if the backend supports bulk creation we can just push all the requests in an array, each request with same name prefix and different number (like bed 1 , bed 2 ) and then stringify the whole array and then send it to the backend.

@vishwansh01
Copy link
Contributor

vishwansh01 commented Feb 19, 2025

@rithviknishad

Approach2

We can add an option where the user can select the number of beds and then push the beds in an array and use promise.all() / make a recursive function / use a loop to send these requests with the prefix bed and there respective number

@AdityaJ2305
Copy link
Contributor

Hey @rithviknishad , Could you assign m this issue ? I made it work locally by following guidelines stated in the issue (hardcoded 3 for demo)

Screen.Recording.2025-02-24.at.10.53.33.PM.mov

@rithviknishad rithviknishad removed question Further information is requested needs-triage labels Feb 25, 2025
@tellmeY18 tellmeY18 moved this from Up Next to In Progress in Care Feb 25, 2025
@AdityaJ2305 AdityaJ2305 linked a pull request Feb 25, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

6 participants