
<div class="page-content-wrapper">
    <div class="page-content all">
        <div class="row ">
            <div class="col-md-12" style="padding-right: 0px; padding-left: 0px;">
                <div class="portlet box blue">
                    <div class="portlet-title" style="height: 5px">
                        <div class="caption">
                            <i class="fa fa-edit"></i> Records
                        </div>
                        <div class="actions">
                            <a href="javascript:;" class="btn btn-default btn-sm" id="record_add">
                                <i class="fa fa-plus"></i> Add New Record </a>
                        </div>                 

                        <div class="actions">
                            <div class="btn-group">
                                <a class="btn btn-default btn-sm" href="javascript:;" data-toggle="dropdown">
                                    TTT <i class="fa fa-angle-down"></i>
                                </a>
                                <ul class="dropdown-menu pull-right">
                                    <li>
                                        <a href="javascript:;" id="addDrug"  data-date="{$presDate}" data-controller="record">
                                            Add </a>
                                    </li>
                                    <li>
                                        <a href="javascript:;" id="showDrugs" data-controller="record">
                                            Show </a>
                                    </li>
                                </ul>
                            </div>
                        </div>


                    </div>
                    <div class="portlet-body" id="justfordrugs" >
                        <div class="table-toolbar">

                        </div>
                        <table class="table table-striped table-hover table-bordered" id="records">
                            <thead>
                                <tr>
                                    <th style="width: 10%;">
                                        Date
                                    </th>
                                    <th style="width: 29%;">
                                        Diagnosis
                                    </th>
                                    <th style="width: 60%;">
                                        TTT
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="recordsBody">
                                {foreach $allRecords as $record}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$record->id}" data-colName="date" data-tableName="records" value="{$record->date}" readonly/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$record->id}" data-colName="diagnosis" data-tableName="records" placeholder="Enter more text">{$record->diagnosis}</textarea>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$record->id}" data-colName="ttt" data-tableName="records" placeholder="Enter more text">{$record->ttt}</textarea>
                                    </td>

                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$record->id}" style=" float: left;" href="#" data-link="record" data-fn="del">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    </td>
                                </tr>
                                {/foreach}
                            </tbody>
                        </table>



                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<input type="hidden" id="patientId" value="{$patientId}"/>
<input type="hidden" id="controllName" value="record"/>
<!----#########################################################################  model ##############################################################################################################--->

<!---------------------------------------------------------------------------add Drugs Model-------------------------------------------------------------------------------------->
<div class="modal fade" tabindex="-1" role="dialog" aria-hidden="false" data-backdrop="static" data-keyboard="false"   id="addPatientDrugs" style="min-width:1000px;">
    <div class="modal-dialog  modal-lg wds90">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close closeDrug" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">  </h4>
            </div>
            <div class="modal-body">
                <div class="portlet-body form">
                    <form class="form-horizontal" role="form" action="" method="post" id="recordDrugs" enctype="multipart/form-data">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="portlet blue-hoki box">
                                    <div class="portlet-title" >
                                        <div class="caption"> Prescription <input type="text" class="form-control datepicker " id="presDate" name="presDate" value="{$presDate}" data-controller="record"  readonly="" placeholder="Date" style="display: inline; width: 65%"> </div>
                                        <div class="actions">
                                            <a href="javascript:;" class="btn btn-default btn-sm" id="addNewDrugRow" data-tableName="recorddrugs">
                                                <i class="fa fa-plus"></i> Add </a>
                                            <a href="javascript:;" class="btn btn-default btn-sm" id="addNewDrugInTable">
                                                <i class="fa fa-plus"></i> Add New Drug </a>

                                        </div>
                                        <div id="husbandFor">
                                            <label class="bold"> <input type="checkbox" id="forHusband" name="forHusband"  value="1" data-controller="record"> Husband</label>
                                        </div>
                                    </div>

                                    <div class="portlet-body">

                                        <table class="table table-striped table-hover table-bordered" id="pre_table" >
                                            <thead>
                                                <tr>
                                                    <th class="col-md-2">
                                                        Group
                                                    </th>
                                                    <th class="col-md-2">
                                                        Drug
                                                    </th>
                                                    <th class="col-md-2">
                                                        Form
                                                    </th>
                                                    <th class="col-md-5">
                                                        Use
                                                    </th>

                                                    <th >
                                                        Delete
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody id="drugContent">

                                                <tr style="display: none"><td colspan="5" ><input type="hidden" id="drugItr" value="{$preItr}" name="drugItr"/></td></tr>
                                                {assign var=itr value=1}
                                                {foreach $PatientPresByDate as $pre}
                                                <tr>
                                                    <td>
                                                        <select class="form-control xx dcat select2me" id="dcat{$itr}" name="dcat{$itr}"  data-itr="{$itr}"  data-placeholder="Select..."  >
                                                            <option value="" {if $pre->drugcat == ""}selected{/if}>Choose Category</option>
                                                            {foreach $allDrugcats as $cat}
                                                            <option value="{$cat['drugcat']}" {if $pre->drugcat == $cat['drugcat'] }selected{/if}>{$cat['drugcat']}</option>
                                                            {/foreach}
                                                            <option value="" {if $pre->drugcat == ""}selected{/if}>Choose Category</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control xx dname select2me updateElement" id="dname{$itr}" data-id="{$pre->id}" data-colName="drugid" data-tableName="recorddrugs" data-itr="{$itr}" data-placeholder="Select..."  >
                                                            <option value="" {if $pre->drugid == ""}selected{/if}>Choose Drug</option>
                                                            {foreach $drugs as $drug}
                                                            <option value="{$drug['id']}" {if $pre->drugid == $drug['id'] }selected{/if}>{$drug['drugname']} {if $ProgramesettingData->visitsform eq 3}(left {$drug['currentbalance']}){/if}</option>
                                                            {/foreach}
                                                            <option value="" {if $pre->drugid == ""}selected{/if}>Choose Drug</option>
                                                        </select>

                                                    </td>
                                                    <td>
                                                        <select class="form-control xx dtype select2me updateElement" id="dtype{$itr}" data-id="{$pre->id}" data-colName="drugtype" data-tableName="recorddrugs" data-itr="{$itr}" data-placeholder="Select..."  >
                                                            <option value="" {if $pre->drugtype == ""}selected{/if}>Choose Form</option>
                                                            {foreach $allDrugTypes as $type}
                                                            <option value="{$type['drugtype']}" {if $pre->drugtype == $type['drugtype'] }selected{/if}>{$type['drugtype']}</option>
                                                            {/foreach}
                                                            <option value="" {if $pre->drugtype == ""}selected{/if}>Choose Form</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control xx select2me updateElement" id="ddos{$itr}" data-id="{$pre->id}" data-colName="drugdos" data-tableName="recorddrugs" data-itr="{$itr}" data-placeholder="Select..."  >
                                                            <option value="" {if $pre->drugdos == ""}selected{/if}>choose dose </option>
                                                            {foreach $allDrugDoses as $dos}
                                                            <option value="{$dos['drugdos']}" {if $pre->drugdos == $dos['drugdos'] }selected{/if}>{$dos['drugdos']}</option>
                                                            {/foreach}
                                                            <option value="" {if $pre->drugdos == ""}selected{/if}>choose dose </option>
                                                        </select>
                                                    </td>

                                                    <td>
                                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$pre->id}" style=" float: left;" href="#" data-link="record" data-fn="addprescription">
                                                            <i class="fa fa-close"></i>
                                                        </a>
                                                    </td>
                                                </tr>
                                                {capture assign=itr}{$itr+1}{/capture}
                                                {/foreach}

                                            </tbody>
                                        </table>
                  
                                        <input type="hidden" id="pId" value="" name="patientId"/>
                                        <input type="hidden" id="preType" value="" name="preType"/>
                                        <input type="hidden" id="preFor" value="" name="preFor"/>

                                        <div id="drugPrint">

                                        </div>

                                    </div>

                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn default printPre"  data-type="add" data-controller="record"> Print  </button>
                                <button type="button" class="btn default closeDrug" id="closemodel" data-dismiss="modal"> Close</button>

                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!---------------------------------------------------------------------------show Drugs Model-------------------------------------------------------------------------------------->
<div class="modal fade" tabindex="-1" role="dialog" aria-hidden="false" data-backdrop="static" data-keyboard="false"   id="showPatientDrugs" style="min-width:1000px;z-index: 10049;">
    <div class="modal-dialog  modal-lg wds90">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">  </h4>
            </div>
            <div class="modal-body">
                <div class="portlet-body form">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="portlet blue-hoki box">
                                <div class="portlet-title" >
                                    <div class="caption"> Prescriptions </div>
                                </div>
                                <div class="portlet-body" id="showPrescriptions">

                                    <table class="table table-striped table-hover table-bordered">
                                        <thead>
                                            <tr>
                                                <th>
                                                    Date
                                                </th>
                                                <th>
                                                    Drug Name
                                                </th>

                                                <th>
                                                    Edit
                                                </th>
                                                <th>
                                                    Print
                                                </th>
                                                <th>
                                                    {if $ProgramesettingData->displaydoctorname eq 1} Doctor{/if}
                                                </th>
                                            </tr>
                                        </thead>

                                    </table>

                                </div>
                                <div id="drugPrintShow">

                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">

                            <button type="button" class="btn default" id="closemodel" data-dismiss="modal"> Close</button>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!------------------##############################-------------------- End of Models -----------------------#########################################-------------->
<div id="newDrugTableDiv"></div>
