Exemple #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (PhoneName.Length != 0)
            {
                hash ^= PhoneName.GetHashCode();
            }
            if (PhoneSystem.Length != 0)
            {
                hash ^= PhoneSystem.GetHashCode();
            }
            if (PhoneModel.Length != 0)
            {
                hash ^= PhoneModel.GetHashCode();
            }
            if (PhoneProducter.Length != 0)
            {
                hash ^= PhoneProducter.GetHashCode();
            }
            if (AppVersion.Length != 0)
            {
                hash ^= AppVersion.GetHashCode();
            }
            if (PhoneMac.Length != 0)
            {
                hash ^= PhoneMac.GetHashCode();
            }
            if (PhoneImei.Length != 0)
            {
                hash ^= PhoneImei.GetHashCode();
            }
            if (PhoneIp.Length != 0)
            {
                hash ^= PhoneIp.GetHashCode();
            }
            if (UserId.Length != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (PlaceCode.Length != 0)
            {
                hash ^= PlaceCode.GetHashCode();
            }
            if (AppCode.Length != 0)
            {
                hash ^= AppCode.GetHashCode();
            }
            if (UserType.Length != 0)
            {
                hash ^= UserType.GetHashCode();
            }
            if (Timestamps != 0L)
            {
                hash ^= Timestamps.GetHashCode();
            }
            return(hash);
        }
Exemple #2
0
        public void StateCodeToRandomPlace_Test(string state)
        {
            PlaceCode randomPlace             = mortalityData.StateCodeToRandomPlace(state);
            IEnumerable <PlaceCode> allPlaces = mortalityData.PlaceCodes.Where(t => t.State.Equals(state));

            // This assertion is actually backwards from how it is intended to be used, however
            // it works for our use case.
            Assert.Contains(randomPlace, allPlaces);
        }
Exemple #3
0
        public ucSelectFrom()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            mSelectedItem = new PlaceCode(0, 0);
            _txt.TextChanged += new EventHandler(TextBoxTextChanged);
            _txt.ReadOnly = true;
        }
Exemple #4
0
        protected override void Execute(NativeActivityContext context)
        {
            var placeCode = PlaceCode.Get(context);

            _fontSize = FontSize.Get(context);
            try
            {
                if (string.IsNullOrEmpty(placeCode))
                {
                    throw new NullReferenceException("Не указан код места");
                }
                using (var mgr = IoC.Instance.Resolve <IBaseManager <Place2Blocking> >())
                {
                    var blocking = mgr.GetFiltered(string.Format("{0}='{1}'",
                                                                 SourceNameHelper.Instance.GetPropertySourceName(typeof(Place2Blocking), Place2Blocking.Place2BlockingPlaceCodePropertyName),
                                                                 placeCode)).ToArray();
                    if (blocking.Length > 0)
                    {
                        Place2Blocking[] actualBlocks;
                        switch (Operation)
                        {
                        case PlaceOperationEnum.IN:
                            actualBlocks =
                                blocking.Where(
                                    i => Equals(i.Place2BlockingBlockingCode, PlaceBlockingEnum.PLACE_BAN.ToString()) || Equals(i.Place2BlockingBlockingCode, PlaceBlockingEnum.PLACE_BAN_IN.ToString()))
                                .ToArray();
                            break;

                        case PlaceOperationEnum.OUT:
                            actualBlocks =
                                blocking.Where(
                                    i => Equals(i.Place2BlockingBlockingCode, PlaceBlockingEnum.PLACE_BAN.ToString()))
                                .ToArray();
                            break;

                        default:
                            actualBlocks = blocking;
                            break;
                        }
                        if (actualBlocks.Length == 0)
                        {
                            Result.Set(context, false);
                        }
                        else
                        {
                            Result.Set(context, true);
                            if (ShowDialog)
                            {
                                var placeName = actualBlocks[0].GetProperty(Place2Blocking.VPLACENAMEPropertyName);
                                var message   = new StringBuilder();
                                message.AppendFormat("Место '{0}' заблокировано!", placeName);
                                foreach (var b in actualBlocks)
                                {
                                    message.AppendFormat("{0}{1}: {2}", System.Environment.NewLine, b.GetProperty(Place2Blocking.VBLOCKINGNAMEPropertyName), b.Place2BlockingDesc);
                                }
                                ShowWarningMessage("Предупреждение", message.ToString());
                            }
                        }
                    }
                    else
                    {
                        Result.Set(context, false);
                    }
                }
            }
            catch (Exception ex)
            {
                if (ShowDialog)
                {
                    ShowErrorMessage(ex);
                }
                Result.Set(context, false);
            }
        }
        protected override void Execute(NativeActivityContext context)
        {
            // получим все параметры
            var teCode = TeCode.Get(context);

            // переведем код ТЕ в верхний регистр
            if (!string.IsNullOrEmpty(teCode))
            {
                teCode = teCode.ToUpper();
            }
            var placeCode  = PlaceCode.Get(context);
            var isPack     = IsPack.Get(context);
            var length     = Length.Get(context);
            var width      = Width.Get(context);
            var height     = Height.Get(context);
            var tareWeight = TareWeight.Get(context);
            var weight     = Weight.Get(context);
            var mandants   = Mandants.Get(context);
            var teTypeCode = TeTypeCode.Get(context);
            var autoTeType = AutoTeType.Get(context);
            var extFilter  = Filter.Get(context);

            _fontSize = FontSize.Get(context);
            var suspendNotifyCollectionChanged = SuspendNotifyCollectionChanged.Get(context);

            var teManager = IoC.Instance.Resolve <IBaseManager <TE> >();

            try
            {
                if (suspendNotifyCollectionChanged)
                {
                    teManager.SuspendNotifications();
                }

                // если поле тип ТЕ пустое и не стоит признак пытаться определить тип ТЕ автоматически
                if (string.IsNullOrEmpty(teTypeCode) && !autoTeType)
                {
                    throw new OperationException("Не указан тип ТЕ");
                }

                // если поле тип ТЕ заполнено и установлен признак получения автоматически
                if (!string.IsNullOrEmpty(teTypeCode) && autoTeType)
                {
                    throw new OperationException("Неверные настройки получения типа ТЕ");
                }

                var uw = BeginTransactionActivity.GetUnitOfWork(context);
                if (uw != null)
                {
                    throw new OperationException("Действие в транзакции запрещено");
                }

                // проверим существование ТЕ
                if (!string.IsNullOrEmpty(teCode))
                {
                    var bpManager = IoC.Instance.Resolve <IBPProcessManager>();
                    var existTe   = bpManager.CheckInstanceEntity("TE", teCode);
                    if (existTe == 1)
                    {
                        var existTeObj = teManager.Get(teCode);
                        if (existTeObj == null)
                        {
                            throw new OperationException("Нет прав на ТЕ с кодом {0}", teCode);
                        }
                        ExceptionResult.Set(context, null);
                        TeCode.Set(context, teCode);
                        OutTe.Set(context, existTeObj);
                        Exist.Set(context, true);
                        Result.Set(context, true);
                        return;
                    }
                }

                // фильтр на тип ТЕ
                var filter = string.Empty;
                // фильтр по мандантам
                if (!string.IsNullOrEmpty(mandants))
                {
                    filter = string.Format(
                        "tetypecode in (select tt2m.tetypecode_r from wmstetype2mandant tt2m where tt2m.partnerid_r in ({0}))",
                        mandants);
                }

                // фильтр по упаковкам
                if (isPack)
                {
                    filter =
                        string.Format(
                            "{0}tetypecode in (select CUSTOMPARAMVAL.cpvkey from wmscustomparamvalue CUSTOMPARAMVAL  where CUSTOMPARAMVAL.CPV2ENTITY = 'TETYPE' and CUSTOMPARAMVAL.CUSTOMPARAMCODE_R = 'TETypeIsPackingL2' and CUSTOMPARAMVAL.CPVVALUE is not null and CUSTOMPARAMVAL.CPVVALUE != '0')",
                            string.IsNullOrEmpty(filter) ? string.Empty : filter + " and ");
                }

                // дополнительный фильтр по типам ТЕ
                if (!string.IsNullOrEmpty(extFilter))
                {
                    filter =
                        string.Format(
                            "{0}{1}",
                            string.IsNullOrEmpty(filter) ? string.Empty : filter + " and ", extFilter);
                }

                // если надо определить тип ТЕ автоматически
                if (autoTeType)
                {
                    teTypeCode = BPH.DetermineTeTypeCodeByTeCode(teCode, filter);
                }

                var teTypeObj = GetTeType(teTypeCode, filter);

                // если не выбрали тип ТЕ
                if (teTypeObj == null)
                {
                    ExceptionResult.Set(context, null);
                    TeCode.Set(context, teCode);
                    OutTe.Set(context, null);
                    Exist.Set(context, false);
                    Result.Set(context, false);
                    return;
                }

                var teObj = new TE();
                teObj.SetKey(teCode);
                teObj.SetProperty(TE.TETypeCodePropertyName, teTypeObj.GetKey());
                teObj.SetProperty(TE.CreatePlacePropertyName, placeCode);
                teObj.SetProperty(TE.CurrentPlacePropertyName, placeCode);
                teObj.SetProperty(TE.StatusCodePropertyName, TEStates.TE_FREE.ToString());
                teObj.SetProperty(TE.TEPackStatusPropertyName,
                                  isPack ? TEPackStatus.TE_PKG_CREATED.ToString() : TEPackStatus.TE_PKG_NONE.ToString());

                teObj.SetProperty(TE.TELengthPropertyName, length ?? teTypeObj.GetProperty(TEType.LengthPropertyName));
                teObj.SetProperty(TE.TEWidthPropertyName, width ?? teTypeObj.GetProperty(TEType.WidthPropertyName));
                teObj.SetProperty(TE.TEHeightPropertyName, height ?? teTypeObj.GetProperty(TEType.HeightPropertyName));
                teObj.SetProperty(TE.TETareWeightPropertyName,
                                  tareWeight ?? teTypeObj.GetProperty(TEType.TareWeightPropertyName));
                teObj.SetProperty(TE.TEMaxWeightPropertyName,
                                  tareWeight ?? teTypeObj.GetProperty(TEType.MaxWeightPropertyName));
                teObj.SetProperty(TE.TEWeightPropertyName,
                                  weight ?? teTypeObj.GetProperty(TEType.TareWeightPropertyName));

                ((ISecurityAccess)teManager).SuspendRightChecking();
                teManager.Insert(ref teObj);

                ExceptionResult.Set(context, null);
                TeCode.Set(context, teCode);
                OutTe.Set(context, teObj);
                Exist.Set(context, false);
                Result.Set(context, true);
            }
            catch (Exception ex)
            {
                TeCode.Set(context, teCode);
                ExceptionResult.Set(context, ex);
                OutTe.Set(context, null);
                Exist.Set(context, false);
                Result.Set(context, false);
            }
            finally
            {
                if (suspendNotifyCollectionChanged)
                {
                    teManager.ResumeNotifications();
                }
                ((ISecurityAccess)teManager).ResumeRightChecking();
            }
        }
        /// <summary>Return a new record populated with fake data.</summary>
        public DeathRecord Generate(bool simple = false)
        {
            DeathRecord record = new DeathRecord();

            Random random = new Random();

            Bogus.Faker   faker      = new Bogus.Faker("en");
            MortalityData dataHelper = MortalityData;

            // Grab Gender enum value
            Bogus.DataSets.Name.Gender gender = sex == "Male" ? Bogus.DataSets.Name.Gender.Male : Bogus.DataSets.Name.Gender.Female;

            // Was married?
            bool wasMarried = faker.Random.Bool();

            record.Identifier = Convert.ToString(faker.Random.Number(999999));
            // record.BundleIdentifier = Convert.ToString(faker.Random.Number(999999));
            DateTime date = faker.Date.Recent();

            record.CertifiedTime        = date.ToString("s");
            record.RegisteredTime       = new DateTimeOffset(date.AddDays(-1).Year, date.AddDays(-1).Month, date.AddDays(-1).Day, 0, 0, 0, TimeSpan.Zero).ToString("s");
            record.StateLocalIdentifier = Convert.ToString(faker.Random.Number(999999));

            // Basic Decedent information

            record.GivenNames = new string[] { faker.Name.FirstName(gender), faker.Name.FirstName(gender) };
            record.FamilyName = faker.Name.LastName(gender);
            record.Suffix     = faker.Name.Suffix();
            if (gender == Bogus.DataSets.Name.Gender.Female && wasMarried)
            {
                record.MaidenName = faker.Name.LastName(gender);
            }

            record.AliasGivenNames = new string[] { faker.Name.FirstName(gender) };
            record.AliasFamilyName = faker.Name.LastName(gender);

            record.FatherFamilyName = record.FamilyName;
            record.FatherGivenNames = new string[] { faker.Name.FirstName(Bogus.DataSets.Name.Gender.Male), faker.Name.FirstName(Bogus.DataSets.Name.Gender.Male) };
            record.FatherSuffix     = faker.Name.Suffix();

            record.MotherGivenNames = new string[] { faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female), faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female) };
            record.MotherMaidenName = faker.Name.LastName(Bogus.DataSets.Name.Gender.Female);
            record.MotherSuffix     = faker.Name.Suffix();

            record.SpouseGivenNames = new string[] { faker.Name.FirstName(), faker.Name.FirstName() };
            record.SpouseFamilyName = record.FamilyName;
            record.SpouseSuffix     = faker.Name.Suffix();

            record.BirthRecordId = Convert.ToString(faker.Random.Number(999999));

            record.Gender = gender.ToString().ToLower();
            record.SSN    = faker.Person.Ssn().Replace("-", string.Empty);
            DateTime       birth    = faker.Date.Past(123, DateTime.Today.AddYears(-18));
            DateTime       death    = faker.Date.Recent();
            DateTimeOffset birthUtc = new DateTimeOffset(birth.Year, birth.Month, birth.Day, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset deathUtc = new DateTimeOffset(death.Year, death.Month, death.Day, 0, 0, 0, TimeSpan.Zero);

            record.DateOfBirth = birthUtc.ToString("yyyy-MM-dd");
            record.DateOfDeath = deathUtc.ToString("yyyy-MM-dd");
            int age = death.Year - birth.Year;

            if (birthUtc > deathUtc.AddYears(-age))
            {
                age--;
            }
            record.AgeAtDeath = new Dictionary <string, string>()
            {
                { "value", age.ToString() }, { "unit", "a" }
            };

            // Birthsex

            record.BirthSex = gender.ToString()[0].ToString();

            // Place of residence

            Dictionary <string, string> residence = new Dictionary <string, string>();
            PlaceCode residencePlace = dataHelper.StateCodeToRandomPlace(state);

            residence.Add("addressLine1", $"{faker.Random.Number(999) + 1} {faker.Address.StreetName()}");
            residence.Add("addressCity", residencePlace.City);
            residence.Add("addressCounty", residencePlace.County);
            residence.Add("addressState", state);
            residence.Add("addressCountry", "United States");
            record.Residence = residence;

            // Residence Within City Limits
            record.ResidenceWithinCityLimitsBoolean = true;

            // Place of birth

            Dictionary <string, string> placeOfBirth = new Dictionary <string, string>();
            PlaceCode placeOfBirthPlace = dataHelper.StateCodeToRandomPlace(state);

            placeOfBirth.Add("addressCity", placeOfBirthPlace.City);
            placeOfBirth.Add("addressCounty", placeOfBirthPlace.County);
            placeOfBirth.Add("addressState", state);
            placeOfBirth.Add("addressCountry", "United States");
            record.PlaceOfBirth = placeOfBirth;

            // Place of death

            PlaceCode placeOfDeathPlace = dataHelper.StateCodeToRandomPlace(state);

            record.DeathLocationName = placeOfDeathPlace.City + " Hospital";

            Dictionary <string, string> deathLocationType = new Dictionary <string, string>();

            deathLocationType.Add("code", "16983000");
            deathLocationType.Add("system", "http://snomed.info/sct");
            deathLocationType.Add("display", "Death in hospital");
            record.DeathLocationType = deathLocationType;

            Dictionary <string, string> placeOfDeath = new Dictionary <string, string>();

            placeOfDeath.Add("addressLine1", $"{faker.Random.Number(999) + 1} {faker.Address.StreetName()}");
            placeOfDeath.Add("addressCity", placeOfDeathPlace.City);
            placeOfDeath.Add("addressCounty", placeOfDeathPlace.County);
            placeOfDeath.Add("addressState", state);
            placeOfDeath.Add("addressCountry", "United States");
            record.DeathLocationAddress = placeOfDeath;

            record.DeathLocationJurisdiction = state;

            // Marital status

            Dictionary <string, string> maritalStatus = new Dictionary <string, string>();

            Tuple <string, string>[] maritalStatusCodes =
            {
                Tuple.Create("M", "Married"),
                Tuple.Create("D", "Divorced"),
                Tuple.Create("W", "Widowed"),
            };
            Tuple <string, string> maritalStatusCode = faker.Random.ArrayElement <Tuple <string, string> >(maritalStatusCodes);

            if (!wasMarried)
            {
                maritalStatusCode = Tuple.Create("S", "Never Married");
            }
            maritalStatus.Add("code", maritalStatusCode.Item1);
            maritalStatus.Add("system", "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus");
            maritalStatus.Add("display", maritalStatusCode.Item2);
            record.MaritalStatus = maritalStatus;

            // Ethnicity
            if (faker.Random.Bool() && !simple)
            {
                var ethnicityDetailed = dataHelper.CDCEthnicityCodes.ElementAt(2 + faker.Random.Number(15));
                Tuple <string, string>[] ethnicity =
                {
                    Tuple.Create("Hispanic or Latino",    "2135-2"),
                    Tuple.Create(ethnicityDetailed.Value, ethnicityDetailed.Key)
                };
                record.Ethnicity = ethnicity;
            }
            else
            {
                Tuple <string, string>[] ethnicity = { Tuple.Create("Not Hispanic or Latino", "2186-5") };
                record.Ethnicity = ethnicity;
            }

            // Race

            if (!simple)
            {
                Tuple <string, string>[] ombRaces =
                {
                    Tuple.Create("Black or African American",                 "2054-5"),
                    Tuple.Create("Asian",                                     "2028-9"),
                    Tuple.Create("American Indian or Alaska Native",          "1002-5"),
                    Tuple.Create("Native Hawaiian or Other Pacific Islander", "2076-8")
                };
                Tuple <string, string> ombRace = faker.Random.ArrayElement <Tuple <string, string> >(ombRaces);
                var cdcRaceW = dataHelper.CDCRaceWCodes.ElementAt(1 + faker.Random.Number(10));
                Tuple <string, string>[] race = { Tuple.Create("White", "2106-3"), Tuple.Create(cdcRaceW.Value, cdcRaceW.Key), ombRace };
                record.Race = race;
            }
            else
            {
                record.Race = new Tuple <string, string>[] { Tuple.Create("White", "2106-3") };
            }

            // Education level

            Dictionary <string, string> education = new Dictionary <string, string>();

            Tuple <string, string>[] educationCodes =
            {
                Tuple.Create("BD",   "College or baccalaureate degree complete"),
                Tuple.Create("GD",   "Graduate or professional Degree complete"),
                Tuple.Create("SEC",  "Some secondary or high school education"),
                Tuple.Create("SCOL", "Some College education"),
            };
            Tuple <string, string> educationCode = faker.Random.ArrayElement <Tuple <string, string> >(educationCodes);

            education.Add("code", educationCode.Item1);
            education.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel");
            education.Add("display", educationCode.Item2);
            record.EducationLevel = education;

            Tuple <string, string>[] occupationIndustries =
            {
                Tuple.Create("secretary",  "State agency"),
                Tuple.Create("carpenter",  "construction"),
                Tuple.Create("Programmer", "Health Insurance"),
            };
            Tuple <string, string> occInd = faker.Random.ArrayElement <Tuple <string, string> >(occupationIndustries);

            // Occupation

            record.UsualOccupation = occInd.Item1;
            DateTime usualOccupationEnd = faker.Date.Past(18, deathUtc.DateTime.AddYears(0));

            record.UsualOccupationEnd = usualOccupationEnd.ToString("yyyy-MM-dd");

            // Industry

            record.UsualIndustry = occInd.Item2;

            // Military Service

            Dictionary <string, string> military = new Dictionary <string, string>();

            Tuple <string, string>[] militaryCodes =
            {
                Tuple.Create("Y", "Yes"),
                Tuple.Create("N", "No"),
            };
            Tuple <string, string> militaryCode = faker.Random.ArrayElement <Tuple <string, string> >(militaryCodes);

            military.Add("code", militaryCode.Item1);
            military.Add("system", "http://terminology.hl7.org/CodeSystem/v2-0136");
            military.Add("display", militaryCode.Item2);
            record.MilitaryService = military;

            // Funeral Home Name

            record.FuneralHomeName      = faker.Name.LastName() + " Funeral Home";
            record.FuneralDirectorPhone = faker.Phone.PhoneNumber();

            // Funeral Home Address

            Dictionary <string, string> fha = new Dictionary <string, string>();
            PlaceCode fhaPlace = dataHelper.StateCodeToRandomPlace(state);

            fha.Add("addressLine1", $"{faker.Random.Number(999) + 1} {faker.Address.StreetName()}");
            fha.Add("addressCity", fhaPlace.City);
            fha.Add("addressCounty", fhaPlace.County);
            fha.Add("addressState", state);
            fha.Add("addressCountry", "United States");
            record.FuneralHomeAddress = fha;

            // Disposition Location Name

            record.DispositionLocationName = faker.Name.LastName() + " Cemetery";

            // Disposition Location Address

            Dictionary <string, string> dispLoc = new Dictionary <string, string>();
            PlaceCode dispLocPlace = dataHelper.StateCodeToRandomPlace(state);

            dispLoc.Add("addressCity", dispLocPlace.City);
            dispLoc.Add("addressCounty", dispLocPlace.County);
            dispLoc.Add("addressState", state);
            dispLoc.Add("addressCountry", "United States");
            record.DispositionLocationAddress = dispLoc;

            // Disposition Method

            Dictionary <string, string> disposition = new Dictionary <string, string>();

            Tuple <string, string>[] dispositionTypeCodes =
            {
                Tuple.Create("449971000124106", "Patient status determination, deceased and buried"),
                Tuple.Create("449961000124104", "Patient status determination, deceased and cremated"),
                Tuple.Create("449931000124108", "Patient status determination, deceased and entombed"),
            };
            Tuple <string, string> dispositionTypeCode = faker.Random.ArrayElement <Tuple <string, string> >(dispositionTypeCodes);

            disposition.Add("code", dispositionTypeCode.Item1);
            disposition.Add("system", "http://snomed.info/sct");
            disposition.Add("display", dispositionTypeCode.Item2);
            record.DecedentDispositionMethod = disposition;

            // Mortician

            record.MorticianFamilyName = faker.Name.LastName();
            record.MorticianGivenNames = new string[] { faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female), faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female) };
            record.MorticianSuffix     = faker.Name.Suffix();

            Dictionary <string, string> morticianIdentifier = new Dictionary <string, string>();

            morticianIdentifier.Add("system", "http://hl7.org/fhir/sid/us-npi");
            morticianIdentifier.Add("value", Convert.ToString(faker.Random.Number(999999)));
            record.MorticianIdentifier = morticianIdentifier;

            // Basic Certifier information

            Dictionary <string, string> certifierIdentifier = new Dictionary <string, string>();

            certifierIdentifier.Add("system", "http://hl7.org/fhir/sid/us-npi");
            certifierIdentifier.Add("value", Convert.ToString(faker.Random.Number(999999)));
            record.CertifierIdentifier = certifierIdentifier;

            record.CertifierFamilyName = faker.Name.LastName();
            record.CertifierGivenNames = new string[] { faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female), faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female) };
            record.CertifierSuffix     = "MD";

            Dictionary <string, string> certifierAddress = new Dictionary <string, string>();
            PlaceCode certifierAddressPlace = dataHelper.StateCodeToRandomPlace(state);

            certifierAddress.Add("addressLine1", $"{faker.Random.Number(999) + 1} {faker.Address.StreetName()}");
            certifierAddress.Add("addressCity", certifierAddressPlace.City);
            certifierAddress.Add("addressCounty", certifierAddressPlace.County);
            certifierAddress.Add("addressState", state);
            certifierAddress.Add("addressCountry", "United States");
            record.CertifierAddress = certifierAddress;

            // Certifier type
            Dictionary <string, string> certificationType = new Dictionary <string, string>();

            certificationType.Add("system", "http://snomed.info/sct");
            certificationType.Add("code", "434641000124105");
            certificationType.Add("display", "Death certification and verification by physician");
            record.CertificationRole = certificationType;

            // CertifierLicenseNumber
            record.CertifierLicenseNumber = Convert.ToString(faker.Random.Number(999999));

            // Pronouncer
            Dictionary <string, string> pronouncerIdentifier = new Dictionary <string, string>();

            pronouncerIdentifier.Add("system", "http://hl7.org/fhir/sid/us-npi");
            pronouncerIdentifier.Add("value", Convert.ToString(faker.Random.Number(999999)));
            record.PronouncerIdentifier = pronouncerIdentifier;
            record.PronouncerFamilyName = faker.Name.LastName();
            record.PronouncerGivenNames = new string[] { faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female), faker.Name.FirstName(Bogus.DataSets.Name.Gender.Female) };
            record.PronouncerSuffix     = faker.Name.Suffix();


            // Interested Party
            record.InterestedPartyName = faker.Name.LastName() + " LLC";
            Dictionary <string, string> interestedPartyAddress = new Dictionary <string, string>();
            PlaceCode interestedPartyAddressPlace = dataHelper.StateCodeToRandomPlace(state);

            interestedPartyAddress.Add("addressLine1", $"{faker.Random.Number(999) + 1} {faker.Address.StreetName()}");
            interestedPartyAddress.Add("addressCity", interestedPartyAddressPlace.City);
            interestedPartyAddress.Add("addressCounty", interestedPartyAddressPlace.County);
            interestedPartyAddress.Add("addressState", state);
            interestedPartyAddress.Add("addressCountry", "United States");
            record.InterestedPartyAddress = interestedPartyAddress;

            Dictionary <string, string> ipId = new Dictionary <string, string>();

            ipId.Add("system", "http://hl7.org/fhir/sid/us-npi");
            ipId.Add("value", Convert.ToString(faker.Random.Number(999999)));
            record.InterestedPartyIdentifier = ipId;

            record.InterestedPartyType = new Dictionary <string, string>()
            {
                { "code", "prov" }, { "system", "http://terminology.hl7.org/CodeSystem/organization-type" }, { "display", "Healthcare Provider" }
            };

            if (type == "Natural")
            {
                Dictionary <string, string> mannerOfDeath = new Dictionary <string, string>();
                mannerOfDeath.Add("code", "38605008");
                mannerOfDeath.Add("system", "http://snomed.info/sct");
                mannerOfDeath.Add("display", "Natural death");
                record.MannerOfDeathType = mannerOfDeath;

                record.DateOfDeath = deathUtc.ToString("o");
                record.DateOfDeathPronouncement = deathUtc.AddHours(1).ToString("o");

                // TransportationEvent

                record.TransportationEventBoolean = false;
                Dictionary <string, string> transportationEvent = new Dictionary <string, string>();
                transportationEvent.Add("code", "N");
                transportationEvent.Add("system", "http://terminology.hl7.org/CodeSystem/v2-0136");
                transportationEvent.Add("display", "No");
                record.TransportationEvent = transportationEvent;

                // Randomly pick one of four possible natural causes
                int choice = faker.Random.Number(3);
                if (choice == 0)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Pulmonary embolism",                                 "30 minutes",    new Dictionary <string, string>()),
                        Tuple.Create("Deep venuous thrombosis in left thigh",              "3 days",        new Dictionary <string, string>()),
                        Tuple.Create("Acute hepatic failure",                              "3 days",        new Dictionary <string, string>()),
                        Tuple.Create("Moderately differentiated hepatocellular carcinoma", "over 3 months", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };;
                    record.ExaminerContactedBoolean = false;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "373067005" }, { "system", "http://snomed.info/sct" }, { "display", "No" }
                    };
                }
                else if (choice == 1)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Acute myocardial infarction",    "2 days",   new Dictionary <string, string>()),
                        Tuple.Create("Arteriosclerotic heart disease", "10 years", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.ContributingConditions = "Carcinoma of cecum, Congestive heart failure";

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };;
                    record.ExaminerContactedBoolean = false;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "373067005" }, { "system", "http://snomed.info/sct" }, { "display", "No" }
                    };
                }
                else if (choice == 2)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Pulmonary embolism",             "1 hour",  new Dictionary <string, string>()),
                        Tuple.Create("Acute myocardial infarction",    "7 days",  new Dictionary <string, string>()),
                        Tuple.Create("Chronic ischemic heart disease", "8 years", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.ContributingConditions = "Non-insulin-dependent diabetes mellitus, Obesity, Hypertension, Congestive heart failure";

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };;
                    record.ExaminerContactedBoolean = false;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "373066001" }, { "system", "http://snomed.info/sct" }, { "display", "Yes" }
                    };
                }
                else if (choice == 3)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Rupture of left ventricle", "Minutes", new Dictionary <string, string>()),
                        Tuple.Create("Myocardial infarction",     "2 Days",  new Dictionary <string, string>()),
                        Tuple.Create("Coronary atherosclerosis",  "2 Years", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.ContributingConditions = "Non-insulin-dependent diabetes mellitus, Cigarette smoking, Hypertension, Hypercholesterolemia, Coronary bypass surgery";

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "Y" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "Yes" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "Y" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "Yes" }
                    };;
                    record.ExaminerContactedBoolean = true;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "373066001" }, { "system", "http://snomed.info/sct" }, { "display", "Yes" }
                    };
                }
            }
            if (type == "Injury")
            {
                // Randomly pick one of three possible injury causes
                int choice = faker.Random.Number(2);
                if (choice == 0)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Carbon monoxide poisoning",              "Unkown", new Dictionary <string, string>()),
                        Tuple.Create("Inhalation of automobile exhaust fumes", "Unkown", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.ContributingConditions = "Terminal gastric adenocarcinoma, depression";

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "Y" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "Yes" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "Y" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "Yes" }
                    };;
                    record.ExaminerContactedBoolean = true;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "UNK" }, { "system", "http://hl7.org/fhir/v3/NullFlavor" }, { "display", "unknown" }
                    };

                    Dictionary <string, string> mannerOfDeath = new Dictionary <string, string>();
                    mannerOfDeath.Add("code", "44301001");
                    mannerOfDeath.Add("system", "http://snomed.info/sct");
                    mannerOfDeath.Add("display", "Suicide");
                    record.MannerOfDeathType = mannerOfDeath;

                    Dictionary <string, string> detailsOfInjury = new Dictionary <string, string>();
                    record.InjuryLocationName        = "Own home garage";
                    record.InjuryDate                = new DateTimeOffset(deathUtc.Year, deathUtc.Month, deathUtc.Day, 0, 0, 0, TimeSpan.Zero).ToString("s");
                    record.InjuryLocationDescription = "Inhaled carbon monoxide from auto exhaust through hose in an enclosed garage";

                    Dictionary <string, string> detailsOfInjuryAddr = new Dictionary <string, string>();
                    detailsOfInjuryAddr.Add("addressLine1", residence["addressLine1"]);
                    detailsOfInjuryAddr.Add("addressCity", residencePlace.City);
                    detailsOfInjuryAddr.Add("addressCounty", residencePlace.County);
                    detailsOfInjuryAddr.Add("addressState", state);
                    detailsOfInjuryAddr.Add("addressCountry", "United States");
                    record.InjuryLocationAddress = detailsOfInjuryAddr;

                    Dictionary <string, string> injuryPlace = new Dictionary <string, string>();
                    injuryPlace.Add("code", "0");
                    injuryPlace.Add("system", "urn:oid:2.16.840.1.114222.4.11.7374");
                    injuryPlace.Add("display", "Home");
                    record.InjuryPlace = injuryPlace;


                    // TransportationEvent

                    record.TransportationEventBoolean = false;
                    Dictionary <string, string> transportationEvent = new Dictionary <string, string>();
                    transportationEvent.Add("code", "N");
                    transportationEvent.Add("system", "http://terminology.hl7.org/CodeSystem/v2-0136");
                    transportationEvent.Add("display", "No");
                    record.TransportationEvent = transportationEvent;

                    record.DateOfDeath = new DateTimeOffset(deathUtc.Year, deathUtc.Month, deathUtc.Day, 0, 0, 0, TimeSpan.Zero).ToString("s");
                }
                else if (choice == 1)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Cardiac tamponade",       "15 minutes", new Dictionary <string, string>()),
                        Tuple.Create("Perforation of heart",    "20 minutes", new Dictionary <string, string>()),
                        Tuple.Create("Gunshot wound to thorax", "20 minutes", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "Y" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "Yes" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "Y" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "Yes" }
                    };
                    record.ExaminerContactedBoolean = true;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "373067005" }, { "system", "http://snomed.info/sct" }, { "display", "No" }
                    };

                    Dictionary <string, string> mannerOfDeath = new Dictionary <string, string>();
                    mannerOfDeath.Add("code", "27935005");
                    mannerOfDeath.Add("system", "http://snomed.info/sct");
                    mannerOfDeath.Add("display", "Homicide");
                    record.MannerOfDeathType = mannerOfDeath;

                    Dictionary <string, string> detailsOfInjury = new Dictionary <string, string>();
                    record.InjuryLocationName        = "restaurant";
                    record.InjuryDate                = deathUtc.AddMinutes(-20).ToString("s");
                    record.InjuryLocationDescription = "Shot by another person using a handgun";

                    Dictionary <string, string> detailsOfInjuryAddr = new Dictionary <string, string>();
                    PlaceCode detailsOfInjuryPlace = dataHelper.StateCodeToRandomPlace(state);
                    detailsOfInjuryAddr.Add("addressLine1", residence["addressLine1"]);
                    detailsOfInjuryAddr.Add("addressCity", detailsOfInjuryPlace.City);
                    detailsOfInjuryAddr.Add("addressCounty", detailsOfInjuryPlace.County);
                    detailsOfInjuryAddr.Add("addressState", state);
                    detailsOfInjuryAddr.Add("addressCountry", "United States");
                    record.InjuryLocationAddress = detailsOfInjuryAddr;

                    Dictionary <string, string> injuryPlace = new Dictionary <string, string>();
                    injuryPlace.Add("code", "5");
                    injuryPlace.Add("system", "urn:oid:2.16.840.1.114222.4.11.7374");
                    injuryPlace.Add("display", "Trade and Service Area");
                    record.InjuryPlace = injuryPlace;


                    // TransportationEvent

                    record.TransportationEventBoolean = false;
                    Dictionary <string, string> transportationEvent = new Dictionary <string, string>();
                    transportationEvent.Add("code", "N");
                    transportationEvent.Add("system", "http://terminology.hl7.org/CodeSystem/v2-0136");
                    transportationEvent.Add("display", "No");
                    record.TransportationEvent = transportationEvent;
                }
                else if (choice == 2)
                {
                    Tuple <string, string, Dictionary <string, string> >[] causes =
                    {
                        Tuple.Create("Cerebral contusion",   "minutes", new Dictionary <string, string>()),
                        Tuple.Create("Fractured skull",      "minutes", new Dictionary <string, string>()),
                        Tuple.Create("Blunt impact to head", "minutes", new Dictionary <string, string>())
                    };
                    record.CausesOfDeath = causes;

                    record.AutopsyPerformedIndicator = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };
                    record.AutopsyResultsAvailable = new Dictionary <string, string>()
                    {
                        { "code", "N" }, { "system", "http://terminology.hl7.org/CodeSystem/v2-0136" }, { "display", "No" }
                    };
                    record.ExaminerContactedBoolean = true;

                    record.TobaccoUse = new Dictionary <string, string>()
                    {
                        { "code", "373067005" }, { "system", "http://snomed.info/sct" }, { "display", "No" }
                    };

                    Dictionary <string, string> mannerOfDeath = new Dictionary <string, string>();
                    mannerOfDeath.Add("code", "7878000");
                    mannerOfDeath.Add("system", "http://snomed.info/sct");
                    mannerOfDeath.Add("display", "Accidental death");
                    record.MannerOfDeathType = mannerOfDeath;

                    Dictionary <string, string> detailsOfInjury = new Dictionary <string, string>();
                    record.InjuryLocationName        = "Highway";
                    record.InjuryDate                = deathUtc.ToString("s");
                    record.InjuryLocationDescription = "Automobile accident. Car slid off wet road and struck tree.";

                    Dictionary <string, string> detailsOfInjuryAddr = new Dictionary <string, string>();
                    PlaceCode detailsOfInjuryPlace = dataHelper.StateCodeToRandomPlace(state);
                    detailsOfInjuryAddr.Add("addressLine1", residence["addressLine1"]);
                    detailsOfInjuryAddr.Add("addressCity", detailsOfInjuryPlace.City);
                    detailsOfInjuryAddr.Add("addressCounty", detailsOfInjuryPlace.County);
                    detailsOfInjuryAddr.Add("addressState", state);
                    detailsOfInjuryAddr.Add("addressCountry", "United States");
                    record.InjuryLocationAddress = detailsOfInjuryAddr;

                    Dictionary <string, string> injuryPlace = new Dictionary <string, string>();
                    injuryPlace.Add("code", "4");
                    injuryPlace.Add("system", "urn:oid:2.16.840.1.114222.4.11.7374");
                    injuryPlace.Add("display", "Street/Highway");
                    record.InjuryPlace = injuryPlace;


                    // TransportationEvent

                    record.TransportationEventBoolean = true;
                    Dictionary <string, string> transportationEvent = new Dictionary <string, string>();
                    transportationEvent.Add("code", "Y");
                    transportationEvent.Add("system", "http://terminology.hl7.org/CodeSystem/v2-0136");
                    transportationEvent.Add("display", "Yes");
                    record.TransportationEvent = transportationEvent;
                }
            }

            if (gender == Bogus.DataSets.Name.Gender.Female)
            {
                Dictionary <string, string> pregnanacyStatus = new Dictionary <string, string>();
                pregnanacyStatus.Add("code", "PHC1260");
                pregnanacyStatus.Add("system", "urn:oid:2.16.840.1.114222.4.5.274");
                pregnanacyStatus.Add("display", "Not pregnant within the past year");
                record.PregnancyStatus = pregnanacyStatus;
            }
            else
            {
                Dictionary <string, string> pregnanacyStatus = new Dictionary <string, string>();
                pregnanacyStatus.Add("code", "NA");
                pregnanacyStatus.Add("system", "http://hl7.org/fhir/v3/NullFlavor");
                pregnanacyStatus.Add("display", "not applicable");
                record.PregnancyStatus = pregnanacyStatus;
            }

            return(record);
        }
Exemple #7
0
    private void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
      if (txt.ReadOnly)
        return;

      //e.Handled = false;
      int selectionStart;
      int selectionLength;
      if (txt.Text.Length > 0 && ((int)e.KeyChar) > 0x1F)
      {
        string newTxt;
        if (txt.SelectionStart > 0 && txt.SelectionStart < txt.Text.Length)
          newTxt = txt.Text.Substring(0, txt.SelectionStart) + e.KeyChar.ToString();
        else
          newTxt = txt.Text + e.KeyChar.ToString();
        int fq = 0;
        TreeNode tn = CASTools.SearchByTextInTreeNodeCollection(tv.Nodes, newTxt, ref fq, false);
        if (tn != null)
        {
          mPC = ((CASTreeItemData)tn.Tag).pPC;
          selectionStart = newTxt.Length;
          selectionLength = tn.Text.Length - newTxt.Length;
          txt.Text = tn.Text;
          txt.SelectionStart = selectionStart;
          txt.SelectionLength = selectionLength;
          e.Handled = true;
          tTip.SetToolTip(txt, tn.FullPath);
          pItemTreeNodeTag = tn.Tag;
        }
        else
        {
          mPC.code = 0;
          tTip.RemoveAll();
          if (!mIsTVVisable && pDownSelectIfNotFound)
          {
            txt.Focus();
          }
          pItemTreeNodeTag = null;
        }
      }
    }
Exemple #8
0
    /// <summary>
    /// Выбираем из дерева
    /// </summary>
    protected virtual void onSelectedItem(object sender, System.EventArgs e)
    {
      try
      {
        //if (tv.SelectedNode != null)
        //{
        /*--made of dsy 30.01.2006--*/
        //  Исправлена очередность присвоений. Сначала должен переприсваиваться тэг!
        //  В начальном варианте это присвоение шло после присвоения названия txt.Text, что в свою
        //  очередь приводило к использованию старого значения тэга при получении PlaceCode текущего элемента
        pItemTreeNodeTag = tv.SelectedNode.Tag;
        mPC = ((CASTreeItemData)tv.SelectedNode.Tag).pPC;
        txt.Text = tv.SelectedNode.Text;
        txt.SelectionStart = 0;
        txt.SelectionLength = 0;
        tTip.SetToolTip(txt, tv.SelectedNode.FullPath);
        if (OnSelectedTreeItem != null)
          OnSelectedTreeItem(this, new EvA_SelectedTreeItem(mPC, txt.Text, pItemTreeNodeTag));
        //}
      }
#if DEBUG
      catch (Exception ex)
      {
        MessageBox.Show("CASSelectFromTV : " + ex.Message);
#else
      catch
      {
#endif
        tTip.RemoveAll();
      }
      finally
      {
        TV(false);
      }
    }
Exemple #9
0
 public void SetItem(PlaceCode aPC)
 {
   mPC = aPC;
   pItemTreeNodeTag = null;
   if (mPC.code > 0)
   {
     tv.Load(mPC, false);
     if (tv.SelectedNode != null)
     {
       txt.Text = tv.SelectedNode.Text;
       if (tv.SelectedNode != null)
         pItemTreeNodeTag = tv.SelectedNode.Tag;
       else
         pItemTreeNodeTag = null;
     }
   }
   else
   {
     tv.Load();
     txt.Text = string.Empty;
   }
 }
Exemple #10
0
 public void SetItem(PlaceCode aPC, string aText)
 {
   mPC = aPC;
   txt.Text = aText;
 }
Exemple #11
0
    public CASSelectFromTV(bool aIsDataGridTextBox)
    {
      mPC = PlaceCode.Empty;
      mTreeViewHeight = 100;
      pIsMayBeWithoutRefbook = false;
      pDownSelectIfNotFound = true;
      pIsExpandLevelWhenLoad = false;
      mIsTVVisable = false;
      pItemTreeNodeTag = null;
      pIsCodeOnly = true;

      SuspendLayout();

      if (aIsDataGridTextBox)
        txt = new DataGridTextBox();
      else
        txt = new TextBox();
      txt.Name = "txt";
      txt.Size = new System.Drawing.Size(160, 22);
      txt.TabIndex = 0;
      txt.Text = "";
      //txt.AutoSize=true;
      txt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnKeyDown);
      txt.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnKeyPress);
      txt.TextChanged += new EventHandler(OnTextChanged);
//-----------
      this.Controls.Add(txt);

      tv = new CASTreeViewBase();
      tv.Font = this.Font;
      tv.ContextMenu = new ContextMenu();
      tv.ContextMenu.MenuItems.Add(new MenuItem("Выбрать", new EventHandler(onSelectedItem), Shortcut.CtrlS));
      tv.Visible = mIsTVVisable;
      tv.onDoCommand += new EvH_CasTVCommand(OnTreeItemDoCommand);

      this.ResumeLayout(false);
      this.Layout += new LayoutEventHandler(OnControlLayout);

      // This call is required by the Windows.Forms Form Designer.
      InitializeComponent();

      //OnResize(EventArgs.Empty);
      //			this.ParentChanged += new EventHandler(CASSelectFromTV_ParentChanged);
    }
Exemple #12
0
        private void ProcessCreateProduct(NativeActivityContext context)
        {
            #region  .  Checks&Ini  .

            if (_items == null || _items.Count == 0)
            {
                return;
            }

            var iwbId         = IWBId.Get(context);
            var placeCode     = PlaceCode.Get(context);
            var operationCode = OperationCode.Get(context);
            var isMigration   = IsMigration.Get(context) ? 1 : 0;
            var timeOut       = TimeOut.Get(context);
            var wfUow         = BeginTransactionActivity.GetUnitOfWork(context);

            // получаем менеджер приемки
            Min min = null;
            using (var mgr = IoC.Instance.Resolve <IBPProcessManager>())
            {
                if (wfUow != null)
                {
                    mgr.SetUnitOfWork(wfUow);
                }

                var minId = mgr.GetDefaultMIN(iwbId);
                if (minId.HasValue)
                {
                    using (var mgrIn = IoC.Instance.Resolve <IBaseManager <Min> >())
                    {
                        if (wfUow != null)
                        {
                            mgr.SetUnitOfWork(wfUow);
                        }

                        min = mgrIn.Get(minId);
                    }
                }
            }

            // определяем параметры приемки
            var isMinCpvExist     = min != null && min.CustomParamVal != null && min.CustomParamVal.Count != 0;
            var isNeedControlOver = isMinCpvExist &&
                                    min.CustomParamVal.Any(
                i => i.CustomParamCode == MinCpv.MINOverEnableCpvName && i.CPVValue == "1");
            var isNeedConfirmOver = isNeedControlOver &&
                                    min.CustomParamVal.Any(
                i =>
                i.CustomParamCode == MinCpv.MINOverEnableNeedConfirmCpvName &&
                i.CPVValue == "1");
            var isMinLimit     = isMinCpvExist && min.CustomParamVal.Any(i => i.VCustomParamParent == MinCpv.MinLimitL2CpvName);
            var itemsToProcess = new List <IWBPosInput>();

            #endregion

            #region  .  BatchCode&OverCount  .

            foreach (var item in _items)
            {
                var itemKey = item.GetKey();
                if (!item.IsSelected || itemKey == null)
                {
                    _failedItems.Enqueue(item);
                    continue;
                }

                item.ManageFlag = null;

                //Ошибки при распознавании batch-кода
                if (!item.NotCriticalBatchcodeError && !item.IsBpBatchcodeCompleted)
                {
                    var message = string.IsNullOrEmpty(item.BatchcodeErrorMessage)
                        ? "Ошибка не определена."
                        : item.BatchcodeErrorMessage;
                    SkipItem(item, message);
                    continue;
                }

                if (item.RequiredSKUCount < 1)
                {
                    SkipItem(item, "Некорректно введено 'Количество по факту'");
                    continue;
                }

                // если пытаемся принять с избытком
                if (isNeedControlOver)
                {
                    var count     = item.ProductCountSKU + (double)item.RequiredSKUCount;
                    var overCount = count - item.IWBPosCount;
                    if (overCount > 0 && isNeedConfirmOver)
                    {
                        var questionMessage = string.Format(
                            "Позиция '{0}' ед.уч. '{1}'.{4}Фактическое кол-во = '{2}'.{4}Излишек составит '{3}'.{4}Принять излишек?",
                            itemKey, item.SKUNAME, count, overCount, Environment.NewLine);

                        var dr = _viewService.ShowDialog(
                            GetDefaultMessageBoxCaption(iwbId),
                            questionMessage,
                            MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes, 14);

                        if (dr == MessageBoxResult.Yes)
                        {
                            item.ManageFlag += (!string.IsNullOrEmpty(item.ManageFlag) ? "," : string.Empty) +
                                               "OVERASK_OK";
                        }
                        else
                        {
                            var message = string.Format("Пользователь отказался принимать излишек по позиции '{0}'",
                                                        itemKey, item.SKUNAME);
                            SkipItem(item, message);
                            continue;
                        }
                    }
                }

                itemsToProcess.Add(item);
            }

            #endregion

            // группируем по артикулу
            var groupItems = itemsToProcess.GroupBy(i => i.ArtCode).ToArray();

            //обработка сроков годности
            if (isMinLimit)
            {
                var ret = ProccesExpireDate(itemsToProcess, min, groupItems, wfUow, iwbId);
                if (!ret)
                {
                    return;
                }
            }

            var ask = new ConcurrentQueue <IWBPosInput>();

            while (true)
            {
                RunCreateProduct(itemsToProcess, ref ask, timeOut, wfUow, operationCode, iwbId, isMigration, placeCode,
                                 isNeedControlOver);
                if (ask == null || ask.Count <= 0)
                {
                    break;
                }

                itemsToProcess.Clear();
                foreach (var item in ask)
                {
                    var message = string.Format("Принять излишек по позиции '{0}' ед.уч. '{1}' ?", item.GetKey(),
                                                item.SKUNAME);
                    var res = _viewService.ShowDialog(GetDefaultMessageBoxCaption(iwbId), message,
                                                      MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes, 14);

                    if (res != MessageBoxResult.Yes)
                    {
                        SkipItem(item,
                                 string.Format("Пользователь отказался принимать излишек по позиции '{0}'", item.GetKey()));
                        continue;
                    }
                    itemsToProcess.Add(item);
                }

                while (!ask.IsEmpty)
                {
                    IWBPosInput someItem;
                    ask.TryDequeue(out someItem);
                }
            }
        }
Exemple #13
0
		/// <summary>
		/// Выбираем из дерева
		/// </summary>
		private void SelectedItem()
		{
			try
			{
				//if (tv.SelectedNode != null)
				//{
				mPC = ((CASTreeItemData)tv.SelectedNode.Tag).pPC; 
				txt.Text = tv.SelectedNode.Text;
				tTip.SetToolTip(txt,tv.SelectedNode.FullPath);
				if (mLblParents != null)
					mLblParents.Text = GetParentsFrom (tv.SelectedNode);
				if (OnSelectedTreeItem != null)
					OnSelectedTreeItem (this, new EvA_SelectedTreeItem(mPC,txt.Text)); 
				//}
			}
#if DEBUG
			catch (Exception ex) 
			{
				MessageBox.Show("CasSparrow : "+ex.Message); 
#else
      catch
      {
#endif
				tTip.RemoveAll();
			}
			finally
			{
				TV(false);
			}
		}
Exemple #14
0
		public void SetItem(PlaceCode aPC)
		{
			mPC = aPC;
			if(mPC.code > 0 )
			{
				tv.Load (mPC.place, mPC.code, false);
				if (tv.SelectedNode != null)
				{
					txt.Text = tv.SelectedNode.Text; 
					if (mLblParents != null)
						mLblParents.Text = GetParentsFrom (tv.SelectedNode);
				}
			}
		}
Exemple #15
0
		public CASSparrow(bool aIsDataGridTextBox, int aQntParentsView)
		{
			mPC = PlaceCode.Empty;
			mTreeViewHeight = 100;
			pIsMayBeWithoutRefbook = false;
			pDownSelectIfNotFound = true;
			pIsExpandLevelWhenLoad = false;
			mIsTVVisable = false;

			SuspendLayout();

			mQntParentsView = aQntParentsView;
			if (mQntParentsView == 0)
			{
				mLblParents = null;
			}
			else
			{
				mLblParents = new Label();
				mLblParents.Size = new System.Drawing.Size(60, 22);
				mLblParents.TextAlign = ContentAlignment.MiddleRight;
				this.Controls.Add(mLblParents);
			}

			if (aIsDataGridTextBox)
				txt = new DataGridTextBox();
			else
				txt = new TextBox();
			txt.Name = "txt";
			txt.Size = new System.Drawing.Size(160, 22);
			txt.TabIndex = 0;
			txt.Text = "";
			//txt.AutoSize=true;
			txt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnKeyDown);
			txt.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnKeyPress);
			txt.TextChanged += new EventHandler(OnTextChanged);
			this.Controls.Add(txt);

			tv = new CASTreeViewCommon();
			tv.Font=this.Font;
			tv.ClearMenuCommand();              //удаляем всё меню !
			tv.AddMenuCommand(eCommand.Choice); //разрешаем только выбирать !
			tv.Visible = mIsTVVisable;
			
			this.ResumeLayout(false);
			this.Layout +=new LayoutEventHandler(OnControlLayout);

			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			OnResize(EventArgs.Empty);
		}