mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
938 lines
66 KiB
PHP
Executable File
938 lines
66 KiB
PHP
Executable File
@extends('layouts.main')
|
|
|
|
@push('styles')
|
|
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
|
|
@endpush
|
|
|
|
@section('content')
|
|
<div class="row bg-title">
|
|
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
|
|
<h4 class="page-title">{{ __('prescriptions.treatment_for_episode') }}:<a>{{ streamline_date(get_name($episode_id, 'id', 'created_at', 'patient_episodes')) }}</h4>
|
|
</div>
|
|
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
|
|
<ol class="breadcrumb">
|
|
<li><a href="{{ route('home') }}">{{ __('prescriptions.dashboard') }}</a></li>
|
|
<li><a href="{{ route('patient_episodes.index') }}">{{ __('prescriptions.patient_home') }}</a></li>
|
|
<li class="active">{{ __('prescriptions.prescription_refill') }}</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
@include('patients::allergies.header')
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<!--Flash messages at the top -->
|
|
@include('flash::message')
|
|
@foreach ($errors->all() as $error)
|
|
<div>{{ $error }}</div>
|
|
@endforeach
|
|
<div class="white-box">
|
|
{{ Form::open(['route' => 'prescriptions.display_selected_drugs' , 'id'=>'prescriptions_form']) }}
|
|
|
|
<!-- ======== check if its a ward prescription and display label to the user ====== -->
|
|
{!! session()->get("ward_prescription") == 1 ? "<font style='color:blue; font-weight: bolder;'>__('prescriptions.ward_prescription')</font>" : "" !!}
|
|
<!-- ======== -->
|
|
<div class="form-group">
|
|
{{ Form::label('drugs', __("prescriptions.prescribe_drugs")) }}
|
|
<div class="row">
|
|
<div class="col-sm-10">
|
|
{{ Form::select('prescription_drugs[]',$drugs,'',['id'=>'prescription-drugs','multiple'=>true,'class' => 'form-control col-sm-8 compulsory prescription-drugs']) }}
|
|
</div>
|
|
<div class="col-sm-2">
|
|
{{ Form::button('Confirm Treatment',['type'=>'submit','class'=>'btn btn-secondary waves-effect waves-light m-r-10','style'=>'padding: .6rem 1.2rem;']) }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{ Form::close() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@php
|
|
$fre_drop = "";
|
|
$fre_query = "select * from dosage_frequencies order by name";
|
|
$results = \DB::select($fre_query);
|
|
foreach ($results as $result){
|
|
$fre_drop .= "<option value='" . $result->id . "'>" . $result->name . "</option>";
|
|
}
|
|
@endphp
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="white-box">
|
|
<div class="table-responsive">
|
|
{{ Form::open(['route' => 'prescriptions.process' , 'data-toggle' => 'validator', 'id' => 'selected_drugs_form']) }}
|
|
<table class="table color-bordered-table success-bordered-table">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 5%;">#</th>
|
|
<th style="width: 15%;">{{ __('prescriptions.drug') }}</th>
|
|
<th style="width: 20%;">{{ __('prescriptions.dosage') }}</th>
|
|
<th style="width: 20%;">{{ __('prescriptions.prompt') }}</th>
|
|
<th style="width: 10%;">{{ __('prescriptions.duration') }}</th>
|
|
<th style="width: 10%;">{{ __('prescriptions.dispense') }}</th>
|
|
<th style="width: 10%;">{{ __('prescriptions.price') }}</th>
|
|
<th style="width: 10%;">{{ __('prescriptions.instructions') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<tr>
|
|
<td colspan="2" style="background-color: #FFE6E6; font-weight: bolder; text-decoration: underline;border: 1px solid #ddd;">Selected</td>
|
|
<td colspan="6" style="border: 1px solid #ddd;"></td>
|
|
</tr>
|
|
@if($patient_prescriptions)
|
|
@if(count($patient_prescriptions) > 0)
|
|
@foreach($patient_prescriptions as $prescription)
|
|
@php
|
|
$patient_is_allergic = \Modules\Pharmacy\Http\Controllers\PrescriptionsController::checkPatientAllergies($patient_id, $prescription->category_id);
|
|
@endphp
|
|
<tr id="my_row{{ $prescription->id }}" class="to_remove">
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
@php
|
|
$total_stock = (($prescription->pharmacy_stock < 0) ? 0 : $prescription->pharmacy_stock) + (($prescription->store_stock < 0) ? 0 : $prescription->store_stock);
|
|
@endphp
|
|
@if ($total_stock > 0 && !$patient_is_allergic)
|
|
<input type="checkbox" name="drug_id[]" id="chk" class="prescription-check" value="{{ $prescription->id }}" />
|
|
<input type="hidden" name="drug_id[]" id="chk" value="{{ $prescription->id }}" />
|
|
@endif
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
@php
|
|
$insurance_color = ($prescription->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) ? "green" : "orange";
|
|
@endphp
|
|
@if ($patient_is_allergic)
|
|
<span class='badge badge-danger'>{{ __('prescriptions.patient_is_allergic') }}</span>
|
|
@endif
|
|
@if ($total_stock <= 0)
|
|
<span class="badge badge-danger">{{ __('prescriptions.out_of_stock') }}</span>
|
|
@endif
|
|
<span style="color:{{ $insurance_color }}"> {{ $prescription->name }}</span>
|
|
<?php
|
|
$pharm_comment = trim($prescription->pharmacy_comment);
|
|
$reference_array = explode(",", $prescription->reference_areas);
|
|
$reference_name = explode(",", $prescription->reference_name);
|
|
?>
|
|
@for ($x = 0; $x < count($reference_array); $x++)
|
|
@if(isset($reference_array[$x]) && isset($reference_name[$x]))
|
|
<a style="font-weight:normal;" href="{{ $reference_array[$x] }}" target="blank">{{ $reference_name[$x] }}</a><br>
|
|
@endif
|
|
@endfor
|
|
@if (!empty($pharm_comment))
|
|
<div style='padding: 1px; margin: 6px 1px 0px 1px; font-size: smaller' class='alert alert-info span12 margin-none well'>{{ $pharm_comment }}</div>
|
|
@endif
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<div class="row">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" style="margin-bottom: 0px;" name='dose[]' id="dose{{$prescription->id}}" class="form-control" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller;">
|
|
<?php $drugunit = getTableInfo('drug_units','name','id='.$prescription->unit_id); ?>
|
|
{{ $drugunit }}
|
|
</span>
|
|
</div>
|
|
<div class="col-sm-8">
|
|
<select class="form-control" name='frequency[]' style="margin-bottom: 0px;" id="frequency{{$prescription->id}}" required>
|
|
<option value=''>select</option>
|
|
<?php echo $fre_drop; ?>
|
|
</select>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv1{{$prescription->id}}"></span>
|
|
<a id="add_dose{{$prescription->id}}" style="font-size: xx-small; color: #98AFC7; float: right;">{{ __('prescriptions.add_dose') }}</a>
|
|
</div>
|
|
</div>
|
|
<div class="row" style="display: none;" id="dose_two_div{{$prescription->id}}">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" name='dose_two[]' style="margin-bottom: 0px;" id="dose_two{{$prescription->id}}" value="0" class="form-control" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller; float: left;">
|
|
<?php $drugunit = getTableInfo('drug_units','name','id='.$prescription->unit_id); ?>
|
|
{{ $drugunit }}
|
|
</span>
|
|
<a id="close_add_dose{{$prescription->id}}" style="font-size: xx-small; color: #98AFC7; display: none; float: right;">Close</a>
|
|
</div>
|
|
<div class="span4">
|
|
<br>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2{{$prescription->id}}"></span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<?php
|
|
// Show the prompt
|
|
if (!empty($prescription->prompt)):
|
|
echo '<div style="padding: 3px 3px 3px 4px; color: #C85F6A;" class="well margin-none span12" >';
|
|
echo $prescription->prompt;
|
|
echo "</div>";
|
|
endif;
|
|
|
|
// Hidden field for Long Term
|
|
echo "<input name = 'long_term[]' type = 'hidden' value = '" . $prescription->long_term . "' >";
|
|
?>
|
|
<input type='hidden' name='dispense[]' id="dispense{{$prescription->id}}" checked='checked' value='Yes' required/>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<input type='number' style="margin-bottom: 0px;" name='duration[]' id="duration{{$prescription->id}}" class="form-control" placeholder="days" required />
|
|
<input type="hidden" name="time[]" value="Days" class="span4" readonly required >
|
|
<span style="margin-bottom: 4px; font-size: xx-small; float: right;">Duration in days</span>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<input type='number' style="margin-bottom: 0px;" name='quantity_dispensed[]' id="quantity_dispensed{{$prescription->id}}" class="form-control" required readonly />
|
|
<?php $drug_form = getTableInfo('unit_of_measure','name','id='.$prescription->form_id); ?>
|
|
<input type="hidden" id="drug_form{{$prescription->id}}" value="{{$drug_form}}">
|
|
|
|
@if($prescription->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1)
|
|
<input type="hidden" id="selling_price{{$prescription->id}}" value="{{$prescription->insured_price}}">
|
|
@else
|
|
<input type="hidden" id="selling_price{{$prescription->id}}" value="{{$prescription->non_insured_price}}">
|
|
@endif
|
|
|
|
<input type="hidden" name="pack[]" id="pack{{$prescription->id}}" value="{{$prescription->pack}}">
|
|
<input type="hidden" name="strength[]" id="strength{{$prescription->id}}" value="{{$prescription->strength}}">
|
|
</td>
|
|
<td class="center" id="auto_price{{$prescription->id}}" style="padding: 2px;border: 1px solid #ddd;"></td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<textarea name="instructions[]" id="instructions{{$prescription->id}}" class="form-control" rows="3" placeholder="Instructions to the patient .."></textarea>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
@endif
|
|
<tr>
|
|
<td colspan="5"></td>
|
|
<td><b>{{ __('prescriptions.grand_total') }}</b></td>
|
|
<td id="grand_total_column" style="font-weight: bold; border: 1px solid #ddd;"></td><td class="instruction_td" style="border: 1px solid #ddd;"></td>
|
|
</tr>
|
|
@else
|
|
<tr class="warning"><td class="center" colspan="8" style="border: 1px solid #ddd;">{{ __('prescriptions.no_drugs_searched') }}</td></tr>
|
|
@endif
|
|
|
|
<!-- Do a refill of previous treatment from parent episode -->
|
|
@if(count($dispensed_drugs_from_parent_episode))
|
|
<tr>
|
|
<td colspan='8' style='height: 45px; border-left: 0px; border-right: 0px; padding: 2px;border: 1px solid #ddd;'></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' style='background-color: #FFE6E6; font-weight: bolder; text-decoration: underline;padding: 2px;border: 1px solid #ddd;'>{{ __('prescriptions.drug_refill_from') }} {{ streamline_date(get_name($parent_episode_id, 'id', 'created_at', 'patient_episodes')) }}</td>
|
|
<td colspan='5'><a class='pull-right' href='/prescriptions/print_treatment'></a></td>
|
|
<td class='instruction_td' style="padding: 2px;border: 1px solid #ddd;"></td>
|
|
</tr>
|
|
|
|
@foreach($dispensed_drugs_from_parent_episode as $dispensed_treatment)
|
|
@if($dispensed_treatment->altered == 0)
|
|
@php
|
|
$drugs_array = explode(",", $dispensed_treatment->drugs);
|
|
$dosage_array = explode(",", $dispensed_treatment->doses);
|
|
$dosage2_array = explode(",", $dispensed_treatment->dose2);
|
|
$frequencies_array = explode(",", $dispensed_treatment->frequencies);
|
|
$duration_array = explode(",", $dispensed_treatment->durations);
|
|
$quantity_dispensed_array = explode(",", $dispensed_treatment->quantities_dispensed);
|
|
$instructions_array = explode(",", $dispensed_treatment->instruction);
|
|
@endphp
|
|
|
|
@for($j = 0; $j < count($drugs_array); $j++)
|
|
@php
|
|
$drug_details = \Streamline\Models\Drug::find($drugs_array[$j]);
|
|
$frequency_name = get_name($frequencies_array[$j], 'id', 'name', 'dosage_frequencies');
|
|
$unit = get_name($drugs_array[$j], 'id', 'name', 'drug_units');
|
|
$unit = $unit=="N/A"?"":$unit;
|
|
$drug_unit = "<small>" . $unit . "</small>";
|
|
$dose2 = (empty($dosage2_array[$j])) ? "" : " | " . $dosage2_array[$j] . $drug_unit;
|
|
@endphp
|
|
|
|
|
|
<tr id="my_row{{ $drug_details->id }}" class="to_remove">
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
@php
|
|
$total_stock = $drug_details->pharmacy_stock;
|
|
@endphp
|
|
@if ($total_stock > 0)
|
|
<input type="checkbox" name="drug_id[]" id="chk" class="prescription-check" value="{{ $drug_details->id }}" />
|
|
<input type="hidden" name="drug_id[]" id="chk" value="{{ $drug_details->id }}" />
|
|
@endif
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
@php
|
|
$insurance_color = ($drug_details->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) ? "green" : "orange";
|
|
@endphp
|
|
|
|
@if ($total_stock <= 0)
|
|
<span class="badge badge-danger">{{ __('prescriptions.out_of_stock') }}</span>
|
|
@endif
|
|
|
|
<span style="color:{{ $insurance_color }}"> {{ $drug_details->name }}</span>
|
|
|
|
<?php
|
|
$pharm_comment = trim($drug_details->pharmacy_comment);
|
|
$reference_array = explode(",", $drug_details->reference_areas);
|
|
$reference_name = explode(",", $drug_details->reference_name);
|
|
?>
|
|
|
|
|
|
@for ($x = 0; $x < count($reference_array); $x++)
|
|
@if(isset($reference_array[$x]) && isset($reference_name[$x]))
|
|
<a style="font-weight:normal;" href="{{ $reference_array[$x] }}" target="blank">{{ $reference_name[$x] }}</a><br>
|
|
@endif
|
|
@endfor
|
|
|
|
@if (!empty($pharm_comment))
|
|
<div style='padding: 1px; margin: 6px 1px 0px 1px; font-size: smaller' class='alert alert-info span12 margin-none well'>{{ $pharm_comment }}</div>
|
|
@endif
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<div class="row">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" style="margin-bottom: 0px;" name='dose[]' id="dose{{$drug_details->id}}" class="form-control" value="{{ $dosage_array[$j] }}" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller;">
|
|
<?php $drugunit = getTableInfo('drug_units','name','id='.$drug_details->unit_id); ?>
|
|
{{ $drugunit }}
|
|
</span>
|
|
</div>
|
|
<div class="col-sm-8">
|
|
<select class="form-control" name='frequency[]' style="margin-bottom: 0px;" id="frequency{{$drug_details->id}}" required>
|
|
<option value="0">--Select --</option>
|
|
@foreach($dosage_frequencies as $frequency)
|
|
<option value="{{ $frequency->id }}" @if($frequencies_array[$j]==$frequency->id) selected @endif>{{ $frequency->name }}</option>
|
|
@endforeach
|
|
</select>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv1{{$drug_details->id}}"></span>
|
|
<a id="add_dose{{$drug_details->id}}" style="font-size: xx-small; color: #98AFC7; float: right;">{{ __('prescriptions.add_dose') }}</a>
|
|
</div>
|
|
</div>
|
|
<div class="row" style="display: none;" id="dose_two_div{{$drug_details->id}}">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" name='dose_two[]' style="margin-bottom: 0px;" id="dose_two{{$drug_details->id}}" value="0" class="form-control" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller; float: left;">
|
|
<?php
|
|
$drugunit = getTableInfo('drug_units','name','id='.$drug_details->unit_id);
|
|
$drugform = getTableInfo('drug_forms','name','id='.$drug_details->form_id);
|
|
?>
|
|
{{ $drugunit }}
|
|
</span>
|
|
<a id="close_add_dose{{$drug_details->id}}" style="font-size: xx-small; color: #98AFC7; display: none; float: right;">Close</a>
|
|
</div>
|
|
<div class="span4">
|
|
<br>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2{{$drug_details->id}}"></span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<?php
|
|
// Show the prompt
|
|
if (!empty($drug_details->prompt)):
|
|
echo '<div style="padding: 3px 3px 3px 4px; color: #C85F6A;" class="well margin-none span12" >';
|
|
echo $drug_details->prompt;
|
|
echo "</div>";
|
|
endif;
|
|
|
|
// Hidden field for Long Term
|
|
echo "<input name = 'long_term[]' type = 'hidden' value = '" . $drug_details->long_term . "' >";
|
|
?>
|
|
<input type='hidden' name='dispense[]' id="dispense{{$drug_details->id}}" checked='checked' value='Yes' required/>
|
|
</td>
|
|
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
|
|
@php $duration_with_days_text = explode(" ", $duration_array[$j]); @endphp
|
|
|
|
<input type='number' style="margin-bottom: 0px;" name='duration[]' id="duration{{$drug_details->id}}" class="form-control" value="{{ isset($duration_with_days_text[0]) ? $duration_with_days_text[0] : '' }}" placeholder="days" required />
|
|
<input type="hidden" name="time[]" value="Days" class="span4" readonly required >
|
|
<span style="margin-bottom: 4px; font-size: xx-small; float: right;">{{ __('prescriptions.duration_in_days') }}</span>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<input type='number' style="margin-bottom: 0px;" name='quantity_dispensed[]' id="quantity_dispensed{{$drug_details->id}}" value="{{ isset($quantity_dispensed_array[$j]) ? $quantity_dispensed_array[$j] : '' }}" class="form-control" required readonly />
|
|
<?php $drug_form = getTableInfo('unit_of_measure','name','id='.$drug_details->form_id); ?>
|
|
<input type="hidden" id="drug_form{{$drug_details->id}}" value="{{$drug_form}}">
|
|
|
|
@if($drug_details->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1)
|
|
<input type="hidden" id="selling_price{{$drug_details->id}}" value="{{$drug_details->insured_price}}">
|
|
@else
|
|
<input type="hidden" id="selling_price{{$drug_details->id}}" value="{{$drug_details->non_insured_price}}">
|
|
@endif
|
|
|
|
<input type="hidden" name="pack[]" id="pack{{$drug_details->id}}" value="{{$drug_details->pack}}">
|
|
<input type="hidden" name="strength[]" id="strength{{$drug_details->id}}" value="{{$drug_details->strength}}">
|
|
</td>
|
|
|
|
<td class="center" id="auto_price{{$drug_details->id}}" style="padding: 2px;border: 1px solid #ddd;"></td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<textarea name="instructions[]" id="instructions{{$drug_details->id}}" class="form-control" rows="3" placeholder="Instructions to the patient ..">
|
|
{{ isset($instructions_array[$j]) ? $instructions_array[$j] : ''}}
|
|
</textarea>
|
|
</td>
|
|
</tr>
|
|
@endfor
|
|
@else
|
|
@php
|
|
$drugs_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'drugs', 'patient_dispensings'));
|
|
$dosage_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'dose', 'patient_dispensings'));
|
|
$dosage2_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'dose2', 'patient_dispensings'));
|
|
$frequencies_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'drug_frequency', 'patient_dispensings'));
|
|
$duration_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'duration', 'patient_dispensings'));
|
|
$quantity_dispensed_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'quantity_dispensed', 'patient_dispensings'));
|
|
$instructions_array = explode(",", get_name($dispensed_treatment->altered, 'id', 'instructions', 'patient_dispensings'));
|
|
@endphp
|
|
|
|
@for($k = 0; $k < count($drugs_array); $k++)
|
|
@php
|
|
$drug_details = \Streamline\Models\Drug::find($drugs_array[$k]);
|
|
$frequency_name = get_name($frequencies_array[$k], 'id', 'name', 'dosage_frequencies');
|
|
$unit = get_name($drugs_array[$k], 'id', 'name', 'drug_units');
|
|
$unit = $unit=="N/A"?"":$unit;
|
|
$drug_unit = "<small>" . $unit . "</small>";
|
|
$dose2 = (empty($dosage2_array[$k])) ? "" : " | " . $dosage2_array[$k] . $drug_unit;
|
|
@endphp
|
|
|
|
<tr id="my_row{{ $drug_details->id }}" class="to_remove">
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
@php
|
|
$total_stock = $drug_details->pharmacy_stock;
|
|
@endphp
|
|
|
|
@if ($total_stock > 0)
|
|
<input type="checkbox" name="drug_id[]" id="chk" class="prescription-check" value="{{ $drug_details->id }}" />
|
|
<input type="hidden" name="drug_id[]" id="chk" value="{{ $drug_details->id }}" />
|
|
@endif
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
@php
|
|
$insurance_color = ($drug_details->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) ? "green" : "orange";
|
|
@endphp
|
|
@if ($total_stock <= 0)
|
|
<span class="badge badge-danger">{{ __('prescriptions.out_of_stock') }}</span>
|
|
@endif
|
|
<span style="color:{{ $insurance_color }}"> {{ $drug_details->name }}</span>
|
|
|
|
<?php
|
|
$pharm_comment = trim($drug_details->pharmacy_comment);
|
|
$reference_array = explode(",", $drug_details->reference_areas);
|
|
$reference_name = explode(",", $drug_details->reference_name);
|
|
?>
|
|
|
|
@for ($x = 0; $x < count($reference_array); $x++)
|
|
@if(isset($reference_array[$x]) && isset($reference_name[$x]))
|
|
<a style="font-weight:normal;" href="{{ $reference_array[$x] }}" target="blank">{{ $reference_name[$x] }}</a><br>
|
|
@endif
|
|
@endfor
|
|
@if (!empty($pharm_comment))
|
|
<div style='padding: 1px; margin: 6px 1px 0px 1px; font-size: smaller' class='alert alert-info span12 margin-none well'>{{ $pharm_comment }}</div>
|
|
@endif
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<div class="row">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" style="margin-bottom: 0px;" name='dose[]' id="dose{{$drug_details->id}}" value="{{ $dosage_array[$k] }}" class="form-control" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller;">
|
|
<?php $drugunit = getTableInfo('drug_units','name','id='.$drug_details->unit_id); ?>
|
|
{{ $drugunit }}
|
|
</span>
|
|
</div>
|
|
<div class="col-sm-8">
|
|
<select class="form-control" name='frequency[]' style="margin-bottom: 0px;" id="frequency{{$drug_details->id}}" required>
|
|
<option value="0">--Select --</option>
|
|
@foreach($dosage_frequencies as $frequency)
|
|
<option value="{{ $frequency->id }}" @if($frequencies_array[$k]==$frequency->id) selected @endif>{{ $frequency->name }}</option>
|
|
@endforeach
|
|
</select>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv1{{$drug_details->id}}"></span>
|
|
<a id="add_dose{{$drug_details->id}}" style="font-size: xx-small; color: #98AFC7; float: right;">{{ __('prescriptions.add_dose') }}</a>
|
|
</div>
|
|
</div>
|
|
<div class="row" style="display: none;" id="dose_two_div{{$drug_details->id}}">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" name='dose_two[]' style="margin-bottom: 0px;" id="dose_two{{$drug_details->id}}" value="0" class="form-control" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller; float: left;">
|
|
<?php $drugunit = getTableInfo('drug_units','name','id='.$drug_details->unit_id); ?>
|
|
{{ $drugunit }}
|
|
</span>
|
|
<a id="close_add_dose{{$drug_details->id}}" style="font-size: xx-small; color: #98AFC7; display: none; float: right;">Close</a>
|
|
</div>
|
|
<div class="span4">
|
|
<br>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2{{$drug_details->id}}"></span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<?php
|
|
// Show the prompt
|
|
if (!empty($drug_details->prompt)):
|
|
echo '<div style="padding: 3px 3px 3px 4px; color: #C85F6A;" class="well margin-none span12" >';
|
|
echo $drug_details->prompt;
|
|
echo "</div>";
|
|
endif;
|
|
|
|
// Hidden field for Long Term
|
|
echo "<input name = 'long_term[]' type = 'hidden' value = '" . $drug_details->long_term . "' >";
|
|
?>
|
|
<input type='hidden' name='dispense[]' id="dispense{{$drug_details->id}}" checked='checked' value='Yes' required/>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
|
|
@php $duration_with_days_text = explode(" ", $duration_array[$k]); @endphp
|
|
|
|
<input type='number' style="margin-bottom: 0px;" name='duration[]' id="duration{{$drug_details->id}}" value="{{ isset($duration_with_days_text[0]) ? $duration_with_days_text[0] : '' }}" class="form-control" placeholder="days" required />
|
|
<input type="hidden" name="time[]" value="Days" class="span4" readonly required >
|
|
<span style="margin-bottom: 4px; font-size: xx-small; float: right;">{{ __('prescriptions.duration_in_days') }}</span>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<input type='number' style="margin-bottom: 0px;" name='quantity_dispensed[]' id="quantity_dispensed{{$drug_details->id}}" class="form-control" value="{{ isset($quantity_dispensed_array[$k]) ? $quantity_dispensed_array[$k] : '' }}" required readonly />
|
|
<?php $drug_form = getTableInfo('unit_of_measure','name','id='.$drug_details->form_id); ?>
|
|
<input type="hidden" id="drug_form{{$drug_details->id}}" value="{{$drug_form}}">
|
|
|
|
@if($drug_details->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1)
|
|
<input type="hidden" id="selling_price{{$drug_details->id}}" value="{{$drug_details->insured_price}}">
|
|
@else
|
|
<input type="hidden" id="selling_price{{$drug_details->id}}" value="{{$drug_details->non_insured_price}}">
|
|
@endif
|
|
|
|
<input type="hidden" name="pack[]" id="pack{{$drug_details->id}}" value="{{$drug_details->pack}}">
|
|
<input type="hidden" name="strength[]" id="strength{{$drug_details->id}}" value="{{$drug_details->strength}}">
|
|
</td>
|
|
<td class="center" id="auto_price{{$drug_details->id}}" style="padding: 2px;border: 1px solid #ddd;"></td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<textarea name="instructions[]" id="instructions{{$drug_details->id}}" class="form-control" rows="3" placeholder="Instructions to the patient ..">
|
|
{{ isset($instructions_array[$k]) ? $instructions_array[$k] : ''}}
|
|
</textarea>
|
|
</td>
|
|
</tr>
|
|
@endfor
|
|
@endif
|
|
@endforeach
|
|
@endif
|
|
<!-- end of refill -->
|
|
|
|
<!-- if there is data in the treatment table for this patient with this episode -->
|
|
@if($treatment)
|
|
@php
|
|
$drugs_array = explode(",", $treatment->drugs);
|
|
$dosage_array = explode(",", $treatment->doses);
|
|
$frequencies_array = explode(",", $treatment->frequencies);
|
|
$duration_array = explode(",", $treatment->durations);
|
|
$quantity_dispensed_array = explode(",", $treatment->quantities_dispensed);
|
|
$total_drug_price = 0;
|
|
$instructions_array = explode(",", $treatment->instruction);
|
|
@endphp
|
|
|
|
<tr><td colspan='8' style='height: 45px; border-left: 0px; border-right: 0px; padding: 2px;border: 1px solid #ddd;'></td></tr>
|
|
<tr><td colspan='2' style='background-color: #FFE6E6; font-weight: bolder; text-decoration: underline;padding: 2px;border: 1px solid #ddd;'>Pending</td>
|
|
<td colspan='5'><a class='pull-right' href='/prescriptions/print_treatment'>Print</a></td>
|
|
<td class='instruction_td' style="padding: 2px;border: 1px solid #ddd;"></td>
|
|
</tr>
|
|
|
|
<!-- the Treatment ID -->
|
|
<input type='hidden' name ='treatment_id' value='{{ $treatment->id }}'>
|
|
<?php
|
|
for ($x = 0; $x < count($drugs_array); $x++) {
|
|
$sql = "select name,non_insured_price,insured_price,prompt,insurance_coverage,pack,strength,unit_id, form_id, pharmacy_comment from drugs WHERE id = {$drugs_array[$x]}";
|
|
$result = \DB::select($sql);
|
|
$treament_drug = isset($result[0])?$result[0]:null;
|
|
if (isset($treament_drug)) {
|
|
$insurance_color = ($treament_drug->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1) ? "green" : "orange";
|
|
echo "<tr id='my_row" . $drugs_array[$x] . "'>"
|
|
. "<td style='padding: 2px;border: 1px solid #ddd;'>";
|
|
|
|
echo "<input type='hidden' name='drug_id[]' id='chk' value='{$drugs_array[$x]}' />";
|
|
|
|
echo "</td>"
|
|
. "<td style='padding: 2px;border: 1px solid #ddd;'>"
|
|
. "<span style='color: {$insurance_color};'>" . $treament_drug->name . "</span>";
|
|
$pharm_comment = trim($treament_drug->pharmacy_comment);
|
|
if (!empty($pharm_comment)):
|
|
echo "<div style='padding: 1px; margin: 6px 1px 0px 1px; font-size: smaller' class='alert alert-info span12 well margin-none'>" . $pharm_comment . "</div>";
|
|
endif;
|
|
echo "</td>";
|
|
?>
|
|
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<div class="row">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" name='dose[]' style="margin-bottom: 0px;" id="dose{{$drugs_array[$x]}}" class="form-control" value="{{$dosage_array[$x]}}" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller; float: left;">
|
|
<?php
|
|
echo getTableInfo('drug_units','name','id='.$treament_drug->unit_id);
|
|
?>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="col-sm-8">
|
|
<select class="form-control" style="margin-bottom: 0px;" name='frequency[]' id='frequency<?php echo $drugs_array[$x]; ?>' required>
|
|
<option value='<?php echo $frequencies_array[$x]; ?>'>
|
|
<?php
|
|
echo getTableInfo('dosage_frequencies','name','id='.$frequencies_array[$x]);
|
|
?>
|
|
</option>
|
|
<?php echo $fre_drop; ?>
|
|
</select>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv1<?php echo $drugs_array[$x]; ?>"></span>
|
|
<a style="font-size: xx-small; color: #98AFC7; float: right;" id="add_dose<?php echo $drugs_array[$x]; ?>">{{ __('prescriptions.add_dose') }}</a>
|
|
</div>
|
|
</div>
|
|
<div class="row" style="display: none;" id="dose_two_div<?php echo $drugs_array[$x]; ?>">
|
|
<div class="col-sm-4">
|
|
<input type='number' step="0.001" name='dose_two[]' style="margin-bottom: 0px;" value="0" id="dose_two<?php echo $drugs_array[$x]; ?>" class="form-control" required />
|
|
<span style="margin-bottom: 4px; font-size: smaller; float: left;">
|
|
<?php
|
|
echo getTableInfo('drug_units','name','id='.$treament_drug->unit_id);
|
|
?>
|
|
</span>
|
|
<a id="close_add_dose<?php echo $drugs_array[$x]; ?>" style="font-size: xx-small; color: #98AFC7; display: none; float: right;">Close</a>
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<br>
|
|
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2<?php echo $drugs_array[$x]; ?>"></span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<?php
|
|
echo "<div style='padding: 3px 3px 3px 4px; color: #C85F6A;' class='well margin-none span12' >"
|
|
. $treament_drug->prompt
|
|
. "</div>";
|
|
?>
|
|
</td>
|
|
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<?php $duration_unit = explode(" ", $duration_array[$x]); ?>
|
|
<input type='number' style="margin-bottom: 0px;" name='duration[]' id="duration<?php echo $drugs_array[$x]; ?>" value="<?php echo $duration_unit[0]; ?>" class="form-control" placeholder="days" required />
|
|
<input type="hidden" name="time[]" value="Days" class="form-control" readonly required >
|
|
<span style="margin-bottom: 4px; font-size: xx-small; float: right;">Duration in days</span>
|
|
</td>
|
|
<td style="padding: 2px;border: 1px solid #ddd;">
|
|
<input type='number' name='quantity_dispensed[]' style="margin-bottom: 0px;" value="<?php echo $quantity_dispensed_array[$x]; ?>" id="quantity_dispensed<?php echo $drugs_array[$x] ?>" class="form-control" required readonly />
|
|
<?php
|
|
$drug_form = getTableInfo('unit_of_measure','name','id='.$treament_drug->form_id);
|
|
?>
|
|
<input type="hidden" id="drug_form<?php echo $drugs_array[$x]; ?>" value="<?php echo $drug_form; ?>">
|
|
|
|
@if($treament_drug->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1)
|
|
<input type="hidden" id="selling_price<?php echo $drugs_array[$x]; ?>" value="<?php echo $treament_drug->insured_price; ?>">
|
|
@else
|
|
<input type="hidden" id="selling_price<?php echo $drugs_array[$x]; ?>" value="<?php echo $treament_drug->non_insured_price; ?>">
|
|
@endif
|
|
|
|
<input type="hidden" name="pack[]" id="pack<?php echo $drugs_array[$x]; ?>" value="<?php echo $treament_drug->pack; ?>">
|
|
<input type="hidden" name="strength[]" id="strength<?php echo $drugs_array[$x]; ?>" value="<?php echo $treament_drug->strength; ?>">
|
|
</td>
|
|
|
|
<?php
|
|
if($treament_drug->insurance_coverage == 1 && patient_insurance_status($patient_id) == 1){
|
|
$drug_price = $treament_drug->insured_price * $quantity_dispensed_array[$x];
|
|
} else {
|
|
$drug_price = $treament_drug->non_insured_price * $quantity_dispensed_array[$x];
|
|
}
|
|
$total_drug_price += $drug_price;
|
|
echo "<td style='padding: 2px;border: 1px solid #ddd;' id='selected_auto_price" . $drugs_array[$x] . "'> "
|
|
. ugandan_shillings($drug_price)
|
|
. "</td>";
|
|
?>
|
|
|
|
<td style="padding: 2px;border: 1px solid #ddd;" class="instruction_td">
|
|
<textarea name='instructions[]' id='instructions<?php echo $drugs_array[$x]; ?>' class="form-control" placeholder="Instruction to patient..."><?php echo trim($instructions_array[$x]); ?></textarea>
|
|
</td>
|
|
|
|
<?php
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
$final_total = ugandan_shillings($total_drug_price);
|
|
?>
|
|
<tr>
|
|
<td colspan="5" style="border: 1px solid #ddd;"></td>
|
|
<td><b>Grand total</b></td>
|
|
<td style="font-weight: bold; border: 1px solid #ddd;"> {{ $final_total }} </td><td class="instruction_td" style="border: 1px solid #ddd;"></td>
|
|
</tr>
|
|
@endif
|
|
</tbody>
|
|
</table>
|
|
<input type="button" id="delete_row_button" class = "btn btn-success pull-right" value="Confirm Selection" />
|
|
|
|
<input type="submit" id="submit_prescription" style="display: none" class = "btn btn-success pull-right" value="Complete Prescription" onsubmit="return onSubmitPrescription()" />
|
|
|
|
{{ Form::close() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="white-box">
|
|
<h4>Treatment Given For This Episode</h4>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover color-table success-table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>DATE</th>
|
|
<th>DRUG NAME</th>
|
|
<th>DOSAGE</th>
|
|
<th>DURATION</th>
|
|
<th>QUANTITY</th>
|
|
<th>STATUS</th>
|
|
<th>INSTRUCTION</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@if(count($dispensed_drugs) > 0)
|
|
@foreach($dispensed_drugs as $treatment)
|
|
@php
|
|
$drugs_array = explode(",", $treatment->drugs);
|
|
$dosage_array = explode(",", $treatment->doses);
|
|
$dosage2_array = explode(",", $treatment->dose2);
|
|
$frequencies_array = explode(",", $treatment->frequencies);
|
|
$duration_array = explode(",", $treatment->durations);
|
|
$quantity_dispensed_array = explode(",", $treatment->quantities_dispensed);
|
|
$instructions_array = explode(",", $treatment->instruction);
|
|
@endphp
|
|
@for($x = 0; $x < count($drugs_array); $x++)
|
|
@php
|
|
$frequency_name = get_name($frequencies_array[$x], 'id', 'name', 'dosage_frequencies');
|
|
$unit = get_name($drugs_array[$x], 'id', 'name', 'drug_units');
|
|
$unit = $unit=="N/A"?"":$unit;
|
|
$drug_unit = "<small>" . $unit . "</small>";
|
|
$dose2 = (empty($dosage2_array[$x])) ? "" : " | " . $dosage2_array[$x] . $drug_unit;
|
|
@endphp
|
|
<tr>
|
|
<td>{{ streamline_date_time($treatment->updated_at) }}</td>
|
|
<td>{{ get_name($drugs_array[$x], 'id', "name", 'drugs') }}</td>
|
|
<td>{{ $dosage_array[$x] }} {!! $drug_unit !!} {{ $dose2 }} {{ $frequency_name }}</td>
|
|
<td>{{ $duration_array[$x] }}</td>
|
|
<td>{{ $quantity_dispensed_array[$x] }}</td>
|
|
<td style='color: green'>
|
|
@if($treatment->altered == 0)
|
|
{{ __('prescriptions.dispensed') }}
|
|
@else
|
|
{{ __('prescriptions.altered_and_dispensed') }}
|
|
@endif
|
|
</td>
|
|
<td>
|
|
{{ isset($instructions_array[$x]) ? trim($instructions_array[$x]) : 'N/A' }}
|
|
</td>
|
|
</tr>
|
|
@endfor
|
|
@endforeach
|
|
@else
|
|
<tr>
|
|
<td colspan="7" class="text-center"><code>No treatment history for this episode</code></td>
|
|
</tr>
|
|
@endif
|
|
<tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
@push('scripts')
|
|
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
|
|
<script src="{{ asset('elite/js/validator.js') }}"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$('.prescription-drugs').select2({
|
|
placeholder: "Select drugs"
|
|
});
|
|
/*
|
|
*1.The javascript code below javascript code from the old streamline
|
|
*2.check to make sure it works then refactor
|
|
*3.only changed the ajax that gets the factor from frequency_id
|
|
*/
|
|
// Higligting for the table rows on the prescription page
|
|
$(".prescription-check").change(function () {
|
|
var ischecked = $(this).is(':checked');
|
|
if (ischecked) {
|
|
$('#my_row' + $(this).val()).addClass('color-tr');
|
|
$('#my_row' + $(this).val()).removeClass('to_remove');
|
|
} else {
|
|
$('#my_row' + $(this).val()).removeClass('color-tr');
|
|
$('#my_row' + $(this).val()).addClass('to_remove');
|
|
}
|
|
});
|
|
|
|
$("#delete_row_button").click(function (e) {
|
|
|
|
var atleast_one_drug_selected = $('input:checkbox').is(':checked'); // Atleast one checkbox selected
|
|
|
|
if (atleast_one_drug_selected) {
|
|
|
|
// begin checking to ensure there is enough quantity dispensed
|
|
let drug_id = $("input[name='drug_id[]']" ).map(function(){
|
|
return this.value;
|
|
}).get();
|
|
|
|
let quantity_dispensed = $("input[name='quantity_dispensed[]']" ).map(function(){
|
|
return this.value;
|
|
}).get();
|
|
|
|
// get unique values from the drug_id array
|
|
drug_id = [...new Set(drug_id)];
|
|
|
|
$.ajax({
|
|
url: '/check_dispensed_drugs_quantity',
|
|
data: {'drug_id_array[]':drug_id, 'quantity_dispensed_array[]':quantity_dispensed},
|
|
success: function(response){
|
|
if (response[0] === "1") {
|
|
alert(response[1]);
|
|
return false;
|
|
} else {
|
|
$(".to_remove").remove();
|
|
$(".prescription-check").attr("disabled", "disabled");
|
|
|
|
$('#submit_prescription').show();
|
|
$('#delete_row_button').hide();
|
|
/*loop thru the prescription_check row and is checked and get the auto_price*/
|
|
/********************************************/
|
|
var auto_price_grand_total = 0;
|
|
$("[id^=auto_price]").each(function(){
|
|
var auto_price = $(this).text();
|
|
if (auto_price.slice(-3) == 'UGx') { //if the auto_price column is a UGx
|
|
var without_ugx = auto_price.slice(0,-3); /*remove 'UGx' e.g turn 2300UGx to 2300*/
|
|
var auto_price_integer = parseInt(without_ugx);
|
|
auto_price_grand_total += auto_price_integer;
|
|
console.log(auto_price_integer);
|
|
}
|
|
});
|
|
$("#grand_total_column").text(auto_price_grand_total + " UGx");
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
e.preventDefault();
|
|
alert("Select atleast one drug.");
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$("[id^=add_dose]").click(function () { // link to the div that has the extra dose for some specific drugs eg Insulin
|
|
var id = parseInt($(this).attr("id").replace('add_dose', ''), 10);
|
|
var add_div = $("#dose_two_div" + id);
|
|
var close_add_dose = $("#close_add_dose" + id);
|
|
add_div.show();
|
|
close_add_dose.show();
|
|
$(this).hide();
|
|
});
|
|
|
|
$("[id^=close_add_dose]").click(function () { // link to close the div that has the extra dose for some specific drugs eg Insulin
|
|
var id = parseInt($(this).attr("id").replace('close_add_dose', ''), 10);
|
|
$("#dose_two" + id).val(0); // Set the second dose to 0
|
|
$("#equiv2" + id).text(""); // Removing the text from the label eg ( 2 tabs)
|
|
$("#dose_two_div" + id).hide();
|
|
var add_div_link = $("#add_dose" + id);
|
|
add_div_link.show();
|
|
$(this).hide();
|
|
});
|
|
|
|
|
|
$("[id^='dose'],[id^='frequency'],[id^='duration'], [id^='quantity_dispensed']").on("change keyup", function () {
|
|
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
|
|
|
|
var pack = parseFloat($("#pack" + id).val());
|
|
var strength = parseFloat($("#strength" + id).val()) || 0;
|
|
|
|
var dose1 = parseFloat($("#dose" + id).val()) || 0;
|
|
var dose2 = parseFloat($("#dose_two" + id).val()) || 0;
|
|
|
|
var equiv1 = dose1 / strength;
|
|
var equiv2 = dose2 / strength;
|
|
|
|
console.log(pack);
|
|
console.log(strength);
|
|
console.log(dose1);
|
|
console.log(dose2);
|
|
console.log(equiv1);
|
|
|
|
// Adding a prompt dynamically eg 500mg = 2tabs
|
|
$("#equiv1" + id).text("( " + equiv1 + " " + $("#drug_form" + id).val() + " )");
|
|
$("#equiv2" + id).text("( " + equiv2 + " " + $("#drug_form" + id).val() + " )");
|
|
|
|
var equiv_total = (dose1 + dose2) / strength;
|
|
if (isNaN(equiv_total) || equiv_total === Infinity) {
|
|
var equiv_total = 0;
|
|
}
|
|
|
|
var frequency_id = $("#frequency" + id).val() || 0;
|
|
var duration_days = parseInt($("#duration" + id).val()) || 0;
|
|
|
|
$.ajax({
|
|
url: '/prescriptions/get_factor/'+frequency_id,
|
|
data: {},
|
|
success: function(data){
|
|
var factor = parseFloat(data);
|
|
var quantity = parseFloat(equiv_total * factor * duration_days) || 0;
|
|
var required = quantity / pack;
|
|
var dispense = Math.ceil(required); // @TODO Roundup this to the nearest whole number
|
|
|
|
$("#quantity_dispensed" + id).val(dispense);
|
|
|
|
var selling_price = parseInt($("#selling_price" + id).val());
|
|
var cost = dispense * selling_price;
|
|
$("#auto_price" + id).text(cost + " UGx");
|
|
},
|
|
error: function(response){
|
|
//
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#instruction_button").click(function () {
|
|
$(".instruction_td").show();
|
|
$(this).hide();
|
|
$("#hide_instruction_button").show();
|
|
});
|
|
|
|
$("#hide_instruction_button").click(function () {
|
|
$(".instruction_td").hide();
|
|
$(this).hide();
|
|
$("#instruction_button").show();
|
|
});
|
|
|
|
function onSubmitPrescription(){
|
|
var dont_continue = "False";
|
|
$.each($("[id^='quantity_dispensed']"), function (e) { // make sure all quantities have been entered
|
|
if ($(this).val() === "" || $(this).val() === '0') {
|
|
dont_continue = 'true';
|
|
}
|
|
});
|
|
|
|
if (dont_continue === 'true') {
|
|
alert("Please fill out the Dosage and Duration of selected drugs.");
|
|
return false;
|
|
}
|
|
}
|
|
/*
|
|
*end of old streamline javascript
|
|
*/
|
|
|
|
/* highlight the checked treatment table row */
|
|
$('.prescription-check').click(function(e) {
|
|
if($(this).is(':checked')){
|
|
$(this).parent().parent().css({
|
|
'background-color': '#FFFF99'
|
|
});
|
|
}
|
|
else{
|
|
$(this).parent().parent().css({
|
|
'background-color': '#fff'
|
|
});
|
|
}
|
|
});
|
|
|
|
/* on table losing focus */
|
|
$(".table").focusout(function(e) {
|
|
/* store auto_price text values into array, loop through auto_price array values and find array_sum to get grand total */
|
|
var auto_price_grand_total = 0;
|
|
$("[id^=auto_price]").each(function(){
|
|
var auto_price = $(this).text();
|
|
if (auto_price.slice(-3) == 'UGx') { //if the auto_price column is a UGx
|
|
var without_ugx = auto_price.slice(0,-3); /*remove 'UGx' e.g turn 2300UGx to 2300*/
|
|
var auto_price_integer = parseInt(without_ugx);
|
|
auto_price_grand_total += auto_price_integer;
|
|
console.log(auto_price_integer);
|
|
}
|
|
});
|
|
$("#grand_total_column").text(auto_price_grand_total + " UGx");
|
|
});
|
|
});
|
|
</script>
|
|
@endpush
|