
<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> Antenatal visits
                        </div>

                        <div class="actions">
                            <a href="{$hosturl}/controllers/followup.php?ac=archive&patientid={$patientid}" class="btn btn-default btn-sm">
                                Archive pregnancy
                            </a>
                        </div>

                    </div>
                    <div class="portlet-body">


                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th class="col-md-1">
                                        G
                                    </th>
                                    <th class="col-md-1">
                                        P
                                    </th>
                                    <th class="col-md-2">
                                        LMP
                                    </th>
                                    <th class="col-md-2">
                                        EDD
                                    </th>
                                    <th class="col-md-2" style="display: none;">
                                        IVF
                                    </th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <input type="text" class="form-control updateElement" data-id="{$followup->id}" data-tableName="followup" data-colName="g" id="g" value="{$followup->g}" />
                                    </td>
                                    <td>
                                        <input type="text" class="form-control updateElement" data-id="{$followup->id}" data-tableName="followup" data-colName="p" id="p" value="{$followup->p}" />
                                    </td>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$followup->id}" data-colName="lmp" id="lmp" data-tableName="followup" value="{$followup->lmp}" readonly/>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" data-id="{$followup->id}" data-tableName="followup" data-colName="eed" id="eed" value="{$followup->eed}" readonly/>
                                    </td>
                                    <td style="display: none;">
                                        <input type="text" class="form-control" data-id="{$followup->id}" data-tableName="followup" data-colName="ivf" id="ivf" value="{$followup->ivf}" readonly/>
                                    </td>
                                    
                                </tr>
                            </tbody>
                        </table>




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

        <div class="row">
            <div class="col-md-12" style="padding-right: 0px; padding-left: 0px;">
                <div class="portlet box blue">
                    <div class="portlet-body">

                        <table class="table table-striped table-hover table-bordered">
                            <tbody>
                                <tr>
                                    <th style="width: 12%; ">
                                        History
                                        </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$followup->id}" data-colName="history" data-tableName="followup" placeholder="Enter more text">{$followup->history}</textarea>
                                    </td>
                                </tr>
                            </tbody>
                        </table>


                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th style="width: 12%;">
                                        Date
                                    </th>
                                    <th>
                                        Diagnosis
                                        <button type="button" class="btn btn-xs blue" id="addDiagnosisAnt"><i class="fa fa-plus"></i></button>
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="diagnosisBody">
                                {if $diagnosis}
                                {foreach  $diagnosis  as $diag}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$diag->id}" data-colName="date" data-tableName="followupdiagnosis" value="{$diag->date}" readonly/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$diag->id}" data-colName="diagnosis" data-tableName="followupdiagnosis" placeholder="Enter Diagnosis">{$diag->diagnosis}</textarea>
                                    </td>
                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$diag->id}" style=" float: left;" href="#" data-link="followup" data-fn="del" data-tableName="followupdiagnosis">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    </td>
                                </tr>
                                {/foreach}
                                {/if}

                            </tbody>
                        </table>
                        
                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th style="width: 12%;">
                                        Date
                                    </th>
                                    <th>
                                        Examination
                                        <button type="button" class="btn btn-xs blue" id="addExam"><i class="fa fa-plus"></i></button>
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="examinationBody">
                                {if $examination}
                                {foreach  $examination  as $diag}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$diag->id}" data-colName="date" data-tableName="followupexam" value="{$diag->date}" readonly/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$diag->id}" data-colName="exam" data-tableName="followupexam" placeholder="Enter Exam Result">{$diag->exam}</textarea>
                                    </td>
                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$diag->id}" style=" float: left;" href="#" data-link="followup" data-fn="del" data-tableName="followupexam">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    </td>
                                </tr>
                                {/foreach}
                                {/if}

                            </tbody>
                        </table>
                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th style="width: 12%;">
                                        Date
                                    </th>
                                    <th>
                                        Investigation
                                        <button type="button" class="btn btn-xs blue" id="addInvAnt"><i class="fa fa-plus"></i></button>
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="investigationBody">
                                {if $invest}
                                {foreach  $invest  as $diag}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$diag->id}" data-colName="date" data-tableName="followupinvest" value="{$diag->date}" readonly/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$diag->id}" data-colName="invest" data-tableName="followupinvest" placeholder="Enter Investigations">{$diag->invest}</textarea>
                                    </td>
                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$diag->id}" style=" float: left;" href="#" data-link="followup" data-fn="del" data-tableName="followupinvest">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    </td>
                                </tr>
                                {/foreach}
                                {/if}

                            </tbody>
                        </table>


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


        <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> All visits
                        </div>
                        <div class="actions">
                            <a href="javascript:;" class="btn btn-default btn-sm" id="follow_add">
                                <i class="fa fa-plus"></i> Add </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="followup">
                                            Add </a>
                                    </li>
                                    <li>
                                        <a href="javascript:;" id="showDrugs" data-controller="followup">
                                            Show </a>
                                    </li>
                                </ul>
                            </div>
                        </div>

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

                        <table class="table table-striped table-hover table-bordered" id="antenalvisit">
                            <thead>
                                <tr>
                                    <th style="width: 11%;">
                                        Date
                                    </th>
                                    <th style="width: 4%;">
                                        GA
                                    </th>
                                    <th style="width: 6%;">
                                        Wt
                                    </th>
                                    <th style="width: 7%;">
                                        Bp
                                    </th>
                                    
                                    <th>
                                        U/S
                                    </th>
                                    <th>
                                        Notes
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="visitBody">
                                {foreach  $visits  as $diag}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement calcWeeksF" data-id="{$diag->id}" data-colName="date" data-tableName="followupvisit" value="{$diag->date}" readonly/>
                                    </td>
                                    <td>
                                        {if $diag->dateFlag == 1}
                                        <label id="ga{$diag->id}" style="color: red ; font-weight: bold;">{$diag->ga}</label>
                                        {else}
                                        <label id="ga{$diag->id}">{$diag->ga}</label>
                                        {/if}
                                    </td>
                                    <td>
                                        <input type="text" class="form-control updateElement" data-id="{$diag->id}" data-colName="wt" data-tableName="followupvisit" value="{$diag->wt}"/>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control bp_mask updateElement" data-id="{$diag->id}" data-colName="bp" data-tableName="followupvisit" value="{$diag->bp}"/>
                                    </td>
                                    
                                    <td>
                                        <input type="text" class="form-control updateElement" data-id="{$diag->id}" data-colName="us" data-tableName="followupvisit" value="{$diag->us}"/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="1" data-id="{$diag->id}" data-colName="notes" data-tableName="followupvisit" placeholder="Enter more text">{$diag->notes}</textarea>
                                    </td>
                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$diag->id}" style=" float: left;" href="#" data-link="followup" data-fn="del" data-tableName="followupvisit">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    </td>
                                </tr>

                                {/foreach}
                            </tbody>
                        </table>

                        <button id="endPreg" class="btn red">
                            End Pregnancy
                        </button>



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

</div>

<input type="hidden" id="patientId" value="{$patientId}"/>
<input type="hidden" id="followId" value="{$followup->id}"/>
<input type="hidden" id="controllName" value="followup"/>
<!----#########################################################################  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="followupDrugs" 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="followup"  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="followupdrugs">
                                                <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="followup">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="followupdrugs" 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="followupdrugs" 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="followupdrugs" 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="followup" 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="followup"> 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>