Beispiel #1
0
        public ActionResult Create(MedicalVendorEditModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.OrganizationEditModel.LogoImage = FileObject(model.OrganizationEditModel.Name, "organization_logo", _mediaRepository.GetOrganizationLogoImageFolderLocation());
                    model.ResultLetterCoBrandingFile      = FileObject(model.OrganizationEditModel.Name, "result_letter", _mediaRepository.GetOrganizationResultLetterFolderLocation());

                    model.DoctorLetterFile = FileObject(model.OrganizationEditModel.Name, "doctor_letter", _mediaRepository.GetOrganizationDoctorLetterFolderLocation());

                    model.OrganizationEditModel.OrganizationType = OrganizationType.MedicalVendor;
                    _organizationService.CreateMedicalVendor(model);

                    var newModel = new MedicalVendorEditModel();
                    SetPackageAndTerritory(newModel);

                    newModel.FeedbackMessage =
                        FeedbackMessageModel.CreateSuccessMessage(string.Format("The medical vendor {0} was saved successfully. You can add more medical vendors from here.", model.OrganizationEditModel.Name));

                    return(View(newModel));
                }
                SetPackageAndTerritory(model);
                return(View(model));
            }
            catch (Exception ex)
            {
                SetPackageAndTerritory(model);
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Failure. Message: " + ex.Message);
                return(View(model));
            }
        }
Beispiel #2
0
 private void SetPackageAndTerritory(MedicalVendorEditModel model)
 {
     model.HospitalPartnerEditModel.OrganizationPackageList = _packageRepository.GetAll().Select(x => new OrganizationPackageViewModel {
         Gender = ((Gender)x.Gender), Id = x.Id, Name = x.Name
     }).OrderBy(x => x.Name).ToList();
     model.HospitalPartnerEditModel.Territories        = _territoryRepository.GetAllTerritoriesIdNamePair(TerritoryType.HospitalPartner).OrderBy(x => x.SecondValue);
     model.HospitalPartnerEditModel.HospitalFacilities = _hospitalFacilityRepository.GetAllForHospitalPartner(model.OrganizationEditModel.Id);
     model.HospitalPartnerEditModel.ShippingOptions    = _shippingOptionRepository.GetAllShippingOptionsForBuyingProcess();
 }
Beispiel #3
0
        public ActionResult Create()
        {
            var model = new MedicalVendorEditModel();

            SetPackageAndTerritory(model);

            var value = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.AskPreQualificationQuestion);
            var askPreQualificationQuestion = value.ToLower() == bool.TrueString.ToLower();

            model.HospitalPartnerEditModel.ShowAskPreQualificationQuestionSetttings = askPreQualificationQuestion;
            return(View(model));
        }
Beispiel #4
0
        public MedicalVendor ToDomain(MedicalVendorEditModel model)
        {
            var binder        = new OrganizationCreateModelBinder();
            var medicalVendor = new MedicalVendor();

            medicalVendor = binder.ToDomain(medicalVendor, model) as MedicalVendor;
            medicalVendor.MedicalVendorType = model.MedicalVendorType;
            medicalVendor.ContractId        = model.ContractId;
            medicalVendor.IsHospitalPartner = model.IsHospitalPartner;
            //medicalVendor.PaymentInstructionId = model.PaymentInstructions.Id;
            //medicalVendor.EvaluationMode = model.EvaluationMode;
            return(medicalVendor);
        }
Beispiel #5
0
        public MedicalVendorEditModel ToModel(MedicalVendor organization, AddressEditModel billingAddress, AddressEditModel businessAddress, File logoImage, File teamImage, PaymentInstructions instructions,
                                              TestPayRate[] payRates, decimal customerPayRate, TestType[] permitted)
        {
            var binder = new OrganizationCreateModelBinder();
            var model  = new MedicalVendorEditModel();

            model = binder.ToModel(model, organization, billingAddress, businessAddress, logoImage, teamImage) as MedicalVendorEditModel;

            model.ContractId        = organization.ContractId;
            model.MedicalVendorType = organization.MedicalVendorType;
            model.IsHospitalPartner = organization.IsHospitalPartner;
            //model.CustomerPayRate = customerPayRate;
            //model.EvaluationMode = organization.EvaluationMode;
            //model.PaymentInstructions = instructions;
            //model.PermittedTests = permitted;
            //model.TestPayRates = payRates;
            return(model);
        }
Beispiel #6
0
        public ActionResult Edit(MedicalVendorEditModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.OrganizationEditModel.LogoImage = FileObject(model.OrganizationEditModel.Name, "organization_logo", _mediaRepository.GetOrganizationLogoImageFolderLocation(), model.OrganizationEditModel.LogoImage != null ? model.OrganizationEditModel.LogoImage.Id : 0);
                    model.ResultLetterCoBrandingFile      = FileObject(model.OrganizationEditModel.Name, "result_letter", _mediaRepository.GetOrganizationResultLetterFolderLocation(), model.ResultLetterCoBrandingFile != null ? model.ResultLetterCoBrandingFile.Id : 0);

                    model.DoctorLetterFile = FileObject(model.OrganizationEditModel.Name, "doctor_letter", _mediaRepository.GetOrganizationDoctorLetterFolderLocation(), model.DoctorLetterFile != null ? model.DoctorLetterFile.Id : 0);

                    var attachedEventIds = _hospitalPartnerRepository.GetAttachedHospitalMaterialEventIdsForHospitalPartner(model.OrganizationEditModel.Id);
                    if (model.ResultLetterCoBrandingFile == null && attachedEventIds.Count() > 0)
                    {
                        model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("You can not remove result letter since event(s) are attached to it.");
                        return(View(model));
                    }
                    model.OrganizationEditModel.OrganizationType = OrganizationType.MedicalVendor;

                    _organizationService.CreateMedicalVendor(model);

                    model.FeedbackMessage = FeedbackMessageModel.CreateSuccessMessage(string.Format("The medical vendor {0} was saved successfully.", model.OrganizationEditModel.Name));

                    SetPackageAndTerritory(model);
                    return(View(model));
                }
                SetPackageAndTerritory(model);
                return(View(model));
            }
            catch (Exception ex)
            {
                SetPackageAndTerritory(model);
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Failure. Message: " + ex.Message);
                return(View(model));
            }
        }
Beispiel #7
0
        public long CreateMedicalVendor(MedicalVendorEditModel model)
        {
            long toDeleteFileId = 0;

            if (model.ResultLetterCoBrandingFile != null)
            {
                model.ResultLetterCoBrandingFile = _fileRepository.Save(model.ResultLetterCoBrandingFile);
            }

            if (model.OrganizationEditModel.Id > 0)
            {
                var inDb = _medicalVendorRepository.GetMedicalVendor(model.OrganizationEditModel.Id);
                if (inDb.ResultLetterCoBrandingFileId.HasValue && inDb.ResultLetterCoBrandingFileId.Value > 0 && (model.ResultLetterCoBrandingFile == null || inDb.ResultLetterCoBrandingFileId != model.ResultLetterCoBrandingFile.Id))
                {
                    toDeleteFileId = inDb.ResultLetterCoBrandingFileId.Value;
                }
            }

            long toDeleteDoctorLetterFileId = 0;

            if (model.DoctorLetterFile != null)
            {
                model.DoctorLetterFile = _fileRepository.Save(model.DoctorLetterFile);
            }

            if (model.OrganizationEditModel.Id > 0)
            {
                var inDb = _medicalVendorRepository.GetMedicalVendor(model.OrganizationEditModel.Id);
                if (inDb.DoctorLetterFileId.HasValue && inDb.DoctorLetterFileId.Value > 0 && (model.DoctorLetterFile == null || inDb.DoctorLetterFileId != model.DoctorLetterFile.Id))
                {
                    toDeleteDoctorLetterFileId = inDb.DoctorLetterFileId.Value;
                }
            }

            var medicalVendor  = Mapper.Map <MedicalVendorEditModel, MedicalVendor>(model);
            var organizationId = Create(model.OrganizationEditModel);

            medicalVendor.Id = organizationId;
            _medicalVendorRepository.Save(medicalVendor);

            if (toDeleteFileId > 0)
            {
                ((IFileRepository)_fileRepository).Delete(toDeleteFileId);
            }

            if (toDeleteDoctorLetterFileId > 0)
            {
                ((IFileRepository)_fileRepository).Delete(toDeleteDoctorLetterFileId);
            }

            if (medicalVendor.IsHospitalPartner)
            {
                var hospitalPartner = Mapper.Map <HospitalPartnerEditModel, HospitalPartner>(model.HospitalPartnerEditModel);
                hospitalPartner.Id = medicalVendor.Id;
                var domain = _hospitalPartnerPackagFactory.CreateDomain(model.HospitalPartnerEditModel.DefaultPackages, hospitalPartner.Id);
                _hospitalPartnerRepository.Save(hospitalPartner);
                _hospitalPartnerPackageRepository.Save(domain, hospitalPartner.Id);
            }
            else
            {
                _hospitalPartnerRepository.Delete(medicalVendor.Id);
            }

            return(organizationId);
        }
Beispiel #8
0
    private MedicalVendorEditModel SetMedicalVendorData(MedicalVendorEditModel medicalVendorEditModel)
    {
        if (medicalVendorEditModel == null)
        {
            medicalVendorEditModel = new MedicalVendorEditModel();
        }

        medicalVendorEditModel.OrganizationEditModel.Name        = txtVendorName.Text;
        medicalVendorEditModel.OrganizationEditModel.Description = DescriptionTextbox.Text;
        medicalVendorEditModel.ContractId = Convert.ToInt64(ddlContracts.SelectedItem.Value);
        //medicalVendorEditModel.EvaluationMode = EvaluationMode.Customer; // This is default for the time being
        //medicalVendorEditModel.CustomerPayRate = Convert.ToDecimal(txtPayRateCustomer.Text);
        medicalVendorEditModel.MedicalVendorType = Convert.ToInt32(ddlVendorType.SelectedValue);
        medicalVendorEditModel.IsHospitalPartner = chkHospitalPartner.Checked;

        #region "Setting Addresses"
        var address = new AddressEditModel();
        address.StreetAddressLine1 = txtAddress1.Text;
        address.StreetAddressLine2 = txtAddress2.Text;
        address.CountryId          = _countryId;

        if (ddlState.SelectedIndex > 0)
        {
            address.StateId = Convert.ToInt32(ddlState.SelectedItem.Value);
        }
        address.City = txtCity.Text;
        if (!string.IsNullOrEmpty(txtZip.Text))
        {
            address.ZipCode = txtZip.Text;
        }


        if (!address.IsEmpty())
        {
            if (medicalVendorEditModel.OrganizationEditModel.BusinessAddress != null)
            {
                address.Id = medicalVendorEditModel.OrganizationEditModel.BusinessAddress.Id;
            }

            medicalVendorEditModel.OrganizationEditModel.BusinessAddress = address;
        }
        else
        {
            medicalVendorEditModel.OrganizationEditModel.BusinessAddress = null;
        }

        if (!chkBiAddress.Checked)
        {
            address = new AddressEditModel();
            address.StreetAddressLine1 = txtBiAddress1.Text;
            address.StreetAddressLine2 = txtBiAddress2.Text;
            address.CountryId          = _countryId;
            if (ddlBiState.SelectedIndex > 0)
            {
                address.StateId = Convert.ToInt32(ddlBiState.SelectedItem.Text);
            }
            address.City = txtBiCity.Text;
            if (!string.IsNullOrEmpty(txtBiZip.Text))
            {
                address.ZipCode = txtBiZip.Text;
            }

            if (!address.IsEmpty())
            {
                if (medicalVendorEditModel.OrganizationEditModel.BillingAddress != null)
                {
                    address.Id = medicalVendorEditModel.OrganizationEditModel.BillingAddress.Id;
                }

                medicalVendorEditModel.OrganizationEditModel.BillingAddress = address;
            }
            else
            {
                medicalVendorEditModel.OrganizationEditModel.BillingAddress = null;
            }
        }
        else
        {
            address.Id = 0;
            if (medicalVendorEditModel.OrganizationEditModel.BillingAddress != null)
            {
                address.Id = medicalVendorEditModel.OrganizationEditModel.BillingAddress.Id;
            }
            medicalVendorEditModel.OrganizationEditModel.BillingAddress = address;
        }
        #endregion

        medicalVendorEditModel.OrganizationEditModel.FaxNumber = new PhoneNumber()
        {
            Number = txtBusinessFax.Text
        };
        medicalVendorEditModel.OrganizationEditModel.PhoneNumber = new PhoneNumber()
        {
            Number = txtBusinessPhone.Text
        };

        //medicalVendorEditModel.PaymentInstructions =
        //    SetMedicalVendorPaymentInstructions(medicalVendorEditModel.PaymentInstructions);


        var selectedItems = (from item in PermittedTestCheckboxList.Items.OfType <ListItem>()
                             where item.Selected
                             select(TestType) Convert.ToInt32(item.Value)).ToArray();

        if (selectedItems.Length < 1)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bijscode", "alert('Please select a test.');", true);
            return(null);
        }

        //medicalVendorEditModel.PermittedTests = selectedItems;

        return(medicalVendorEditModel);
    }
Beispiel #9
0
    private bool SaveData()
    {
        var organziationService = IoC.Resolve <IOrganizationService>();
        var userService         = IoC.Resolve <IUserService>();
        var countryRepository   = IoC.Resolve <ICountryRepository>();

        _countryId = countryRepository.GetAll().FirstOrDefault().Id;

        MedicalVendorEditModel medicalVendorEditModel = null;
        User user = null;

        if (MedicalVendorId > 0)
        {
            medicalVendorEditModel = organziationService.GetMedicalVendorCreateModel(MedicalVendorId);
            user = userService.GetDefaultUserforOrganization(MedicalVendorId, OrganizationType.MedicalVendor);
        }

        var userRepository = IoC.Resolve <IUserRepository <User> >();

        if (user == null || (user.Email.ToString() != UCAddress1.Email))
        {
            if (!userRepository.UniqueEmail(UCAddress1.Email))
            {
                divErrorMsg.Visible   = true;
                divErrorMsg.InnerHtml = "Contact email already exists. Please try another email.";
                return(false);
            }
        }

        medicalVendorEditModel = SetMedicalVendorData(medicalVendorEditModel);
        user = SetDefaulUserData(user);

        if (MedicalVendorId == 0 && userRepository.UserNameExists(txtUserName.Text))
        {
            divErrorMsg.Visible   = true;
            divErrorMsg.InnerHtml = "Please specify a unique user name.";
            return(false);
        }

        if (medicalVendorEditModel == null || user == null)
        {
            return(false);
        }

        try
        {
            using (var scope = new TransactionScope())
            {
                var organizationId = organziationService.CreateMedicalVendor(medicalVendorEditModel);
                userService.SaveDefaultUserforOrganization(organizationId, OrganizationType.MedicalVendor, user);
                SaveHospitalPartner(organizationId);
                scope.Complete();
                return(true);
            }
        }
        catch (InvalidAddressException ex)
        {
            divErrorMsg.Visible   = true;
            divErrorMsg.InnerText = "Some database error occured. Exception Message : " + ex.Message;
            return(false);
        }
        catch (Exception ex)
        {
            divErrorMsg.Visible   = true;
            divErrorMsg.InnerText = "Some database error occured. Exception Message : " + ex.Message;
            return(false);
        }
    }