public boolean isValidFacilityNpi() {
   String npiNumber = billing1500FormHome.getInstance().getFacilityNpi();
   if (!Strings.isNullOrEmpty(npiNumber)) {
     // Organization organization = getOrganizationByNpiNumber(npiNumber);
     Organization organization = null;
     if (organization != null) {
       organizationHome.setInstance(organization);
       return true;
     } else {
       billing1500FormHome.getInstance().setFacilityNpi(null);
     }
   }
   if (Strings.isNullOrEmpty(billing1500FormHome.getInstance().getFacilityName())) {
     organizationHome.setInstance(null);
     resetFacility();
     return false;
   }
   return true;
 }
 private void prepareFacilityInformation() {
   if (organizationHome.getInstance().getOrganizationLocationList() != null
       && organizationHome.getInstance().getOrganizationLocationList().size() > 0) {
     OrganizationLocation organizationLocation =
         organizationHome.getInstance().getOrganizationLocationList().get(0);
     billing1500FormHome.getInstance().setFacilityName(organizationHome.getInstance().getName());
     if (organizationLocation.getLocation() != null) {
       billing1500FormHome
           .getInstance()
           .setFacilityAddress(organizationLocation.getLocation().getStreet1());
       billing1500FormHome
           .getInstance()
           .setFacilityCity(organizationLocation.getLocation().getCity());
       billing1500FormHome
           .getInstance()
           .setFacilityState(organizationLocation.getLocation().getState());
       billing1500FormHome
           .getInstance()
           .setFacilityZipCode(organizationLocation.getLocation().getZipcodeId());
     }
   }
 }
 /** @param result */
 public void populateFacility(Object result) {
   if (result != null) {
     Organization organization = (Organization) result;
     organizationHome.setInstance(organization);
     // NpiNumber npiNumber = getNpiNumberByOrganization(organization.getOrganizationId());
     NpiNumber npiNumber = null;
     if (npiNumber != null) {
       billing1500FormHome.getInstance().setFacilityNpi(String.valueOf(npiNumber.getNumber()));
     } else {
       billing1500FormHome.getInstance().setFacilityNpi(null);
     }
     prepareFacilityInformation();
   }
 }
 private void prepareProviderInformation() {
   billing1500FormHome.getInstance().setFederalTaxId(organizationHome.getInstance().getTaxId());
   billing1500FormHome.getInstance().setProviderName(organizationHome.getInstance().getName());
   if (organizationHome.getInstance().getOrganizationLocationList() != null
       && organizationHome.getInstance().getOrganizationLocationList().size() > 0) {
     OrganizationLocation organizationLocation =
         organizationHome.getInstance().getOrganizationLocationList().get(0);
     if (organizationLocation.getLocation() != null) {
       organizationLocationHome.setInstance(organizationLocation);
       billing1500FormHome
           .getInstance()
           .setProviderAddress(organizationLocationHome.getInstance().getLocation().getStreet1());
       billing1500FormHome
           .getInstance()
           .setProviderCity(organizationLocationHome.getInstance().getLocation().getCity());
       billing1500FormHome
           .getInstance()
           .setProviderState(organizationLocationHome.getInstance().getLocation().getState());
       billing1500FormHome
           .getInstance()
           .setProviderZipCode(
               organizationLocationHome.getInstance().getLocation().getZipcodeId());
     } else {
       resetOrganizationLocation();
     }
   } else {
     resetOrganizationLocation();
   }
   if (organizationHome.getInstance().getOrganizationTelephonesList() != null
       && organizationHome.getInstance().getOrganizationTelephonesList().size() > 0) {
     OrganizationTelephone organizationTelephone =
         organizationHome.getInstance().getOrganizationTelephonesList().get(0);
     billing1500FormHome
         .getInstance()
         .setProviderPhone(organizationTelephone.getTelephone().getFullTelephone());
   } else {
     billing1500FormHome.getInstance().setProviderPhone(null);
   }
 }
  public void validatePatient() {
    String patientId = billing1500FormHome.getInstance().getPatientId();
    if (!Strings.isNullOrEmpty(patientId)) {
      Client client = getPatient(patientId);
      if (client != null) {
        clientHome.setInstance(client);
        billing1500FormHome
            .getInstance()
            .setPatientFirstName(clientHome.getInstance().getFirstname());
        billing1500FormHome
            .getInstance()
            .setPatientLastName(clientHome.getInstance().getLastname());
        billing1500FormHome
            .getInstance()
            .setPatientMiddleName(clientHome.getInstance().getMiddleinitial());
        billing1500FormHome
            .getInstance()
            .setPatientBirthDate(clientHome.getInstance().getBirthDate());
        if (!Strings.isNullOrEmpty(clientHome.getInstance().getGender())) {
          if (clientHome.getInstance().getGender().toUpperCase().equals("MALE")) {
            billing1500FormHome.getInstance().setPatientGender("M");
          } else if (clientHome.getInstance().getGender().toUpperCase().equals("FEMALE")) {
            billing1500FormHome.getInstance().setPatientGender("F");
          }
        }
        if (clientHome.getInstance().getMailingAddress() != null
            && clientHome.getInstance().getMailingAddress().getAddress() != null) {
          billing1500FormHome
              .getInstance()
              .setPatientAddress(
                  clientHome.getInstance().getMailingAddress().getAddress().getStreetaddress());
          billing1500FormHome
              .getInstance()
              .setPatientCity(clientHome.getInstance().getMailingAddress().getAddress().getCity());
          billing1500FormHome
              .getInstance()
              .setPatientState(
                  clientHome.getInstance().getMailingAddress().getAddress().getState());
          billing1500FormHome
              .getInstance()
              .setPatientZipCode(
                  clientHome.getInstance().getMailingAddress().getAddress().getZipcode());
        }
        if (clientHome.getInstance().getHomePhone() != null
            && clientHome.getInstance().getHomePhone().getPhone() != null) {
          billing1500FormHome
              .getInstance()
              .setPatientPhone(clientHome.getInstance().getHomePhone().getPhone().getFullNumber());
        }

        // populate registration insurance info
        PublicQuestionAnswers publicQuestionAnswers = getRegistrationInsuranceByClient(client);
        if (publicQuestionAnswers != null && publicQuestionAnswers.getAnswer() != null) {
          billingEobFormHome.getInstance().setOtherInsuranceName(publicQuestionAnswers.getAnswer());
        } else {
          billingEobFormHome.getInstance().setOtherInsuranceName(null);
        }
      } else {
        organizationHome.setInstance(null);
        billingEobFormHome.getInstance().setOtherInsuranceName(null);
        resetPatient();
      }
    }
  }