
<div class="page-content-wrapper">
    <div class="page-content all">
        <div class="row ">
    <div class="col-md-9" style="margin-right: 12px; width: 87%; ">
        <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> Infertility Sheet
                        </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="infertility">
                                            Add </a>
                                    </li>
                                    <li>
                                        <a href="javascript:;" id="showDrugs" data-controller="infertility">
                                            Show </a>
                                    </li>
                                </ul>
                            </div>
                        </div>

                    </div>
                    <div class="portlet-body" id="justfordrugs" >
                        <table class="table table-striped table-hover table-bordered">
                            <thead>

                                <tr>
                                    <th style="width: 12%;">
                                        Date
                                        <button type="button" class="btn btn-xs blue" id="addDiagnosis"><i class="fa fa-plus"></i></button>
                                    </th>
                                    <th>
                                        Wife Diagnosis
                                    </th>
                                    <th>
                                        Husband Diagnosis
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="diagnosisBody">
                                {if $diagnosis }
                                {foreach $diagnosis as $record}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$record->id}" data-colName="date" data-tableName="infertilitydiagnosis" value="{$record->date}" readonly/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$record->id}" data-colName="diagnosiswife" data-tableName="infertilitydiagnosis" placeholder="Enter more text">{$record->diagnosiswife}</textarea>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="2" data-id="{$record->id}" data-colName="diagnosishusband" data-tableName="infertilitydiagnosis" placeholder="Enter more text">{$record->diagnosishusband}</textarea>
                                    </td>

                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$record->id}" style=" float: left;" href="#" data-link="infertility" data-tableName="infertilitydiagnosis" data-fn="del">
                                            <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 colspan="4">
                                        History
                                    </th>
                                </tr>
                            </thead>
                            <tbody>

                                <tr>
                                    <td>
                                        Marriage
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement" value="{$infertility->marriage}"   data-tableName="infertility" data-colName="marriage" data-id="{$infertility->id}"/>  
                                    </td>
                                    <td>
                                        Menstr
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement" value="{$infertility->menstr}"   data-tableName="infertility" data-colName="menstr" data-id="{$infertility->id}"/>  
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 13%;">
                                        Operations or Dis
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement" value="{$infertility->operations}"   data-tableName="infertility" data-colName="operations" data-id="{$infertility->id}"/>  
                                    </td>
                                    <td style="width: 11%;"> 
                                        Sexual History
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement"  value="{$infertility->sexualhistory}"   data-tableName="infertility" data-colName="sexualhistory" data-id="{$infertility->id}"/>  
                                    </td>
                                </tr>
                             
                            </tbody>
                        </table>

                        <table class="table table-striped table-hover table-bordered">
                            <thead>

                                <tr>
                                    <th colspan="4">
                                        General Exam
                                    </th>
                                </tr>
                            </thead>
                            <tbody>

                                <tr>
                                    <td>
                                        Breast
                                    </td>
                                    <td>
                                        <input type="text" class="form-control updateElement" value="{$infertility->breast}"   data-tableName="infertility" data-colName="breast" data-id="{$infertility->id}"/>  
                                    </td>
                                    <td>
                                        Hirsuitism
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement" value="{$infertility->hirsuitism}"   data-tableName="infertility" data-colName="hirsuitism" data-id="{$infertility->id}"/>  
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 9%;">
                                        2ry Sex Ch
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement"  value="{$infertility->sexch}"   data-tableName="infertility" data-colName="sexch" data-id="{$infertility->id}"/>  
                                    </td>
                                    <td style="width: 14%;">
                                        Obesity Or Malnutr
                                    </td>
                                    <td>
                                <input type="text" class="form-control updateElement" value="{$infertility->obesity}"    data-tableName="infertility" data-colName="obesity" data-id="{$infertility->id}"/>  
                                    </td>
                                </tr>
                             
                            </tbody>
                        </table>
                        <table class="table table-striped table-hover table-bordered">
                            <thead>

                                <tr>
                                    <th colspan="16">
                                        Gyna . Exam
                                        <button type="button" class="btn btn-xs blue" id="addGyna"><i class="fa fa-plus"></i></button>
                                    </th>
                                </tr>
                            </thead>

                            <tbody id="gynaBody">
                                {if $gyna }
                                {foreach $gyna as $record}

                                <tr class="gyna{$record->id}">
                                    <td style="width: 6%; background-color: #ddd;display: none;">
                                        Date
                                    </td>
                                    <td colspan="2" style="width: 12%; display: none;">
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$record->id}" data-colName="date" data-tableName="infertilitygyna" value="{$record->date}" readonly/>
                                    </td>
                                    <td colspan="2" style="width: 8%;">
                                        Vagina
                                    </td>
                                    <td colspan="14" style="width: 92%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilitygyna" data-colName="vagina" data-id="{$record->id}" value="{$record->vagina}"/>  
                                    </td>
                                </tr>
                                <tr class="gyna{$record->id}">
                                    <td colspan="2" style="width: 8%;">
                                        Uterus
                                    </td>
                                    <td colspan="5" style="width: 39%;"> 
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilitygyna" data-colName="exam" data-id="{$record->id}" value="{$record->exam}"/>  
                                    </td>
                                     <td colspan="3" style="width: 14%;">
                                         Uterus (Cervix)
                                     </td>
                                    <td colspan="6" style="width: 39%;"> 
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilitygyna" data-colName="sounding" data-id="{$record->id}" value="{$record->sounding}"/>  
                                    </td>
                                </tr>
                                <tr class="gyna{$record->id}">
                                    <td colspan="2" style="width: 8%;">
                                        Adenxae
                                    </td>
                                    <td colspan="13" style="width: 90%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilitygyna" data-colName="adenxae" data-id="{$record->id}" value="{$record->adenxae}"/>  
                                    </td>
                                    <td style="width: 2%;">
                                        <a class="btn grey-cascade btn-xs deletemsgEXDiv" data-divName="gyna{$record->id}" data-id="{$record->id}" style=" float: left;" href="#" data-link="followup" data-fn="del" data-tableName="infertilitygyna">
                                            <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>
                                        Note
                                        <button type="button" class="btn btn-xs blue" id="addNotes"><i class="fa fa-plus"></i></button>
                                    </th>
                                    <th style="width: 1%;">
                                        Delete
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="noteBody">
                                {if $notes }
                                {foreach $notes as $record}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$record->id}" data-colName="date" data-tableName="infertilitynotes" value="{$record->date}" readonly/>
                                    </td>
                                    <td>
                                        <textarea class="form-control updateElement" rows="1" data-id="{$record->id}" data-colName="note" data-tableName="infertilitynotes" placeholder="Enter more text">{$record->note}</textarea>
                                    </td>

                                    <td>
                                        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$record->id}" style=" float: left;" href="#" data-link="infertility" data-tableName="infertilitynotes" data-fn="del">
                                            <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 colspan="16">
                                        Investigations
                                        <button type="button" class="btn btn-xs blue" id="addInvs"><i class="fa fa-plus"></i></button>
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="invBody">
                                {if $invest }
                                {foreach $invest as $record}
                                <tr class="invest{$record->id}">
                                    <td style="width: 6%; background-color: #ddd;">
                                        Date
                                    </td>
                                    <td colspan="2" style="width: 12%;">
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$record->id}" data-colName="date" data-tableName="infertilityinvest" value="{$record->date}" readonly/>
                                    </td>
                                    <td style="width: 6%;">
                                        Semen
                                    </td>
                                    <td colspan="12" style="width: 76%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="semen" data-id="{$record->id}" value="{$record->semen}"/>  
                                    </td>

                                </tr>

                                <tr class="invest{$record->id}">
                                    <td style="width: 6%;">
                                        FSH
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="fsh" data-id="{$record->id}" value="{$record->fsh}"/>
                                    </td>

                                    <td style="width: 6%;">
                                        ANH
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="pct" data-id="{$record->id}" value="{$record->pct}"/>
                                    </td>

                                </tr>

                                <tr class="invest{$record->id}">
                                    <td style="width: 6%;">
                                        LH
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="lh" data-id="{$record->id}" value="{$record->lh}"/>
                                    </td>

                                    <td style="width: 6%;">
                                        F.Tests
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="us" data-id="{$record->id}" value="{$record->us}"/>
                                    </td>


                                </tr>

                                <tr class="invest{$record->id}">
                                    <td style="width: 6%;">
                                        Prolact.
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="prolactin" data-id="{$record->id}" value="{$record->prolactin}"/>
                                    </td>

                                    <td style="width: 6%;">
                                        T.Tests
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="thyr" data-id="{$record->id}" value="{$record->thyr}"/>
                                    </td>

                                </tr>
                                <tr class="invest{$record->id}">
                                    <td style="width: 6%;">
                                        TSH
                                    </td>
                                    <td  colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="peg" data-id="{$record->id}" value="{$record->peg}"/>
                                    </td>
                                    <td style="width: 6%;">
                                        HSG
                                    </td>
                                    <td colspan="7" style="width: 44%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="hsg" data-id="{$record->id}" value="{$record->hsg}"/>
                                    </td>

                                </tr>

                                <tr class="invest{$record->id}">
                                    <td  colspan="2"style="width: 11%;">
                                        Others
                                    </td>
                                    <td colspan="14" style="width: 89%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="others" data-id="{$record->id}" value="{$record->others}"/>
                                    </td>
                                </tr>

                                <tr class="invest{$record->id}">
                                    <td  colspan="2"style="width: 11%;">
                                        La Paroscopy
                                    </td>
                                    <td colspan="13" style="width: 87%;">
                                        <input type="text" class="form-control updateElement"   data-tableName="infertilityinvest" data-colName="laparoscopy" data-id="{$record->id}" value="{$record->laparoscopy}"/>
                                    </td>
                                    <td style="width: 2%;">
                                        <a class="btn grey-cascade btn-xs deletemsgEXDiv" data-divName="invest{$record->id}" data-id="{$record->id}" style=" float: left;" href="#" data-link="followup" data-fn="del" data-tableName="infertilityinvest">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    </td>

                                </tr>

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


                
        </div>
            

                         


                    </div>
                </div>
            </div>
            
            <div class="col-md-2" style="padding-right: 0px; padding-left: 0px; width: 11%;">
                <div class="portlet box blue">
                    <div class="portlet-title" style="height: 5px">
                        <div class="caption">
                            <i class="fa fa-edit"></i> LMP
                        </div>
                        <div class="actions">
                            <button type="button" class="btn btn-xs blue fright" id="addLmp"><i class="fa fa-plus"></i></button>
                        </div>                 

                        


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

                        </div>
                        <table class="table table-striped table-hover table-bordered" id="records">
                            {if $notes }
                            <tbody id="lmpBody">
                                {foreach $lmp as $record}
                                <tr>
                                    <td>
                                        <input type="text" class="form-control datepicker updateElement" data-id="{$record->id}" data-colName="date" data-tableName="infertilitylmp" value="{$record->date}" readonly/>
                                    </td>
                                </tr>
                                {/foreach}
                                {/if}
                            </tbody>
                        </table>


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

        </div>
    </div>

</div>
<input type="hidden" id="patientId" value="{$patientId}"/>
<input type="hidden" id="controllName" value="infertility"/>
<input type="hidden" id="infertilityId" value="{$infertility->id}"/>
<!----#########################################################################  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="infertilityDrugs" 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="infertility"  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="infertilitydrugs">
                                                <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="infertility"> 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="infertilitydrugs" 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="infertilitydrugs" 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="infertilitydrugs" 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="infertility" 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="infertility"> 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>
