Coding An Electronic EEG Logbook [Part 2]

Welcome to Part 2 of “Coding An Electronic EEG Logbook.” In this post, I will outline the dashboard, email notifications, my main SQL table structure, and adding ICD-10 codes.


For my dashboard I used Highcharts. Here is an example of ~6 months of data entered for 2018 displaying the volume of patients from each unit. I have two separate files, one to display the data, and one to query the database.

Highcharts PHP/HTML displaying the chart:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unit Volume 2018</title>

<script type="text/javascript" src="code/highcharts.js" ></script>

<script src=""></script>

<script type="text/javascript">
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
title: {
text: 'Unit Volume 2018'
    xAxis: {
        type: 'category',
        labels: {
            rotation: -45,
            style: {
                fontSize: '13px',
                fontFamily: 'Verdana, sans-serif'
    yAxis: {
        min: 0,
        title: {
            text: 'Volume'
tooltip: {
formatter: function() {
return '<b>'+ +'</b>: '+ this.y +' ';
plotOptions: {
bar: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ +'</b>: '+ this.y +' ';
series: [{
type: 'column',
dataLabels: {
enabled: true,},
colorByPoint: true,
name: 'Unit Volume',
data: []
$.getJSON("unit_data2018.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

Highcharts PHP data file to run the MYSQL query (See the SQL query highlighted):

$con = mysql_connect("localhost","username","password"); 
if (!$con) 
	die('Could not connect: ' . mysql_error()); 
mysql_select_db("mate2", $con); 

$result = mysql_query(
"SELECT  COUNT(*) location_count, b.unit
FROM    eeg_reading a
INNER JOIN location_table b
ON a.location_unit =
WHERE YEAR(date_recorded)=2018
GROUP BY b.unit

// while($row = mysql_fetch_array($result)) 
	// { 
	// echo 	$row['reading_md'] . "\t" . 
			// $row['reading_md_count']. "\n"; 
	// } 
$rows = array();
while($r = mysql_fetch_array($result)) {
$row[0] = $r[1];
$row[1] = $r[0];
print json_encode($rows, JSON_NUMERIC_CHECK);

Example JSON output:

[[” Program Admit”,466],[“Clinic EEG”,719],[“Clinic JPB PT EEG”,50],[“EEG INPT”,360],[“EEG Other (ISAT\/PET)”,24],[“EEG Program Admit”,318],[“EEG UH 4920”,244],[“EEG UH ICU”,485],[“INPT 5000”,828],[“INPT EEG”,55],[“INPT EEG H8000”,591],[“INPT EEG ICU”,927],[“INPT EEG PICU”,244]]

HTML/JQUERY output column chart displaying unit volume:

Automatic email notifications 

Now that you have data coming into your database, you can find scripts online or write your own that will simply query your database with an SQL statement and then email you or others with the results. This can be helpful for daily/weekly/monthly reports. I used the following script to query my database and send monthly results to our accounting team.

Here is a Github link to an example script I used. You will need to set up a CRON job on your webserver. No relation to StudiOwens but I do like the name.

MySql database structure for the EEG Logbook table

You should start off with a unique id for every row, (e.g. id). For the ‘id’ row make it an integer that is set so AUTO_INCREMENT, this will assign it a new unique id number for every entry in the database.

For any file data you wish to upload, like pictures or Word documents, make it a BLOB. In my database I have one medium blob called file_data, this is for uploading the EEG reports.

Adding ICD-10 codes to your database

You can easily download all of the ICD-10 diagnosis codes in a text file from the CMS website here.

Extract and open this file in any text editor like Textwrangler for Mac or Notepad++ for Windows and you will see the entire list. I extracted only the pertinent epilepsy codes from the list and imported them into my SQL database. I use PhpMyAdmin to import and administer my MySQL database.

Example of the ICD-10 codes in a drop-down from our MEG/MSI database:

Stay tuned for Part 3, I’ll upload a demo with anonymous data and talk about putting the database into the cloud for ease of access with secure authentication and HIPAA compliance.

One thought on “Coding An Electronic EEG Logbook [Part 2]”

  1. This is quite impressive, thanks for sharing. We use XLTEK (Natus) Sleepworks and it seems to be moving towards incorporating this kind of tracking within the software, but this is very helpful before they get there.

Leave a Reply

Your email address will not be published.