Example usage for org.eclipse.jface.dialogs MessageDialog ERROR

List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog ERROR.

Prototype

int ERROR

To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:org.celllife.idart.gui.clinic.AddClinic.java

License:Open Source License

@Override
protected void cmdSaveWidgetSelected() {

    if (fieldsOk()) {
        Transaction tx = null;/*w w w. j a  va2s. co  m*/

        try {
            tx = getHSession().beginTransaction();

            NationalClinics nclinic = AdministrationManager.getNationalClinic(getHSession(),
                    cmbProvince.getText().trim(), cmbDistrict.getText().trim(), cmbSubDistrict.getText().trim(),
                    cmbFacility.getText().trim());

            if (localClinic == null && isAddnotUpdate) {
                localClinic = new Clinic();

                List<User> users = AdministrationManager.getUsers(getHSession());
                for (User usr : users) {
                    if (usr.getClinics() == null) {
                        usr.setClinics(new HashSet<Clinic>());
                    }

                    usr.getClinics().add(localClinic);
                }
            }

            localClinic.setNotes(txtClinicNotes.getText().trim());
            localClinic.setClinicName(txtClinic.getText().trim());
            localClinic.setTelephone(txtTelephone.getText().trim());
            localClinic.setClinicDetails(nclinic);

            AdministrationManager.saveClinic(getHSession(), localClinic);
            getHSession().flush();
            tx.commit();

            showMessage(MessageDialog.INFORMATION, "Database Updated",
                    "The Clinic '" + localClinic.getClinicName() + "' has been saved.");

        } catch (HibernateException he) {
            showMessage(MessageDialog.ERROR, "Problems Saving to the Database",
                    "There was a problem saving the Clinic's information to the database. Please try again.");
            if (tx != null) {
                tx.rollback();
            }
            getLog().error(he);
        }
        cmdCancelWidgetSelected();
    }

}

From source file:org.celllife.idart.gui.doctor.AddDoctor.java

License:Open Source License

@Override
protected void cmdSaveWidgetSelected() {

    if (fieldsOk()) {

        Transaction tx = null;/*from  w ww. j a v a  2s  .  c  o  m*/
        String action = ""; //$NON-NLS-1$

        try {
            tx = getHSession().beginTransaction();
            // this is a new doctor
            if (localDoctor == null && isAddnotUpdate) {

                localDoctor = new Doctor(txtDoctorSurname.getText(), txtDoctorFirstname.getText(),
                        txtTelephone.getText(), txtCellphoneNo.getText(), txtEmail.getText(), 'T',
                        rdBtnActive.getSelection() ? true : false, 0);
                action = Messages.getString("adddoctor.action"); //$NON-NLS-1$
                AdministrationManager.saveDoctor(getHSession(), localDoctor);

            }

            // else, we're updating an existing doctor
            else if (localDoctor != null && !isAddnotUpdate) {
                localDoctor.setLastname(txtDoctorSurname.getText());
                localDoctor.setFirstname(txtDoctorFirstname.getText());
                localDoctor.setTelephoneno(txtTelephone.getText());
                localDoctor.setMobileno(txtCellphoneNo.getText());
                localDoctor.setEmailAddress(txtEmail.getText());
                localDoctor.setActive(rdBtnActive.getSelection() ? true : false);
                action = Messages.getString("adddoctor.updated"); //$NON-NLS-1$
            }

            getHSession().flush();
            tx.commit();
            String message = MessageFormat.format(Messages.getString("adddoctor.message"), //$NON-NLS-1$
                    localDoctor.getFullname(), action);
            showMessage(MessageDialog.INFORMATION, Messages.getString("adddoctor.messageupdate"), message);//$NON-NLS-1$ 
            fireChangeEvent(localDoctor);
            cmdCancelWidgetSelected();
        } catch (HibernateException he) {
            getLog().error(Messages.getString("adddoctor.errordb"), he); //$NON-NLS-1$
            showMessage(MessageDialog.ERROR, Messages.getString("adddoctor.errordb"), //$NON-NLS-1$ 
                    Messages.getString("adddoctor.errordb.saving"));//$NON-NLS-1$
            if (tx != null) {
                tx.rollback();
            }
        }

    }

}

From source file:org.celllife.idart.gui.doctor.AddDoctor.java

License:Open Source License

private void cmdSearchWidgetSelected() {

    Search doctorSearch = new Search(getHSession(), getShell(), CommonObjects.DOCTOR, true);

    if (doctorSearch.getValueSelected() != null) {

        localDoctor = AdministrationManager.getDoctor(getHSession(), doctorSearch.getValueSelected()[0]);

        if (loadDoctorsDetails()) {
            enableFields(true);/*from   w  ww .j a v  a2 s.  com*/
            btnSearch.setEnabled(false);
            txtDoctorSurname.setEnabled(false);
            txtDoctorFirstname.setEnabled(false);
        }

        else {
            showMessage(MessageDialog.ERROR, Messages.getString("adddoctor.db.error"), //$NON-NLS-1$
                    Messages.getString("adddoctor.db.doctorinfo"));//$NON-NLS-1$
        }
    }
}

From source file:org.celllife.idart.gui.drug.AddDrug.java

License:Open Source License

/**
 * Check if the necessary field names are filled in. Returns true if there
 * are fields missing//from   ww w.  jav  a 2s.  co  m
 * 
 * @return boolean
 */
@Override
protected boolean fieldsOk() {

    // checking all simple fields

    if (txtName.getText().equals("")) {
        MessageBox b = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        b.setMessage("Nome do medicamento no pode ser vazio");
        b.setText("Informao em Falta");
        b.open();
        txtName.setFocus();
        return false;
    }

    if (chkBtnAdult.getSelection() && chkBtnPediatric.getSelection()) {
        MessageBox b = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        b.setMessage("O ARV deve ser Pediatrico ou de Adulto, No ambos ");
        b.setText("Selecao Errada");
        b.open();

        return false;
    }

    if (!chkBtnAdult.getSelection() && !chkBtnPediatric.getSelection()) {
        MessageBox b = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        b.setMessage(" Seleccione se o ARV  peditrico ou de Adulto ");
        b.setText("Selecao Errada");
        b.open();

        return false;
    }

    if (DrugManager.drugNameExists(getHSession(), txtName.getText()) && isAddnotUpdate) {
        MessageBox b = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        b.setMessage("Nome do Medicameento j existe. Inserir um nome diferente");
        b.setText("Nome do medicamento suplicado");
        b.open();
        txtName.setFocus();
        return false;
    }

    if (cmbForm.indexOf(cmbForm.getText()) == -1) {
        MessageBox b = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        b.setMessage("A forma do medicamento deve ser da lista.");
        b.setText("Informao incorrecta");
        b.open();
        cmbForm.setFocus();
        return false;
    }

    if (txtPacksize.getText().equals("")) {
        MessageBox b = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        b.setMessage("Inserir quantidade no frasco");
        b.setText("Informao em Falta");
        b.open();

        return false;
    }

    try {
        Integer.parseInt(txtPacksize.getText());
    } catch (NumberFormatException nfe) {
        MessageBox incorrectData = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
        incorrectData.setText("Quantidade no Frasco incorrecto");
        incorrectData.setMessage("A Quantidade no Frasco que inseriu  invlido. Inserir Nmero.");
        incorrectData.open();
        txtPacksize.setFocus();
        return false;
    }

    if (txtAmountPerTime.isVisible() & (!txtAmountPerTime.getText().trim().equals(""))) {

        try {
            Double.parseDouble(txtAmountPerTime.getText().trim());
        } catch (NumberFormatException nfe) {
            MessageBox incorrectData = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
            incorrectData.setText("Valor do padro da posologia incorrecto");
            incorrectData.setMessage("A posologia padro que inseriu  incorrecto. Inserir nmero.");
            incorrectData.open();
            txtAmountPerTime.setFocus();
            return false;
        }

    }

    if (!txtAtc.getText().trim().isEmpty()) {
        AtcCode atccode = AdministrationManager.getAtccodeFromCode(getHSession(), txtAtc.getText().trim());
        if (atccode == null) {
            showMessage(MessageDialog.ERROR, "Cdigo FNM Disconhecido",
                    "O cdigo FNM que seleccionou no est na base de dados.");
            return false;
        }
    }

    if (!txtTimesPerDay.getText().trim().equals("")) {
        try {
            Integer.parseInt(txtTimesPerDay.getText());
        } catch (NumberFormatException nfe) {
            MessageBox incorrectData = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
            incorrectData.setText("o valor do padro da posologia incorrecto");
            incorrectData.setMessage("A posologia padro que inseriu  incorrecto. Inserir nmero.");
            incorrectData.open();
            txtTimesPerDay.setFocus();
            return false;
        }
    }

    // end of checking all simple fields

    Set<ChemicalDrugStrength> chemicalDrugStrengthList = new HashSet<ChemicalDrugStrength>();

    // go through and check the chemical compounds table
    for (int i = 0; i < tblChemicalCompounds.getItemCount(); i++) {
        TableItem ti = tblChemicalCompounds.getItem(i);

        // there should be a strength for each checked chemical compound
        if (ti.getChecked()) {
            // create a ChemicalCompound object from the TableItem
            // information
            String currentChemComString = ti.getText(0);

            // get the acronym and name
            int endOfAcronym = currentChemComString.indexOf("]") + 1;
            String acronym = currentChemComString.substring(0, endOfAcronym).trim();
            String name = currentChemComString.substring(endOfAcronym + 1, currentChemComString.length())
                    .trim();

            // create the chemicalCompound using name and acronym
            ChemicalCompound currentChemicalCompound = new ChemicalCompound(name, acronym);

            int strength = 0;
            try {
                strength = Integer.parseInt(ti.getText(1));

                if (strength <= 0) {
                    MessageBox incorrectData = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
                    incorrectData.setText("O valor da posologia no  Vlido");
                    incorrectData.setMessage("A posologia inserida para " + ti.getText(0)
                            + "  invlido. Inserir valor positivo");
                    incorrectData.open();
                    txtPacksize.setFocus();
                    return false;
                }
            } catch (NumberFormatException nfe) {

                if (ti.getText(1).trim().equals("")) {
                    MessageBox incorrectData = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
                    incorrectData.setText("Posologia do componente no foi inserido");
                    incorrectData.setMessage("Voc indicou que este medicamento contm o componente "
                            + ti.getText(0) + ", mas no entraram a posologia do componente.");
                    incorrectData.open();
                    txtPacksize.setFocus();
                    return false;
                } else {
                    MessageBox incorrectData = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
                    incorrectData.setText("posologia do componente no insserido");
                    incorrectData.setMessage("O posologia do componente inserido para  " + ti.getText(0)
                            + " no  nmero. \n\nInserir um nmero.");
                    incorrectData.open();
                    txtPacksize.setFocus();
                    return false;
                }
            }

            // get the drug
            if (localDrug == null) {
                localDrug = new Drug();
            }

            // create ChemicalDrugStrength which combines
            // chemicalCompound
            // and strength information
            ChemicalDrugStrength currentChemicalStrength = new ChemicalDrugStrength(currentChemicalCompound,
                    strength, localDrug);

            // add to the set of chemical compounds for this drug
            chemicalDrugStrengthList.add(currentChemicalStrength);

        }
    } // end of for loop

    if (localDrug != null) {
        setLocalDrug();
    }
    // all ARV drugs must have a chemical compound and must not have the
    // same chemical compounds and strengths as an existing drug
    if (rdBtnARV.getSelection()) {

        if (localDrug == null) {
            localDrug = new Drug();
        }

        setLocalDrug();

        if (chemicalDrugStrengthList.isEmpty()) {
            MessageBox m = new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
            m.setText("Sem componentes");
            m.setMessage(
                    "Todos medicamentos ARV tem uma composio qumica. \nAdicionar uma composio para"
                            + localDrug.getName());
            m.open();

            return false;
        } else {
            /*// check that there are no other drugs already with the same
            // chemical composition
            String chemicalDrugMatch = DrugManager
            .existsChemicalComposition(getHSession(),
                  chemicalDrugStrengthList, localDrug.getName());
                    
            boolean flag = DrugManager
            .formChemicalComposition(getHSession(),
                  chemicalDrugStrengthList, localDrug.getName(), localDrug.getForm().getForm());
                    
            if (chemicalDrugMatch != null) {
               if(flag){
                  MessageBox m = new MessageBox(getShell(),
                SWT.ICON_INFORMATION | SWT.OK);
                  m.setText("Duplicate ARV Drug");
                  m
                  .setMessage("The drug you are trying to add has the same chemical composition as drug '"
                + chemicalDrugMatch +" Form ("+localDrug.getForm().getForm()+")"
                + "' which is already in the database.\n\nIf this is the same drug, but a different manufacturer, you will capture this information when you receive the stock using 'Stock Arrives at the Pharmacy' screen.");
                  m.open();
                  return false;
               }
                       
            }*/
        }
    }
    return true;
}

From source file:org.celllife.idart.gui.packaging.NewPatientPackaging.java

License:Open Source License

private void attemptCaptureDateReset() {
    Date today = new Date();
    Date chosenDate = new Date();
    if (btnCaptureDate.getDate() != null) {
        chosenDate = btnCaptureDate.getDate();
    }// ww w  . ja va2s  .co m

    if (chosenDate.after(today)) {
        MessageBox mb = new MessageBox(getShell(), SWT.OK | SWT.ICON_ERROR);
        mb.setText("Data de dispensa No pode ser no futuro");
        mb.setMessage("A Data de dispensa No pode ser no futuro");
        mb.open();
        btnCaptureDate.setDate(today);
        chosenDate = today;
    }

    // Obtaining the currently selected capture date
    // if there is a previous pack date which is not
    // after the currently selected pack date.
    if (previousPack != null) {
        Date pickupDate = previousPack.getPickupDate();
        if (iDARTUtil.before(chosenDate, pickupDate)) {
            String msg = "O Paciente \"{0}\" teve sua ltima dispensa em {1,date,medium}. "
                    + "\n\nA data para a nova dispensa que est a criar deve estar depois desta data.";
            showMessage(MessageDialog.ERROR, "Erro da data de dispensa",
                    MessageFormat.format(msg, localPatient.getPatientId(), pickupDate));

            btnCaptureDate.setDate(today);
            chosenDate = today;
        }
    }

    if (iDARTUtil.before(chosenDate, today)) {
        chosenDate = iDARTUtil.zeroTimeStamp(chosenDate);
        btnCaptureDate.setDate(chosenDate);
    }

    if (fieldsEnabled) {
        String clinicName = localPatient.getClinicAtDate(chosenDate).getClinicName();
        // Check if clinic has changed. If so, show message
        if (!lblClinic.getText().equalsIgnoreCase(clinicName)) {
            MessageBox m = new MessageBox(getShell(), SWT.OK | SWT.ICON_INFORMATION);
            m.setText("US do paciente mudou");
            m.setMessage("Note que em " + sdf.format(btnCaptureDate.getDate()) + ", paciente '"
                    + localPatient.getPatientId() + "' foi dispensado seus medicamentos " + clinicName
                    + ".\n\n Todas dispensas feitas deste paciente"
                    + "neste dia ser destinado para esta US, " + "no na US actual do paciente.");
            m.open();
        }

        lblClinic.setText(clinicName);
        setDateExpectedFields();
        populatePrescriptionDetails();
        updateDateOfLastPickup();
    }
    if (newPack != null) {
        newPack.setPackDate(chosenDate);
    }
}

From source file:org.celllife.idart.gui.packaging.NewPatientPackaging.java

License:Open Source License

/**
 * Method fieldsOkay.//from  w  ww .  j  a v  a  2  s  .  c  o  m
 * 
 * @param allPackagedDrugsList
 *            java.util.List<PackageDrugInfo>
 * @return boolean
 */
private boolean fieldsOkay(java.util.List<PackageDrugInfo> allPackagedDrugsList) {
    Patient patient = PatientManager.getPatient(getHSession(), localPatient.getId());

    if (patient == null || txtPatientId.getText().equals("")) {
        showMessage(MessageDialog.ERROR, "Nenhum Paciente Seleccionado",
                "Nenhum Paciente foi Seleccionado. Precisa de seleccionar um.");
        return false;
    }

    if (!drugQuantitiesOkay()) {
        showMessage(MessageDialog.ERROR, "Nenhuma quantidade de medicamento foi Dispensado",
                "Voc no inseriu quantidades para qualquer um dos medicamentos.");
        return false;
    }

    if (btnCaptureDate.getDate().before(newPack.getPrescription().getDate()) && !(sdf
            .format(btnCaptureDate.getDate()).equals(sdf.format(newPack.getPrescription().getDate())))) {
        showMessage(MessageDialog.ERROR, "Data de Dispensa Invlida!",
                "A Data de dispensa no pode estar antes da data da prescrio "
                        + sdf.format(newPack.getPrescription().getDate()) + " ");
        return false;
    }

    if (btnNextAppDate.getDate() != null && btnNextAppDate.getDate().before(btnCaptureDate.getDate())
            && !(sdf.format(btnCaptureDate.getDate()).equals(sdf.format(btnNextAppDate.getDate())))) {
        showMessage(MessageDialog.ERROR, "A data do proximo levantamento esta antes da data deste levantamento",
                "A data do prximo levantamento no pode ser antes da data deste levantamento.");
        return false;
    }

    if (PackageManager.patientHasUncollectedPackages(getHSession(), patient)) {

        Date oldPackDate = PackageManager.getPackDateForUncollectedPackage(getHSession(),
                PatientManager.getPatient(getHSession(), txtPatientId.getText()));
        showMessage(MessageDialog.ERROR, "Frasco de medicamento j foi criado para Patient",
                "O Frasco j foi criados para este paciente'" + txtPatientId.getText() + "' em "
                        + sdf.format(oldPackDate) + " e ainda no foi entregue ao paciente. "
                        + "\n\nS podes criar outro frasco para este paciente "
                        + "Quando o frasco anterior for entregue ao paciente ou "
                        + "devolvido a farmcia (usando a tela 'Devolver Frascos no Entregues ao Paciente').");
        return false;
    }

    if (dateAlreadyDispensed) {
        Packages lastPackageMade = PackageManager.getLastPackageMade(getHSession(), patient);
        // if package hasn't been collected yet or date is not today
        // http://dev.cell-life.org/jira/browse/IDART-14
        Date pickupDate = lastPackageMade.getPickupDate();
        if (pickupDate == null || iDARTUtil.hasZeroTimestamp(pickupDate)) {
            Date oldPackDate = lastPackageMade.getPackDate();

            showMessage(MessageDialog.ERROR, "Frasco j foi criado neste dia",
                    "O Frasco j foi criado para o paciente '" + txtPatientId.getText() + "' em "
                            + sdf.format(oldPackDate)
                            + ".\n\niDART no aceita criar outro frasco para este paciente no mesmo dia, "
                            + "assim como o tempo em que eles foram criados ser a mesmo. "
                            + "Isso causa problemas na contagem de comprimidos. ");
            return false;
        }
    }

    // open temporary session
    Session sess = HibernateUtil.getNewSession();
    for (PackageDrugInfo pdi : allPackagedDrugsList) {
        if (!checkStockStillAvailable(sess, pdi)) {
            showMessage(MessageDialog.ERROR, "O Stock seleccionado est vazio.",
                    "O lote do stock seleccionado para " + pdi.getDrugName()
                            + " no contm mais stock.\n\nSeleccione outro lote.");
            return false;
        }
    }

    // close temp session
    sess.close();

    for (PackageDrugInfo pdi : allPackagedDrugsList) {
        if (!checkForBreakingPacks(pdi)) {
            return false;
        }
    }

    return true;
}

From source file:org.celllife.idart.gui.packaging.NewPatientPackaging.java

License:Open Source License

/**
 * This method populates the Patient Details and then runs the Populate
 * Prescription Details details This method is run on startup and when the
 * patient Id is clicked./*from   ww w .  j  a v  a2 s .c  om*/
 * 
 * @param patientID
 *            String
 */
private void populatePatientDetails(int patientID) {
    localPatient = PatientManager.getPatient(getHSession(), patientID);
    previousPack = null;
    searchBar.setText(localPatient.getPatientId());
    searchBar.setSelection(0, localPatient.getPatientId().length());
    lstWaitingPatients.setSelection(new StructuredSelection(new PatientIdAndName(localPatient.getId(),
            localPatient.getPatientId(), localPatient.getFirstNames() + "," + localPatient.getLastname())));
    if (!localPatient.getAccountStatusWithCheck() || localPatient.getCurrentPrescription() == null) {
        showMessage(MessageDialog.ERROR, "O Paciente no pode ser dispensado.",
                "Paciente est inativo ou no tem uma prescrio vlida.");
        initialiseSearchList();
        clearForm();
        return;
    }

    Clinic clinic = localPatient.getCurrentClinic();
    setDispenseTypeFromClinic();
    lblClinic.setText(clinic.getClinicName());
    txtPatientId.setText(localPatient.getPatientId());
    txtPatientName.setText(localPatient.getFirstNames() + " " + localPatient.getLastname());
    txtPatientAge.setText("" + localPatient.getAge());
    txtPatientDOB.setText(new SimpleDateFormat("dd MMM yyyy").format(localPatient.getDateOfBirth()));
    if (localPatient.getAge() < 15) {
        lblPicChild.setVisible(true);

    } else {
        lblPicChild.setVisible(false);

    }

    if (!iDartProperties.summaryLabelDefault) {
        rdBtnPrintSummaryLabelYes.setSelection(false);
        rdBtnPrintSummaryLabelNo.setSelection(true);
    } else {
        rdBtnPrintSummaryLabelYes.setSelection(false);
        rdBtnPrintSummaryLabelNo.setSelection(true);
    }

    Prescription pre = localPatient.getCurrentPrescription();
    if (pre == null) {
        MessageBox noScript = new MessageBox(getShell(), SWT.OK | SWT.ICON_INFORMATION);
        noScript.setText("O Paciente no tem uma prescrio vlida");
        noScript.setMessage("Patient '".concat(localPatient.getPatientId())
                .concat("' no tem uma prescrio vlida."));
        noScript.open();
        initialiseSearchList();
        clearForm();
    } else {
        newPack = new Packages();
        newPack.setPrescription(pre);
        newPack.setClinic(localPatient.getCurrentClinic());
        // String theWeeks = cmbSupply.getText();
        //
        // int numPeriods =
        // Integer.parseInt(theWeeks.split(" ")[0]);
        //
        // if (theWeeks.endsWith("months") ||
        // theWeeks.endsWith("month")) {
        // numPeriods = numPeriods * 4;
        // }

        // weeks supply = script duration
        int numPeriods = pre.getDuration() >= 4 ? 4 : pre.getDuration();
        newPack.setWeekssupply(numPeriods);

        btnCaptureDate.setDate(new Date());
        newPack.setPackDate(btnCaptureDate.getDate());

        previousPack = PackageManager.getLastPackagePickedUp(getHSession(), localPatient);

        if (patientHasPackageAwaitingPickup()) {
            MessageBox m = new MessageBox(getShell(), SWT.OK | SWT.ICON_INFORMATION);
            m.setText("O Paciente no pode ser dispensado");
            m.setMessage("No pode dispensar medicamento para " + txtPatientId.getText()
                    + " uma vez que um frasco j foi criado em " + sdf.format(previousPack.getPackDate())
                    + " para este paciente. " + "\nEste frasco ainda no foi colectado pelo paciente. "
                    + "\n\n Se o frasco est correcto, porfavor de scanar "
                    + "para e entrega o paciente usando a tela 'Scanar frascos para os pacientes.' "
                    + "\n\nSe o frasco no est correcto, "
                    + "por favor apague-o usando a tela 'Apagar Stock, Prescription & Frascos' " + "");

            m.open();
            clearForm();
            return;
        } else {
            populatePrescriptionDetails();
            populatePresciptionTable();
            prepopulateQuantities();
        }

        enableFields(true);

        resetGUIforDispensingType();

        pillFacade = new PillCountFacade(getHSession());

        if (previousPack != null && rdBtnDispenseNow.getSelection()) {
            pillCountTable.populateLastPackageDetails(previousPack, newPack.getPackDate());
        }

        if (rdBtnDispenseNow.getSelection()) {
            // Display the next appointment date if there is one,
            // or else base next appointment on todays date.
            Appointment nextApp = PatientManager.getLatestAppointmentForPatient(localPatient, true);
            if (nextApp == null) {
                Calendar theCal = Calendar.getInstance();
                attemptCaptureDateReset();
                theCal.setTime(newPack.getPackDate());
                theCal.add(Calendar.DATE, numPeriods * 7);
                adjustForNewDispDate(btnCaptureDate.getDate());
                adjustForNewAppointmentDate(theCal.getTime());
            }
        }
    }
}

From source file:org.celllife.idart.gui.packaging.NewPatientPackaging.java

License:Open Source License

private void setDispenseTypeFromClinic() {
    Clinic clinic = localPatient//from  www .ja  v  a 2s.co  m
            .getClinicAtDate(btnCaptureDate.getDate() != null ? btnCaptureDate.getDate() : new Date());
    if (clinic == null) {
        showMessage(MessageDialog.ERROR, "Paciente no Activo na Data Seleccionada ",
                "O paciente no tem um episdio em aberto na data que voc especificou Ento voc no  capaz de dispensar a eles nesta data.\n\n "
                        + "Por favor, seleccione uma data de quando o paciente foi ativo.\n\n "
                        + "Para ver quando o paciente estave ativo, olhar para os seus episdios na tela 'Relatrio do Histrico do Paciente' (pressione o boto no meio da tela para carregar este relatrio).");
        btnCaptureDate.setDate(new Date());
    } else {
        boolean isMainClinic = clinic.isMainClinic();

        rdBtnDispenseNow.setSelection(isMainClinic & iDartProperties.dispenseDirectlyDefault);
        rdBtnDispenseLater.setSelection(!(isMainClinic & iDartProperties.dispenseDirectlyDefault));

        resetGUIforDispensingType();
    }
}

From source file:org.celllife.idart.gui.parameter.UpdateParameter.java

License:Open Source License

@Override
protected void cmdSaveWidgetSelected() {

    if (fieldsOk()) {

        Transaction tx = null;/*  w  ww .  jav a2 s. c  o  m*/
        String action = ""; //$NON-NLS-1$

        try {
            tx = getHSession().beginTransaction();

            Integer amcData = Integer.parseInt(txtValue.getText());
            if (amcData.intValue() <= 0 || amcData.intValue() >= 29) {
                JOptionPane.showMessageDialog(null, "Please select a number between 1 and 28");
                return;
            }

            localParameter.setParameterValue(txtValue.getText());

            getHSession().flush();
            tx.commit();
            String message = MessageFormat.format(Messages.getString("adddoctor.message"), //$NON-NLS-1$
                    localParameter.getParameterValue(), action);
            showMessage(MessageDialog.INFORMATION, Messages.getString("adddoctor.messageupdate"), message);//$NON-NLS-1$ 
            fireChangeEvent(localParameter);
            cmdCancelWidgetSelected();
        } catch (HibernateException he) {
            getLog().error(Messages.getString("adddoctor.errordb"), he); //$NON-NLS-1$
            showMessage(MessageDialog.ERROR, Messages.getString("adddoctor.errordb"), //$NON-NLS-1$ 
                    Messages.getString("adddoctor.errordb.saving"));//$NON-NLS-1$
            if (tx != null) {
                tx.rollback();
            }
        }

    }

}

From source file:org.celllife.idart.gui.patient.AddPatient.java

License:Open Source License

private void updateMobilisrContactDetails(String oldCellNo, String firstName, String lastName,
        String newCellNo) {//from   ww  w. ja va  2 s .c  om
    try {
        if (StudyManager.patientEverOnStudy(getHSession(), localPatient.getId())) {
            MobilisrManager.updateMobilisrCellNo(oldCellNo, firstName, lastName, newCellNo);
        }
    } catch (RestCommandException e) {
        showMessage(MessageDialog.ERROR, "Error", "Error updating patients mobile number" + " in Communicate");
    }
}