0

I am making a medical software and I am stuck at a point. I have to make a report section where user will fill up the reports for the patient. The main catch is since the fields/column is variable(less/more). Say if I fill up form in blood test, columns option are different and for X-ray columns is different.

I have made a database so it will store option values for that test id and patient id

CREATE TABLE IF NOT EXISTS `mp_tests_options` (
`test_optn_id` int(11) NOT NULL AUTO_INCREMENT,
`optn_test_id` int(11) NOT NULL,
`optn_patient_id` int(11) NOT NULL,
`test_optn_name` varchar(255) NOT NULL,
`test_optn_value` LONGTEXT DEFAULT NULL,
`test_optn_def_value` LONGTEXT DEFAULT NULL,  
PRIMARY KEY (`test_optn_id`),
INDEX (`optn_test_id`),
INDEX (`optn_patient_id`),
FOREIGN KEY (optn_test_id) REFERENCES mp_tests(test_id) 
ON UPDATE CASCADE ON DELETE   RESTRICT 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

But how do i make the front end for user with proper validation. I dont want to write each form individually.

Thanks for your time.

Hasan
  • 1
  • 3
  • I think adding and removing columns dynamically is pretty bad idea. Why don't you create a reference to another table with different fields as rows? – Shubham May 18 '14 at 11:24

1 Answers1

0

Create a separate table for what columns are required in every form you want.

 _______________________________________________
|   formName  | fields                          |
|-----------------------------------------------|
| x-ray       |field1,field2,field3,field4      |
|-----------------------------------------------|
| bloodtest   |field1,field2,field3,field4      |
|_______________________________________________|

And then use explode() it to convert it to array. Also create a table that has possible fields to every form names. Just insert a blank to unneeded fields.

Leouze
  • 1
  • I need to make proper javascript validation for those, how will do do that.Also if some fields depends on other like field A and field B depends on what use has selected using radio then? – Hasan May 19 '14 at 17:44