A method and system for dynamic form, field configuration and storage
By using a dynamic form configuration method that dynamically creates rules using JSON/XML format and SQL statements in the remote consultation platform, the problem of adaptability of patient information format under different needs is solved, flexible field configuration and efficient form generation are achieved, and the extensibility and maintainability of the code are improved.
Patent Information
- Application Number
- CN202210681488.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-16
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2042-06-16
AI Technical Summary
When faced with patient information and format requirements from different hospitals, testing institutions, and veterinary pathology departments, traditional methods for remote consultation platforms require writing multiple sets of code, resulting in a large workload and low code scalability and maintainability.
It uses JSON/XML field formatting rules and SQL statement dynamic creation rules to configure and store dynamic form fields. By defining initial database fields and SQL statement dynamic creation rules, it completes the dynamic association and storage of target forms and target fields, and renders and validates them on the HTML page.
It improves the flexibility of field configuration and form generation, reduces repetitive work for developers, increases software development efficiency, and enhances code scalability and maintainability.
Smart Images

Figure CN114911775B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, and in particular relates to a method and system for configuring and storing dynamic forms and fields. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] The remote consultation platform uploads the patient's basic information, preliminary diagnosis, and imaging data to the network. Experts then access the patient's information online to make corresponding diagnoses, addressing issues such as the uneven distribution of medical resources. The consultation platform is deployed on a cloud platform, connecting different hospitals (the consultation initiating end) and experts (the diagnosis result issuing end). In practical use, different hospitals and third-party testing institutions have different requirements for patient information and formats. With social development and the improvement of people's living standards, the demand for veterinary pathology is gradually emerging, making it particularly important for the remote consultation platform to adapt to various needs.
[0004] When deploying a remote consultation platform, all clients use the same program. To meet the different needs of clients, the traditional approach is to add new methods or comment out related code. For example, if hospital A needs to use the name field in method C, then method C is modified to add code to read the name field. However, if hospital B does not need to use the name field, then the name field often needs to be commented out or hospital B's method C needs to be modified to meet the client's requirements. The traditional approach involves writing multiple sets of code to provide customized services, which results in a large workload for the platform and low code scalability and maintainability. Summary of the Invention
[0005] To address the varying requirements for patient information and formats from different hospitals, laboratories, or veterinary pathologists in remote consultation platforms, this invention provides a method and system for dynamic form and field configuration and storage. Based on JSON / XML field formatting rules and SQL statement dynamic creation rules, it configures and stores dynamic form fields, enabling dynamic form rendering and interaction, improving the flexibility of field configuration and form generation, and solving the problems of high workload and low code scalability and maintainability in existing platforms.
[0006] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:
[0007] The first aspect of this invention provides a method for configuring and storing dynamic forms and fields;
[0008] A method for configuring and storing dynamic forms and fields, including:
[0009] Define the initial fields of the database, define the field format rules and the rules for dynamically creating SQL statements, and complete the creation of preconditions;
[0010] Define the target fields to be added or modified using field formatting rules, and use SQL statements to dynamically create rules to complete the dynamic association and storage of the target form and target fields;
[0011] Retrieve all field data from the target form, parse each field into HTML tags, render it into an HTML page, validate the user's input on the HTML tags, and dynamically create rules for valid input using SQL statements to save them to the database.
[0012] Furthermore, the field format rules are in JSON / XML format, including attributes such as field type, field name, field display name, validation rules, and database type.
[0013] Furthermore, the SQL statement dynamic creation rules include SQL statement templates for adding fields, modifying field types, querying fields, deleting fields, and adding data.
[0014] Furthermore, to add or modify target fields, the values of the corresponding attributes are supplemented according to the attributes in the field format rules to obtain the target field information in JSON / XML format.
[0015] Furthermore, the dynamic association storage of the target form and target fields involves using SQL statements to query fields to retrieve all fields of the target form stored in the database, determining whether the target field is included, and if it exists, updating the database information of the target field using SQL statements to modify the field type, delete the field, and add the field; if it does not exist, saving the target field using SQL statements to add the field, and storing the association relationship between the target form and the target field.
[0016] Furthermore, based on the association between the target form and the target fields, all field data of the target form are obtained;
[0017] The data for each field is parsed into HTML tags according to the field type, field name, field display name, validation rules, and database type attributes in the field format rules.
[0018] Furthermore, the user's input on the HTML tags is validated according to the validation rules in the field format rules.
[0019] A second aspect of the present invention provides a system for dynamic forms, field configuration, and storage.
[0020] A system for configuring and storing dynamic forms and fields, including a precondition creation module, a dynamic form field storage module, and a dynamic form rendering and interaction module;
[0021] The precondition creation module is configured to: define initial database fields, define field format rules and SQL statement dynamic creation rules, and complete the precondition creation;
[0022] The dynamic form field storage module is configured to: define the target fields to be added or modified using field format rules, and dynamically create rules using SQL statements to complete the dynamic association and storage of the target form and target fields;
[0023] The dynamic form rendering and interaction module is configured to: obtain all field data of the target form, parse each field into HTML tags, render it into an HTML page, validate the user's input on the HTML page according to the field format rules, and dynamically create rules for validated input using SQL statements and save them to the database.
[0024] A third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps of a method for configuring and storing dynamic forms and fields as described in the first aspect of the present invention.
[0025] A fourth aspect of the present invention provides an electronic device including a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a method for configuring and storing dynamic forms and fields as described in the first aspect of the present invention.
[0026] The above one or more technical solutions have the following beneficial effects:
[0027] The method for dynamic form and field configuration and storage proposed in this invention is based on JSON / XML field formatting rules and SQL statement dynamic creation rules. It stores dynamic fields and associated target forms in the database to achieve dynamic management of form fields. The rendering and interaction of the target form are achieved by dynamically parsing and rendering the associated fields obtained from the database.
[0028] This dynamic form, field configuration, and storage method improves the flexibility of field configuration and form generation, reduces the workload of developers in repetitive development, improves software development efficiency, and solves the problems of large workload and low code scalability and maintainability of existing platforms.
[0029] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0030] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0031] Figure 1 This is a prerequisite for the first embodiment;
[0032] Figure 2 This is a flowchart of the dynamic form field storage process in the first embodiment;
[0033] Figure 3 The form data for the first embodiment;
[0034] Figure 4 A flowchart illustrating the dynamic form rendering interaction process in the first embodiment;
[0035] Figure 5 This refers to the field data in the first embodiment;
[0036] Figure 6 This is a system structure diagram of the second embodiment. Detailed Implementation
[0037] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of this disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains.
[0038] It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations according to this disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus.
[0039] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0040] Example 1
[0041] This embodiment discloses a method for configuring and storing dynamic forms and fields;
[0042] A method for configuring and storing dynamic forms and fields, including:
[0043] Step 1: Define the initial database fields, define the field formatting rules and SQL statement dynamic creation rules, and complete the creation of preconditions, such as... Figure 1 As shown.
[0044] Prerequisite 1: Define initial database fields F, such as: name, gender, age.
[0045] Precondition 2: Define field format rule H, which is in JSON / XML format, for example:
[0046] {
[0047] type:'input',
[0048] name:'Name',
[0049] key:'input_name',
[0050] rules:[{
[0051] required: false,
[0052] message:'Required field'
[0053] regular:'^[A-Za-z0-9]{4,40}$'
[0054] }],
[0055] datatype:'vachar(50)'
[0056] }
[0057] Precondition 3: Define the SQL statement dynamic creation rule G, which is the SQL statement template, and it is further divided into:
[0058] Prerequisite 3.1: Add a field
[0059] ALTER TABLE table_name ADD COLUMN 'field_name' Field type default value;
[0060] Precondition 3.2: Modify field type
[0061] ALTER TABLE table_name ALTER COLUMN 'field_name' new field type;
[0062] Precondition 3.3: Query Fields
[0063] SELECT*FROM information_schema.COLUMNS WHERE table_name='table name';
[0064] Precondition 3.4: Deleting a field
[0065] ALTER TABLE table_name DROP COLUMN 'column_name';
[0066] Prerequisite 3.5: Adding data
[0067] INSERT INTO table_name('field_name1','field_name2', ...) VALUES('field1 value','field2 value', ...).
[0068] Step 2: Define the target fields to be added or modified using field formatting rules, and use SQL statements to dynamically create rules to complete the dynamic association and storage of the target form and target fields;
[0069] Use SQL statements to query fields to retrieve all fields of the target form stored in the database. Determine if the target field is included. If it exists, update the database information of the target field using SQL statements to modify the field type, delete the field, and add the field. If it does not exist, save the target field using SQL statements to add the field and store the association between the target form and the target field.
[0070] A specific application scenario involves administrators configuring and storing dynamic form fields on the form field configuration page of the consultation platform, such as... Figure 2 As shown, the specific steps are as follows:
[0071] Step 2-1: Open the consultation platform form field configuration page. When the form field information changes, click the save button. Define the fields to be added or modified according to field format rule H, and obtain the current form's JSON / XML structure data, such as... Figure 3 As shown, the added or modified field information and the current form data are sent to the server via an HTTP request;
[0072] Step 2-2: After receiving the field information and form information, the server calls different JSON or XML parsing methods to parse the field information and form information into a collection of field objects M and a form object U, respectively.
[0073] Steps 2-3: Dynamically create the preconditions in rule G using SQL statements. 3.3 Query method to obtain the list of field information R in the database table;
[0074] Steps 2-4: Iterate through the field object collection M using a for loop, setting i = 0;
[0075] Step 2-4-1: Assume z = M[i], compare z.key with the data R in the table, and determine whether z.key exists in R. If it exists, go to step 2-4-2; otherwise, go to step 2-4-3.
[0076] Step 2-4-2: Dynamically create the precondition 3.3 in rule G based on the SQL statement to obtain the field type of z.key in R. Check whether the datatype of the z field in R is consistent with the type in M. If they are consistent, go to step 2-4-4; if they are inconsistent, dynamically create the precondition 3.2 in rule G based on the datatype of z in M and dynamically modify the SQL table field type using the SQL statement. Go to step 2-4-4.
[0077] Step 2-4-3: Dynamically create the preconditions in rule G using SQL statements. 3.1 Add method: Add z to the database table, then go to step 2-4-4;
[0078] Step 2-4-4: Based on the field name and field type of z in M, determine whether the form type of z is a drop-down list. If yes, go to step 2-4-4-1; otherwise, go to step 2-4-5.
[0079] Step 2-4-4-1: Obtain the data dictionary table values from the database;
[0080] Step 2-4-4-2: Iterate through z's options, and set j = 0;
[0081] Step 2-4-4-3: Determine if each option value in z[j] exists in the table. If it does not exist, dynamically create the precondition 3.5 in rule G through SQL statement and add the data rule to the data dictionary table, then proceed to step 2-4-4-4; if it exists, then directly proceed to step 2-4-4-4.
[0082] Step 2-4-4-4: j++, if j is less than or equal to the length of z's options, go to step 2-4-4-3 to continue the loop, if j is greater than the length of z's options, end the loop and go to step 2-4-5;
[0083] Steps 2-4-5: Delete the corresponding field from R based on z.key, increment i, if i is less than or equal to the length of M, go to step 4.1 and continue the loop, if i is greater than the length of M, end the loop and go to step 5;
[0084] Step 2-5: Determine if the remaining length of R is greater than 0. If it is equal to 0, proceed to step 2-6; if it is greater than 0, iterate through R and delete the corresponding columns from the data table using the precondition 3.4 deletion method in rule G through SQL statement, and then proceed to step 2-6.
[0085] Steps 2-6: After the fields are stored, update M in the dynamic form data table of the database according to the form object U. The storage of dynamic forms and fields is then complete.
[0086] Step 3: Obtain all field data of the target form, parse each field into HTML tags, render it into an HTML page, validate the user's input on the HTML tags, and dynamically create rules for the validated input using SQL statements to save it to the database.
[0087] Based on the relationship between the target form and the target fields, retrieve all field data from the target form. For each field, parse the data into HTML tags according to the field type, field name, field display name, validation rules, and database type attributes specified in the field formatting rules. Then, validate the user's input within the HTML tags according to the validation rules in the field formatting rules.
[0088] The specific application scenario is after the administrator has configured the dynamic forms and fields using the method in step 2, such as... Figure 4 As shown, the specific steps for dynamic form rendering interaction are as follows:
[0089] Step 3-1: Open the consultation platform, obtain the current form object U based on the entered page, and the browser W initiates an HTTP request to obtain the JSON / XML structure data of the current form based on U, such as... Figure 3 As shown, based on the association between the target form and the target fields, all field data of the current form is retrieved. The JSON / XML structured data is as follows: Figure 5 As shown;
[0090] Step 3-2: After the browser obtains the form data and field data, it iterates through the obtained form JSON / XML structure to retrieve information such as the type, tag, style, and validation rules of each field, and renders it into HTML page tags based on this information. For example, for input fields, it renders... <input key=""value=""> The tag is loaded into the HTML page as each tag is rendered, and then proceeds to step 3-3 after completion;
[0091] Step 3-3: After the user enters information on the page and clicks save, retrieve all tag content T in the template, loop through and validate each value of T, and perform a validity check on it according to the validation rules. If it does not meet the requirements, exit the loop and prompt the user that it is invalid, and proceed to step 3-8; if all the validation rules are met, proceed to step 3-4.
[0092] Step 3-4: Send content T to the server via browser W, call different JSON or XML parsing methods to parse content T into a collection of field objects M and a form object U, save M to the database using the data addition method in rule G's precondition 3.5, update the collection of field objects M, return the success result and M to browser W, and proceed to step 3-5;
[0093] Steps 3-5: Browser W prompts the user that the operation was successful. After obtaining the collection of field objects, browser W iterates through M and sets e = 0.
[0094] Steps 3-6: Using M[e].key, match tags in the HTML page that have the same M[e].key, and write the value of M[e] back to the tag's value;
[0095] Step 3-7: e++, if e is less than or equal to the length of M, go to step 3-6 to continue page rendering, if e is greater than the length of M, end the loop and go to step 3-8;
[0096] Steps 3-8: Dynamic form rendering interaction ends.
[0097] Example 2
[0098] This embodiment discloses a system for dynamic forms, field configuration, and storage;
[0099] like Figure 6 As shown, a system for configuring and storing dynamic forms and fields includes a precondition creation module, a dynamic form field storage module, and a dynamic form rendering and interaction module.
[0100] The precondition creation module is configured to: define initial database fields, define field format rules and SQL statement dynamic creation rules, and complete the precondition creation;
[0101] The dynamic form field storage module is configured to: define the target fields to be added or modified using field format rules, and dynamically create rules using SQL statements to complete the dynamic association and storage of the target form and target fields;
[0102] The dynamic form rendering and interaction module is configured to: obtain all field data of the target form, parse each field into HTML tags, render it into an HTML page, validate the user's input on the HTML page according to the field format rules, and dynamically create rules for validated input using SQL statements and save them to the database.
[0103] Example 3
[0104] The purpose of this embodiment is to provide a computer-readable storage medium.
[0105] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of a method for configuring and storing dynamic forms and fields as described in Embodiment 1 of this disclosure.
[0106] Example 4
[0107] The purpose of this embodiment is to provide an electronic device.
[0108] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a method for configuring and storing dynamic forms and fields as described in Embodiment 1 of this disclosure.
[0109] The steps and methods involved in the apparatuses of Embodiments 2, 3, and 4 above correspond to those in Embodiment 1. For specific implementation details, please refer to the relevant description section of Embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood as including any medium capable of storing, encoding, or carrying an instruction set for execution by a processor and enabling the processor to perform any of the methods in this invention.
[0110] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computer device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. The present invention is not limited to any particular combination of hardware and software.
[0111] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method for configuring and storing dynamic forms and fields, characterized in that, include: Define the initial fields of the database, define the field format rules and the rules for dynamically creating SQL statements, and complete the creation of preconditions; Define the target fields to be added or modified using field formatting rules, and use SQL statements to dynamically create rules to complete the dynamic association and storage of the target form and target fields; The target form and target field are dynamically associated and stored. The SQL statement for querying the field is used to retrieve all fields of the target form stored in the database. It is then determined whether the target field is included. If it exists, the database information of the target field is updated using SQL statements for modifying the field type, deleting the field, and adding the field. If it does not exist, the target field is saved using the SQL statement for adding the field, and the association between the target form and the target field is stored. The field format rules are in JSON / XML format and include attributes such as field type, field name, field display name, validation rules, and database type. Get all field data of the target form, traverse and parse each field into HTML tags, render it into an HTML page, validate the user's input content on the HTML tags, and use SQL statements to dynamically create rules for the validated input content and save them to the database. Based on the relationship between the target form and the target fields, obtain all field data of the target form; parse the data of each field into HTML tags according to the field type, field name, field display name, validation rules, and database type attributes in the field format rules; validate the user's input content on the HTML tags according to the validation rules in the field format rules.
2. The method for configuring and storing dynamic forms and fields as described in claim 1, characterized in that, The SQL statement dynamic creation rules include SQL statement templates for adding fields, modifying field types, querying fields, deleting fields, and adding data.
3. The method for configuring and storing dynamic forms and fields as described in claim 1, characterized in that, To add or modify a target field, supplement the corresponding attribute values according to the attributes in the field format rules to obtain the target field information in JSON / XML format.
4. A system for dynamic form, field configuration, and storage, characterized in that: It includes a precondition creation module, a dynamic form field storage module, and a dynamic form rendering and interaction module; The precondition creation module is configured to: define initial database fields, define field format rules and SQL statement dynamic creation rules, and complete the precondition creation; The dynamic form field storage module is configured to: define the target fields to be added or modified using field format rules, and dynamically create rules using SQL statements to complete the dynamic association and storage of the target form and target fields; The target form and target field are dynamically associated and stored. The SQL statement for querying the field is used to retrieve all fields of the target form stored in the database. It is then determined whether the target field is included. If it exists, the database information of the target field is updated using SQL statements for modifying the field type, deleting the field, and adding the field. If it does not exist, the target field is saved using the SQL statement for adding the field, and the association between the target form and the target field is stored. The field format rules are in JSON / XML format and include attributes such as field type, field name, field display name, validation rules, and database type. The dynamic form rendering and interaction module is configured to: retrieve all field data of the target form, parse each field into HTML tags, render it into an HTML page, validate user input on the HTML page according to field format rules, dynamically create rules for validated input using SQL statements and save them to the database, retrieve all field data of the target form based on the association between the target form and the target fields; parse the data of each field into HTML tags according to the field type, field name, field display name, validation rules, and database type attributes in the field format rules; and validate user input on the HTML tags according to the validation rules in the field format rules.
5. A computer-readable storage medium having a program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method for configuring and storing dynamic forms and fields as described in any one of claims 1-3.
6. An electronic device, comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the method for configuring and storing dynamic forms and fields as described in any one of claims 1-3.
Citation Information
Patent Citations
Database processing method and device, storage medium and electronic equipment
CN111104409A
Code generation method of application program, code generator, electronic equipment and medium
CN114443035A