%%
%% This is file `diadia.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% diadia.dtx  (with options: `package')
%% 
%% Copyright (C) 2015 by:
%% Josef Kleber
%% <josef.kleber@gmx.de>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of LaTeX version
%% 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is Josef Kleber.
%% 
%% This work consists of all files listed in manifest.txt.
%% 
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{diadia}[2015/05/20 v1.1 diadia.sty - Josef Kleber (C) 2015]%
\RequirePackage{xkeyval}%
\newcommand*\DD@JK@define@key[4]%
{%
  \expandafter\gdef\csname#1@#3\endcsname{#4}%
  \define@key{#2.sty}{#3}[#4]%
  {%
    \expandafter\gdef\csname#1@#3\endcsname{##1}%
  }%
  \define@key{#2}{#3}%
  {%
    \expandafter\def\csname#1@#3\endcsname{##1}%
  }%
}%
\DD@JK@define@key{DD@JK}{diadia}{tabstyle}{simple}%
\DD@JK@define@key{DD@JK}{diadia}{tabcolor}{none}%
\DD@JK@define@key{DD@JK}{diadia}{plotstyle}{none}%
\DD@JK@define@key{DD@JK}{diadia}{plotclosedcycle}{false}%
\DD@JK@define@key{DD@JK}{diadia}{mcnotewidth}{3cm}%
\DD@JK@define@key{DD@JK}{diadia}{columnsep}{18pt}%
\DD@JK@define@key{DD@JK}{diadia}{columnseprule}{0pt}%
\DD@JK@define@key{DD@JK}{diadia}{columnseprulecolor}{\normalcolor}%
\ExecuteOptionsX{tabstyle,tabcolor,plotstyle,plotclosedcycle,mcnotewidth,%
                 columnsep,columnseprule,columnseprulecolor}%
\ProcessOptionsX*\relax%
\RequirePackage{pgfplots}%
\RequirePackage{pgfplotstable}%
\RequirePackage{pgfcalendar}%
\RequirePackage{tabularx}%
\RequirePackage{booktabs}%
\RequirePackage{colortbl}%
\RequirePackage{ifthen}%
\RequirePackage{calc}%
\RequirePackage{translations}%
\RequirePackage{amsmath}%
\RequirePackage[many]{tcolorbox}%
\RequirePackage{environ}%
\RequirePackage{multicol}%
\RequirePackage{amssymb}%
\usepgfplotslibrary{dateplot}%
\def\DD@JK@closedcycle{}%
\def\DD@JK@addplotdefault{}%
\input{diadia-fallback.trsl}%
\input{diadia-english.trsl}%
\input{diadia-german.trsl}%
\def\DD@JK@trans@BloodSugar{\GetTranslation{dd-BloodSugar}}%
\def\DD@JK@trans@Insulin{\GetTranslation{dd-Insulin}}%
\def\DD@JK@trans@BloodPressure{\GetTranslation{dd-BloodPressure}}%
\def\DD@JK@trans@Weight{\GetTranslation{dd-Weight}}%
\def\DD@JK@trans@MedicationChart{\GetTranslation{dd-MedicationChart}}%
\def\DD@JK@trans@issued{\GetTranslation{dd-issued}}%
\def\DD@JK@trans@Pharmaceutical{\GetTranslation{dd-Pharmaceutical}}%
\def\DD@JK@trans@Morning{\GetTranslation{dd-Morning}}%
\def\DD@JK@trans@Noon{\GetTranslation{dd-Noon}}%
\def\DD@JK@trans@Evening{\GetTranslation{dd-Evening}}%
\def\DD@JK@trans@Night{\GetTranslation{dd-Night}}%
\def\DD@JK@trans@Note{\GetTranslation{dd-Note}}%
\def\DD@JK@trans@Info{\GetTranslation{dd-Info}}%
\def\DD@JK@trans@Date{\GetTranslation{dd-Date}}%
\def\DD@JK@trans@BSi{\GetTranslation{dd-BSi}}%
\def\DD@JK@trans@BSii{\GetTranslation{dd-BSii}}%
\def\DD@JK@trans@BSiii{\GetTranslation{dd-BSiii}}%
\def\DD@JK@trans@IDi{\GetTranslation{dd-IDi}}%
\def\DD@JK@trans@IDii{\GetTranslation{dd-IDii}}%
\def\DD@JK@trans@IDiii{\GetTranslation{dd-IDiii}}%
\def\DD@JK@trans@BPs{\GetTranslation{dd-BPs}}%
\def\DD@JK@trans@BPd{\GetTranslation{dd-BPd}}%
\def\DD@JK@trans@Weight{\GetTranslation{dd-Weight}}%
\def\DD@JK@trans@CU{\GetTranslation{dd-CU}}%
\def\DD@JK@trans@Pulse{\GetTranslation{dd-Pulse}}%
\def\DD@JK@trans@Hbaonec{\GetTranslation{dd-Hbaonec}}%
\def\DD@JK@trans@Value{\GetTranslation{dd-Value}}%
\newcolumntype{Z}{>{\raggedright\let\newline\\\arraybackslash}X}%
\newcolumntype{Y}{>{\raggedright\let\newline\\\arraybackslash}p{\DD@JK@mcnotewidth}}%
\IfFileExists{diadia.cfg}%
{%
  \input{diadia.cfg}%
}%
{%
  \PackageError{diadia}{diadia.cfg not found}%
  {Please install diadia.cfg! The style definitions are missing!}%
}%
\newcommand*{\annotation}[4][]%
{%
  \node[ddpannotation,#1] at (#2,#3) {#4};%
}%
\newcommand*{\diadiatab}[3][]%
{%
  \begingroup%
  %    \end{macrocode}
    \setkeys{diadia}{#1}%
    \ifthenelse{\equal{\DD@JK@tabstyle}{simple}}%
    {}%
    {%
      \ifthenelse{\equal{\DD@JK@tabstyle}{advanced}}%
      {%
        \pgfplotstableset%
        {%
          every head row/.style={before row=\toprule,after row=\midrule},%
          every last row/.style={after row=\bottomrule}%
        }%
      }%
      {}%
    }%
    \ifthenelse{\equal{\DD@JK@tabcolor}{none}}%
    {}%
    {%
      \pgfplotstableset%
      {%
        every even row/.style={before row={\rowcolor{\DD@JK@tabcolor}}}%
      }%
    }%
    \pgfplotstabletypeset[#2]{#3}%
  \endgroup%
}%
\newcommand*\diadiaaddplot{\@ifstar\@@diadiaaddplot\@diadiaaddplot}%
\newcommand*\@diadiaaddplot[4][]%
{%
  \addplot+[\DD@JK@addplotdefault,#2] table[#3] {#4}\DD@JK@closedcycle;%
}%
\newcommand*\@@diadiaaddplot[4][]%
{%
  \addplot[#2] table[#3] {#4}\DD@JK@closedcycle;%
}%
\newenvironment{diadiaplot}[2][]%
{%
  \begin{tikzpicture}[baseline]%
    \setkeys{diadia}{#1}%
    \ifthenelse{\equal{\DD@JK@plotclosedcycle}{true}}%
    {\def\DD@JK@closedcycle{\closedcycle}}%
    {\def\DD@JK@closedcycle{}}%
    \def\DD@JK@ddpmode{}%
    \ifthenelse{\equal{\DD@JK@plotstyle}{none}}%
    {%
      \def\DD@JK@ddpmode{}%
    }%
    {%
      \ifthenelse{\equal{\DD@JK@plotstyle}{weight}}%
      {%
        \def\DD@JK@ddpmode{ddpweight}%
        \def\DD@JK@closedcycle{\closedcycle}%
      }%
      {%
        \ifthenelse{\equal{\DD@JK@plotstyle}{bloodpressure}}%
        {%
          \def\DD@JK@ddpmode{ddpbloodpressure}%
        }%
        {%
          \ifthenelse{\equal{\DD@JK@plotstyle}{insulin}}%
          {%
            \def\DD@JK@ddpmode{ddpinsulin}%
          }%
          {%
            \ifthenelse{\equal{\DD@JK@plotstyle}{bloodsugar}}%
            {%
              \def\DD@JK@ddpmode{ddpbloodsugar}%
            }%
            {%
              \ifthenelse{\equal{\DD@JK@plotstyle}{pulse}}%
              {%
                \def\DD@JK@ddpmode{ddppulse}%
              }%
              {%
                \ifthenelse{\equal{\DD@JK@plotstyle}{cu}}%
                {%
                  \def\DD@JK@ddpmode{ddpcu}%
                  \def\DD@JK@addplotdefault{ddaddplotfill}%
                }%
                {%
                  \ifthenelse{\equal{\DD@JK@plotstyle}{hbaonec}}%
                  {%
                    \def\DD@JK@ddpmode{ddphbaonec}%
                    \def\DD@JK@addplotdefault{ddaddplotfill}%
                  }%
                  {}%
                }%
              }%
            }%
          }%
        }%
      }%
    }%
    \begin{axis}[ddpdefault,%
                 \DD@JK@ddpmode,%
                 #2%
                ]%
}%
{%
    \end{axis}%
  \end{tikzpicture}%
}%
\newcommand*{\mcentry}[6]%
{%
  #1 & #2 & #3 & #4 & #5 & #6 \\%
}%
\NewEnviron{medicationchart}[3][]%
{%
  \begingroup%
    \setkeys{diadia}{#1}%
    \tcbox[medicationchart,%
           title={\DD@JK@trans@MedicationChart\space (\DD@JK@trans@issued: #3)},#2]%
    {%
      \renewcommand{\arraystretch}{1.2}%
      \begin{tabularx}{\textwidth-13.64pt}{Z||r|r|r|r||Y}%
        \DD@JK@trans@Pharmaceutical & \DD@JK@trans@Morning & \DD@JK@trans@Noon &%
        \DD@JK@trans@Evening & \DD@JK@trans@Night & \DD@JK@trans@Note\\\hline\hline%
        \BODY%
      \end{tabularx}%
    }%
  \endgroup%
}%
\newcommand{\infobox}[3]%
{%
  \begin{tcolorbox}[infobox,title={\DD@JK@trans@Info\space (#2)},#1]%
    #3%
  \end{tcolorbox}%
}%
\newenvironment{diadiasidebyside}[1][]%
{%
  \setkeys{diadia}{#1}%
  \setlength{\columnsep}{\DD@JK@columnsep}%
  \setlength{\columnseprule}{\DD@JK@columnseprule}%
  \def\columnseprulecolor{\DD@JK@columnseprulecolor}%
  \pgfplotsset{width=\columnwidth}%
  \begin{multicols}{2}%
}%
{%
  \end{multicols}%
}%
\newcommand*{\setlimit}[2][]%
{%
  \pgfplotsset{%
                extra y ticks={#2},%
                extra tick style={grid=major, major grid style={setlimit, #1}}%
              }%
}%
\endinput
%%
%% End of file `diadia.sty'.
