Пример #1
0
        /// <summary>
        /// 获取病人最新体征情况 GL 2015-10-10
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="ItemType"></param>
        /// <param name="ItemCode"></param>
        /// <returns></returns>
        public ValueTime GetLatestPatientVitalSigns(DataConnection pclsCache, string UserId, string ItemType, string ItemCode)
        {
            ValueTime item = new ValueTime();

            try
            {
                if (!pclsCache.Connect())
                {
                    return(item);
                }
                InterSystems.Data.CacheTypes.CacheSysList list = null;
                list = Ps.VitalSigns.GetLatestPatientVitalSigns(pclsCache.CacheConnectionObject, UserId, ItemType, ItemCode);
                if (list != null)
                {
                    item.Value      = list[0];
                    item.RecordDate = list[1];
                    item.RecordTime = list[2];
                }
                return(item);
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "VitalInfoMethod.GetLatestPatientVitalSigns", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                return(item);
            }
            finally
            {
                pclsCache.DisConnect();
            }
        }
Пример #2
0
        public ValueTime GetLatestPatientVitalSigns(string UserId, string ItemType, string ItemCode)
        {
            ValueTime ret = repository.GetLatestPatientVitalSigns(pclsCache, UserId, ItemType, ItemCode);

            //return new ExceptionHandler().Common(Request, ret);
            return(ret);
        }
Пример #3
0
 public GossipTimestampResponseMessage(Guid guid, IList <Timestamps> timestamps, IList <string> queryNames,
                                       ValueTime requestSendTimestamp, ValueTime requestReceiveTimestamp) : base(guid)
 {
     Timestamps              = timestamps;
     QueryNames              = queryNames;
     RequestSendTimestamp    = requestSendTimestamp;
     RequestReceiveTimestamp = requestReceiveTimestamp;
 }
Пример #4
0
 public TimestampsInfo(ValueContact contact, int level, IList <Timestamps> myTimestamps,
                       IList <Timestamps> hisTimestamps, IList <string> myQueryNames, IList <string> hisQueryNames,
                       ValueTime hisSendTime, ValueTime myReceiveTime)
     : this(contact, level, myTimestamps, hisTimestamps, myQueryNames, hisQueryNames)
 {
     HisSendTime   = hisSendTime;
     MyReceiveTime = myReceiveTime;
 }
Пример #5
0
        public static void Main(string[] args)
        {
            var zmiName      = string.Empty;
            ZMI fatherZmi    = null;
            RSA rsa          = null;
            var receiverHost = string.Empty;
            var receiverPort = 0;
            var rpcHost      = string.Empty;
            var rpcPort      = 0;

            IDictionary <string, string> configuration = new Dictionary <string, string>();

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(opts =>
            {
                zmiName = opts.ZmiName.Trim(' ');
                if (string.IsNullOrEmpty(opts.ConfigFile) || !TryParseConfig(opts.ConfigFile, out fatherZmi))
                {
                    fatherZmi = ZMI.FromPathName(zmiName);
                }

                receiverHost = opts.ReceiverHost;
                receiverPort = opts.ReceiverPort;
                rpcHost      = opts.RpcHost;
                rpcPort      = opts.RpcPort;

                rsa = RSAFactory.FromPublicKey(opts.PublicKeyPath);

                if (string.IsNullOrEmpty(opts.IniFileName))
                {
                    return;
                }

                using var file   = File.OpenRead(opts.IniFileName);
                using var stream = new StreamReader(file);
                configuration    = INIParser.ParseIni(stream);
            })
            .WithNotParsed(errs =>
            {
                foreach (var err in errs)
                {
                    Console.WriteLine($"OPTIONS PARSE ERROR: {err}");
                }
                Environment.Exit(1);
            });

            var creationTimestamp = new ValueTime(DateTimeOffset.Now);

            fatherZmi.ApplyForEach(zmi => zmi.Attributes.AddOrChange("update", creationTimestamp));
            if (!fatherZmi.TrySearch(zmiName, out var myZmi))
            {
                Console.WriteLine($"Could not find node {zmiName} in ZMIs");
                Environment.Exit(1);
            }
            myZmi.Attributes.AddOrChange("timestamp", creationTimestamp);
            myZmi.Attributes.AddOrChange("contacts",
                                         new ValueSet(
                                             new HashSet <Value>(new[]
                                                                 { new ValueContact(myZmi.PathName, IPAddress.Parse(receiverHost), receiverPort) }),
                                             AttributeTypePrimitive.Contact));
            myZmi.Attributes.AddOrChange("isSingleton", new ValueBoolean(true));

            var manager = ManagerFromIni(receiverHost, receiverPort, rpcHost, rpcPort, configuration, rsa, myZmi);

            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
            Console.WriteLine("End");
            manager.Dispose();
        }
Пример #6
0
        /// <summary>
        /// 浙大输出接口 LY 2015-10-29
        /// </summary>
        /// <param name="PatientId"></param>
        /// <returns></returns>
        public string GetPatientInfo(DataConnection pclsCache, string PatientId)
        {
            List <TypeAndName> List = new List <TypeAndName>();

            List.Add(new TypeAndName
            {
                Type = "ubid",
                Name = "DW0101111447049158"
            });
            PatBasicInfo BasicInfo = new UsersRepository().GetPatBasicInfo(pclsCache, PatientId);

            if (BasicInfo == null)
            {
                return("病人不存在");
            }
            List.Add(new TypeAndName
            {
                Type = "name",
                Name = BasicInfo.UserName
            });
            List.Add(new TypeAndName
            {
                Type = "age",
                Name = BasicInfo.Age
            });
            List.Add(new TypeAndName
            {
                Type = "sex",
                Name = BasicInfo.Gender
            });
            string PhoneNumber = new UsersMethod().GetPhoneNoByUserId(pclsCache, PatientId);

            List.Add(new TypeAndName
            {
                Type = "mobilephone",
                Name = PhoneNumber
            });
            ValueTime H = new ValueTime();

            H = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Height", "Height_1");
            string Height = H.Value;

            ValueTime W = new ValueTime();

            W = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Weight", "Weight_1");
            string Weight = W.Value;

            ValueTime Wa = new ValueTime();

            Wa = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Waistline", "Waistline_1");
            string Waistline = Wa.Value;

            if (Height == null)
            {
                Height = "";
            }
            if (Weight == null)
            {
                Weight = "";
            }
            List.Add(new TypeAndName
            {
                Type = "height",
                Name = Height
            });
            List.Add(new TypeAndName
            {
                Type = "weight",
                Name = Weight
            });
            List.Add(new TypeAndName
            {
                Type = "birthday",
                Name = BasicInfo.Birthday.Insert(4, "-").Insert(7, "-")
            });
            if (Waistline != null)
            {
                List.Add(new TypeAndName
                {
                    Type = "waistline",
                    Name = Waistline
                });
            }
            try
            {
                string BasicJson = "{";
                foreach (TypeAndName Line in List)
                {
                    BasicJson = BasicJson + '"' + Line.Type + '"' + ':' + '"' + Line.Name + '"' + ',';
                }
                BasicJson  = BasicJson.TrimEnd(',');
                BasicJson += "}";
                byte[] bytedata = Encoding.UTF8.GetBytes(BasicJson);
                string content  = Convert.ToBase64String(bytedata, 0, bytedata.Length);
                content = "type=docapp&action=004&content=" + content + "&contentkey=#HQ*" + content;
                string         Url     = "http://qacsupport.duapp.com/port/port.php";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                request.Method      = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                byte[] bytes = Encoding.UTF8.GetBytes(content);
                request.ContentLength = bytes.Length;
                //request.Timeout = 10000;
                Stream reqstream = request.GetRequestStream();
                reqstream.Write(bytes, 0, bytes.Length);
                HttpWebResponse response      = (HttpWebResponse)request.GetResponse();
                Stream          streamReceive = response.GetResponseStream();
                Encoding        encoding      = Encoding.UTF8;
                StreamReader    streamReader  = new StreamReader(streamReceive, encoding);
                string          strResult     = streamReader.ReadToEnd();
                streamReceive.Dispose();
                streamReader.Dispose();
                return(strResult);
            }
            catch (WebException ex)
            {
                using (WebResponse response = ex.Response)
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)response;
                    Console.WriteLine("Error code: {0}", httpResponse.StatusCode);
                    using (Stream data = response.GetResponseStream())
                        using (var reader = new StreamReader(data))
                        {
                            string text = reader.ReadToEnd();
                            Console.WriteLine(text);
                        }
                }
                return(ex.Message);
            }
        }
Пример #7
0
        public static bool TryCreateValue(string typeString, string valueString, out Value value)
        {
            value = null;

            var isNull = valueString.Equals("NULL") || valueString.Equals("null") || valueString.Equals("");

            switch (typeString)
            {
            case "integer":
                if (isNull)
                {
                    value = new ValueInt(null);
                    return(true);
                }
                if (!long.TryParse(valueString, out var intResult))
                {
                    return(false);
                }
                value = new ValueInt(intResult);
                return(true);

            case "string":
                if (isNull)
                {
                    value = new ValueString(null);
                    return(true);
                }
                value = new ValueString(valueString.Trim('\"'));
                return(true);

            case "time":
                if (isNull)
                {
                    value = new ValueTime(null as RefStruct <long>);
                    return(true);
                }
                value = new ValueTime(valueString);
                return(true);

            case "double":
                if (isNull)
                {
                    value = new ValueDouble(null);
                    return(true);
                }
                if (!double.TryParse(valueString, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleResult))
                {
                    return(false);
                }
                value = new ValueDouble(doubleResult);
                return(true);

            case "boolean":
                if (isNull)
                {
                    value = new ValueBoolean(null);
                    return(true);
                }
                if (!bool.TryParse(valueString, out var booleanResult))
                {
                    return(false);
                }
                value = new ValueBoolean(booleanResult);
                return(true);

            case "duration":
                if (isNull)
                {
                    value = new ValueDuration(null as RefStruct <long>);
                    return(true);
                }
                value = new ValueDuration(valueString);
                return(true);

            case "contact":
                if (isNull)
                {
                    value = new ValueContact(null, null);
                    return(true);
                }

                var split = valueString.Split(' ');
                if (split.Length != 2 && split.Length != 3)
                {
                    return(false);
                }
                if (!IPAddress.TryParse(split[1], out var address))
                {
                    return(false);
                }
                var port = 555;
                if (split.Length == 3 && !int.TryParse(split[2], out port))
                {
                    return(false);
                }
                if (!split[0].StartsWith("/"))
                {
                    split[0] = '/' + split[0];
                }
                value = new ValueContact(new PathName(split[0]), address, port);
                return(true);
            }

            var splitByOf = typeString.Split(" of ", 2);

            if (splitByOf.Length != 2)
            {
                return(false);
            }
            var splitBySpace = splitByOf[1].Split(' ', 2);

            if (splitBySpace.Length != 2)
            {
                return(false);
            }

            if (!int.TryParse(splitBySpace[0], out var count))
            {
                return(false);
            }

            // based on StackOverflow answer: https://stackoverflow.com/a/3147901
            var collectionStrings = Regex.Split(valueString.Trim('{', '}', '[', ']'), ",(?=(?:[^']*'[^']*')*[^']*$)")
                                    .Select(s => s.Trim(' ')).ToList();

            if (collectionStrings.Count != count)
            {
                if (count != 0 && (collectionStrings.Count != 1 || !string.IsNullOrEmpty(collectionStrings[0])))
                {
                    return(false);
                }
                collectionStrings = new List <string>(count);
            }

            var elements          = new List <Value>(count);
            var elementTypeString = splitBySpace[1];

            foreach (var element in collectionStrings)
            {
                if (!TryCreateValue(elementTypeString, element, out var elementVal))
                {
                    return(false);
                }
                elements.Add(elementVal);
            }

            if (!TryGetPrimitiveAttributeType(elementTypeString, out var elementType))
            {
                return(false);
            }

            switch (splitByOf[0])
            {
            case "set":
                value = new ValueSet(elements.ToHashSet(), elementType);
                return(true);

            case "list":
                value = new ValueList(elements, elementType);
                return(true);
            }

            return(false);
        }
Пример #8
0
 public void SetReceiveTimestamp(ValueTime timestamp)
 {
     ReceiveTimestamp = timestamp;
 }
Пример #9
0
 public void SetSendTimestamp(ValueTime timestamp)
 {
     SendTimestamp = timestamp;
 }
Пример #10
0
 private Functions()
 {
     _epoch = new ValueTime("2000/01/01 00:00:00.000");
 }
Пример #11
0
 public void SetSendTimestamp(ValueTime timestamp)
 {
     ResponseSendTimestamp = timestamp;
 }