|
|
|
|
@ -14,12 +14,14 @@ import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FilenameFilter;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
|
|
@ -35,6 +37,7 @@ import siprp.data.MedicoData;
|
|
|
|
|
import siprp.data.TrabalhadorData;
|
|
|
|
|
import siprp.importer.Importer;
|
|
|
|
|
import siprp.medicina.MarcacoesMedicinaHandler;
|
|
|
|
|
import siprp.printer.Printer;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.Singleton;
|
|
|
|
|
import com.evolute.utils.data.IDObject;
|
|
|
|
|
@ -221,6 +224,20 @@ public class FichaWindow extends TabbedWindow
|
|
|
|
|
"Apagar Fichas Anteriores", null,
|
|
|
|
|
0, false );
|
|
|
|
|
|
|
|
|
|
registerAction( new ActionHandler(){
|
|
|
|
|
public void execute()
|
|
|
|
|
{
|
|
|
|
|
printToFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean activate( boolean newAction, boolean editAction,
|
|
|
|
|
boolean cancelAction, boolean saveAction,
|
|
|
|
|
boolean deleteAction, boolean selectAction )
|
|
|
|
|
{
|
|
|
|
|
return saveAction || editAction;
|
|
|
|
|
}
|
|
|
|
|
}, "Exportar", "Exportar para PDF", null, 0, true );
|
|
|
|
|
|
|
|
|
|
// registerAction( new ActionHandler(){
|
|
|
|
|
// public void execute()
|
|
|
|
|
// {
|
|
|
|
|
@ -560,7 +577,7 @@ public class FichaWindow extends TabbedWindow
|
|
|
|
|
System.out.println( "no id" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
print( id );
|
|
|
|
|
print( id, false );
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
@ -568,7 +585,7 @@ public class FichaWindow extends TabbedWindow
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void print( Integer exameID )
|
|
|
|
|
private void print( Integer exameID, boolean toFile )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
|
|
|
|
|
@ -578,10 +595,48 @@ public class FichaWindow extends TabbedWindow
|
|
|
|
|
throw new Exception( "N\u00e3o existe exame" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lflores - ignore FO (for now)
|
|
|
|
|
byte fo[] = null; //(byte []) exame.get( ExameData.FO );
|
|
|
|
|
byte fo[] = (byte []) exame.get( ExameData.FO );
|
|
|
|
|
byte pdf[] = (byte []) exame.get( ExameData.PDF );
|
|
|
|
|
|
|
|
|
|
if( toFile )
|
|
|
|
|
{
|
|
|
|
|
TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR );
|
|
|
|
|
String fileName = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) );
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
fileName = fileName + sdf.format( date );
|
|
|
|
|
fileName = fileName.replace( ' ', '_' );
|
|
|
|
|
JFileChooser dialog = new JFileChooser();
|
|
|
|
|
dialog.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
|
|
|
|
|
int result = dialog.showSaveDialog( this );
|
|
|
|
|
if( result == JFileChooser.APPROVE_OPTION )
|
|
|
|
|
{
|
|
|
|
|
File selectedFile = dialog.getSelectedFile();
|
|
|
|
|
if( selectedFile != null )
|
|
|
|
|
{
|
|
|
|
|
String absolutePath = selectedFile.getAbsolutePath();
|
|
|
|
|
if( absolutePath != null )
|
|
|
|
|
{
|
|
|
|
|
if(absolutePath.charAt( absolutePath.length() - 1) != File.separatorChar )
|
|
|
|
|
{
|
|
|
|
|
absolutePath = absolutePath + File.separatorChar;
|
|
|
|
|
}
|
|
|
|
|
fileName = absolutePath + fileName + ".pdf";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( fo != null )
|
|
|
|
|
{
|
|
|
|
|
Printer.printFoToFile( fo, fileName, true );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Printer.printPDFToFile( pdf, fileName, true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( fo != null )
|
|
|
|
|
{
|
|
|
|
|
FichaAptidaoCreator.getCreator().print( fo );
|
|
|
|
|
@ -594,27 +649,47 @@ public class FichaWindow extends TabbedWindow
|
|
|
|
|
ePDF.print( pdf, nomeFicheiro );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printFO( Integer exameID )
|
|
|
|
|
throws Exception
|
|
|
|
|
private void printToFile()
|
|
|
|
|
{
|
|
|
|
|
// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
|
|
|
|
|
ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
|
|
|
|
|
if( exame == null )
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
throw new Exception( "N\u00e3o existe exame" );
|
|
|
|
|
if( trabalhadorID != null )
|
|
|
|
|
{
|
|
|
|
|
Integer id = fdpProvider.getLastExameIDForTrabalhador( trabalhadorID );
|
|
|
|
|
if( id != null )
|
|
|
|
|
{
|
|
|
|
|
print(id, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lflores - ignore FO (for now)
|
|
|
|
|
byte fo[] = (byte []) exame.get( ExameData.FO );
|
|
|
|
|
|
|
|
|
|
if( fo != null )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo );
|
|
|
|
|
new PDFFilePrinter( pdf, true );
|
|
|
|
|
DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel exportar", true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private void printFO( Integer exameID )
|
|
|
|
|
// throws Exception
|
|
|
|
|
//{
|
|
|
|
|
//// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
|
|
|
|
|
// ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
|
|
|
|
|
// if( exame == null )
|
|
|
|
|
// {
|
|
|
|
|
// throw new Exception( "N\u00e3o existe exame" );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // lflores - ignore FO (for now)
|
|
|
|
|
// byte fo[] = (byte []) exame.get( ExameData.FO );
|
|
|
|
|
//
|
|
|
|
|
// if( fo != null )
|
|
|
|
|
// {
|
|
|
|
|
// byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo );
|
|
|
|
|
// new PDFFilePrinter( pdf, true );
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
public byte[] createFO( ExameData exame )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
@ -1117,11 +1192,17 @@ public class FichaWindow extends TabbedWindow
|
|
|
|
|
{
|
|
|
|
|
if( useFO )
|
|
|
|
|
{
|
|
|
|
|
printFO( ( ( IDObject )value ).getID() );
|
|
|
|
|
ExameData exame = (ExameData) JDO.load( ExameData.class, ( ( IDObject )value ).getID() );
|
|
|
|
|
if( exame == null )
|
|
|
|
|
{
|
|
|
|
|
throw new Exception( "N\u00e3o existe exame" );
|
|
|
|
|
}
|
|
|
|
|
byte fo[] = (byte[]) exame.get( ExameData.FO );
|
|
|
|
|
Printer.printFO( fo );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print( ( ( IDObject )value ).getID() );
|
|
|
|
|
print( ( ( IDObject )value ).getID(), false );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
|