#!/usr/bin/perl

sub bodytemp 
{
	print"Please Enter Patients Temperature between 85.0 to 105.0: ";
        $btemp = <STDIN>;
                 
        if($btemp < 70.0 || $btemp > 105.0){
                print "Invalid Temperature!\n";
                next;}   
        
        if($btemp >= 102.0 && $btemp < 106.0){
                print "Give Tylenol 2 tablets 325 mg each or suppository every 4 hours.\n";
                }
        elsif ($btemp > 101.0 && $btemp < 101.9){
                print "Give Tylenol 2 tablets 325 mg each or suppository every 4 hours as needed for temperature.\n";
                }
        elsif ($btemp > 95.0 && $btemp < 100.9){
                print "Patient temperature is within normal limits and no corrective action is needed at this time.\n";
                }
        elsif ($btemp > 85.0 && $btemp < 94.9){
                print "Patient is hypothermic and must be warmed up slowly.\n";
                }
        else{
                print "Patient has expired.\n";
                }
}


sub resprate 
{
 	print"Enter Patient Respiratory Rate Based on a 1 Minute Count: ";
        $resp = <STDIN>;
                
        if($resp < 0 || $resp > 50){
                print"Invalid Respiratory Rate!\n";
                next;} 
        
        if($resp > 40 && $resp < 51){

      }
        elsif($resp > 12 && $resp < 39){
                print"Respiratory Rate is Normal.\n";
                }  
        else{
                print"Start Respiratory Rescue!\n";
                }
}


sub patientweight 
{
 	print"Enter Patient Weight in Pounds: ";
        $wt = <STDIN>;
        
        if($wt < 0 || $wt > 400){
                print"Invalid Weight!\n";
                next;}
                
        $pwt = $wt/2.2;
        
        printf"Patient Weight in kg: %8.2f\n", $pwt;
}

VITAL:{
	while(1){
		&bodytemp;
		&resprate;
		&patientweight;
		
		print "Ready to quit (yes or no)? ";
        	chomp($answer = <STDIN>);
        	if ("$answer" eq "yes") {last;}
        	redo VITAL;
	}
}
