Location: PHPKode > projects > WebETB > patient/create.php4
<?php
/******************************************************************************/
/*	MODUL:	patient/all.php4        														*/
/*																										*/
/* DATUM:	27.03.2006, Version 0.1															*/
/* BESCHR.:	Anlegen und verwalten von Patientenschluesseln/Nummern            */
/*																										*/
/*	AUTOR:   Marcus Groh																			*/
/*	LIZENZ:  GPL v2 vom Juni 1991 															*/
/*																										*/
/*	AENDERUNGEN:	13.01.2006        -initiale Version								   */
/*                27.03.2006 v 0.1, -Versionskennzeichnung eingefuehrt        */
/*                                  -Code unter GPL v2 gestellt               */
/*                                  -Tabellenname dynamisiert                 */
/*																										*/
/******************************************************************************/
$allowed_groups=array("elw");
include ('../_include/header_1.php4');
// Count num of patienten total
$select_totl_pat_eintr="select * from $T_patient where eid=$eid";
$result_totl_pat_eintr=@mysql_db_query($database["database"],$select_totl_pat_eintr,$db);
$result_totl_pat_eintr=mysql_num_rows($result_totl_pat_eintr);

//Count num of patienten used
$select_used_pat_eintr="select * from $T_patient where eid=$eid and used like 'Y'";
$result_used_pat_eintr=@mysql_db_query($database["database"],$select_used_pat_eintr,$db);
$result_used_pat_eintr=mysql_num_rows($result_used_pat_eintr);

if ( ( $writemode == "TRUE" ) && ( $isclosed == "FALSE" ) )
{
   // Datensatz eintragen
   if ( isset($create) )
   {

      // create etb-entry flag
      $etb_entry=0;
      
      // pat_num_max and pat_num_min should be NUM
      $pat_num_min=eregi_replace("([a-z])","",$pat_num_min);
      $pat_num_max=eregi_replace("([a-z])","",$pat_num_max);
      
      // pat_num_min should not be negative
      if ( $pat_num_min <= 0 )
      {
         $pat_num_min=0;
      }
      
      // pat_num_max must be grater than pat_num_min
      if ( $pat_num_max <= $pat_num_min )
      {
         $pat_num_max=$pat_num_min+1;
      }

      // Insert formated values
      for ( $i=$pat_num_min; $i<=$pat_num_max; $i++)
      {
         $zeros="";
         if ( $i <= 9 )
         {
           $zeros="0000";
         }
         elseif ( $i <= 99 )
         {
            $zeros="000";
         }
         elseif ( $i <= 999 )
         {
            $zeros="00";
         }
         elseif ( $i <= 9999 )
         {
            $zeros="0";
         }                   
         // Build string
         $new_pat_num=$pat_num_pref . $zeros . $i;
         // check if whe have it allready
         $check_new_pat_num="select pid from $T_patient where pat_nr like '$new_pat_num' and eid='$eid'";
         $result_new_pat_num=@mysql_db_query($database["database"],$check_new_pat_num,$db);
         $anzahl_new_pat_num=mysql_num_rows($result_new_pat_num);
         if ( $anzahl_new_pat_num == 0 )
         {
            $insert_new_pat_num="Insert into $T_patient values ('%','$eid','N','NULL','$new_pat_num','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL')";
            mysql_db_query($database["database"],$insert_new_pat_num,$db);
            $etb_entry=1;
         }
      }
      if ($etb_entry)
      {
          // Calc. new lfdnr
          $select_etb="select lfdnr from $T_etb where eid=$eid";
          $result=@mysql_db_query($database["database"],$select_etb,$db);
          $lfd=mysql_num_rows($result);
          $lfd++;
          $zeit=date("H:i:s");
          $datum=date("y-m-d");
          // Insert values
          $insert_etb="insert into $T_etb values ('$lfd','NULL','NULL','ELW','ETB','$datum','$zeit','Neue Patientennummern von $pat_num_min bis $pat_num_max angelegt','','','$uid','$eid')";
          mysql_db_query($database["database"],$insert_etb,$db);
      }
   }
   $create="";
   
   // Count num of patienten total again
   $result_totl_pat_eintr=@mysql_db_query($database["database"],$select_totl_pat_eintr,$db);
   $result_totl_pat_eintr=mysql_num_rows($result_totl_pat_eintr);
   ?>
       <br>
       <center>
          <form action="" method=post name="insert_patnums">
          <table border="0" cellspacing="0" cellpadding="0">
          <tr>
             <th colspan="7">Patientennummern erzeugen</th>
          </tr>
          <tr>
             <td>Prefix:</td>
             <td width="30">&nbsp;</td>
             <td colspan="5"><input type=text name="pat_num_pref" value="<? echo $PAT_PREFIX; ?>" maxlength="4" style="width: 50px; border: 1px solid silver;"></td>
          </tr>
          <tr>
             <td>Nr. von:</td>
             <td width="30">&nbsp;</td>
             <td><input type=text name="pat_num_min" value="<? echo $result_totl_pat_eintr+1; ?>" maxlength="5" style="width: 50px; border: 1px solid silver;"></td>
             <td width="50">&nbsp;</td>
             <td>Nr. bis:</td>
             <td width="30">&nbsp;</td>
             <td><input type=text name="pat_num_max" value="<? echo $result_totl_pat_eintr+30; ?>" maxlength="5" style="width: 50px; border: 1px solid silver;"></td>
          </tr>
          </table>
          <br>
          <input type=hidden name="create" value="TRUE">
          <input type=submit VALUE="Anlegen" style="border: 1px solid silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type=reset VALUE="Abbrechen" style="border: 1px solid silver;">
          </form>
          </center>
   <?
}
?>
   <center>
   <br><br>

   <table border="0" cellspacing="0" cellpadding="0" width="300">
   <tr>
      <th colspan="3">Patientenstatistik</th>
   </tr>
   <tr>
      <td colspan="3" height="5"><img src="../_img/spacer.gif" border="0" width="300" height="5"></td>
   </tr>
   <tr>
      <td>&nbsp;Insgesamt angelegt:</td>
      <td width="30">&nbsp;</td>
      <td><? echo $result_totl_pat_eintr ; ?></td>      
   </tr>
   <tr>
      <td>&nbsp;Davon zugeordnet:</td>
      <td width="30">&nbsp;</td>
      <td><? echo $result_used_pat_eintr; ?></td>      
   </tr>
   <tr>
      <td colspan="3" height="5"><img src="../_img/spacer.gif" border="0" width="300" height="5"></td>
   </tr>     
   </table>
</center>
<?

include ('../_include/footer_1.php4');

?>
Return current item: WebETB