1 package org
.therapi
.reha
.patient
;
3 import hauptFenster
.Reha
;
5 import java
.awt
.AlphaComposite
;
6 import java
.awt
.BorderLayout
;
7 import java
.awt
.Dimension
;
8 import java
.awt
.Graphics
;
9 import java
.awt
.Graphics2D
;
10 import java
.awt
.Point
;
11 import java
.awt
.event
.ActionEvent
;
12 import java
.awt
.event
.ActionListener
;
13 import java
.awt
.event
.KeyEvent
;
14 import java
.awt
.event
.WindowEvent
;
15 import java
.awt
.event
.WindowListener
;
16 import java
.text
.DecimalFormat
;
17 import java
.util
.Iterator
;
21 import javax
.swing
.ImageIcon
;
22 import javax
.swing
.JButton
;
23 import javax
.swing
.JComponent
;
24 import javax
.swing
.JOptionPane
;
25 import javax
.swing
.JPanel
;
27 import oOorgTools
.OOTools
;
29 import org
.jdesktop
.swingworker
.SwingWorker
;
30 import org
.jdesktop
.swingx
.JXPanel
;
32 import CommonTools
.SqlInfo
;
33 import systemEinstellungen
.SystemConfig
;
34 import CommonTools
.JRtaCheckBox
;
35 import systemTools
.LeistungTools
;
36 import terminKalender
.DatFunk
;
37 import ag
.ion
.bion
.officelayer
.application
.OfficeApplicationException
;
38 import ag
.ion
.bion
.officelayer
.document
.DocumentDescriptor
;
39 import ag
.ion
.bion
.officelayer
.document
.IDocument
;
40 import ag
.ion
.bion
.officelayer
.document
.IDocumentDescriptor
;
41 import ag
.ion
.bion
.officelayer
.document
.IDocumentService
;
42 import ag
.ion
.bion
.officelayer
.text
.ITextDocument
;
43 import ag
.ion
.bion
.officelayer
.text
.ITextField
;
44 import ag
.ion
.bion
.officelayer
.text
.ITextFieldService
;
45 import ag
.ion
.bion
.officelayer
.text
.TextException
;
46 import ag
.ion
.noa
.NOAException
;
48 import com
.jgoodies
.forms
.builder
.PanelBuilder
;
49 import com
.jgoodies
.forms
.layout
.CellConstraints
;
50 import com
.jgoodies
.forms
.layout
.FormLayout
;
52 import dialoge
.PinPanel
;
53 import dialoge
.RehaSmartDialog
;
54 import events
.RehaTPEvent
;
55 import events
.RehaTPEventClass
;
56 import events
.RehaTPEventListener
;
58 public class AusfallRechnung
extends RehaSmartDialog
implements RehaTPEventListener
,WindowListener
, ActionListener
{
62 private static final long serialVersionUID
= 1L;
64 public JRtaCheckBox
[] leistung
= {null,null,null,null,null};
66 private RehaTPEventClass rtp
= null;
67 private AusfallRechnungHintergrund rgb
;
69 public JButton uebernahme
;
70 public JButton abbrechen
;
71 public String afrNummer
;
72 public AusfallRechnung(Point pt
){
73 super(null,"AusfallRechnung");
76 pinPanel
= new PinPanel();
77 pinPanel
.setName("AusfallRechnung");
78 pinPanel
.getGruen().setVisible(false);
79 setPinPanel(pinPanel
);
80 getSmartTitledPanel().setTitle("Ausfallrechnung erstellen");
83 setPreferredSize(new Dimension(300,270));
84 getSmartTitledPanel().setPreferredSize(new Dimension (300,270));
85 setPinPanel(pinPanel
);
86 rgb
= new AusfallRechnungHintergrund();
87 rgb
.setLayout(new BorderLayout());
90 new SwingWorker
<Void
,Void
>(){
93 protected Void
doInBackground() throws Exception
{
95 rgb
.setBackgroundPainter(Reha
.thisClass
.compoundPainter
.get("RezeptGebuehren"));
100 rgb
.add(getGebuehren(),BorderLayout
.CENTER
);
102 getSmartTitledPanel().setContentContainer(rgb
);
103 getSmartTitledPanel().getContentContainer().setName("AusfallRechnung");
104 setName("AusfallRechnung");
106 //Point lpt = new Point(pt.x-125,pt.y+30);
107 Point lpt
= new Point(pt
.x
-150,pt
.y
+30);
110 rtp
= new RehaTPEventClass();
111 rtp
.addRehaTPEventListener((RehaTPEventListener
) this);
121 /****************************************************/
123 private JPanel
getGebuehren(){ // 1 2 3 4 5 6 7
124 FormLayout lay
= new FormLayout("10dlu,fill:0:grow(0.50),right:80dlu,10dlu,80dlu,fill:0:grow(0.50),10dlu",
125 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
126 "15dlu,p,10dlu,p,2dlu,p,2dlu,p,2dlu,p, 10dlu, p, 20dlu, p ,20dlu");
127 PanelBuilder pb
= new PanelBuilder(lay
);
128 CellConstraints cc
= new CellConstraints();
130 pb
.getPanel().setOpaque(false);
132 pb
.addLabel("Bitte die Positionen auswählen die Sie berechnen wollen",cc
.xyw(2, 2, 4));
134 pb
.addLabel("Heilmittel 1",cc
.xy(3, 4));
135 String lab
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(48);
136 leistung
[0] = new JRtaCheckBox((lab
.equals("") ?
"----" : lab
));
137 leistung
[0].setOpaque(false);
139 leistung
[0].setSelected(true);
141 leistung
[0].setSelected(false);
142 leistung
[0].setEnabled(false);
144 pb
.add(leistung
[0],cc
.xyw(5, 4, 2));
146 pb
.addLabel("Heilmittel 2",cc
.xy(3, 6));
147 lab
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(49);
148 leistung
[1] = new JRtaCheckBox((lab
.equals("") ?
"----" : lab
));
149 leistung
[1].setOpaque(false);
153 leistung
[1].setSelected(false);
154 leistung
[1].setEnabled(false);
156 pb
.add(leistung
[1],cc
.xyw(5, 6, 2));
158 pb
.addLabel("Heilmittel 3",cc
.xy(3, 8));
159 lab
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(50);
160 leistung
[2] = new JRtaCheckBox((lab
.equals("") ?
"----" : lab
));
161 leistung
[2].setOpaque(false);
165 leistung
[2].setSelected(false);
166 leistung
[2].setEnabled(false);
168 pb
.add(leistung
[2],cc
.xyw(5, 8, 2));
170 pb
.addLabel("Heilmittel 4",cc
.xy(3, 10));
171 lab
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(51);
172 leistung
[3] = new JRtaCheckBox((lab
.equals("") ?
"----" : lab
));
173 leistung
[3].setOpaque(false);
177 leistung
[3].setSelected(false);
178 leistung
[3].setEnabled(false);
180 pb
.add(leistung
[3],cc
.xyw(5, 10, 2));
182 pb
.addLabel("Eintragen in Memo",cc
.xy(3, 12));
183 leistung
[4] = new JRtaCheckBox("Fehldaten");
184 leistung
[4].setOpaque(false);
185 leistung
[4].setSelected(true);
186 pb
.add(leistung
[4],cc
.xyw(5, 12, 2));
188 uebernahme
= new JButton("drucken & buchen");
189 uebernahme
.setActionCommand("uebernahme");
190 uebernahme
.addActionListener(this);
191 uebernahme
.addKeyListener(this);
192 pb
.add(uebernahme
,cc
.xy(3,14));
194 abbrechen
= new JButton("abbrechen");
195 abbrechen
.setActionCommand("abbrechen");
196 abbrechen
.addActionListener(this);
197 abbrechen
.addKeyListener(this);
198 pb
.add(abbrechen
,cc
.xy(5,14));
200 pb
.getPanel().validate();
201 return pb
.getPanel();
203 /****************************************************/
205 public void rehaTPEventOccurred(RehaTPEvent evt
) {
206 // TODO Auto-generated method stub
208 if(evt
.getDetails()[0] != null){
209 if(evt
.getDetails()[0].equals(this.getName())){
210 this.setVisible(false);
211 rtp
.removeRehaTPEventListener((RehaTPEventListener
) this);
215 //System.out.println("****************Ausfallrechnung -> Listener entfernt**************");
218 }catch(NullPointerException ne
){
219 //System.out.println("In PatNeuanlage" +evt);
222 public void windowClosed(WindowEvent arg0
) {
223 // TODO Auto-generated method stub
225 this.setVisible(false);
226 rtp
.removeRehaTPEventListener((RehaTPEventListener
) this);
231 //System.out.println("****************Ausfallrechnung -> Listener entfernt (Closed)**********");
237 public void actionPerformed(ActionEvent arg0
) {
238 // TODO Auto-generated method stub
239 if(arg0
.getActionCommand().equals("uebernahme")){
241 new SwingWorker
<Void
,Void
>(){
243 protected Void
doInBackground() throws Exception
{
245 starteAusfallRechnung(Reha
.proghome
+"vorlagen/"+Reha
.aktIK
+"/AusfallRechnung.ott");
247 if(leistung
[4].isSelected()){
250 }catch(Exception ex
){
251 ex
.printStackTrace();
252 JOptionPane
.showMessageDialog(null, "Fehler bei der Erstellung der Ausfallrechnung");
254 getInstance().dispose();
259 new SwingWorker<Void,Void>(){
261 protected Void doInBackground() throws Exception {
262 if(leistung[4].isSelected()){
271 if(arg0
.getActionCommand().equals("abbrechen")){
276 private AusfallRechnung
getInstance(){
279 private void doBuchen(){
280 StringBuffer buf
= new StringBuffer();
281 buf
.append("insert into rgaffaktura set ");
282 buf
.append("rnr='"+afrNummer
+"', ");
283 buf
.append("reznr='"+(String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(1)+"', ");
284 buf
.append("pat_intern='"+(String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(0)+"', ");
285 buf
.append("rgesamt='"+(String
)SystemConfig
.hmAdrAFRDaten
.get("<AFRgesamt>").replace(",",".")+"', ");
286 buf
.append("roffen='"+(String
)SystemConfig
.hmAdrAFRDaten
.get("<AFRgesamt>").replace(",",".")+"', ");
287 buf
.append("rdatum='"+DatFunk
.sDatInSQL(DatFunk
.sHeute())+"',");
288 buf
.append("ik='"+Reha
.aktIK
+"'");
289 SqlInfo
.sqlAusfuehren(buf
.toString());
291 private void macheMemoEintrag(){
292 StringBuffer sb
= new StringBuffer();
293 sb
.append(DatFunk
.sHeute()+" - unentschuldigt oder zu spät abgesagt - Rechnung!! - Rechnung-Nr.: "+SystemConfig
.hmAdrAFRDaten
.get("<AFRnummer>")+"\n");
294 sb
.append(Reha
.thisClass
.patpanel
.pmemo
[1].getText());
295 Reha
.thisClass
.patpanel
.pmemo
[1].setText(sb
.toString());
296 String cmd
= "update pat5 set pat_text='"+sb
.toString()+"' where pat_intern = '"+Reha
.thisClass
.patpanel
.aktPatID
+"'";
297 SqlInfo
.sqlAusfuehren(cmd
);
299 private void macheAFRHmap(){
301 String mappreis
= "";
304 String
[] inpos
= {null,null};
307 Double gesamt
= new Double(0.00);
309 DecimalFormat df
= new DecimalFormat( "0.00" );
311 for(int i
= 0 ; i
< 4; i
++){
312 mappos
= "<AFRposition"+(i
+1)+">";
313 mappreis
= "<AFRpreis"+(i
+1)+">";
314 mapkurz
= "<AFRkurz"+(i
+1)+">";
315 maplang
= "<AFRlang"+(i
+1)+">";
316 if(leistung
[i
].isSelected()){
317 Double preis
= new Double( (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(18+i
));
318 String s
= df
.format( preis
);
319 SystemConfig
.hmAdrAFRDaten
.put(mappos
,leistung
[i
].getText());
320 SystemConfig
.hmAdrAFRDaten
.put(mappreis
,s
);
321 gesamt
= gesamt
+preis
;
323 spos
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(8+i
);
324 sart
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(1);
325 sart
= sart
.substring(0,2);
326 preisgruppe
= Integer
.parseInt(Reha
.thisClass
.patpanel
.vecaktrez
.get(41))-1;
327 inpos
= LeistungTools
.getLeistung(sart
, spos
,preisgruppe
);
328 SystemConfig
.hmAdrAFRDaten
.put(maplang
,inpos
[0]);
329 SystemConfig
.hmAdrAFRDaten
.put(mapkurz
,inpos
[1]);
330 ////System.out.println(inpos[0]);
331 ////System.out.println(inpos[1]);
334 spos
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(8+i
);
335 sart
= (String
)Reha
.thisClass
.patpanel
.vecaktrez
.get(1);
336 sart
= sart
.substring(0,2);
337 preisgruppe
= Integer
.parseInt(Reha
.thisClass
.patpanel
.vecaktrez
.get(41))-1;
338 inpos
= LeistungTools
.getLeistung(sart
, spos
,preisgruppe
);
340 SystemConfig
.hmAdrAFRDaten
.put(mappos
,leistung
[i
].getText());
341 SystemConfig
.hmAdrAFRDaten
.put(mappreis
,"0,00");
342 SystemConfig
.hmAdrAFRDaten
.put(maplang
,(!inpos
[0].equals("") ? inpos
[0] : "----") );
343 SystemConfig
.hmAdrAFRDaten
.put(mapkurz
,(!inpos
[1].equals("") ? inpos
[1] : "----") );
348 SystemConfig
.hmAdrAFRDaten
.put("<AFRgesamt>",df
.format( gesamt
));
349 /// Hier muß noch die Rechnungsnummer bezogen und eingetragen werden
350 afrNummer
= "AFR-"+Integer
.toString(SqlInfo
.erzeugeNummer("afrnr"));
351 SystemConfig
.hmAdrAFRDaten
.put("<AFRnummer>",afrNummer
);
353 public void keyPressed(KeyEvent event
) {
354 if(event
.getKeyCode()==10){
356 if( ((JComponent
)event
.getSource()).getName().equals("uebernahme")){
359 if( ((JComponent
)event
.getSource()).getName().equals("abbrechen")){
363 //System.out.println("Return Gedrückt");
365 if(event
.getKeyCode()==27){
369 @SuppressWarnings({ "unchecked", "rawtypes" })
370 public static void starteAusfallRechnung(String url
){
371 IDocumentService documentService
= null;;
372 //System.out.println("Starte Datei -> "+url);
373 if(!Reha
.officeapplication
.isActive()){
374 Reha
.starteOfficeApplication();
377 documentService
= Reha
.officeapplication
.getDocumentService();
378 } catch (OfficeApplicationException e
) {
380 JOptionPane
.showMessageDialog(null, "Fehler im OpenOffice-System - Ausfallrechnung kann nicht erstellt werden");
383 IDocumentDescriptor docdescript
= new DocumentDescriptor();
384 docdescript
.setHidden(false);
385 docdescript
.setAsTemplate(true);
386 IDocument document
= null;
387 //ITextTable[] tbl = null;
389 document
= documentService
.loadDocument(url
,docdescript
);
390 } catch (NOAException e
) {
394 ITextDocument textDocument
= (ITextDocument
)document
;
395 ITextFieldService textFieldService
= textDocument
.getTextFieldService();
396 ITextField
[] placeholders
= null;
398 placeholders
= textFieldService
.getPlaceholderFields();
399 } catch (TextException e
) {
402 for (int i
= 0; i
< placeholders
.length
; i
++) {
403 boolean schonersetzt
= false;
404 String placeholderDisplayText
= placeholders
[i
].getDisplayText().toLowerCase();
406 Set
<?
> entries
= SystemConfig
.hmAdrPDaten
.entrySet();
407 Iterator
<?
> it
= entries
.iterator();
408 while (it
.hasNext()) {
409 Map
.Entry
<String
,String
> entry
= ((Map
.Entry
<String
,String
>) it
.next());
410 if(((String
)entry
.getKey()).toLowerCase().equals(placeholderDisplayText
)){
411 placeholders
[i
].getTextRange().setText(((String
)entry
.getValue()));
417 entries
= SystemConfig
.hmAdrAFRDaten
.entrySet();
418 it
= entries
.iterator();
419 while (it
.hasNext() && (!schonersetzt
)) {
420 Map
.Entry entry
= (Map
.Entry
) it
.next();
421 if(((String
)entry
.getKey()).toLowerCase().equals(placeholderDisplayText
)){
422 placeholders
[i
].getTextRange().setText(((String
)entry
.getValue()));
428 OOTools
.loescheLeerenPlatzhalter(textDocument
, placeholders
[i
]);
437 class AusfallRechnungHintergrund
extends JXPanel
{
441 private static final long serialVersionUID
= 1L;
444 AlphaComposite xac1
= null;
445 AlphaComposite xac2
= null;
446 public AusfallRechnungHintergrund(){
449 hgicon = new ImageIcon(Reha.proghome+"icons/geld.png");
450 icx = hgicon.getIconWidth()/2;
451 icy = hgicon.getIconHeight()/2;
452 xac1 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.15f);
453 xac2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1.0f);
458 public void paintComponent( Graphics g
) {
459 super.paintComponent( g
);
460 @SuppressWarnings("unused")
461 Graphics2D g2d
= (Graphics2D
)g
;
464 //g2d.setComposite(this.xac1);
465 //g2d.drawImage(hgicon.getImage(), (getWidth()/2)-icx , (getHeight()/2)-icy,null);
466 //g2d.setComposite(this.xac2);