Storing,Viewing and Deleting List and then Sorting in Firebase

I'm having a problem with sorting my list in my app. I've made a demo where Users can register a patient in the app and be shown there and the rest in a list.


My plan is that whenever a user registers, that goes into a list and tagged into a sorted number. First register goes into 1, the second goes to 2 and etc. Those sorted will be then sorted accordingly into Firebase then get back for viewing. This viewing will be accordance to what number the patient is given (Patient 1 goes to 1 and so on.) If a user wishes to delete a patient, for example Patient 2, then Patient 1 will be moved to 2 and becomes the new Patient 2. That would mean if a user registers into a new patient, it goes back to one and becomes patient 1.

I've gotten only getting the data, but no idea how to update, store, delete and sort it

Here is the app
Patients.aia (7.1 KB)

Can anyone help?

You do not show how you are storing the data in firebase (blocks and firebase console).

From an initial view of the blocks you do show, you need to re-consider your data structure, storage and retrieval.

(You could just use google sheets for this...)

first store user info in firebse as you requested.. There is not height key any where in your db
image

also as per your screenshot, you want only four users to be stored in your db? what will you if user want to store more than that..

as said by Tim reconsider your algorithum

Ah, I think the cause for that is that I changed the Firebase Token to get another db from another app I made, my bad.

Also regarding the algorithm, I have made that so as I was planning to have these patients have pictures beside them, and I have no clue how to save images into the Firebase.

Use cloudDB to upload image , get url, save the url in fb

Use Firebase storage to upload images, and save the link in your database with the other patient information, then don't have to use cloudDB as well.

Alright, I decided to use the Listpicker to show the list patients added to the app.

My problem currently is the delete button doesnt work completely. It deletes the element on the list, but not on the actual Firebase Database. Does anyone know what I'm doing wrong here?


Patients.aia (5.2 KB)

In the Delete event, just set your ProjectBucket to Patientlist/

Your problem might be the global variable OrderTag.

I see 2 possibilities for what your intentions are for that variable:

  • The high water mark for all patient numbers, for purposes of assigning new patients unique numbers, or
  • the last chosen patient number, for purposes of setting up a proper deletion of a patient from Firebase.

You might be missing a global variable, needed to distinguish between the two uses.

Consider adding the patient number to the contents of your ListView Elements, to simplify the update and deletion processes by using the Selection instead of the SelectionIndex.

Your Elements are close to YAML in their formats,
Going full YAML would make extraction from an Element easier (split Selection at \n to get tag:value list, split each item at : to get tags and values.)

I've downloaded the FirebaseStorage Extension so I can store images and put it in both the List and Firebase. Now I'm wondering how do I store the image and or the filepath in the list and into the Firebase.

When you store a file, use the event block to get the download url:

image

then upload this to firebase realtime database / add to your list in the app.

You should also be considering patient confidentiality. At present I am guessing you have read and write settings as true in your realtime database and storage. This may not be advisable in production, which will present you with some issues when using the extensions....

also, since you are deleting the patient please do not use patient count while saving the data in firebase, you will meet collapse of algorithum then..
To avoid the confusion pls use timestamp in running format or random integer
image

Okay I'll add the random integer then.

I'm still confused on how to implement the FirebaseStorage


I tried using it but it comes out as an error like so
noe
I'm trying to upload an image into the app for the patients profile picture, and then after clicking the register patient button, save both on the list and into the Firebase

This

image

is probably wrong.

Example:

filename = myimage1.png
path = /storage/emulated/0/Pictures/ (or /Pictures/) or without the trailing slash.

The extension may now be out of date with the filescope changes required for Android 11+

It may be easier to use the web component ?

I've looked into it but I really just want to store images from my phone to the firebase, and then get it back.

I also tried changing the file and path, and still nothing came up.


Screenshot_20230302_142934

I have never seen the path/directory Phone Storage before. if it does exist the fact that there is a space in the directory name is most probably causing the problem.

Android OS is essentially a linux framework, therefore spaces in directory and filenames should be avoided.

Phone storage means that the storage I'm taking is not in the SD card but unto the phone itself since the phone has its own storage, like in case you dont have an SD card on your device, so you use the Phone's storage itself to store stuff. This is getting a bit confusing for me to be honest. Do you have an example I can draw upon? preferably where the user picks an image wherever? SD or Phone Storage and then stores it in Firebase and be able to get it back? If not... maybe I'll just stick to TinyDB for the Image only instead

See here to understand more about "phone storage"

Of course, there is NO path
"Phone Storage/DCIM/..." in Android.
(But it might be shown on your device.)

The path should be:
/storage/emulated0/DCIM/... (absolute path) or
file:///storage/emulated0/DCIM/... (full path).