#!/usr/bin/perl
# The purpose of this program will allow the user to enter medical information with 
# important feedback from the medical program. For example if the user inputs a 
# temperature of 103.2, the program will give the correct feedback on what the 
# correct course of action should be.
VITAL:{
        
while(1){
                 
        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";
                }
                 
        print"Please Enter Pulse Rate Based on a 1 Minute Count: ";
        $pulse = <STDIN>;
        
        if($pulse < 0 || $pulse > 200){
                print"Invalid Pulse Rate!\n";
                next;}
                
        if($pulse > 120 && $pulse < 201){
                print"Send Patient to CCU.\n";

}
        elsif($pulse > 50 && $pulse < 119){
                print"Pulse Rate is Normal.\n";
                }
        elsif($pulse > 30 && $pulse < 49){
                print"Send Patient to a Telementry Floor.\n";
                }
        else{
                print"Start CPR!\n";
                }
        
        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";
                }
                
        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;
               
        print "Ready to quit (yes or no)? ";
        chomp($answer = <STDIN>);
        if ("$answer" eq "yes") {last;}
        redo VITAL;
}
}
