Example usage for java.io FileWriter append

List of usage examples for java.io FileWriter append

Introduction

In this page you can find the example usage for java.io FileWriter append.

Prototype

@Override
    public Writer append(CharSequence csq) throws IOException 

Source Link

Usage

From source file:patientmanagerv1.HomeController.java

public void saveJudgementAndInsight() {
    //insightintact, insightimpaired, insightminimal, insightmoderate, insightsevere;
    String judgement = " ";

    if (judgementintact.isSelected() == true) {
        judgement = judgement + "judgementintact,";
    }//from www.j  a  v a  2 s.  co  m
    if (judgementimpaired.isSelected() == true) {
        judgement = judgement + "judgementimpaired,";
    }
    if (judgementminimal.isSelected() == true) {
        judgement = judgement + "judgementminimal,";
    }
    if (judgementmoderate.isSelected() == true) {
        judgement = judgement + "judgementmoderate,";
    }
    if (judgementsevere.isSelected() == true) {
        judgement = judgement + "judgementsevere,";
    }

    judgement = judgement.substring(0, judgement.length() - 1);
    judgement = judgement.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/judgement.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(judgement.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

    //insightintact, insightimpaired, insightminimal, insightmoderate, insightsevere;
    String insight = " ";

    if (insightintact.isSelected() == true) {
        insight = insight + "insightintact,";
    }
    if (insightimpaired.isSelected() == true) {
        insight = insight + "insightimpaired,";
    }
    if (insightminimal.isSelected() == true) {
        insight = insight + "insightminimal,";
    }
    if (insightmoderate.isSelected() == true) {
        insight = insight + "insightmoderate,";
    }
    if (insightsevere.isSelected() == true) {
        insight = insight + "insightsevere,";
    }

    insight = insight.substring(0, insight.length() - 1);
    insight = insight.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/insight.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(insight.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

}

From source file:patientmanagerv1.HomeController.java

public void saveSignatureZone() {
    if (businesscardprovided.isSelected() == true) {
        try {/*from w  ww. ja v  a2 s . com*/
            File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                    + lastName.toLowerCase() + dob + "/EvaluationForm/bcp.txt");
            FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            writ.append("true");
            bw.close();
            writ.close();
        } catch (IOException exception) {
            //System.out.println(exception);
        }
    } else {
        try {
            File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                    + lastName.toLowerCase() + dob + "/EvaluationForm/bcp.txt");
            FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            writ.append("false");
            bw.close();
            writ.close();
        } catch (IOException exception) {
            //System.out.println(exception);
        }
    }

    if (discussedassistant.isSelected() == true) {
        try {
            File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                    + lastName.toLowerCase() + dob + "/EvaluationForm/discussedassistant.txt");
            FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            writ.append("true");
            bw.close();
            writ.close();
        } catch (IOException exception) {
            //System.out.println(exception);
        }
    } else {
        try {
            File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                    + lastName.toLowerCase() + dob + "/EvaluationForm/discussedassistant.txt");
            FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            writ.append("false");
            bw.close();
            writ.close();
        } catch (IOException exception) {
            //    System.out.println(exception);
        }
    }

    //saves "WHO"
    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/who.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(who.getText());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //System.out.println(exception);
    }

    //saves signature comments
    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/signaturenotes.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(signaturenotes.getText());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }
}

From source file:patientmanagerv1.HomeController.java

public void saveEnd() {
    //ebox1, ebox2;
    //yes1, yes2, no1, no2, riskofsuicidelow, riskofsuicidemoderate, riskofsuicidehigh, riskofsuicidemodifiableriskfactorsaddressed,
    //dangertootherslow, dangertoothersmoderate, dangertoothershigh, dangertoothersmodifiableriskfactorsaddressed;

    String e = " ";

    if (yes1.isSelected() == true) {
        e = e + "yes1,";
    }//  w w  w . jav a 2  s . c o  m
    if (yes2.isSelected() == true) {
        e = e + "yes2,";
    }

    if (no1.isSelected() == true) {
        e = e + "no1,";
    }

    if (riskofsuicidelow.isSelected() == true) {
        e = e + "riskofsuicidelow,";
    }

    if (riskofsuicidemoderate.isSelected() == true) {
        e = e + "riskofsuicidemoderate,";
    }

    if (riskofsuicidehigh.isSelected() == true) {
        e = e + "riskofsuicidehigh,";
    }

    if (riskofsuicidemodifiableriskfactorsaddressed.isSelected() == true) {
        e = e + "riskofsuicidemodifiableriskfactorsaddressed,";
    }

    if (dangertootherslow.isSelected() == true) {
        e = e + "dangertootherslow,";
    }

    if (dangertoothersmoderate.isSelected() == true) {
        e = e + "dangertoothersmoderate,";
    }

    if (dangertoothershigh.isSelected() == true) {
        e = e + "dangertoothershigh,";
    }

    if (dangertoothersmodifiableriskfactorsaddressed.isSelected() == true) {
        e = e + "dangertoothersmodifiableriskfactorsaddressed,";
    }

    e = e.substring(0, e.length() - 1);
    e = e.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/endcheckboxes.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(e.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/endbox1.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(ebox1.getText());
        bw.close();
        writ.close();

    } catch (IOException ex) {
        //    System.out.println("reached here");
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/endbox2.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(ebox2.getText());
        bw.close();
        writ.close();

    } catch (IOException ex2) {
        //    System.out.println("reached here");
    }
}

From source file:patientmanagerv1.HomeController.java

public void assistantSign() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);/*from   w  w w .  ja v a 2s  . c  o m*/
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text("Please enter the physician's assistant password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician's Assistant Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("siberianplatypus")) {
                partnerSigned = true;

                dialog.close();

                assistantsign.setVisible(false);
                saveButton.setDisable(true);
                //signature.setText("This document has been digitally signed by David Zhvikov MD");
                //signature.setVisible(true);
                //signature2.setVisible(true);
                assistantsignature.setVisible(true);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/assistantsigned.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("true");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(true);

                //System.out.println(engaged.isSelected());
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });
}

From source file:patientmanagerv1.HomeController.java

public void saveLabs() {
    //k'able young ahs, s in a nutshell: p is proportional to age, rik
    //blanklabs, vitd, hivscreen, vitaminb12folicacid, ua, uds, selectrolyte, lithium, lamictallevel, 
    //trileptallevel, depakotelevel, bmp, tft, lft, hgba1c, lipidprofile, cmp, cbc;

    String labs = " ";

    if (blanklabs.isSelected() == true) {
        labs = labs + "blanklabs,";
    }/*from  w  w  w . jav a 2  s  .c  o m*/
    if (vitd.isSelected() == true) {
        labs = labs + "vitd,";
    }

    if (hivscreen.isSelected() == true) {
        labs = labs + "hivscreen,";
    }

    if (vitaminb12folicacid.isSelected() == true) {
        labs = labs + "vitaminb12folicacid,";
    }

    if (ua.isSelected() == true) {
        labs = labs + "ua,";
    }

    if (uds.isSelected() == true) {
        labs = labs + "uds,";
    }

    if (selectrolyte.isSelected() == true) {
        labs = labs + "selectrolyte,";
    }

    if (lithium.isSelected() == true) {
        labs = labs + "lithium,";
    }

    if (lamictallevel.isSelected() == true) {
        labs = labs + "lamictallevel,";
    }

    if (trileptallevel.isSelected() == true) {
        labs = labs + "trileptallevel,";
    }

    if (depakotelevel.isSelected() == true) {
        labs = labs + "depakotelevel,";
    }

    if (bmp.isSelected() == true) {
        labs = labs + "bmp,";
    }

    if (tft.isSelected() == true) {
        labs = labs + "tft,";
    }

    if (lft.isSelected() == true) {
        labs = labs + "lft,";
    }

    if (hgba1c.isSelected() == true) {
        labs = labs + "hgba1c,";
    }

    if (lipidprofile.isSelected() == true) {
        labs = labs + "lipidprofile,";
    }

    if (cmp.isSelected() == true) {
        labs = labs + "cmp,";
    }

    if (cbc.isSelected() == true) {
        labs = labs + "cbc,";
    }

    labs = labs.substring(0, labs.length() - 1);
    labs = labs.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/labs.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(labs.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/labstextfield.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(labstextfield.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //System.out.println("reached here");
    }

}

From source file:patientmanagerv1.HomeController.java

public void signEvaluation() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);//from w w w. ja  v a 2  s  . com
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren()
            .add(new Text("Only the physician can sign this document. Please enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dccSigned = true;

                dialog.close();

                sign.setVisible(false);
                saveButton.setDisable(true);
                signature.setText("This document has been digitally signed by David Zhvikov MD");
                signature.setVisible(true);
                signature2.setVisible(true);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("true");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(true);

                //System.out.println(engaged.isSelected());
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

    //"save as document" (exporting) should become enabled after signing? (ask dcc if he wants this) --> it should automatically convert the generated word document to a pdf
}

From source file:patientmanagerv1.HomeController.java

public void saveSideEffects() {
    //CheckBox riskforreboundhypertension, complexsleeprelatedbehavior, ssoftoxicity, withdrawalsyndrome, riskforaddiction, seizures; 
    //CheckBox prolongedqtc, tardivedyskinesiadistonia, acuteneurologicalse, metabolicsyndrome, 
    //decreasedeffectivenessofobc, teratogenicity, hyponatremia, hypothyroidism, rashsjsyndrome, 
    //weightgainloss, constipation, drymouth, increasedriskofsi, hyperprolactinemia, serotoninsyndrome, hairloss, hypotension, htn, dizziness, insomnia, sedation, sexual, gi;

    String se = " ";

    if (riskforreboundhypertension.isSelected() == true) {
        se = se + "riskforreboundhypertension,";
    }/*from  w w  w .  j  a v a2  s .c  o  m*/
    if (complexsleeprelatedbehavior.isSelected() == true) {
        se = se + "complexsleeprelatedbehavior,";
    }
    if (ssoftoxicity.isSelected() == true) {
        se = se + "ssoftoxicity,";
    }
    if (withdrawalsyndrome.isSelected() == true) {
        se = se + "withdrawalsyndrome,";
    }
    if (riskforaddiction.isSelected() == true) {
        se = se + "riskforaddiction,";
    }
    if (seizures.isSelected() == true) {
        se = se + "seizures,";
    }
    if (prolongedqtc.isSelected() == true) {
        se = se + "prolongedqtc,";
    }
    if (tardivedyskinesiadystonia.isSelected() == true) {
        se = se + "tardivedyskinesiadystonia,";
    }
    if (acuteneurologicalse.isSelected() == true) {
        se = se + "acuteneurologicalse,";
    }
    if (metabolicsyndrome.isSelected() == true) {
        se = se + "metabolicsyndrome,";
    }

    //decreasedeffectivenessofobc, teratogenicity, hyponatremia, hypothyroidism, rashsjsyndrome, 
    //weightgainloss, constipation, drymouth, increasedriskofsi, hyperprolactinemia, serotoninsyndrome, 
    //hairloss, hypotension, htn, dizziness, insomnia, sedation, sexual, gi;
    if (decreasedeffectivenessofobc.isSelected() == true) {
        se = se + "decreasedeffectivenessofobc,";
    }
    if (teratogenicity.isSelected() == true) {
        se = se + "teratogenicity,";
    }
    if (hyponatremia.isSelected() == true) {
        se = se + "hyponatremia,";
    }
    if (hypothyroidism.isSelected() == true) {
        se = se + "hypothyroidism,";
    }
    if (rashsjsyndrome.isSelected() == true) {
        se = se + "rashsjsyndrome,";
    }
    if (weightgainloss.isSelected() == true) {
        se = se + "weightgainloss,";
    }
    if (constipation.isSelected() == true) {
        se = se + "constipation,";
    }
    if (drymouth.isSelected() == true) {
        se = se + "drymouth,";
    }
    if (increasedriskofsi.isSelected() == true) {
        se = se + "increasedriskofsi,";
    }
    if (hyperprolactinemia.isSelected() == true) {
        se = se + "hyperprolactinemia,";
    }
    if (serotoninsyndrome.isSelected() == true) {
        se = se + "serotoninsyndrome,";
    }
    if (hairloss.isSelected() == true) {
        se = se + "hairloss,";
    }
    if (hypotension.isSelected() == true) {
        se = se + "hypotension,";
    }
    if (htn.isSelected() == true) {
        se = se + "htn,";
    }
    if (dizziness.isSelected() == true) {
        se = se + "dizziness,";
    }
    if (insomnia.isSelected() == true) {
        se = se + "insomnia,";
    }
    if (sedation.isSelected() == true) {
        se = se + "sedation,";
    }
    if (sexual.isSelected() == true) {
        se = se + "sexual,";
    }
    if (gi.isSelected() == true) {
        se = se + "gi,";
    }

    se = se.substring(0, se.length() - 1);
    se = se.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/sideeffectsdiscussed.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(se.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/sebox1.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(sebox1.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //    System.out.println("reached here");
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/sebox2.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(sebox2.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //    System.out.println("reached here");
    }

}

From source file:patientmanagerv1.HomeController.java

public void enableBackdoorModifications() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);//from  w w w.  j  a va  2 s.  c  o m
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text(
            "Only the physician can open this document for modification. Please Enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dialog.close();

                sign.setVisible(true);
                saveButton.setDisable(false);
                signature.setText("This document has been digitally signed by David Zhvikov MD");
                signature.setVisible(false);
                signature2.setVisible(false);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("false");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(false);

                //System.out.println(engaged.isSelected());
            } else if (password.equalsIgnoreCase("siberianplatypus")) {
                dialog.close();

                sign.setVisible(true);
                assistantsign.setVisible(true);
                assistantsign.setDisable(false);
                saveButton.setDisable(false);
                //signature.setText("This document has been digitally signed by David Zhvikov MD");
                assistantsignature.setVisible(false);
                signature.setVisible(false);
                signature2.setVisible(false);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("false");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/assistantsigned.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("false");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(false);

                //System.out.println(engaged.isSelected());
            }

            else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

}

From source file:patientmanagerv1.HomeController.java

public void saveClinicalNotes() {
    try {/*from ww  w.ja  v a2  s. c o m*/
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/clinicalnotes.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(clinicalnotes.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //    System.out.println("reached here");
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis4.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis4.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //    System.out.println("reached here");
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis4otherbox.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis4otherbox.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //System.out.println("reached here");
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis5current.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis5current.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //    System.out.println("reached here");
    }

    try {
        File cFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis5highestinpastyear.txt");
        FileWriter writ = new FileWriter(cFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis5highestinpastyear.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
        //    System.out.println("reached here");
    }

    //saves textareas
    try {
        File axis = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis1.txt");
        FileWriter writ = new FileWriter(axis, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis1.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }
    try {
        File axis = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis2.txt");
        FileWriter writ = new FileWriter(axis, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis2.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }

    try {
        File axis = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis3.txt");
        FileWriter writ = new FileWriter(axis, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(axis3.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }
    /*try
    {
            File cnFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase() + "/EvaluationForm/axis4.txt");
            FileWriter writ = new FileWriter(cnFile, false);                                    //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            //writ.append(dobText.getText());
            writ.append(axis4.getText());
            bw.close();
            writ.close();
                    
    }
    catch(IOException e){}
            
    try
    {
            File cnFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase() + "/EvaluationForm/axis4otherbox.txt");
            FileWriter writ = new FileWriter(cnFile, false);                                    //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            //writ.append(dobText.getText());
            writ.append(axis4otherbox.getText());
            bw.close();
            writ.close();
                    
    }
    catch(IOException e){}
            
    try
    {
            File cnFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase() + "/EvaluationForm/axis5current.txt");
            FileWriter writ = new FileWriter(cnFile, false);                                    //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            //writ.append(dobText.getText());
            writ.append(axis5current.getText());
            bw.close();
            writ.close();
                    
    }
    catch(IOException e){}
            
    try
    {
            File cnFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase() + "/EvaluationForm/axis5highestinpastyear.txt");
            FileWriter writ = new FileWriter(cnFile, false);                                    //it is set to false so that it (the current patient) will be overwritten every time
            BufferedWriter bw = new BufferedWriter(writ);
            //writ.append(dobText.getText());
            writ.append(axis5highestinpastyear.getText());
            bw.close();
            writ.close();
                    
    }
    catch(IOException e){}*/

    //saves all checkboxes
    //a4none, a4primarysupportgroup, a4partnerrelationalproblems, a4parentchildrelationalproblems, 
    //a4socialenvironment, a4occupation, a4economics, a4legalsystem, a4education, a4housing, 
    //a4noncompliancewithtreatment, a4other, axis5none;
    String a4 = " ";

    if (a4none.isSelected() == true) {
        a4 = a4 + "a4none,";
    }
    if (a4primarysupportgroup.isSelected() == true) {
        a4 = a4 + "a4primarysupportgroup,";
    }
    if (a4partnerrelationalproblems.isSelected() == true) {
        a4 = a4 + "a4partnerrelationalproblems,";
    }
    if (a4parentchildrelationalproblems.isSelected() == true) {
        a4 = a4 + "a4parentchildrelationalproblems,";
    }
    if (a4socialenvironment.isSelected() == true) {
        a4 = a4 + "a4socialenvironment,";
    }
    //a4occupation, a4economics, a4legalsystem, a4education, a4housing, 
    //a4noncompliancewithtreatment, a4other, axis5none;
    if (a4occupation.isSelected() == true) {
        a4 = a4 + "a4occupation,";
    }
    if (a4economics.isSelected() == true) {
        a4 = a4 + "a4economics,";
    }
    if (a4legalsystem.isSelected() == true) {
        a4 = a4 + "a4legalsystem,";
    }
    if (a4education.isSelected() == true) {
        a4 = a4 + "a4education,";
    }
    if (a4housing.isSelected() == true) {
        a4 = a4 + "a4housing,";
    }
    if (a4noncompliancewithtreatment.isSelected() == true) {
        a4 = a4 + "a4noncompliancewithtreatment,";
    }
    if (a4other.isSelected() == true) {
        a4 = a4 + "a4other,";
    }

    a4 = a4.substring(0, a4.length() - 1);
    a4 = a4.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis4checkboxes.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(a4.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/a4other.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(a4other.getText());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

    //insightintact, insightimpaired, insightminimal, insightmoderate, insightsevere;
    String a5checkbox = " ";

    if (axis5none.isSelected() == true) {
        a5checkbox = a5checkbox + "axis5none,";
    }

    a5checkbox = a5checkbox.substring(0, a5checkbox.length() - 1);
    a5checkbox = a5checkbox.trim();

    try {
        File hFile = new File(installationPath + "/userdata/" + firstName.toLowerCase() + lastName.toLowerCase()
                + dob + "/EvaluationForm/axis5none.txt");
        FileWriter writ = new FileWriter(hFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(a5checkbox.toLowerCase());
        bw.close();
        writ.close();
    } catch (IOException exception) {
        //    System.out.println(exception);
    }

}

From source file:patientmanagerv1.HomeController.java

public void deleteProgressReport() {
    /*try{// w w  w . j  a v  a2 s. com
        String currRep = listOfProgressReports.getSelectionModel().getSelectedItem().toString();
        String currRepNoColons = currRep.replace(":", "");
        currRepNoColons = currRepNoColons.trim();
            
            
    int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this progress note?","Warning", JOptionPane.OK_CANCEL_OPTION);
     //System.out.println(result);
    //JOptionPane.showConfirmDialog(null, "Would you like to save any changes before logging out?", "save changes?", YES_NO_CANCEL_OPTION);
    //Object selection = JOptionPane.get    
            
    if(result == 0)
    {
    //0 is "OK"
    //System.out.println("pressed ok");
            
    //locates the current report
    try{
        String cR = listOfProgressReports.getSelectionModel().getSelectedItem().toString();
        String cRNC = cR.replace(":", "");
            
        //1) removes the report from the list in the file
        try
        {
            FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");              
            BufferedReader b2 = new BufferedReader(r2); 
            
                String s;
                ArrayList progressNotes = new ArrayList();
            
            
                while((s = b2.readLine()) != null)
                {
                    //System.out.println(s);
            
                    if(!s.equalsIgnoreCase(currRep))
                    {progressNotes.add(s);}
                }
            
            
            
                b2.close();
                r2.close();
            
            
                File fff = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                    FileWriter ddd = new FileWriter(fff, false);           
                    BufferedWriter bw = new BufferedWriter(ddd);
                    ddd.append("");
                    bw.close();
                    ddd.close();
            
                for(int i = 0; i < progressNotes.size(); i++)
                {
                    File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                    FileWriter fw = new FileWriter(openProgressReportsList, true);           
                    BufferedWriter bufferedwriter = new BufferedWriter(fw);
                    fw.append(progressNotes.get(i) + "\n");
                    bufferedwriter.close();
                    fw.close();
                }
        }
        catch(Exception e)
        {
            
        }
            
            
            
        /*try{
                FileReader reader = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                BufferedReader br = new BufferedReader(reader); 
                String fileContents = br.readLine();
                br.close();
                reader.close();
            
                fileContents = fileContents.replace(currRep, "");
                //System.out.println("fc:" + fileContents);
            
                //writes the new contents to the file:
                //writes the new report to the list
                File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                FileWriter fw = new FileWriter(openProgressReportsList, false);           
                BufferedWriter bufferedwriter = new BufferedWriter(fw);
                fw.append(fileContents);
                bufferedwriter.close();
                fw.close();
        }
        catch(Exception e)
        {
            
        }*/

    //2) Deletes the folder for that progress report
    /*try
    {
        File path = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);            
        File[] files = path.listFiles();
            
        for(int i = 0; i<files.length; i++)
        {
            files[i].delete();
        }
        //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket
        path.delete();
        //deleteDirectory(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);
        //Files.delete(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);
    }
    catch(Exception e)
    {}
            
            
            
    //3) removes the report from the listview (clears and then repopulates the list)
    listOfProgressReports.getItems().clear();
            
    try
    {
    FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");              
    BufferedReader b2 = new BufferedReader(r2); 
            
            String s;
            ArrayList progressNotes = new ArrayList();
            
            
            while((s = b2.readLine()) != null)
            {
                System.out.println(s);
                progressNotes.add(s);
            }
            
            
            
            b2.close();
            r2.close();
            
            //Adds the Progress Notes to the ListView
            
            
               ObservableList<String> items = FXCollections.observableArrayList (
    "Single", "Double");
    items.clear();
            
    for(int counter = 0; counter < progressNotes.size(); counter++)
    {
        items.add(progressNotes.get(counter).toString());
    }
            
        listOfProgressReports.setItems(items);
            
            //String[] ethnicityArray = ethnicity.split(",");
    }
    catch (Exception e)
    {
    System.out.println("file not found");
    }
    }
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again");
    }
            
    }
            
    if(result == 2)
    {
    //2 is "Cancel"
    //System.out.println("pressed cancel");
    }
            
            
    }
    catch(Exception e)
    {JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again");}*/

    try {
        String currRep = listOfProgressReports.getSelectionModel().getSelectedItem().toString();
        String currRepNoColons = currRep.replace(":", "");
        currRepNoColons = currRepNoColons.trim();

        int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this progress note?",
                "Warning", JOptionPane.OK_CANCEL_OPTION);
        //System.out.println(result);
        //JOptionPane.showConfirmDialog(null, "Would you like to save any changes before logging out?", "save changes?", YES_NO_CANCEL_OPTION);
        //Object selection = JOptionPane.get    

        if (result == 0) {
            //0 is "OK"
            //System.out.println("pressed ok");

            //locates the current report
            try {
                String cR = listOfProgressReports.getSelectionModel().getSelectedItem().toString();
                String cRNC = cR.replace(":", "");

                //1) removes the report from the list in the file
                try {
                    FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob
                            + "/ProgressReports.txt");
                    BufferedReader b2 = new BufferedReader(r2);

                    String s;
                    ArrayList progressNotes = new ArrayList();

                    while ((s = b2.readLine()) != null) {
                        //System.out.println(s);

                        if (!s.equalsIgnoreCase(currRep)) {
                            progressNotes.add(s);
                        }
                    }

                    b2.close();
                    r2.close();

                    File fff = new File(installationPath + "/userdata/" + firstName + lastName + dob
                            + "/ProgressReports.txt");
                    FileWriter ddd = new FileWriter(fff, false);
                    BufferedWriter bw = new BufferedWriter(ddd);
                    ddd.append("");
                    bw.close();
                    ddd.close();

                    for (int i = 0; i < progressNotes.size(); i++) {
                        File openProgressReportsList = new File(installationPath + "/userdata/" + firstName
                                + lastName + dob + "/ProgressReports.txt");
                        FileWriter fw = new FileWriter(openProgressReportsList, true);
                        BufferedWriter bufferedwriter = new BufferedWriter(fw);
                        fw.append(progressNotes.get(i) + "\n");
                        bufferedwriter.close();
                        fw.close();
                    }
                } catch (Exception e) {

                }

                /*try{
                FileReader reader = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                BufferedReader br = new BufferedReader(reader); 
                String fileContents = br.readLine();
                br.close();
                reader.close();
                        
                fileContents = fileContents.replace(currRep, "");
                //System.out.println("fc:" + fileContents);
                        
                //writes the new contents to the file:
                //writes the new report to the list
                File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                FileWriter fw = new FileWriter(openProgressReportsList, false);           
                BufferedWriter bufferedwriter = new BufferedWriter(fw);
                fw.append(fileContents);
                bufferedwriter.close();
                fw.close();
                }
                catch(Exception e)
                {
                        
                }*/

                //2) Deletes the folder for that progress report
                try {
                    File path = new File(installationPath + "/userdata/" + firstName + lastName + dob
                            + "/ProgressNotes/" + currRepNoColons);
                    File[] files = path.listFiles();

                    for (int i = 0; i < files.length; i++) {
                        files[i].delete();
                    }
                    //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket
                    path.delete();
                    //deleteDirectory(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);
                    //Files.delete(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);
                } catch (Exception e) {
                }

                //3) removes the report from the listview (clears and then repopulates the list)
                listOfProgressReports.getItems().clear();

                try {
                    FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob
                            + "/ProgressReports.txt");
                    BufferedReader b2 = new BufferedReader(r2);

                    String s;
                    ArrayList progressNotes = new ArrayList();

                    while ((s = b2.readLine()) != null) {
                        //System.out.println(s);
                        progressNotes.add(s);
                    }

                    b2.close();
                    r2.close();

                    //Adds the Progress Notes to the ListView

                    ObservableList<String> items = FXCollections.observableArrayList("Single", "Double");
                    items.clear();

                    for (int counter = 0; counter < progressNotes.size(); counter++) {
                        items.add(progressNotes.get(counter).toString());
                    }

                    listOfProgressReports.setItems(items);

                    //String[] ethnicityArray = ethnicity.split(",");
                } catch (Exception e) {
                    //System.out.println("file not found");
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null,
                        "Please select a progress report from the list and try again");
            }

        }

        if (result == 2) {
            //2 is "Cancel"
            //System.out.println("pressed cancel");
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again");
    }

    listOfProgressReports.getSelectionModel().clearSelection();
}