コード例 #1
0
ファイル: test_forms.py プロジェクト: onnudilol/vetcalc
 def test_form_rejects_non_numeric_input(self):
     form = CRICPRForm(data={'weight': 'wait',
                             'rate': 'eight',
                             'vol': 'volume',
                             'dobutamine': 'nobutamine',
                             'dopamine': 'nopamine',
                             'lidocaine': 'hidocaine'})
     self.assertFalse(form.is_valid())
コード例 #2
0
ファイル: test_forms.py プロジェクト: onnudilol/vetcalc
 def test_form_rejects_empty_string(self):
     form = CRICPRForm(data={'weight': '',
                             'rate': '',
                             'vol': '',
                             'dobutamine': '',
                             'dopamine': '',
                             'lidocaine': ''})
     self.assertFalse(form.is_valid())
コード例 #3
0
ファイル: views.py プロジェクト: onnudilol/vetcalc
def calc_cri_cpr(request):
    """Calculates CRI dosages for post CPR maintenance

    GET parameters:
        weight: weight in kg
        rate: current rate
        volume: current iv vol in mL
        dobutamine: target dobutamine rate
        dopamine: target dopamine rate
        lidocaine: target lidocaine rate

    Context:
        rx: calculated cri dosages rounded to 3 decimal places

    """

    form = CRICPRForm()
    rx = dict()

    if request.method == 'GET' and request.is_ajax():
        form = CRICPRForm(data=request.GET)

        if form.is_valid():
            weight = float(request.GET['weight'])
            rate = float(request.GET['rate'])
            volume = float(request.GET['volume'])
            dobutamine = float(request.GET['dobutamine'])
            dopamine = float(request.GET['dopamine'])
            lidocaine = float(request.GET['lidocaine'])

            rx = {'maint': round((weight * 2.2 * 30)/24, 3),
                  'maint_plus': round((weight * 30 + 70)/24, 3),
                  'dose_dobutamine': round(((weight * dobutamine) / 12500)/(rate/60) * volume, 3),
                  'dose_dopamine': round((weight * dopamine / 40000)/(rate/60) * volume, 3),
                  'dose_lidocaine': round((weight * lidocaine / 20000)/(rate/60) * volume, 3),
                  'dose_epinephrine': round((weight/1000)/(rate/60) * volume, 3),
                  'dose_mannitol': round(weight * 4, 3),
                  'dose_solumedrol': round(weight * 30, 3)}

    return render(request, 'calc/cri_cpr.html', {'navbar': 'calc',
                                                 'form': form,
                                                 'rx': rx})