Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mrNumber"></param>
        /// <returns></returns>
        private GenServiceModel RetrieveDataFromGenServices(string mrNumber, string vunetId)
        {
            GenServiceModel gsm = new GenServiceModel();
            RetrieveCoverageAndInsurance coverageinfo = new RetrieveCoverageAndInsurance();
            RetrievePatientInformation   patientinfo  = new RetrievePatientInformation();
            RetrieveCensusInformation    censusinfo   = new RetrieveCensusInformation();
            CoverageInfo         coverages            = coverageinfo.GetCoverageAndInsurance(mrNumber, vunetId).Where(c => c.IsActive == true).FirstOrDefault();
            InsuranceInformation insurances           = coverageinfo.GetInsurances(mrNumber, vunetId).Where(i => i.EffectiveDate <= DateTime.Today && (i.TerminationDate >= DateTime.Today || i.TerminationDate == null)).FirstOrDefault();
            Patient     patient = patientinfo.GetPatient(mrNumber, vunetId);
            CensusModel census  = censusinfo.GetCensusRecords(mrNumber, vunetId).FirstOrDefault();

            gsm.PatientDemographics = patient;
            gsm.Coverages           = coverages;
            gsm.Insurances          = insurances;
            gsm.Census = census;

            return(gsm);
        }
Exemplo n.º 2
0
        public ActionResult RequestView(RequestModel model, FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                string          vunetId         = User.Identity.Name;
                string          genResponse     = string.Empty;
                GenServiceModel genServiceModel = new GenServiceModel();
                if (model.RequestType == "VHAN")
                {
                    genServiceModel.PatientDemographics = new Patient();
                    genServiceModel.Census = new CensusModel();
                    //genServiceModel.Coverages = new CoverageInfo();
                    genServiceModel.Insurances = new InsuranceInformation();
                }
                else
                {
                    try
                    {
                        genServiceModel = RetrieveDataFromGenServices(model.MrNumber, vunetId);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    if (string.IsNullOrEmpty(genServiceModel.PatientDemographics.MRN))
                    {
                        model.IsPostSuccess = "failure";
                        return(View(model));
                    }
                }

                genServiceModel.PatientDemographics.Weight     = model.PatientWeight.ToString();
                genServiceModel.PatientDemographics.WeightUnit = model.WeightUnit.ToString();
                int    callerId = GetCallerId(model.CallerName);
                string destinationNameToSave = string.IsNullOrEmpty(model.DestinationName) ? string.Empty : model.DestinationName.Split(',').FirstOrDefault();
                if (model.RequestType != "Discharge")
                {
                    model.DestinationType = "Hospital/NursingHome";
                }
                int destinationId = DestinationEntry(model.DestinationType, destinationNameToSave, model.DestinationInstructions, model.AddressLineOne, model.City, model.State, model.Zip, model.Phone, model.TravelTime, model.Miles);
                int pickupId      = 0;
                if (!string.IsNullOrEmpty(model.PickupName) || !string.IsNullOrEmpty(model.PickupAddressLine1))
                {
                    string pickupNameToSave = model.PickupName.Split(',').FirstOrDefault();
                    pickupId = PickupEntry(pickupNameToSave, model.PickupInstructions, model.PickupAddressLine1, model.PickupCity, model.PickupState, model.PickupZip, model.Phone);
                }
                if (model.RequestType == "VHAN")
                {
                    string[] patientName  = model.PatientName.Replace(" ", "").Split(',');
                    var      patientFname = patientName[0].Trim();
                    var      patientLname = patientName[1].Trim();

                    genServiceModel.PatientDemographics.FirstName = patientFname;
                    genServiceModel.PatientDemographics.LastName  = patientLname;
                    genServiceModel.Insurances.InsuranceId        = Convert.ToInt64(model.PatientInsuranceId);
                    genServiceModel.Insurances.Payorname          = model.PatientInsuranceProvider;
                }
                int patientId   = PatientEntry(genServiceModel.PatientDemographics);
                int censusId    = CensusEntry(genServiceModel.Census, model.MrNumber);
                int coverageId  = CoverageEntry(genServiceModel.Coverages, model.MrNumber);
                int insuranceId = InsuranceEntry(genServiceModel.Insurances, model.MrNumber);
                DischargeNeedsEntry(model.SpecialNeeds, patientId);

                string caseNumber = string.Empty;
                if (genServiceModel.Census != null)
                {
                    caseNumber = genServiceModel.Census.CaseNumber;
                }

                int dischargeRequestId = DischargeRequestEntry(callerId, destinationId, model.DischargeTime, insuranceId, censusId, model.SelectedEmsAgency, model.MrNumber, caseNumber, patientId, model.SpecialInstructions, model.LifeSupport, pickupId, model.RequestType, model.RequesStatus, model.Notes, model.AppointmentTime);
                if (dischargeRequestId != 0)
                {
                    model = new RequestModel
                    {
                        IsPostSuccess = "Success"
                    };
                    if (callerId == 0)
                    {
                        model.IsPostSuccess += " new caller";
                    }
                }
            }
            return(View(model));
        }