75
Views
4
Comments
Solved
Create a list of blocks and append a new block upon clicking a "add a block" button

Hello,

I am very new to this tool (started two days ago) and having lots of trouble with a web block approach I want to set up.

Basically, I am a scientist working with patients with cancer. I tried to make a web app to follow-up on the patients. I created à web block that gives me information on which step of the treatment the patients are as well as some information about the data collection process among other basic data, the whole embedded within an accordion. This content has multiple expressions in it, as well as buttons and other components (dynamic progression bar, picture of the treatment time-line) and these are linked to the classic "detail" page created when dropping the database entity in the layout. 

It is "working" (even though I am pretty sure real dev would get crazy about the way it does lol) and I can make multiple patients manually, but with very little knowledge with this tool and very little time on my schedule, I spent multiple nights trying to figure out how to automate the patient creation part. I believe it is by making the patient_web-block part of a list and use the append to list function though I did not manage to make it work. I can't get how to specify a block as a variable into the database or a local variable (sorry if not the right words, very new to it)

So basically, what I would like to do is to develop a way to clone a template patient (database, server and server actions, pages and block) using a button on the screen (add patient) and a prompt asking me the number of the new patient. The "manual logic" i use behind it would be this one :

- Clone Database entity

- Drag the new database into the canvas so the logic part is automatically created

- Insert New_Patient web-block in the "patient follow-up" page just after the previous patient ("web-block list" but not "really" a list, just blocks one after the other for now)

- Insert/specify the database link for each item (change expression to getdb.current.etc)

- Go to the detail page and replace the automatically generated form by a patient detail block i made where I can make changes to the patient-follow-up accordion

Manually, it does take some time that I, unfortunately, don't have much to spare of. Reassigning every time the link to the db for each parameter (i use ctrl + f to replace patient1 in the expression by  patient2 to get it quicker) but still, it takes ages. And I know for sure there is a better way to do this but I tried multiple videos, outsystems documentation and tutorials and after three nights on it is all gibberish to me. I must not have the right keywords and when I get closer, it is old posts that do not apply to the current version. I do understand coding concepts and might be able to make some scripts works but don't have the skills for this kind of development nor the time to get a full course on it. However, if I manage to complete this tool, it might be a game-changer for patient follow-up for my research team.

So if you were kind enough to guide me through this process or direct me to relevant literature, it would be much appreciated.


Have a great day, 


PS: Attached a fake patient for illustration


website.png

Rank: #136
Solution

Abderrahim Benmoussa wrote:

Hello,


Thank you for your answer. 


I would think I get these concepts. Actually, I just did not get how to make them work. You will find the file attached.

I looked at it again today with fresh eyes and actually made some improvements. The thing was that I had my containers within a placeholder so I had to respecify the links once on the parent page. Also, I tried to use the input variable to gather ID and now every time I insert this block, I must specify the id and it retrieves the patient from the DB based on the ID which is a huge improvement.   I also don't think the ontoggle action is the way to do it what I intend to.

Also, I still can't find how to insert a new block on the page and assign it a new id value when I click on add a patient.

The flow would simply be: at click insert a new-patient web block with an Id superior to the highest one in the list. I still can't figure out how to make that happen. Here is the file. Some of the links are inactivated for now but it is "working"


Thank you for your help,


Have a great day,


 But, by the warnings, me having to specify the id number should not be the case, as it asks for data type and not an integer.  This is perfectly normal, although identifiers are indeed integers, Outsystems is very strongly typed and wants you to explicitly cast an integer to an identifier.  Function to use is IntegerToIdentifier(4) for example.

I'm not really understanding why you want to manually add blocks for specific patients to screen1.  Who are these patients ?  Don't you want all patients, and if not, what is your criteria for selecting them ?  I have gone ahead and assumed that you just want a block for each patient in your database.  See screen ListOfBlocks.

What you do is you add an aggregate retrieving all the patients (or if you only would want specific patients on this screen, use filter on this aggregate.)  You have a list widget on the screen bound to the result of the aggregate.  And the only widget inside that list is your "NewPatient" block.  You pass in the id of the current patient in the list.

GetPatients.List.Current.Patient.Id

 

Inserting a new patient : As soon as a new patient gets added to the database, it will appear as an extra block on your list.  Why not just have an addpatient button that will bring you to the detail screen in the same way that now the edit button does ?


As for the highest number, id is autonumber so that is automatically taken care of.

An area where a lot of improvement can (and should) still be made, is your datamodel.  Things like gender and risk level and cancer_type should be codified (typically in static entities, with a reference attribute in your patient entity)  But also really not a fan of all the repeated attributes to represent at what times what information is gathered.


Good luck,

Dorine


testmodified.oml

Rank: #136

Hi Abderrahim,


you sure are right about the real dev would get crazy part ;-)


you say you understand coding concepts, but I think you are missing out on the most basic one : there is a level of abstraction between actual data, patients, procedures, and the model/software/data representing these.  

The software design works with types of everything, in the datamodel the type of data gathered about a patient or a treatment is described, all logic and screens are designed in terms of what type of action would take place on what type of information.

What you are trying to do here, sounds a bit like if you would try to develop a calculator, and would write a new piece of code for every possible addition you want the calculator to be able to handle.  See, there's no abstraction going on here.  What you really want is to describe that, given any number a and any number b, the result should be a number c, being the addition of a and b.  See, all possible values are abstracted to just 3 letters.

So you want to make a model of the data you would like to collect "for a given patient", not "for patient John Doe".  And all your logic and screens and webblocks, you want them to do some processing "for a given patient".  And then by changing the "given patient", the same screen can be reused for all your patients.  This "given patient" concept is translated in the fact that in your database, all your patients have an id, and passing the id to a screen or piece of logic will make that logic do what it needs to do with that patient.


So you are talking about linking to the scaffolded screen of patient details, so I'm thinking, maybe you get above concept but just don't know how to apply it to the data gathering and treatment process.  Can you maybe share either your oml, or some screen shots of your data model to show where we could improve.

Dorine

Hello,


Thank you for your answer. 


I would think I get these concepts. Actually, I just did not get how to make them work. You will find the file attached.

I looked at it again today with fresh eyes and actually made some improvements. The thing was that I had my containers within a placeholder so I had to respecify the links once on the parent page. Also, I tried to use the input variable to gather ID and now every time I insert this block, I must specify the id and it retrieves the patient from the DB based on the ID which is a huge improvement.  But, by the warnings, me having to specify the id number should not be the case, as it asks for data type and not an integer. I also don't think the ontoggle action is the way to do it what I intend to.

Also, I still can't find how to insert a new block on the page and assign it a new id value when I click on add a patient.

The flow would simply be: at click insert a new-patient web block with an Id superior to the highest one in the list. I still can't figure out how to make that happen. Here is the file. Some of the links are inactivated for now but it is "working"


Thank you for your help,


Have a great day,


test.oml