<?php

class medicament
{
	function get_medicament($id_consult)
	{
		$q = "SELECT * FROM medicament WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);
	
		if ($r)
		{
			$n = mysql_fetch_assoc($r);
			return $n;
		}
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	
		return false;
	}
	
	function edit_medicament($id_consult, $medic_benzo, $medic_benzo_mesu, $medic_anxio, $medic_anxio_mesu, $medic_hypno, $medic_hypno_mesu, $medic_antidepr, $medic_antidepr_mesu, $medic_neuro, $medic_neuro_mesu, $medic_barbi, $medic_barbi_mesu, $medic_autres, $medic_autres_mesu, $medic_autres_desc, $medic_methadone, $medic_metha_mesu, $medic_subutex, $medic_subu_mesu, $medic_subst_autres, $medic_subst_autres_mesu, $medic_iv, $medic_anorexie, $medic_boulimie, $medic_jeupath, $medic_anxiete, $medic_depression, $medic_eval_psy, $medic_trouble_psy)
	{
		if ($id_consult)
			$this->del_medicament($id_consult);
			
		$q = "INSERT INTO medicament (id_consult, medic_benzo, medic_benzo_mesu, medic_anxio, medic_anxio_mesu, medic_hypno, medic_hypno_mesu, medic_antidepr, medic_antidepr_mesu, medic_neuro, medic_neuro_mesu, medic_barbi, medic_barbi_mesu, medic_autres, medic_autres_mesu, medic_autres_desc, medic_methadone, medic_metha_mesu, medic_subutex, medic_subu_mesu, medic_subst_autres, medic_subst_autres_mesu, medic_iv, medic_anorexie, medic_boulimie, medic_jeupath, medic_anxiete, medic_depression, medic_eval_psy, medic_trouble_psy) VALUES ('" . $id_consult . "', '" . $medic_benzo . "' , '" . $medic_benzo_mesu . "' , '" . $medic_anxio . "' , '" . $medic_anxio_mesu . "' , '" . $medic_hypno . "' , '" . $medic_hypno_mesu . "' , '" . $medic_antidepr . "' , '" . $medic_antidepr_mesu . "' , '" . $medic_neuro . "' , '" . $medic_neuro_mesu . "' , '" . $medic_barbi . "' , '" . $medic_barbi_mesu . "' , '" . $medic_autres . "' , '" . $medic_autres_mesu . "' , '" . sqldata($medic_autres_desc) . "' , '" . $medic_methadone . "' , '" . $medic_metha_mesu . "' , '" . $medic_subutex . "' , '" . $medic_subu_mesu . "' , '" . $medic_subst_autres . "' , '" . $medic_subst_autres_mesu . "' , '" . $medic_iv . "' , '" . $medic_anorexie . "' , '" . $medic_boulimie . "' , '" . $medic_jeupath . "' , '" . $medic_anxiete . "' , '" . $medic_depression . "' , '" . $medic_eval_psy . "' , '" . $medic_trouble_psy . "')";
		$r = mysql_query($q);
	
		if ($r) 
			return true;
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	
		return false;
	}

	function del_medicament($id_consult)
	{
		$q = "DELETE FROM medicament WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			$q = "OPTIMIZE TABLE medicament";
			$r = mysql_query($q);

			return true;
		}
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());

		return false;
	}
}

?>