ToBoolean() public static méthode

public static ToBoolean ( System.DateTime value ) : bool
value System.DateTime
Résultat bool
        public WkHtmlToPdfConverter()
        {
            bool useX11 = false;

            try
            {
                useX11 = SysConvert.ToBoolean(ConfigurationManager.AppSettings["WkHtmlToXSharp.UseX11"]);
            }
            catch (Exception ex)
            {
                _Log.Error("Unable to parse 'WkHtmlToXSharp.UseX11' app. setting.", ex);
            }

            // Try to deploy native libraries bundles.
            WkHtmlToXLibrariesManager.InitializeNativeLibrary();

            var version = NativeCalls.WkHtmlToPdfVersion();

            if (NativeCalls.wkhtmltopdf_init(useX11 ? 1 : 0) == 0)
            {
                throw new InvalidOperationException(string.Format("wkhtmltopdf_init failed! (version: {0}, useX11 = {1})", version, useX11));
            }

            _Log.DebugFormat("Initialized new converter instance (Version: {0}, UseX11 = {1})", version, useX11);
        }
        /// <summary>
        /// Converts a value to a <see cref="bool"/>.
        /// </summary>
        /// <param name="value">The object to convert.</param>
        /// <returns>The converted <paramref name="value"/>.</returns>
        public bool ToBoolean(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(SConvert.ToBoolean(value, CultureInfo.InvariantCulture));
        }
        public HandGunChangeMessage(P2PMessage msg, bool forOtherPlayer = false)
        {
            isForOtherPlayer = forOtherPlayer;
            if (isForOtherPlayer)
            {
                playerId = msg.ReadByte();
            }

            destroy = Convert.ToBoolean(msg.ReadByte());
            type    = (GunType)msg.ReadByte();
        }
 public bool IsValid(string statement)
 {
     try
     {
         object evaluator = Activator.CreateInstance(_evaluatorType);
         return(Convert.ToBoolean(_evaluatorType.InvokeMember("Eval", BindingFlags.InvokeMethod, null, evaluator, new object[] { statement })));
     }
     catch (Exception)
     {
         return(false);
     }
 }
        private static IEnumerable <IDataRow> GetCompletionList(HttpContext context, out IDataSourceView3 ds3, out int countRows)
        {
            var start           = 0;
            var limit           = 10;
            var prefixTextValue = string.Empty;
            var isKz            = false;
            var dataSourceType  = string.Empty;
            var parameters      = string.Empty;
            var refParent       = string.Empty;
            var fullModelData   = false;

            if (!string.IsNullOrEmpty(context.Request[Start]))
            {
                start = Convert.ToInt32(context.Request[Start]);
            }

            if (!string.IsNullOrEmpty(context.Request[Limit]))
            {
                limit = Convert.ToInt32(context.Request[Limit]);
            }

            if (!string.IsNullOrEmpty(context.Request[PrefixText]))
            {
                prefixTextValue = context.Request[PrefixText];
            }

            if (!string.IsNullOrEmpty(context.Request[DataSourceType]))
            {
                dataSourceType = context.Request[DataSourceType];
            }

            if (!string.IsNullOrEmpty(context.Request["isKz"]))
            {
                isKz = Convert.ToBoolean(context.Request["isKz"]);
            }

            if (!string.IsNullOrEmpty(context.Request["parameters"]))
            {
                parameters = context.Request["parameters"];
            }

            if (!string.IsNullOrEmpty(context.Request["node"]))
            {
                refParent = context.Request["node"];
            }

            var sourceObj = Activator.CreateInstance(BuildManager.GetType(dataSourceType, true, true), null);

            ds3 = (IDataSourceView3)sourceObj;
            return(GetData(prefixTextValue, start, limit, isKz, (IDataSourceView2)sourceObj, ds3, parameters, refParent, out countRows));
        }
Exemple #6
0
        private void LoadVariables()
        {
            allowWhenBlocked = Convert.ToBoolean(GetConfig("Global", "Allow spawn when building blocked", false));
            Prefix           = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[My MiniCopter] :")); // Chat prefix
            cooldownmin      = Convert.ToSingle(GetConfig("Cooldown (on permission)", "Value in minutes", "60"));
            useCooldown      = Convert.ToBoolean(GetConfig("Cooldown (on permission)", "Use Cooldown", true));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Exemple #7
0
        public string AddPatientCategorization(int patientId, int patientMasterVisitId, string artRegimenPeriod, string activeOis, string visitsAdherant, string vlCopies, string ipt, string bmi, string age, string healthcareConcerns)
        {
            PatientCategorizationStatus categorizationStatus;

            string[] arr1 = new string[] {};

            if (Convert.ToBoolean(activeOis) && Convert.ToBoolean(artRegimenPeriod) && Convert.ToBoolean(visitsAdherant) && Convert.ToBoolean(vlCopies) && Convert.ToBoolean(ipt) && Convert.ToBoolean(age) && Convert.ToBoolean(healthcareConcerns) && Convert.ToBoolean(bmi))
            {
                categorizationStatus = PatientCategorizationStatus.Stable;
            }
            else
            {
                categorizationStatus = PatientCategorizationStatus.UnStable;
            }

            var patientCategorization = new PatientCategorization()
            {
                PatientId            = patientId,
                Categorization       = categorizationStatus,
                DateAssessed         = DateTime.Now,
                PatientMasterVisitId = patientMasterVisitId
            };

            try
            {
                var categorization = new PatientCategorizationManager();
                Result = categorization.AddPatientCategorization(patientCategorization);
                if (Result > 0)
                {
                    Msg = "Patient Categorization Added Successfully!";

                    var lookUpLogic = new LookupLogic();
                    var status      = lookUpLogic.GetItemIdByGroupAndItemName("StabilityAssessment", categorizationStatus.ToString());
                    var itemId      = 0;
                    if (status.Count > 0)
                    {
                        itemId = status[0].ItemId;
                    }

                    arr1 = new string[] { Msg, itemId.ToString() };
                }
            }
            catch (Exception e)
            {
                Msg = e.Message;
            }

            return(new JavaScriptSerializer().Serialize(arr1));
        }
Exemple #8
0
        public string[] GetCompletionList(string prefixText, int count, string contextKey)
        {
            string[] split = contextKey.Split(',');
            if (split.Length < 4)
            {
                //todo: log
                return(null);
            }

            bool isKz   = string.IsNullOrEmpty(split[0]) ? false : Convert.ToBoolean(split[0]);
            bool isCode = string.IsNullOrEmpty(split[1]) ? false : Convert.ToBoolean(split[1]);
            var  type   = BuildManager.GetType(split[2], false, true);

            if (type == null)
            {
                if (split[2].EndsWith("JournalDataSourceView"))
                {
                    var tableType     = BuildManager.GetType(split[2].Substring(0, split[2].Length - "JournalDataSourceView".Length), false, true);
                    var getListType   = BuildManager.GetType("Nat.Web.Core.Controls.DataAdapters.LegacyAdapter", false, true);
                    var methodGetList = getListType?.GetMethod("GetCompletionList", BindingFlags.Public | BindingFlags.Static);
                    if (tableType != null && methodGetList != null)
                    {
                        var jss  = new JavaScriptSerializer();
                        var data = (IEnumerable <Pair>)methodGetList.Invoke(null, new object[] { tableType, HttpContext.Current, prefixText, count });
                        return(data?.Select(r => jss.Serialize(r)).ToArray());
                    }
                }
                return(null);
            }
            var    sourceObj = Activator.CreateInstance(type, null);
            string value     = split[3];

            //todo: переключение языка потока
            var dataSourse2 = sourceObj as IDataSourceView2;

            if (dataSourse2 != null)
            {
                return(GetData(prefixText, count, isKz, isCode, dataSourse2, sourceObj as IDataSourceView3, value));
            }

            var dataSourse1 = (IDataSourceView)sourceObj;

            return(GetData(prefixText, count, isKz, isCode, dataSourse1, value));
        }
Exemple #9
0
        public static bool GetValueWithDefault(this object value, bool @default)
        {
            var result = @default;

            if (value == null)
            {
                return(result);
            }

            try
            {
                result = Convert.ToBoolean(value);
            }
            catch
            {
                result = @default;
            }

            return(result);
        }
Exemple #10
0
        public override MapFieldAttribute GetMapField(TypeExtension typeExtension, MemberAccessor member, out bool isSet)
        {
            var extList = typeExtension[member.Name]["MapField"];

            if (extList != AttributeExtensionCollection.Null)
            {
                isSet = true;
                var attr = new MapFieldAttribute();

                var extFormat  = extList.FirstOrDefault(x => x.Name == "Format");
                var extMapName = extList.FirstOrDefault(x => x.Name == "MapName");
                var extIsInheritanceDiscriminator = extList.FirstOrDefault(x => x.Name == "IsInheritanceDiscriminator");
                var extOrigName = extList.FirstOrDefault(x => x.Name == "OrigName");
                var extStorage  = extList.FirstOrDefault(x => x.Name == "Storage");

                if (extFormat != null)
                {
                    attr.Format = (string)extFormat.Value;
                }
                if (extMapName != null)
                {
                    attr.MapName = (string)extMapName.Value;
                }
                if (extFormat != null)
                {
                    attr.IsInheritanceDiscriminator = Convert.ToBoolean(extIsInheritanceDiscriminator.Value);
                }
                if (extFormat != null)
                {
                    attr.OrigName = (string)extOrigName.Value;
                }
                if (extFormat != null)
                {
                    attr.Storage = (string)extStorage.Value;
                }
                return(attr);
            }

            return(base.GetMapField(typeExtension, member, out isSet));
        }
Exemple #11
0
        public WkHtmlToPdfConverter()
        {
            bool useX11 = false;

            try
            {
                useX11 = SysConvert.ToBoolean(ConfigurationManager.AppSettings["WkHtmlToXSharp.UseX11"]);
            }
            catch (Exception ex)
            {
                _Log.Error("Unable to parse 'WkHtmlToXSharp.UseX11' app. setting.", ex);
            }

            var ptr     = wkhtmltopdf_version();
            var version = Marshal.PtrToStringAnsi(ptr);

            if (!wkhtmltopdf_init(useX11 ? 1 : 0))
            {
                throw new InvalidOperationException(string.Format("wkhtmltopdf_init failed! (version: {0}, useX11 = {1})", version, useX11));
            }

            _Log.DebugFormat("Initialized new converter instance (Version: {0}, UseX11 = {1})", version, useX11);
        }
Exemple #12
0
		bool IConvertible.ToBoolean (IFormatProvider provider)
		{
			return Convert.ToBoolean (Value, provider);
		}
Exemple #13
0
 public bool ToBoolean(object value)
     => SystemConvert.ToBoolean(value);
 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 {
     return(values.Aggregate(true, (current, t) => current && (t as bool? ?? SystConvert.ToBoolean(t))));
 }
Exemple #15
0
 bool IConvertible.ToBoolean(IFormatProvider provider)
 {
     return(Convert.ToBoolean(m_value));
 }
        private static IEnumerable <IDataRow> GetData(HttpContext context, bool excelExport, out int total)
        {
            var start          = 0;
            var limit          = 0;
            var isKz           = false;
            var showHistory    = false;
            var dataSourceType = string.Empty;
            var parameters     = string.Empty;
            var refParent      = string.Empty;
            var search         = string.Empty;

            if (!string.IsNullOrEmpty(context.Request[Start]))
            {
                start = Convert.ToInt32(context.Request[Start]);
            }

            if (!string.IsNullOrEmpty(context.Request[Limit]))
            {
                limit = Convert.ToInt32(context.Request[Limit]);
            }

            if (!string.IsNullOrEmpty(context.Request[DataSourceType]))
            {
                dataSourceType = context.Request[DataSourceType];
            }

            if (!string.IsNullOrEmpty(context.Request["isKz"]))
            {
                isKz = Convert.ToBoolean(context.Request["isKz"]);
            }

            if (!string.IsNullOrEmpty(context.Request["showHistory"]))
            {
                showHistory = Convert.ToBoolean(context.Request["showHistory"]);
            }

            if (!string.IsNullOrEmpty(context.Request["parameters"]))
            {
                parameters = context.Request["parameters"];
            }

            if (!string.IsNullOrEmpty(context.Request["node"]))
            {
                refParent = context.Request["node"];
            }

            if (!string.IsNullOrEmpty(context.Request["search"]))
            {
                search = context.Request["search"];
            }

            if (isKz)
            {
                LocalizationHelper.SetThreadCulture("kk-kz", null);
            }

            var sourceObj = Activator.CreateInstance(BuildManager.GetType(dataSourceType, true, true), null);
            var journal   = string.IsNullOrEmpty(context.Request[JournalType])
                              ? null
                              : Activator.CreateInstance(BuildManager.GetType(context.Request[JournalType], true, true));
            var queryParameters = GetQueryParameters(parameters, showHistory, search, context.Request["gridFilters"], (IJournal)journal);

            if (!excelExport)
            {
                return(GetData(start, limit, (IDataSourceViewExtNet)sourceObj, queryParameters, refParent, out total));
            }

            ICollection <string> selectedValues = context.Request["selectedValues"]?.Split(',');

            Export(context, queryParameters, (IDataSourceView4)sourceObj, (IExportJournal)journal, selectedValues);
            total = 0;
            return(null);
        }
Exemple #17
0
        protected void ddlFG_OnSelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            var cInvoice = new CInvoice();
            var invoice  = cInvoice.Get(Convert.ToInt32(RadGridInvoice.SelectedValue.ToString()));

            invoice.IsFinancialGurantee = Convert.ToBoolean(ddlFG.SelectedValue);

            if (cInvoice.Update(invoice))
            {
                var cInvoiceItem = new CInvoiceItem();
                var invoiceItems = cInvoiceItem.GetInvoiceItems(invoice.InvoiceId);

                // fg mode
                if (invoice.IsFinancialGurantee)
                {
                    foreach (var v in invoiceItems)
                    {
                        // save fg
                        var cInvoiceItemFg = new CInvoiceItemFg();
                        var InvoiceItemFg  = cInvoiceItemFg.Get(v.InvoiceItemId);
                        if (InvoiceItemFg == null)
                        {
                            cInvoiceItemFg.Add(new InvoiceItemFg()
                            {
                                InvoiceItemId = v.InvoiceItemId,
                                StandardPrice = v.StandardPrice,
                                StudentPrice  = v.StudentPrice,
                                AgencyPrice   = v.AgencyPrice,
                                CreatedId     = CurrentUserId,
                                CreatedDate   = DateTime.Now
                            });
                        }
                        else
                        {
                            InvoiceItemFg.StandardPrice = v.StandardPrice;
                            InvoiceItemFg.StudentPrice  = v.StudentPrice;
                            InvoiceItemFg.AgencyPrice   = v.AgencyPrice;
                            InvoiceItemFg.UpdatedId     = CurrentUserId;
                            InvoiceItemFg.UpdatedDate   = DateTime.Now;

                            cInvoiceItemFg.Update(InvoiceItemFg);
                        }

                        // original invoice set negative value to zero
                        if (v.StandardPrice < 0)
                        {
                            v.StandardPrice = 0;
                        }

                        if (v.StudentPrice < 0)
                        {
                            v.StudentPrice = 0;
                        }

                        cInvoiceItem.Update(v);
                    }
                }
                else
                {
                    foreach (var v in invoiceItems)
                    {
                        // save fg
                        var cInvoiceItemFg = new CInvoiceItemFg();
                        var invoiceItemFg  = cInvoiceItemFg.Get(v.InvoiceItemId);

                        if (invoiceItemFg != null)
                        {
                            v.StandardPrice = invoiceItemFg.StandardPrice;
                            v.StudentPrice  = invoiceItemFg.StudentPrice;
                            v.AgencyPrice   = invoiceItemFg.AgencyPrice;
                            v.UpdatedId     = CurrentUserId;
                            v.UpdatedDate   = DateTime.Now;
                        }
                        cInvoiceItem.Update(v);
                    }
                }

                ShowMessage("Updated to Financial Gurantee status");
            }

            RadGridInvoice.Rebind();
        }
Exemple #18
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            try
            {
                string           fileName    = "";
                string           reqFilename = Path.GetFileName(context.Request.Url.AbsolutePath).ToLower();
                System.IO.Stream stream      = null;
                if (reqFilename == "headimg.ashx")
                {
                    int  userid = Convert.ToInt32(context.Request.QueryString["user"]);
                    int  size   = Convert.ToInt32(context.Request.QueryString["size"] ?? "0");
                    bool gred   = Convert.ToBoolean(context.Request.QueryString["gred"] ?? "false");

                    AccountInfo userInfo = AccountImpl.Instance.GetUserInfo(userid);

                    string preFileName = "";
                    if (String.IsNullOrEmpty(userInfo.HeadIMG))
                    {
                        preFileName = context.Server.MapPath("~/" + ServerImpl.Instance.ResPath + "/Themes/Default/HeadIMG/user");
                    }
                    else
                    {
                        preFileName = ServerImpl.Instance.MapPath(userInfo.HeadIMG);
                        if (!System.IO.File.Exists(preFileName))
                        {
                            throw new Exception();
                        }
                        ServerImpl.Instance.CheckPermission(context, userInfo.HeadIMG, IOPermission.Read);
                    }
                    fileName = preFileName;
                    if (gred)
                    {
                        fileName += ".gred";
                    }
                    if (size > 0)
                    {
                        fileName += String.Format(".{0}", size);
                    }
                    if (fileName != preFileName)
                    {
                        fileName += ".png";
                        if (!File.Exists(fileName))
                        {
                            fileName = ZoomHeadImage(preFileName, fileName, size, size, gred);
                        }
                    }
                    stream = System.IO.File.Open(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                }
                else
                {
                    fileName = ServerImpl.Instance.GetFullPath(context, GlobalObject.unescape(context.Request["FileName"]));
                    ServerImpl.Instance.CheckPermission(context, fileName, IOPermission.Read);
                    stream = Core.IO.File.Open(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                }
                if (stream == null)
                {
                    throw new Exception();
                }
                try
                {
                    string ext = Path.GetExtension(fileName).ToUpper();
                    if (ContentType.ContainsKey(ext))
                    {
                        context.Response.ContentType = ContentType[ext] as string;
                        context.Response.AppendHeader("Content-Disposition", string.Format("filename={0}{1}", UTF8_FileName(Path.GetFileNameWithoutExtension(fileName)), Path.GetExtension(fileName)));
                    }
                    else
                    {
                        context.Response.ContentType = "application/octet-stream";
                        context.Response.AppendHeader("Content-Disposition", string.Format("attachment;filename={0}{1}", UTF8_FileName(Path.GetFileNameWithoutExtension(fileName)), Path.GetExtension(fileName)));
                    }


                    FileSystemInfo fileInfo = new FileInfo(fileName);
                    if (fileInfo != null)
                    {
                        context.Response.AppendHeader("Last-Modified", String.Format("{0:R}", fileInfo.LastWriteTime));
                    }

                    context.Response.AppendHeader("Content-Length", stream.Length.ToString());

                    byte[] buffer = new byte[4 * 1024];
                    while (true)
                    {
                        int c = stream.Read(buffer, 0, buffer.Length);
                        if (c == 0)
                        {
                            break;
                        }
                        context.Response.OutputStream.Write(buffer, 0, c);
                        context.Response.Flush();
                    }
                }
                finally
                {
                    stream.Close();
                }
            }
            catch
            {
                context.Response.StatusCode = 404;
                context.Response.End();
            }
        }
Exemple #19
0
        public string AddPatientFamilyTesting(string familyMembers)
        {
            int      patientId; int patientMasterVisitId; string firstName; string middleName; string lastName; int sex; string dob; int relationshipId; int baselineHivStatusId; string baselineHivStatusDate; /*string hivTestingresultId;*/ string hivTestingresultDate; bool cccreferal; string cccReferalNumber;  int userId;
            DateTime?linkageDate;
            bool     dobPrecision;

            //FamilyMembers[] familyMembrs = JsonConvert.DeserializeObject<FamilyMembers[]>(familyMembers);
            FamilyMembers[] familyMembrs = new JavaScriptSerializer().Deserialize <FamilyMembers[]>(familyMembers);

            int count = familyMembrs.Length;

            for (int i = 0; i < count; i++)
            {
                patientId            = int.Parse(HttpContext.Current.Session["PatientPK"].ToString());
                patientMasterVisitId = int.Parse(Session["PatientMasterVisitId"].ToString());
                userId = Convert.ToInt32(Session["AppUserId"]);

                firstName  = GlobalObject.unescape(familyMembrs[i].firstName);
                middleName = GlobalObject.unescape(familyMembrs[i].middleName);
                lastName   = GlobalObject.unescape(familyMembrs[i].lastName);
                int hivresultId = familyMembrs[i].hivTestingresultId == "" ? 0 : Convert.ToInt32(familyMembrs[i].hivTestingresultId);
                sex                   = familyMembrs[i].sex;
                dob                   = familyMembrs[i].dob;
                dobPrecision          = Convert.ToBoolean(familyMembrs[i].dobPrecision);
                relationshipId        = familyMembrs[i].relationshipId;
                baselineHivStatusId   = familyMembrs[i].baselineHivStatusId;
                baselineHivStatusDate = familyMembrs[i].baselineHivStatusDate;
                cccreferal            = familyMembrs[i].cccreferal;
                cccReferalNumber      = familyMembrs[i].cccReferalNumber;
                hivTestingresultDate  = familyMembrs[i].hivTestingresultDate;
                linkageDate           = familyMembrs[i].cccReferalDate;

                PatientFamilyTesting patientFamilyTesting = new PatientFamilyTesting()
                {
                    PatientId            = patientId,
                    PatientMasterVisitId = patientMasterVisitId,
                    FirstName            = firstName,
                    MiddleName           = middleName,
                    LastName             = lastName,
                    Sex                 = sex,
                    DateOfBirth         = DateTime.Parse(dob),
                    DobPrecision        = dobPrecision,
                    RelationshipId      = relationshipId,
                    BaseLineHivStatusId = baselineHivStatusId,
                    //BaselineHivStatusDate = baselineHivStatusDate,
                    //HivTestingResultsDate = hivTestingresultDate,
                    HivTestingResultsId = hivresultId,
                    CccReferal          = cccreferal,
                    CccReferaalNumber   = cccReferalNumber,
                    LinkageDate         = linkageDate
                };

                if (hivTestingresultDate != "")
                {
                    patientFamilyTesting.HivTestingResultsDate = DateTime.Parse(hivTestingresultDate);
                }
                if (baselineHivStatusDate != "")
                {
                    patientFamilyTesting.BaselineHivStatusDate = DateTime.Parse(baselineHivStatusDate);
                }

                try
                {
                    var testing = new PatientFamilyTestingManager();
                    var fam     =
                        testing.GetPatientFamilyList(patientId)
                        .Where(
                            x =>
                            x.FirstName == firstName && x.MiddleName == middleName && x.LastName == lastName &&
                            x.RelationshipId == relationshipId);
                    if (!fam.Any())
                    {
                        Result = testing.AddPatientFamilyTestings(patientFamilyTesting, userId);
                        if (Result > 0)
                        {
                            Msg = "Patient family testing Added Successfully!";
                        }
                    }
                    else
                    {
                        Msg = firstName + " " + middleName + " " + lastName + " Not saved. Family member already exists!";
                    }
                }
                catch (Exception e)
                {
                    Msg = e.Message;
                }
            }


            return(Msg);
        }
Exemple #20
0
        public string GetPatientEnrollmentDetails()
        {
            try
            {
                EnrollmentDetails enrollmentDetails = new EnrollmentDetails();
                enrollmentDetails.IndentifiersList = new List <Identifier>();
                PersonId = int.Parse(Session["PersonId"].ToString());
                PatientLookupManager     patientLookupManager = new PatientLookupManager();
                PatientEntryPointManager entryPointManager    = new PatientEntryPointManager();
                PatientIdentifierManager identifierManager    = new PatientIdentifierManager();
                IdentifierManager        ideManager           = new IdentifierManager();
                PersonLookUpManager      personLookUp         = new PersonLookUpManager();

                PatientLookup patientList = patientLookupManager.GetPatientByPersonId(PersonId);

                if (patientList != null)
                {
                    enrollmentDetails.DOB          = String.Format("{0:dd-MMM-yyyy}", patientList.DateOfBirth);
                    enrollmentDetails.DobPrecision = patientList.DobPrecision;
                    if (enrollmentDetails.DOB == null)
                    {
                        PersonLookUp person = personLookUp.GetPersonById(PersonId);
                        if (person.DateOfBirth != null)
                        {
                            enrollmentDetails.DOB          = String.Format("{0:dd-MMM-yyyy}", person.DateOfBirth);
                            enrollmentDetails.DobPrecision = person.DobPrecision == null?false:Convert.ToBoolean(person.DobPrecision);
                        }
                    }
                    enrollmentDetails.NationalId     = patientList.NationalId;
                    enrollmentDetails.EnrollmentDate = String.Format("{0:dd-MMM-yyyy}", patientList.EnrollmentDate);

                    var entryPoints   = entryPointManager.GetPatientEntryPoints(patientList.Id);
                    var identifiers   = identifierManager.GetAllPatientEntityIdentifiers(patientList.Id);
                    var dynamicFields = EnrollmentService.ServiceDynamicFields(1);
                    if (entryPoints.Count > 0)
                    {
                        string Name = LookupLogic.GetLookupNameById(entryPoints[0].EntryPointId);
                        if (Name == "Unknown")
                        {
                            enrollmentDetails.EntryPointIdUnknown = true;
                            enrollmentDetails.EntryPointId        = entryPoints[0].EntryPointId;
                        }
                        else
                        {
                            enrollmentDetails.EntryPointIdUnknown = false;
                            enrollmentDetails.EntryPointId        = entryPoints[0].EntryPointId;
                        }
                    }
                    var dynamicObject = new ExpandoObject() as IDictionary <string, Object>;
                    foreach (var field in dynamicFields)
                    {
                        foreach (var itemsEntityIdentifier in identifiers)
                        {
                            if (itemsEntityIdentifier.IdentifierTypeId == field.ID)
                            {
                                var code = field.Code;
                                dynamicObject.Add(code, itemsEntityIdentifier.IdentifierValue);
                            }
                        }
                    }
                    //if (identifiers.Count > 0)
                    //{
                    //    enrollmentDetails.IndentifierId = identifiers[0].IdentifierTypeId;
                    //}

                    foreach (var dynamicItem in dynamicObject)
                    {
                        var key           = dynamicItem.Key;
                        var identifier    = ideManager.GetIdentifierByCode(key);
                        var dynIdentifier = new Identifier();
                        if (identifier.PrefixType != null)
                        {
                            string[] enrollmentParts = dynamicItem.Value.ToString().Split('-');
                            int      parts           = enrollmentParts.Length;
                            if (parts > 1)
                            {
                                dynIdentifier.Code       = key;
                                dynIdentifier.PrefixType = enrollmentParts[0];
                                dynIdentifier.DataType   = enrollmentParts[1];
                                //enrollmentDetails.EnrollmentValue = enrollmentParts[1];
                                //enrollmentDetails.Prefix = enrollmentParts[0];
                                //enrollmentDetails.Suffix = null;
                            }
                            else
                            {
                                dynIdentifier.Code     = key;
                                dynIdentifier.DataType = dynamicItem.Value.ToString();
                                //enrollmentDetails.EnrollmentValue = dynamicItem.Value.ToString();
                            }
                        }
                        else
                        {
                            dynIdentifier.Code     = key;
                            dynIdentifier.DataType = dynamicItem.Value.ToString();
                        }
                        enrollmentDetails.IndentifiersList.Add(dynIdentifier);
                    }

                    //string[] enrollmentParts = patientList[0].EnrollmentNumber.Split('-');
                    //int parts = enrollmentParts.Length;
                    //if (parts > 1)
                    //{
                    //    enrollmentDetails.EnrollmentValue = enrollmentParts[1];
                    //    enrollmentDetails.Prefix = enrollmentParts[0];
                    //    enrollmentDetails.Suffix = null;
                    //}
                    //else
                    //{
                    //    enrollmentDetails.EnrollmentValue = patientList[0].EnrollmentNumber;
                    //}
                }
                else
                {
                    PersonLookUp person = personLookUp.GetPersonById(PersonId);
                    if (person.DateOfBirth != null)
                    {
                        enrollmentDetails.DOB          = String.Format("{0:dd-MMM-yyyy}", person.DateOfBirth);
                        enrollmentDetails.DobPrecision = person.DobPrecision == null ? false : Convert.ToBoolean(person.DobPrecision);
                    }
                }

                return(new JavaScriptSerializer().Serialize(enrollmentDetails));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #21
0
 bool IConvertible.ToBoolean(IFormatProvider provider)
 {
     return(Convert.ToBoolean(this));
 }