{"id":4467,"date":"2025-01-20T16:06:16","date_gmt":"2025-01-20T08:06:16","guid":{"rendered":"https:\/\/five.co\/?p=4467"},"modified":"2025-04-24T08:27:03","modified_gmt":"2025-04-24T00:27:03","slug":"transform-unstructured-data-into-structured-data","status":"publish","type":"post","link":"https:\/\/preview-php85.dzine.org\/five\/blog\/transform-unstructured-data-into-structured-data\/","title":{"rendered":"Using AI to Transform Unstructured Data Into Structured Data"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As developers, we often encounter unstructured data that needs to be stored in a structured format, such as in a relational database like MySQL. <strong>But how do we transform messy, unstructured data into organized, searchable records? <\/strong>Structuring data requires defining patterns and relationships, a process now simplified with AI and large language models (LLMs). These tools can interpret unstructured inputs and return neatly formatted data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we\u2019ll walk you through a straightforward 5-step process to convert raw unstructured data, such as text into structured data, and store it in a relational database.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div class=\"root-eb-toc-31ob0 wp-block-essential-blocks-table-of-contents\"><div class=\"eb-parent-wrapper eb-parent-eb-toc-31ob0 \"><div class=\"eb-toc-container eb-toc-31ob0  eb-toc-is-not-sticky eb-toc-not-collapsible eb-toc-initially-not-collapsed eb-toc-scrollToTop style-1 list-style-none\" data-scroll-top=\"false\" data-scroll-top-icon=\"fas fa-angle-up\" data-collapsible=\"false\" data-sticky-hide-mobile=\"false\" data-sticky=\"false\" data-scroll-target=\"scroll_to_toc\" data-copy-link=\"false\" data-editor-type=\"\" data-hide-desktop=\"false\" data-hide-tab=\"false\" data-hide-mobile=\"false\" data-itemcollapsed=\"false\" data-highlight-scroll=\"false\"><div class=\"eb-toc-header\"><h2 class=\"eb-toc-title\">Table of Contents<\/h2><\/div><div class=\"eb-toc-wrapper \" data-headers=\"[{&quot;level&quot;:2,&quot;content&quot;:&quot;Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database &quot;,&quot;text&quot;:&quot;Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database &quot;,&quot;link&quot;:&quot;learn-how-to-use-ai-to-transform-unstructured-data-and-store-it-in-a-relational-database&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Transform Unstructured Data to Structured Data: Sample Application&quot;,&quot;text&quot;:&quot;Transform Unstructured Data to Structured Data: Sample Application&quot;,&quot;link&quot;:&quot;transform-unstructured-data-to-structured-data-sample-application&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;How to Transform Unstructured Data to Structured Data: Tutorial&quot;,&quot;text&quot;:&quot;How to Transform Unstructured Data to Structured Data: Tutorial&quot;,&quot;link&quot;:&quot;how-to-transform-unstructured-data-to-structured-data-tutorial&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Recap: Transform Unstructured Data to Structured Data&quot;,&quot;text&quot;:&quot;Recap: Transform Unstructured Data to Structured Data&quot;,&quot;link&quot;:&quot;recap-transform-unstructured-data-to-structured-data&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Required Tools&quot;,&quot;text&quot;:&quot;Required Tools&quot;,&quot;link&quot;:&quot;required-tools&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Structuring Your Data For Better Data Management&quot;,&quot;text&quot;:&quot;Structuring Your Data For Better Data Management&quot;,&quot;link&quot;:&quot;structuring-your-data-for-better-data-management&quot;}]\" data-visible=\"[true,true,true,true,true,true]\" data-delete-headers=\"[{&quot;label&quot;:&quot;Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database &quot;,&quot;value&quot;:&quot;learn-how-to-use-ai-to-transform-unstructured-data-and-store-it-in-a-relational-database&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Transform Unstructured Data to Structured Data: Sample Application&quot;,&quot;value&quot;:&quot;transform-unstructured-data-to-structured-data-sample-application&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;How to Transform Unstructured Data to Structured Data: Tutorial&quot;,&quot;value&quot;:&quot;how-to-transform-unstructured-data-to-structured-data-tutorial&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Recap: Transform Unstructured Data to Structured Data&quot;,&quot;value&quot;:&quot;recap-transform-unstructured-data-to-structured-data&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Required Tools&quot;,&quot;value&quot;:&quot;required-tools&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Structuring Your Data For Better Data Management&quot;,&quot;value&quot;:&quot;structuring-your-data-for-better-data-management&quot;,&quot;isDelete&quot;:false}]\" data-smooth=\"true\" data-top-offset=\"\"><div class=\"eb-toc__list-wrap\"><ul class=\"eb-toc__list\"><li><a href=\"#learn-how-to-use-ai-to-transform-unstructured-data-and-store-it-in-a-relational-database\">Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database <\/a><li><a href=\"#transform-unstructured-data-to-structured-data-sample-application\">Transform Unstructured Data to Structured Data: Sample Application<\/a><li><a href=\"#how-to-transform-unstructured-data-to-structured-data-tutorial\">How to Transform Unstructured Data to Structured Data: Tutorial<\/a><li><a href=\"#recap-transform-unstructured-data-to-structured-data\">Recap: Transform Unstructured Data to Structured Data<\/a><ul class=\"eb-toc__list\"><li><a href=\"#required-tools\">Required Tools<\/a><li><a href=\"#structuring-your-data-for-better-data-management\">Structuring Your Data For Better Data Management<\/a><\/li><\/ul><\/ul><\/div><\/div><\/div><\/div><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Transform Unstructured Data to Structured Data: Sample Application<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we start, check out our <a href=\"https:\/\/default-aimednote-tryfive.5au.dev\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">sample application<\/a> for analyzing doctor&#8217;s notes. The application extracts prescriptions, dosage, and reasons for the prescription automatically from an unstructured note (a text input).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s how it works exactly:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The sample application accepts unstructured text input, such as this doctor&#8217;s note: <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\" \/* \nTo whom it may concern,\n\nJohn Doe was seen in my office today for complaints of mild seasonal allergies. He has been prescribed Loratadine 10 mg to be taken once daily for a period of 14 days.\n\nThe patient is advised to drink plenty of fluids and avoid allergens where possible. If symptoms persist beyond two weeks, a follow-up visit is recommended.\n\nThank you for your attention.\n*\/ \" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #7F848E; font-style: italic\">\/* <\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">To whom it may concern,<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">John Doe was seen in my office today for complaints of mild seasonal allergies. He has been prescribed Loratadine 10 mg to be taken once daily for a period of 14 days.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">The patient is advised to drink plenty of fluids and avoid allergens where possible. If symptoms persist beyond two weeks, a follow-up visit is recommended.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">Thank you for your attention.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">*\/<\/span><span style=\"color: #ABB2BF\"> <\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">It then transforms this text input into structured data stored in a MySQL database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can give this a go yourself:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Open the <a href=\"https:\/\/default-aimednote-tryfive.5au.co\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">sample application<\/a>.<br>2. Click on <strong>Doctor&#8217;s Notes &gt; Yellow Plus Button <\/strong>and <strong>fill in the form. <\/strong>Paste the doctor&#8217;s note from above into the large text box, as shown here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"387\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1024x387.png\" alt=\"\" class=\"wp-image-4468\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1024x387.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-300x113.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-768x290.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1536x581.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-2048x774.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">3. Next, click <strong>Generate<\/strong>. This sends the doctor&#8217;s note to OpenAI for analysis. <br>4. OpenAI returns a response, which is stored in a SQL database table which has five fields:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><em><strong>Date<\/strong><\/em>: This is automatically set to today&#8217;s date.<\/li>\n\n\n\n<li><em><strong>Doctor<\/strong><\/em>: This field stores the doctor&#8217;s name. <\/li>\n\n\n\n<li><em><strong>Reason<\/strong><\/em>: This field is populated by the AI&#8217;s response.<\/li>\n\n\n\n<li><em><strong>Prescription<\/strong><\/em>: This field is populated by the AI&#8217;s response.<\/li>\n\n\n\n<li><em><strong>Dosage<\/strong><\/em>: This field is populated by the AI&#8217;s response.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">5. To view the database record that now stores structured data, click <strong>Medical Info <\/strong>and select your record from the list. Here&#8217;s what the record for our sample doctor&#8217;s note now looks like:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"355\" src=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1-1024x355.png\" alt=\"\" class=\"wp-image-4469\" srcset=\"https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1-1024x355.png 1024w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1-300x104.png 300w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1-768x266.png 768w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1-1536x532.png 1536w, https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/image-1-2048x709.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">In short, through the use of AI, we went from a lengthy text input that didn&#8217;t have any structure to neat, structured data that we can now use for further analysis or reporting. For example, we could now create an email template that is automatically sent out to patients with just the reason, prescription, and dosage. Or we could write an SQL query to view the most prescribed medicine in the last 3 months. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once we&#8217;re dealing with structured data, we have much greater control over our data.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"background-color: #001524;\"><hr style=\"height: 5px;\" \/>\n<pre style=\"text-align: center; overflow: hidden; white-space: pre-line;\"><span style=\"color: #f1ebda; background-color: #4588d8; font-size: calc(18px + 0.390625vw);\"><strong>Build Your Own AI Application<\/strong><br \/><span style=\"font-size: 14pt;\">Rapidly build and deploy your application today<\/span><\/span><\/pre>\n<p style=\"text-align: center;\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\" target=\"_blank\" rel=\"noopener\"><button style=\"background-color: #f8b92b; border: none; color: black; padding: 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 18px; cursor: pointer; margin: 4px 2px; border-radius: 5px;\"><strong>Get Instant Access<\/strong><\/button><br \/><\/a><\/p>\n<hr style=\"height: 5px;\" \/><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How to Transform Unstructured Data to Structured Data: Tutorial<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To build an application like this, follow the steps below. The tool we are using is Five, a rapid application development environment that allows us to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Model a SQL database;<\/li>\n\n\n\n<li>Auto-generate a user interface; and<\/li>\n\n\n\n<li>Write JavaScript functions to invoke the AI agent.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Sign up for a <a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\">free trial of Five&#8217;s development environment.<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Model your database. <\/strong><br>If you&#8217;re not sure how to model a database in Five, follow <a href=\"https:\/\/preview-php85.dzine.org\/five\/blog\/creating-tables\/\" target=\"_blank\" rel=\"noreferrer noopener\">our series of blog posts on database modeling<\/a>. Remember, the database is what structures your data. So if you plan to extract three, five, or seven pieces of information from an unstructured input, you should have three, five, or seven database fields. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Create your user interface.<\/strong><br>All we need is a form. Use <a href=\"https:\/\/preview-php85.dzine.org\/five\/blog\/form-designer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Five&#8217;s Form Wizard<\/a> to do so. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. Add the JavaScript functions to prompt your LLM. <\/strong><br>We need two functions: one that runs on the client and one that runs on the server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The client-side function holds the fields sent to AI as variables. Here&#8217;s what our client-side function for the sample app above looks like:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function OpenaiClient(five, context, result)  {\n    const entry = five.field.Entry;\n    const date = five.field.Date;\n    const doctorName = five.field.DoctorName;\n\n    const variables = {};\n    variables[&quot;Entry&quot;] = entry;\n    variables[&quot;Date&quot;] = date;\n    variables[&quot;DoctorName&quot;] = doctorName;\n\n    five.executeFunction(&quot;OpenaiServer&quot;, variables, null, null, null, function (result) {\n\n    })\n\n\n    return five.success(result);\n}\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">OpenaiClient<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">five<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">context<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">)  {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">entry<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">field<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">Entry<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">date<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">field<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">Date<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">doctorName<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">field<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">DoctorName<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">variables<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> {};<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E06C75\">variables<\/span><span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #98C379\">&quot;Entry&quot;<\/span><span style=\"color: #ABB2BF\">] <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">entry<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E06C75\">variables<\/span><span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #98C379\">&quot;Date&quot;<\/span><span style=\"color: #ABB2BF\">] <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">date<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E06C75\">variables<\/span><span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #98C379\">&quot;DoctorName&quot;<\/span><span style=\"color: #ABB2BF\">] <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">doctorName<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">executeFunction<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;OpenaiServer&quot;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75\">variables<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">null<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">null<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">null<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> (<\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">) {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    })<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">success<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">result<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Attach the client-side function to the <strong>Generate <\/strong>button by triggering an <strong>On-Click <\/strong>event.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our server-side function does the heavy lifting and contains our AI prompt. Don&#8217;t forget to provide your API key in line 3.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function OpenaiServer(five, context, result)  {\n    five.log(&quot;Hello from backend&quot;);\n    const apiKey = 'Your API Key'\n    const client = five.httpClient();\n    client.addHeader(&quot;Authorization&quot;, `Bearer ${apiKey}`);\n    client.addHeader('Content-Type', 'application\/json');\n    client.setContentType(&quot;application\/json&quot;);\n\n    const messages = [\n        {\n            role: &quot;developer&quot;,\n            content: `You are a text scraper. Give me three JSON items: the medicine, the dosage, and the reason. Return the result as JSON.`,\n        },\n        {\n            role: &quot;user&quot;,\n            content: `${context.Entry}`,\n        },\n    ];\n\n    const parseData = {\n        model: &quot;gpt-4o&quot;,\n        messages: messages\n    }\n\n    client.setContent(JSON.stringify(parseData));\n\n    let results = client.post(&quot;https:\/\/api.openai.com\/v1\/chat\/completions&quot;)\n    const content = results.response.choices[0].message.content;\n    const jsonString = content.replace(\/```json\\n|\\n```\/g, '');\n    const parsedResponse = JSON.parse(jsonString);\n    const { medicine, dosage, reason } = parsedResponse;\n    const sql = &quot;INSERT INTO MedicalInfo (MedicalInfoKey, Prescription, Dosage, Reason, Date, Doctor) VALUES (?,?,?,?,?,?)&quot;;\n    five.executeQuery(sql, 0, five.uuid(), medicine, dosage, reason, five.now(), context.DoctorName);\n\n\n    return five.success(result);\n}\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">function<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">OpenaiServer<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75; font-style: italic\">five<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">context<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75; font-style: italic\">result<\/span><span style=\"color: #ABB2BF\">)  {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">log<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;Hello from backend&quot;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">apiKey<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Your API Key&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">client<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">httpClient<\/span><span style=\"color: #ABB2BF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">client<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">addHeader<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;Authorization&quot;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">`Bearer <\/span><span style=\"color: #C678DD\">${<\/span><span style=\"color: #E06C75\">apiKey<\/span><span style=\"color: #C678DD\">}<\/span><span style=\"color: #98C379\">`<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">client<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">addHeader<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39;Content-Type&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;application\/json&#39;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">client<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">setContentType<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;application\/json&quot;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">messages<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> [<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E06C75\">role<\/span><span style=\"color: #ABB2BF\">: <\/span><span style=\"color: #98C379\">&quot;developer&quot;<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E06C75\">content<\/span><span style=\"color: #ABB2BF\">: <\/span><span style=\"color: #98C379\">`You are a text scraper. Give me three JSON items: the medicine, the dosage, and the reason. Return the result as JSON.`<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        },<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E06C75\">role<\/span><span style=\"color: #ABB2BF\">: <\/span><span style=\"color: #98C379\">&quot;user&quot;<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #E06C75\">content<\/span><span style=\"color: #ABB2BF\">: <\/span><span style=\"color: #98C379\">`<\/span><span style=\"color: #C678DD\">${<\/span><span style=\"color: #E5C07B\">context<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">Entry<\/span><span style=\"color: #C678DD\">}<\/span><span style=\"color: #98C379\">`<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        },<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ];<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">parseData<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #E06C75\">model<\/span><span style=\"color: #ABB2BF\">: <\/span><span style=\"color: #98C379\">&quot;gpt-4o&quot;<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #E06C75\">messages<\/span><span style=\"color: #ABB2BF\">: <\/span><span style=\"color: #E06C75\">messages<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">client<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">setContent<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E5C07B\">JSON<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">stringify<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">parseData<\/span><span style=\"color: #ABB2BF\">));<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">let<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">results<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">client<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">post<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&quot;https:\/\/api.openai.com\/v1\/chat\/completions&quot;<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">content<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">results<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E5C07B\">response<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">choices<\/span><span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #D19A66\">0<\/span><span style=\"color: #ABB2BF\">].<\/span><span style=\"color: #E5C07B\">message<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">content<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">jsonString<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">content<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">replace<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">\/```json\\n<\/span><span style=\"color: #ABB2BF\">|<\/span><span style=\"color: #E06C75\">\\n```\/<\/span><span style=\"color: #C678DD\">g<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">parsedResponse<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">JSON<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">parse<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">jsonString<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> { <\/span><span style=\"color: #E5C07B\">medicine<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E5C07B\">dosage<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E5C07B\">reason<\/span><span style=\"color: #ABB2BF\"> } <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">parsedResponse<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">const<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">sql<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&quot;INSERT INTO MedicalInfo (MedicalInfoKey, Prescription, Dosage, Reason, Date, Doctor) VALUES (?,?,?,?,?,?)&quot;<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">executeQuery<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">sql<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">0<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">uuid<\/span><span style=\"color: #ABB2BF\">(), <\/span><span style=\"color: #E06C75\">medicine<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75\">dosage<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75\">reason<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">now<\/span><span style=\"color: #ABB2BF\">(), <\/span><span style=\"color: #E5C07B\">context<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #E06C75\">DoctorName<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">return<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E5C07B\">five<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #61AFEF\">success<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">result<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. Test the application. <\/strong><br>Once you&#8217;re done developing, remember to test the application so that it works as intended.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>Accelerate Your Development<\/strong>: <strong>If you get stuck at any of these steps, contact our team of developers by posting on our <a href=\"https:\/\/five.org\" rel=\"nofollow noopener\" target=\"_blank\">user community.<\/a><\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Recap: Transform Unstructured Data to Structured Data<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Required Tools<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To transform unstructured text data like a doctor\u2019s note into structured data suitable for a database, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Ingestion<\/strong>: Import the doctor&#8217;s note into a processing tool or application.<\/li>\n\n\n\n<li><strong>Text Parsing and Analysis<\/strong>: Use AI or natural language processing (NLP) to extract key fields such as prescription name, dosage, and duration.<\/li>\n\n\n\n<li><strong>Data Mapping<\/strong>: Match parsed data to predefined database columns.<\/li>\n\n\n\n<li><strong>Data Storage<\/strong>: Insert structured data into a relational database for querying and analysis.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Tools like Five simplify this process for rapid application development. With Five, you can build a simple AI-driven application that transforms unstructured data into structured data for any use case, industry, or field. Just follow the steps above.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Structuring Your Data For Better Data Management<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In conclusion, transforming unstructured data into structured data enables better organization, searchability, and analytical insights. Approaching this challenge with AI and low-code tools provides significant efficiencies in data processing, particularly for complex text like doctor\u2019s notes or business documents.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Key takeaways include leveraging natural language processing for data extraction, mapping information to predefined schemas, and ensuring data integrity within a relational database. Adopting structured storage solutions enhances decision-making, reporting, and automation. Ultimately, this approach empowers developers and organizations to unlock value from previously untapped data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database As developers, we often encounter unstructured data that needs to be stored in a structured format, such as in a relational database like MySQL. But how do we transform messy, unstructured data into organized, searchable records? Structuring data requires [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":4470,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[21],"tags":[],"class_list":["post-4467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"uagb_featured_image_src":{"full":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data.jpg",1280,720,false],"thumbnail":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data-150x150.jpg",150,150,true],"medium":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data-300x169.jpg",300,169,true],"medium_large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data-768x432.jpg",768,432,true],"large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data.jpg",1280,720,false],"2048x2048":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2025\/01\/Five.Co-Using-AI-to-Transform-Unstructured-Data-Into-Structured-Data.jpg",1280,720,false]},"uagb_author_info":{"display_name":"Dominik Keller","author_link":"https:\/\/preview-php85.dzine.org\/five\/author\/f1v5_ed3_my\/"},"uagb_comment_info":0,"uagb_excerpt":"Learn How to Use AI to Transform Unstructured Data and Store It In a Relational Database As developers, we often encounter unstructured data that needs to be stored in a structured format, such as in a relational database like MySQL. But how do we transform messy, unstructured data into organized, searchable records? Structuring data requires&hellip;","_links":{"self":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/4467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/comments?post=4467"}],"version-history":[{"count":0,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/4467\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media\/4470"}],"wp:attachment":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media?parent=4467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/categories?post=4467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/tags?post=4467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}