Skip to content
This repository was archived by the owner on May 10, 2022. It is now read-only.

GSoC2018 report generator #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7c71034
Adding migrations and models for report generator tables
Trodrige May 26, 2018
3db8a1b
An attempt to add Factories and seeders for the report generator. Add…
Trodrige May 28, 2018
b62f74a
Added the junction table for report format and draggable component re…
Trodrige Jun 4, 2018
ff73094
display draggable components
Trodrige Jun 6, 2018
eae3984
Getting the option IDs of selected components
Jun 11, 2018
2fc50a5
Sending CSRF header and getting response from controller
Jun 12, 2018
84cb384
corrected previous PR. Added command to create two laravel-ehr databases
Trodrige Jun 14, 2018
2e6ac8d
An attempt to get data from selected columns, and send to views
Trodrige Jun 17, 2018
33fc9c7
Attempt to retrieve data
Trodrige Jun 22, 2018
8536b8a
cleaned showReport function, and sending data to view
Trodrige Jun 23, 2018
8d4896c
attempt to display rendered data in the view
Trodrige Jun 23, 2018
eae851d
Displaying rendered data
Trodrige Jun 25, 2018
877388b
Add new system feature
Trodrige Jul 1, 2018
b1cb778
Adding ability to save report format. Adding entries to join table
Trodrige Jul 2, 2018
780e21a
Updating instruction.txt to show Libre EHR Db configurations
Trodrige Jul 2, 2018
8e281b5
Merging install and instruction files in README file
Trodrige Jul 5, 2018
83de3ee
dumping test data for features and report formats
Trodrige Jul 5, 2018
6b70601
updating and deleting system features
Trodrige Jul 16, 2018
c932ea5
Delete report format
Trodrige Jul 16, 2018
4558a47
Edit report format title and description
Trodrige Jul 20, 2018
29bbb2b
View existing report from selected report format
Trodrige Jul 20, 2018
00a4f22
hiding save report format button when showing existing report
Trodrige Jul 23, 2018
bc024c6
Adding pdf_report.php for PDF generation function
Trodrige Jul 27, 2018
7f33e3f
sending for columns for use in pdf generation
Trodrige Jul 28, 2018
ecc9ebc
keeping all draggable components in drop box and draggable pool.
Trodrige Aug 3, 2018
2320022
--amend
Trodrige Aug 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Documentation/instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Instructions:
5. Navigate to lh-ehr-laravel-port directory
'cd lh-ehr-laravel-port'

6. Add you .env file by running this command: 'cp .env.example .env'
6. Add your .env file by running this command: 'cp .env.example .env'

7. Add your .env file to .gitignore filename. // It is already, just check!
7. Add your .env file to .gitignore filename. // It is already there, just check!

8. Generate key for your application by running the command below
'php artisan key:generate'
Expand All @@ -57,7 +57,8 @@ Instructions:
'php artisan migrate'

12. You can seed the database width
'php artisan db:seed'
'php artisan db:seed' // This shouldn't work for now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obviously a WIP comment. Making a comment here just so we make sure to check for these when it is final review time.

If seeding fails, then use the librereportgenerator.sql file in this directory to import sample data.

13. Start the application by running the command below in the terminal:
'php artisan serve'
Expand Down
49 changes: 49 additions & 0 deletions Documentation/librereportgenerator.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Use this file to seed the Report generator for now.
--
-- Database: `librereportgenerator`
--
-- --------------------------------------------------------
--
-- Dumping data for table `draggable_components`
--
INSERT INTO `draggable_components` (`id`, `option_id`, `is_default`, `user`, `title`, `order`, `active`, `notes`, `toggle_sort`, `toggle_display`, `created_at`, `updated_at`) VALUES
(1, 'pfullname', 1, 'default', 'Patient Fullname', 5, 1, 'patient_data:fname|mname|lname', 0, 0, NULL, NULL),
(2, 'plfname', 1, 'default', 'Patient Last Firstname', 10, 1, 'patient_data:lname|fname', 0, 0, NULL, NULL),
(3, 'pflname', 1, 'default', 'Patient First Lastname', 15, 1, 'patient_data:fname|lname', 0, 0, NULL, NULL),
(4, 'preversedname', 1, 'default', 'Patient Full reversed name', 20, 1, 'patient_data:lname|mname|fname', 0, 0, NULL, NULL),
(5, 'pfmname', 1, 'default', 'Patient First Middlename', 25, 1, 'patient_data:fname|mname', 0, 0, NULL, NULL),
(6, 'pid', 1, 'default', 'Patient Id', 30, 1, 'patient_data:id', 0, 0, NULL, NULL),
(7, 'pstreet', 1, 'default', 'Patient Street', 35, 1, 'patient_data:street', 0, 0, NULL, NULL),
(8, 'pcity', 1, 'default', 'Patient First Lastname', 40, 1, 'patient_data:city', 0, 0, NULL, NULL),
(9, 'pstate', 1, 'default', 'Patient Full reversed name', 45, 1, 'patient_data:lname|mname|fname', 0, 0, NULL, NULL),
(10, 'pstreetcity', 1, 'default', 'Patient Street City', 50, 1, 'patient_data:street|city', 0, 0, NULL, NULL),
(11, 'pcitystate', 1, 'default', 'Patient City State', 55, 1, 'patient_data:city|state', 0, 0, NULL, NULL),
(12, 'pstreetcitystate', 1, 'default', 'Patient Street City State', 60, 1, 'patient_data:street|city|state', 0, 0, NULL, NULL),
(13, 'ppcode', 1, 'default', 'Patient Postal Code', 65, 1, 'patient_data:postal_code', 0, 0, NULL, NULL),
(14, 'poccupation', 1, 'default', 'Patient Occupation', 70, 1, 'patient_data:occupation', 0, 0, NULL, NULL),
(15, 'pemail', 1, 'default', 'Patient Email', 75, 1, 'patient_data:email', 0, 0, NULL, NULL),
(16, 'pphone', 1, 'default', 'Patient Phone Contact', 80, 1, 'patient_data:phone_contact', 0, 0, NULL, NULL),
(17, 'planguage', 1, 'default', 'Patient Language', 85, 1, 'patient_data:language', 0, 0, NULL, NULL),
(18, 'pregdate', 1, 'default', 'Patient Register date', 90, 1, 'patient_data:regdate', 0, 0, NULL, NULL),
(19, 'psex', 1, 'default', 'Patient Sex', 95, 1, 'patient_data:sex', 0, 0, NULL, NULL),
(20, 'pemailphone', 1, 'default', 'Patient Email Phone', 100, 1, 'patient_data:email|phone_contact', 0, 0, NULL, NULL),
(21, 'pidfullname', 1, 'default', 'Patient PID Fullname', 105, 1, 'patient_data:id|fname|mname|lname', 0, 0, NULL, NULL),
(22, 'pdob', 1, 'default', 'Patient Date of birth', 110, 1, 'patient_data:DOB', 0, 0, NULL, NULL),
(23, 'pss', 1, 'default', 'Patient SS', 115, 1, 'patient_data:ss', 0, 0, NULL, NULL),
(24, 'pstatus', 1, 'default', 'Patient Status', 120, 1, 'patient_data:status', 0, 0, NULL, NULL),
(25, 'preferrer', 1, 'default', 'Patient Referrer', 125, 1, 'patient_data:referrer', 0, 0, NULL, NULL),
(26, 'pstatussex', 1, 'default', 'Patient Status Sex', 130, 1, 'patient_data:status|sex', 0, 0, NULL, NULL),
(27, 'pidnamecontact', 1, 'default', 'Patient ID Name Contact', 135, 1, 'patient_data:id|fname|mname|phone_contact|email', 0, 0, NULL, NULL),
(28, 'pidnameAddress', 1, 'default', 'Patient ID Name Address', 140, 1, 'patient_data:id|fname|mname|street|city|state|postal_code', 0, 0, NULL, NULL),
(29, 'poccupationmonthlyincome', 1, 'default', 'Patient Occupation Monthly Income', 145, 1, 'patient_data:occupation|monthly_income', 0, 0, NULL, NULL),
(30, 'psexstatusfamilysize', 1, 'default', 'Patient Sex Status Family Size', 150, 1, 'patient_data:sex|status|family_size', 0, 0, NULL, NULL);

-- --------------------------------------------------------

--
-- Dumping data for table `report_formats`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take dump of whole database. What if user do not run migrations or somehow migration fails? He/she do not know your table structure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took these when I had no entries for report_formats, and system features in the database. I'll populate those tables with some entries and dump again!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that you are taking dump of one table draggable_components. Instead take dump of whole database librereportgenerator. I think now I'm clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get you!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I export the entire database, then it'll have CREATE TABLE xyz, and migration command takes care of creating tables.
We need only the INSERT sql statements in this file.

--

Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* This file creates draggable_components for the report-generator.
* This is close to the list_options table, but this one if for the report generator module.
*
* TODO Link this table to users table in order to keep track of user adding or editing a component.
*
* Copyright 2018 Tigpezeghe Rodrige K. <[email protected]>
*/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Expand All @@ -8,10 +16,6 @@ class CreateDraggableComponentsTable extends Migration
{
/**
* Run the migrations.
* This file creates draggable_components for the report-generator.
* This is close to the list_options table, but this one if for the report generator module.
*
* TODO Link this table to users table in order to keep track of user adding or editing a component.
*
* @author Tigpezeghe Rodrige K. <[email protected]> (2018)
*
Expand All @@ -27,7 +31,7 @@ public function up()
$table->string('title', 255)->comment = "This is the text on the component that end users see.";
$table->integer('order', 0)->comment = "The order in which components appear in the list.";
$table->boolean('active')->default(1)->comment = "0 -> False, 1 -> True whether the component should be active or not.";
$table->json('notes', 255)->comment = "This stores the fields that the component relates to in the database.";
$table->string('notes', 1000)->comment = "This stores the fields that the component relates to in the database.";
$table->boolean('toggle_sort')->default(0)->comment = "0 -> False (Descending), 1 -> True (Ascending).";
$table->boolean('toggle_display')->default(0)->comment = "0 -> False, 1 -> True. Display field if checked (1), and no if unchecked (0).";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/**
* This file creates draggable_components for the report-generator.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be "This file created report_format for report-generator." . Just a guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked!

* This is close to the list_options table, but this one if for the report generator module.
*
* TODO Link this table to users table in order to keep track of user adding or editing a component.
*
* Copyright 2018 Tigpezeghe Rodrige K. <[email protected]>
*/
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
Expand All @@ -8,10 +15,6 @@ class CreateReportFormatsTable extends Migration
{
/**
* Run the migrations.
* This file creates draggable_components for the report-generator.
* This is close to the list_options table, but this one if for the report generator module.
*
* TODO Link this table to users table in order to keep track of user adding or editing a component.
*
* @author Tigpezeghe Rodrige K. <[email protected]> (2018)
*
Expand All @@ -25,7 +28,7 @@ public function up()
$table->string('title', 255)->comment = "This is the report name e.g Patient List.";
$table->string('system_feature', 255)->comment = "The system feature under which the report belongs.";
$table->text('description')->comment = "This describes the report format briefly.";
$table->json('draggable_components_id')->comment = "This stores the id of all the components that belong to this report format";
//$table->string('draggable_components_id', 1000)->comment = "This stores the id of all the components that belong to this report format";

$table->timestamps();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these names are for WIP versioning for now, or are they intended to serve in a meaningful way to version components later?

Copy link
Collaborator Author

@Trodrige Trodrige Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aethelwulffe that's the Laravel convention. I am trying to make the table names as obvious as possible.

/**
* This file creates a join or junction table between Report formats and Draggable components.
* This table is used to handle the many-to-many relationship between both tables.
*
* Copyright 2018 Tigpezeghe Rodrige K. <[email protected]>
*/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDraggableComponentReportFormatTable extends Migration
{
/**
* Run the migrations.
*
* @author Tigpezeghe Rodrige K. <[email protected]> (2018)
*
* @return void
*/
public function up()
{
Schema::connection('mysql_report_generator')->create('draggable_component_report_format', function (Blueprint $table) {
$table->increments('id')->comment = "Primary key.";
$table->integer('draggable_component_id')->unsigned()->comment = "Used to access the draggable_components.";
$table->foreign('draggable_component_id')->references('id')->on('draggable_components');
$table->integer('report_format_id')->unsigned()->comment = "Ussed to access the report_formats.";
$table->foreign('report_format_id')->references('id')->on('report_formats');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be something, that what happens if it is deleted. Like onDelete('cascade').

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked!

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('draggable_component_report_format');
}
}
11 changes: 11 additions & 0 deletions Modules/ReportGenerator/Entities/DraggableComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Modules\ReportGenerator\Entities;

use Illuminate\Database\Eloquent\Model;
use Modules\ReportGenerator\Entities\ReportFormat as ReportFormat;

class DraggableComponent extends Model
{
Expand All @@ -32,4 +33,14 @@ class DraggableComponent extends Model
* @var string
*/
protected $connection = 'mysql_report_generator';

/**
* The report formats that belong to the Draggable component.
*
* @return Response
*/
public function report_formats()
{
return $this->belongsToMany('ReportFormat')->withTimestamps();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the naming convention for many-to-one, one-to-many elements. Nice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the beauty of Laravel!

}
}
12 changes: 12 additions & 0 deletions Modules/ReportGenerator/Entities/ReportFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Modules\ReportGenerator\Entities;

use Illuminate\Database\Eloquent\Model;
use Modules\ReportGenerator\Entities\DraggableComponent as DraggableComponent;

class ReportFormat extends Model
{
Expand All @@ -32,4 +33,15 @@ class ReportFormat extends Model
* @var string
*/
protected $connection = 'mysql_report_generator';

/**
* The draggable components that belong to the Report Format.
*
* @return Response
*/
public function draggable_components()
{
return $this->belongsToMany('DraggableComponent')->withTimestamps();
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<?php
/*
|--------------------------------------------------------------------------
| Report generator controller.
|--------------------------------------------------------------------------
|
| This is the main controller for this report generator module.
| Copyright 2018 Tigpezeghe Rodrige K. <[email protected]>
|
*/

namespace Modules\ReportGenerator\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;

use Modules\ReportGenerator\Entities\DraggableComponent as DraggableComponent;

class ReportGeneratorController extends Controller
{
/**
Expand All @@ -14,7 +25,16 @@ class ReportGeneratorController extends Controller
*/
public function index()
{
return view('reportgenerator::index');
$draggableComponents = DraggableComponent::all();

return view('reportgenerator::index')->with('draggableComponents', $draggableComponents);

/* foreach ($draggableComponents as $draggableComponent) {
print_r($draggableComponent->title);
echo '<br>';
}

return view('reportgenerator::index'); */
}

/**
Expand Down
35 changes: 9 additions & 26 deletions Modules/ReportGenerator/Resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body" id="second">
<p class="note">Why am I stil empty?</p>
<p class="note">Why am I still empty?</p>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the same way. 😸

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is my still empty? 🍷

</div>
</div>
</div>
Expand All @@ -96,31 +96,14 @@
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<p class="note">Frequently used columns</p>
<div class="row">
<div class="col-sm-3" id="draggable"><p>I am one</p></div>
<div class="col-sm-3" id="draggable"><p>I am two</p></div>
<div class="col-sm-3" id="draggable"><p>I am three</p></div>
<div class="col-sm-3" id="draggable"><p>I am four</p></div>
</div>
<div class="row">
<div class="col-sm-3" id="draggable"><p>I am five</p></div>
<div class="col-sm-3" id="draggable"><p>I am six</p></div>
<div class="col-sm-3" id="draggable"><p>I am seven</p></div>
<div class="col-sm-3" id="draggable"><p>I am eight</p></div>
</div>
<hr />
<p class="note">All columns that concern reports</p>
<div class="row">
<div class="col-sm-3" id="draggable"><p>I am one</p></div>
<div class="col-sm-3" id="draggable"><p>I am two</p></div>
<div class="col-sm-3" id="draggable"><p>I am three</p></div>
<div class="col-sm-3" id="draggable"><p>I am four</p></div>
</div>
<div class="row">
<div class="col-sm-3" id="draggable"><p>I am five</p></div>
<div class="col-sm-3" id="draggable"><p>I am six</p></div>
<div class="col-sm-3" id="draggable"><p>I am seven</p></div>
<div class="col-sm-3" id="draggable"><p>I am eight</p></div>
<div class="row" id="draggable-column">
@foreach ($draggableComponents as $draggableComponent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good use of foreach to write compact code. 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreach is indeed a beautiful construct. One that sometimes leaves me thinking "My code can't work! There isn't enough....CODE!" 😜

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mentors catch everything!!!

<div class="col-sm-2 wordwrap draggable" id="{{ $draggableComponent->title }}">
<p data-toggle="tooltip" data-placement="top" title="{{ $draggableComponent->title }}">
{{ $draggableComponent->title }}
</p>
</div>
@endforeach
</div>
</div>
</div>
Expand Down
15 changes: 14 additions & 1 deletion public/assets/css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
text-align: center;
}

#draggable{
.draggable{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ID to class? Was that an error correction or just a refactor of the approach?

max-width: 24.5%;
height: 50px;
border: 1px solid lightgrey;
Expand All @@ -19,3 +19,16 @@
margin-top: -7px;
margin-bottom: -7px;
}
#draggable-column {
/* overflow: auto; */
height: 500px;
}

/*Wrap and break the draggable components' titles*/
.wordwrap {
padding: 3px;
width: 130px;
word-break: break-all;
word-wrap: break-word;
overflow: hidden;
}
8 changes: 5 additions & 3 deletions public/assets/js/master.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
$( function(){
$('.col-sm-3').draggable({
$('.col-sm-2').draggable({
addClasses: true
});

var addClasses = $('.col-sm-3').draggable("option", "addClasses");
var addClasses = $('.col-sm-2').draggable("option", "addClasses");
$('#second').droppable({
drop: function(event, ui){
$(this)
.addClass('ui-state-highlight')
.css('background-color', '#fd7e14')
.find('p')
.html("Dropped " + $(ui.draggable).attr("id"));
.html("Dropped " + $(ui.draggable).attr("id"))
.html();
$(ui.draggable).addClass('ui-state-highlight');
//$(ui.draggable).draggable('disable');
console.log('Dragged: ' + $(ui.draggable).attr("id"));
Expand Down