private void populateTable() {
    DefaultTableModel model = (DefaultTableModel) billjTable1.getModel();

    model.setRowCount(0);
    for (Network n : business.getNetworkList()) {
      for (Enterprise enterprise : n.getEnterpriseDirectory().getEnterpriseList()) {

        if (enterprise instanceof DistributorEnterprise) {
          for (WorkRequest request : enterprise.getWorkQueue().getWorkRequestList()) {

            Object[] row = new Object[5];
            row[0] = request;
            // row[] = request.getSender().getEmployee().getName();
            row[1] =
                request.getReceiver() == null
                    ? null
                    : request.getReceiver().getEmployee().getName();
            row[2] = ((ProviderWorkRequest) request).getOrder();
            row[3] = ((ProviderWorkRequest) request).getTotalPrice();
            row[4] = request.getStatus();

            model.addRow(row);
          }
        }
      }
    }
  }
  private void populateEnterpriseNetworkTable(Network n) {

    //        for (Network country : system.getNetworkList())
    //            for (Network state : country.getSubnetworklist())
    //                for (Network city : state.getSubnetworklist())

    DefaultTableModel model = (DefaultTableModel) InfoJTable.getModel();
    model.setRowCount(0);
    for (Enterprise ent : n.getEnterpriseDirectory().getEnterpriseList()) {
      Object row[] = new Object[3];
      row[0] = ent.getName();
      row[1] = n.getNetworkname() + " , " + n.getNetworkname() + " , " + n.getNetworkname();
      row[2] = ent.getEnterpriseType();
      model.addRow(row);
    }
  }
  private void manageOrganizationJButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_manageOrganizationJButtonActionPerformed

    ManageOrganizationJPanel manageOrganizationJPanel =
        new ManageOrganizationJPanel(userProcessContainer, enterprise.getOrganizationDirectory());
    userProcessContainer.add("manageOrganizationJPanel", manageOrganizationJPanel);
    CardLayout layout = (CardLayout) userProcessContainer.getLayout();
    layout.next(userProcessContainer);
  } // GEN-LAST:event_manageOrganizationJButtonActionPerformed
  public void populateTree() {

    DefaultTreeModel model = (DefaultTreeModel) JTree.getModel();

    ArrayList<Network> networkList = system.getNetworkList();
    ArrayList<Enterprise> enterpriseList;
    ArrayList<Organization> organizationList;

    Network network;
    Enterprise enterprise;
    Organization organization;

    DefaultMutableTreeNode networks = new DefaultMutableTreeNode("Networks");
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    root.removeAllChildren();
    root.insert(networks, 0);

    DefaultMutableTreeNode networkNode;
    DefaultMutableTreeNode enterpriseNode;
    DefaultMutableTreeNode organizationNode;

    for (int i = 0; i < networkList.size(); i++) {
      network = networkList.get(i);
      networkNode = new DefaultMutableTreeNode(network.getName());
      networks.insert(networkNode, i);

      enterpriseList = network.getEnterpriseDirectory().getEnterpriseList();

      for (int j = 0; j < enterpriseList.size(); j++) {
        enterprise = enterpriseList.get(j);
        enterpriseNode = new DefaultMutableTreeNode(enterprise.getName());
        networkNode.insert(enterpriseNode, j);

        organizationList = enterprise.getOrganizationDirectory().getOrganizationList();
        for (int k = 0; k < organizationList.size(); k++) {
          organization = organizationList.get(k);
          organizationNode = new DefaultMutableTreeNode(organization.getName());
          enterpriseNode.insert(organizationNode, k);
        }
      }
    }

    model.reload();
  }
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:

    if (PhysiciansjCheckBox2.isSelected()) {
      ErrorPerson ep1 = workRequest.getEpd().createPersonnel(ErrorPerson.ErrorPersonType.PHYSICIAN);
      // doctorReport.getEpd().getErrorpersonlist().add(ep1);
    }
    if (nursejCheckBox3.isSelected()) {
      ErrorPerson ep1 = workRequest.getEpd().createPersonnel(ErrorPerson.ErrorPersonType.NURESE);
      // doctorReport.getEpd().getErrorpersonlist().add(ep1);
    }
    if (pathologistjCheckBox5.isSelected()) {
      ErrorPerson ep1 =
          workRequest.getEpd().createPersonnel(ErrorPerson.ErrorPersonType.PATHOLOGIST);
      // doctorReport.getEpd().getErrorpersonlist().add(ep1);
    }
    if (phajCheckBox6.isSelected()) {
      ErrorPerson ep1 =
          workRequest.getEpd().createPersonnel(ErrorPerson.ErrorPersonType.PHARMACIST);
      // doctorReport.getEpd().getErrorpersonlist().add(ep1);
    }
    if (adminstrationjCheckBox1.isSelected()) {
      ErrorPerson ep1 =
          workRequest.getEpd().createPersonnel(ErrorPerson.ErrorPersonType.ADMINSTRATION);
      // doctorReport.getEpd().getErrorpersonlist().add(ep1);
    }
    if (surgeonjCheckBox4.isSelected()) {
      ErrorPerson ep1 = workRequest.getEpd().createPersonnel(ErrorPerson.ErrorPersonType.SURGEON);
      // doctorReport.getEpd().getErrorpersonlist().add(ep1);
    }

    if (devicejCheckBox1.isSelected()) {
      workRequest.setDevicecause(Device.DEVICE_DEFECT_OR_FAILURE);
    }
    if (useerrorjCheckBox2.isSelected()) {
      workRequest.setDevicecause(Device.USER_ERROR);
    }
    if (unknownjCheckBox4.isSelected()) {
      workRequest.setDevicecause(Device.UNKNOWN);
    }
    if (combinationjCheckBox3.isSelected()) {
      workRequest.setDeviceerror(Device.COMBINATION);
    }

    workRequest.setLocation((String) locationjComboBox1.getSelectedItem());
    workRequest.setDeviceerror((String) devicejComboBox3.getSelectedItem());

    for (Organization o : e.getOrganizationDirectory().getOrganizationList()) {
      if (o instanceof ServiceOrganization) {
        o.getWorkQueue().getWorkRequestList().add(workRequest);
      }
    }
    ua.getWorkQueue().getWorkRequestList().add(workRequest);
    JOptionPane.showMessageDialog(null, "The report has been submitted");
  } // GEN-LAST:event_jButton1ActionPerformed
  private void forwardBilljButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_forwardBilljButtonActionPerformed
    int selectedRow = billjTable1.getSelectedRow();
    if (selectedRow < 0) {
      return;
    } else {

      ProviderWorkRequest request2 = (ProviderWorkRequest) billjTable1.getValueAt(selectedRow, 0);

      if (request2.getStatus().equals("Pending")) {
        JOptionPane.showMessageDialog(null, "Order is Pending");
      } else if (request2.getStatus().equals("Completed")) {
        Enterprise ent = null;

        for (Enterprise ent1 : n.getEnterpriseDirectory().getEnterpriseList()) {
          if (ent1 instanceof CDCEnterprise) {
            ent = ent1;
            break;
          }
        }
        if (ent != null) {
          System.out.println(request2.getOrder() + "order check");
          int price = calculatePrice(request2.getOrder());

          request2.setTotalPrice(price);
          System.out.println(price + "dddd");
          ent.getWorkQueue().getWorkRequestList().add(request2);
          // userAccount.getWorkQueue().getWorkRequestList();
          // System.out.println(price +"sss");

        }
      } else {
        JOptionPane.showMessageDialog(null, "Order is Pending");
      }
    }

    // TODO add your handling code here:
  } // GEN-LAST:event_forwardBilljButtonActionPerformed
  public void populateRequestTable() {
    DefaultTableModel model = (DefaultTableModel) workRequestJTable.getModel();
    model.setRowCount(0);

    for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) {
      if (org instanceof CareTeamOrganization) {
        for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) {
          Object[] row = new Object[6];
          row[0] = request;
          row[1] = request.getReceiver();
          row[2] = request.getRequestDate();
          row[3] = ((SurgeryOperationWorkRequest) request).getRequiredCareTeamSize();
          row[4] = ((SurgeryOperationWorkRequest) request).getAssignedTeamSize();
          row[5] = request.getStatus();
          model.addRow(row);
        }
      }
    }
  }
 private void btnManageVolunteersActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnManageVolunteersActionPerformed
   // TODO add your handling code here:
   VolunteerUserAccountJPanel vuajp = null;
   for (Organization organization : enterprise.getOrganizationList().getOrganizationList()) {
     if (organization instanceof VolunteerOrganization) {
       vuajp =
           new VolunteerUserAccountJPanel(
               userProcessContainer,
               (VolunteerOrganization) organization,
               (KitchenEnterprise) enterprise,
               userAccount);
       break;
     }
   }
   userProcessContainer.add("VolunteerUserAccountJPanel", vuajp);
   CardLayout layout = (CardLayout) userProcessContainer.getLayout();
   layout.next(userProcessContainer);
 } // GEN-LAST:event_btnManageVolunteersActionPerformed
  public void populateCareTeamTable() {

    DefaultTableModel dtm = (DefaultTableModel) careTeamMemberjTable2.getModel();
    dtm.setRowCount(0);

    for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) {
      if (org instanceof CareTeamOrganization) {
        CareTeamOrganization ctOrg = (CareTeamOrganization) org;
        for (CareTeamMember ctm : ctOrg.getCareTeamDirectory().getCareTeamMemberList()) {
          if (ctm.getRole() instanceof CareTeamMemberRole) {
            Object[] row = new Object[5];
            row[0] = ctm;
            row[1] = ctm.getSpeciality();
            row[2] = ctm.getAvailabilityStatus();
            row[3] = ctm.getCurrentVacantStatus();
            row[4] = ctm.getNextScheduledActivityDate();
            dtm.addRow(row);
          }
        }
      }
    }
  }
  public static Enterprise getSystem() {
    // Step 1
    Enterprise systemEnterprise = new Business.System.System("System");
    String ssn = "1";
    Person sysAdminisPerson = systemEnterprise.getPersonDirectory().addNewPerson("1");

    Staff systemAdmin = systemEnterprise.getEnterpriseAdmin().addNewUser(sysAdminisPerson);
    systemAdmin.setUserName("s");
    systemAdmin.setPassword("s");

    SystemAdministratorWorkArea systemAdministratorWorkArea =
        new SystemAdministratorWorkArea("SystemAdministratorWorkArea");

    systemAdmin.setWorkArea(systemAdministratorWorkArea);
    systemEnterprise.setWorkArea(systemAdministratorWorkArea);

    // Step 2

    Network newNetwork = ((Business.System.System) systemEnterprise).AddNewNetwork("India");
    Enterprise enterprise = newNetwork.newEnterprise("HospitalEnterprise", "BostonGeneral");

    Person person5 = enterprise.getPersonDirectory().addNewPerson("5");

    Staff enterpriseAdministrator = enterprise.getEnterpriseAdmin().addNewUser(person5);
    enterpriseAdministrator.setUserName("e");
    enterpriseAdministrator.setPassword("e");

    EnterpriseAdministratorWorkArea enterpriseAdministratorWorkArea =
        new EnterpriseAdministratorWorkArea("EnterpriseAdministratorWorkArea");

    enterpriseAdministrator.setWorkArea(enterpriseAdministratorWorkArea);
    enterprise.setWorkArea(enterpriseAdministratorWorkArea);

    Person patientPerson = enterprise.getPersonDirectory().addNewPerson("2");
    Patient patientConfigured = enterprise.getPatientDirectory().newPatient(patientPerson);

    MedicalHistory medicalHistoryPatient = patientConfigured.addNewMedicalHistory();

    medicalHistoryPatient.setAge(22);
    medicalHistoryPatient.setBloodPressureRate("90/120mgh");
    MedicationOrder addNewMedicationOrder = medicalHistoryPatient.addNewMedicationOrder();
    addNewMedicationOrder.setDrugAdministered("SSN");
    // medicalHistoryPatient.setDrugAdministered("Crocin");
    medicalHistoryPatient.setVitalSigns("Fever");
    medicalHistoryPatient.setWeight(90);

    // step 3

    Organisation newOrganisation =
        enterprise.newOrganisation("HospitalEnterprise", "CausaltyOrganisation");
    // step 4
    Person person3 = enterprise.getPersonDirectory().addNewPerson("3");
    Staff organisationstaff = newOrganisation.getStaffDirectory().addNewUser(person3);
    organisationstaff.setUserName("o");
    organisationstaff.setPassword("o");

    Organisation newOrganisations =
        enterprise.newOrganisation("HospitalEnterprise", "DoctorManagementOrganisation");
    // step 4
    Person person4 = enterprise.getPersonDirectory().addNewPerson("4");
    Staff organisationstaffes = newOrganisations.getStaffDirectory().addNewUser(person4);
    organisationstaffes.setUserName("do");
    organisationstaffes.setPassword("do");

    // step 5

    DoctorManagementWorkArea dmwa = new DoctorManagementWorkArea("DoctorManagementWorkArea");
    CausaltyWorkArea causaltyWorkArea = new CausaltyWorkArea("CausaltyWorkArea");

    // step 6

    organisationstaff.setWorkArea(causaltyWorkArea);
    newOrganisation.setWorkArea(causaltyWorkArea);

    organisationstaffes.setWorkArea(dmwa);
    newOrganisations.setWorkArea(dmwa);

    return systemEnterprise;
  }
 private void populateText() {
   unamejTextField2.setText(ua.getUserName());
   // namejTextField3.setText(ua.getPatient().getPatientname());
   hosnamejTextField4.setText(enterprise.getOrgName());
   rolejTextField5.setText(ua.getRole().toString());
 }