1. Miles Pickens
  2. dynaforms

Commits

Miles Pickens  committed 8ec733d

Added SQL files and more to the README and also added a README to the sql directory

  • Participants
  • Parent commits c0e225f
  • Branches master

Comments (0)

Files changed (2)

File README.md

View file
+# DynaForms Purpose and Goals
 The purpose is this project is to load form structure and other form settings from JSON, store that form structure and use it to present a list of available forms to the user.  The user will then submit their form entries to an endpoint which is assigned per form.  The primary goal for this project are:
-#1 To enable table driven form creation and form submittion capture
-#2 To be Offline by default (to accommodate when a Cellular Network or WiFi are not available.)
-
-[Example test endpoint here]
-[Example JSON return here]
+*1 To enable table driven form creation and form submittion capture
+*2 To be Offline by default (to accommodate when a Cellular Network or WiFi are not available.)
 
 This purpose of this project is to enable anyone to be able to incorporate this into their Android application. The purposes might include; Surveys, Report entry, Signature capture, and more.  
 
 The purpose for which the Author will be using this module is to enable Point of Care form entry for Nurses and Physicians when visiting Patients in their homes.  
+
+# Examples and endpoints to use for testing
+## Example test endpoint:
+https://www.myhospicecenter.com/app/v1/getforms
+
+##Example JSON return:
+[{"formsid":1,"title":"Who Are You?","category":"People","posturl":"https:\/\/www.myhospicecenter.com\/v1\/put_form","form_elementsid":1,"element_label":"Name","element_helptext":"Here is where you put your name","element_placeholder":"Bob","element_required":0,"element_validation":null,"elementtype":"EditText","elementoptions_id":null,"elementoptions_value":null,"elementoptions_name":null},.....]
+
+##Example Form submission endpoint: 
+https://www.myhospicecenter.com/app/v1/putform
+GET Method is used for form submission and the variables expected are:
+submitdata (JSON)
+createdate (Date of User Submission)
+username (Name of Submitter)
+If successful a JSON message will show you the inserted form entry id and also the data submitted
+example successful result: {"success":123,"submitted_data":{"submittedfield1":value,"submittedfield2":value...}}

File sql/README.md

View file
+# SQL Files
+Each file will hold the table structure and some example data
+forms.sql will hold a list of available forms
+form_elements.sql will hold a list of elements on each form and their structure
+form_element_options.sql will hold a list of options for some form elements which present options to the user (i.e. Dropdown menus, radios, checkboxes)
+form_submissions.sql will hold the form submissions
+
+# Example queries
+## this will be cleaned up but you should be able to get a general idea
+
+
+	public function get_forms()
+	{
+		$DB = $this->load->database("MHC", TRUE);
+		$DB->select("formsid, title, category, posturl, fe.id as form_elementsid, label as element_label, helptext as element_helptext,
+placeholder as element_placeholder, required as element_required, validation as element_validation, elementtype,
+feo.id as elementoptions_id,
+feo.[value] as elementoptions_value,
+feo.[name] as elementoptions_name");
+		$DB->from('forms as f');
+		$DB->join('form_elements as fe', 'f.id = fe.formsid');
+		$DB->join('form_element_options as feo', 'fe.id = feo.form_elementsid', 'left');
+		$DB->where('f.active', 1);
+		$DB->order_by('formsid, fe.id');
+		$query = $DB->get();
+		if($query->num_rows() > 0)
+		{
+			return $query->result_array();
+		}
+		else
+		{
+			return FALSE;
+		}
+
+	}
+
+	public function putFormSubmission($data)
+	{
+		$DB = $this->load->database("MHC", TRUE);
+		$DB->insert('form_submissions', $data);
+
+		return array('success' => $DB->insert_id(), 'submitted_data' => $data);
+	}