Topic: Match Tablegrid with Combobox

Hi everyone.
(This is gonna be hard to explain.)
I'm working on a project regarding Antibiotics taken by patients in a hospital.
There are 1000 patients and 30 different antibiotics.
The antibiotic types are recorded using a combobox as you can see the attached sample.
What I need to do is that when I search patients' names, all the medicine info (number , price and antibiotic types) that he took as well as those he did not take are shown in a tablegrid (if he didn't take that antibiotic , the related cell should be left blank.) and all of these info should be shown in just one row of the tablegrid
the antibiotics should be ordered alphabetically for example in the tablegrid (search form):
the first row is First name (Jack , Eva , ...)
the second row  is Last name
the third row is Medicine Type ( only azithromycin)
the forth row is number ( the number of azithromycin that the patient took and if the patient did not take any of that pill this row should be left blank or Zero)
the fifth row is price ( the price of that specific antibiotic and again if the patient did not take any pill this row should be left blank or Zero)
the sixth row should be Medicine Type (only ampicillin )
the seventh row is number
so on and so forth (Please see the attached picture and hopefully you will understand what I Mean)

guys this is not for aesthetic purpose this is because I need to know which pills a patient did not take and compare it to other patients with similar diseases who took that specific antibiotic so similar antibiotic for different patients should be in the same column of the tablegrid.

if you have any other approaches feel free to share

thank you guys you have helped me a lot with my project

Post's attachments

Attachment icon Hospital 1.zip 463.07 kb, 75 downloads since 2024-05-27 

Re: Match Tablegrid with Combobox

The development environment does not support cross-tabs (what you need, judging by the picture), but you can achieve the desired display using a script. However, its implementation will take time and effort, and performance for 1000 patients will leave much to be desired. For this reason, the master/detail view is used in such cases. But if the waiting time for generating such a report is not critical, then you can try to implement it. The plan is this: using the SQLQuery procedure, obtain the initial data set, and then fill the cross-table row by row in a loop; first, using a separate query, you need to get a list of medications and add the corresponding number of columns.

Визуальное программирование: блог и телеграм-канал.

Re: Match Tablegrid with Combobox

I can’t quite imagine what you will do with this table when you have more than 90 columns and many rows on your screen. These columns, accordingly, will not all be visible at the same time, and scrolling to the right to the left will be effective only if the first columns are permanently fixed. And even so, I doubt the effectiveness.
In general, it looks like you are trying to create an analogue of Excel.
Konstantin, as for the output to the table, I don’t see any obstacles. You can generate a query dynamically through a script, based on the number of antibiotics, and display the result in a table without manually creating and filling columns in a loop. Everything will depend on the database structure.
And yet, in the place of the author, I tried to change the result. It looks like a road to nowhere and sooner or later you will be forced to upgrade the program.

Re: Match Tablegrid with Combobox

Thank you sparrow and K245
fixing the first columns permanently will also help me.
this project is for a doctoral thesis and it will be effective when comparing a specific antibiotic for some patients ( not all of 1000 instances)  who took that medicine and those who did not take it.
I know it will be difficult to compare as there will be many rows and columns but  it will definitely fit my purpose . besides I have no other choices.
is there any script that match that combobox in Drug Form ( Antibiotic Type ) with a specific column of the tabelgrid in the Search Form?
For example the first line of combobox is shown on the third column of the tablegrid
but still there is another unsolvable obstacle which is the 2 textboxes ( Number and price of antibiotic) that are related to that combobox.
So I guess there is no solution to this approach
thank you guys for trying to help

Re: Match Tablegrid with Combobox

If I understand you correctly, then you are interested in the dependence of the structure of treatment on the drugs used and their combinations for patients with the same diagnosis. You should look for other ways to get the analytical information you need. For example, building various queries using SQL and aggregate functions.More information is needed to make any specific recommendations.

Визуальное программирование: блог и телеграм-канал.

6 (edited by sparrow 2024-05-27 13:40:15)

Re: Match Tablegrid with Combobox

Something like this
35 antibiotic positions have been added for the test

Post's attachments

Attachment icon hospital-m.zip 329.96 kb, 84 downloads since 2024-05-27 

Re: Match Tablegrid with Combobox

nicely done sparrow
you made my day
thank you so much that's exactly what I needed
and thank you k245 for giving me some ideas

Re: Match Tablegrid with Combobox

Just need to be careful.
Due to the simplified patient database, the result will be incorrect if the first and last names of some patients match.

Re: Match Tablegrid with Combobox

Hello sparrow, hello everyone.
Out of curiosity I looked at the project. As always a very complicated solution, at least for me, solved by sparrow.
I don't want to be a killjoy but I found a problem: what I noticed is that you can't edit the patient. Whether you click on the "Edit" button or double click on the row in the TableGrid, the message that no records are selected appears.

10 (edited by sparrow 2024-05-27 19:01:45)

Re: Match Tablegrid with Combobox

Hi Fabio,


First, let's solve the problem of duplicates. Here's a slightly modified procedure:

group by 1, 2';

Replaced by:

group by id_patient, 1, 2';

The task that the author set for himself and us and the solution to this task is called rotating the table (pivot table). From vertical to horizontal. And this is not a trivial task.   Especially with more than 30 columns. Where can you reach the limit on the number of characters in a request? Although in Excel everything is quite simple.
Now to the issue of editing. Let's say 15 vertical records are moved to 35 horizontal ones in their places. Now which of these client records do you want to edit??? All at once, 1, 11 or 32??? And under what ID? What if the data is also summarized from several lines? 
This table rotation is usually the final report and is not intended for editing. I hope the author understands this too.
Now for editing we need to look for another solution.
And the decision itself is not difficult.

Re: Match Tablegrid with Combobox

Hi sparrow,
It's definitely not a trivial task. What I thought was that perhaps there is the possibility of adding or removing a drug to the same patient unless it is a patient for whom a treatment is prescribed only once.

Re: Match Tablegrid with Combobox

I wouldn't like to think that this is some kind of test bed on patients.   
Maybe I can prescribe you another pill like this? ))))
Most likely this is an analysis of treatments, including costs. Alive but poor or half-dead with some savings)))


It’s better to be on this side of the statistics))).
Good health to everyone.

Re: Match Tablegrid with Combobox

Hi sparrow,
If I understand correctly, the program is used in a hospital to find out which antibiotic has been prescribed to the patient, I don't think it is used to carry out tests.

Re: Match Tablegrid with Combobox

Fabio
attenzione ai software per ospedali in Italia le norme sono molto severe!
un abbraccio!

Domebil

Re: Match Tablegrid with Combobox

The database is filled with data (garbage)
medicines 35 units,
patients (in different conditions) 1000 pcs.,
selectively populated with patients, drugs, prices and quantities in 19,000 database records.
Adding a patient, editing a patient, and deleting a patient from the table works.
Search by criteria has been fixed.
Good health to everyone.

Post's attachments

Attachment icon Hospital-M1.zip 676.17 kb, 91 downloads since 2024-05-28 

Re: Match Tablegrid with Combobox

Now that's the script I have been looking forward to. smile
thank you so much Sparrow you rock

17 (edited by sparrow 2024-05-29 07:53:49)

Re: Match Tablegrid with Combobox

identity wrote:

Now that's the script I have been looking forward to

Replace the function in the script procedure "search_Button1_OnClick":

SQLQuery('SELECT id FROM medicinetype ORDER BY id', Results);

CHANGE TO:

SQLQuery('SELECT id FROM medicinetype WHERE CASE WHEN '+search.ComboBox1.sqlValue+'>0 '+
    'THEN id='+search.ComboBox1.sqlValue+' ELSE 1 END ORDER BY id', Results);

This replacement will improve the display of information in the table when using ComboBox to search for a medicine.

P.S. The test database for some patients contains multiple entries for the same drug. When displayed in a table, the quantity and price indicators are added together. However, when searching by quantity and/or price, there may be situations when the search does not display all records for this medicine.
I would not recommend that you use multiple records for the same drug for the same patient.
Otherwise, you need to change your search query.

Re: Match Tablegrid with Combobox

domebil wrote:

Fabio
attenzione ai software per ospedali in Italia le norme sono molto severe!
un abbraccio!

Ciao Domenico,
tanto la mia era solo una curiosità nel vedere come funzionava il programma. Immagino comunque quanti aspetti bisognerà considerare in Italia.
Un abbraccio anche a te.

19 (edited by identity 2024-06-05 03:46:02)

Re: Match Tablegrid with Combobox

Hi Everyone
Its me again with several problems looking for solutions
I have updated the sample that "Sparrow" developed.
The price textbox (Searchform) does not work so I decided to insert an advanced search button that somehow works fine.
The patients only take medicine in 2 departments of hospital: Clinic or surgery.
so I used a checkbox and one of these 2 should always be checked.
the only problem that I have here is regarding Import button.
I have recorded many patients in Excel form and converted to CSV format but I can't import the file into the project.
I searched the forum a lot looking tor import samples but the schema of this project is different and I don't know how to import since the Excel data should be imported to different tables of the project and that's what make it difficult to import.
Please guide me through the import
thanks a lot guys specially Sparrow

Post's attachments

Attachment icon Hospital-M1.zip 351.01 kb, 57 downloads since 2024-06-05 

Re: Match Tablegrid with Combobox

Hi,

In order to help you, you need to see at least an example of your Excel file.
At least one or two patients with column names. You can change the patient's first and last name to XXX, YYY.

Re: Match Tablegrid with Combobox

Sorry It's my bad
I thought I have attached it
the excel form is like the attached one but with 35 types of antibiotics

Post's attachments

Attachment icon ICU.zip 55.82 kb, 57 downloads since 2024-06-05 

Re: Match Tablegrid with Combobox

We need to write our own procedure in this type of import file.
It's possible.
But for this I am forced to request additional information.
1. Is the patient import data stored in one file or a separate file for each patient?
2. If each patient has its own import file, how similar are the fields in the files?
3. Does each patient have a different number of drug columns?
4. Forced to ask for the ORIGINAL Excel file/files. Two or three patients are enough. You can hide personal information (first name, last name, dates, city, address) with one asterisk, it doesn’t matter. I am interested in how the table further provides information about medications for several patients and several medications for one patient.
I suspect that the file you sent has already been edited and prepared by you. Perhaps the original information is in a different form? This applies to medications.
As for your modified base. I would not include in the database fields that can be calculated when displayed in the form, such as year, month, number of days, total cost of the medicine.
The year, month, and number of days are not contained in the import file, but the diagnosis is superfluous in the import table.

Re: Match Tablegrid with Combobox

hi sparrow and thanks a lot
1- all the patients' data are stored in just one sheet of an Excel form
2- all of the title fields of the patients are similar with different data ( each row of the Excel has about 30 cells for specific antibiotic, 30 cells for number of that antibiotic, 30 cells for unit price and 30 cells for total price) if a patient does not take a particular antibiotic, the fields regarding that specific antibiotic are empty.
3- the title of the column of the excel are the same only the number of antibiotics that each patient took is different.
4- the attached Excel is exactly the same as the original excel form but with only 10 different types of antibiotic ( the original form has 30 types of antibiotics)
thank you so much for your help

Post's attachments

Attachment icon ICU2.zip 114.84 kb, 46 downloads since 2024-06-06 

Re: Match Tablegrid with Combobox

Thanks for answers. If I need additional information I will write. No questions yet. There is a solution to your question, but it will take me a little more time to implement it in the procedure. Sorry force majeure. I hope to finish it by Monday.

Re: Match Tablegrid with Combobox

Hi


An EXCEL table must end with the last row. The numbering in the first column should be equal to the number of lines.The sheet name is "Sheet1".
Save the EXCEL file in XLS format (EXCEL 97-2003). Any file name. Place ONE file in the EXCEL directory.Example file in directory.


The procedure is bound to the IMPORT button. Use this procedure to import a source file. The procedure is strictly tied to the fields of the example table and will not work with the MVD export file. If the fields are changed, the procedure will need to be adjusted.
The procedure works with the file that was provided as an example. Not tested with a regional date format different from mine. There shouldn't be any problems.

Post's attachments

Attachment icon Hospital-M1-import.zip 313.41 kb, 59 downloads since 2024-06-08