Exemplo n.º 1
0
        public string AddCcd(string key, string secretKey, string mergeId, Stream data)
        {
            string s3Key;

            try
            {
                string xmlString;
                using (var sr = new StreamReader(data))
                {
                    xmlString = sr.ReadToEnd();
                }

                s3Key = S3Interface.AddCcdRecord(Guid.Parse(mergeId), xmlString, key);
            }
            catch (UnAuthorizedAccesssException)
            {
                var ctx = WebOperationContext.Current;
                if (ctx != null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Unauthorized;
                }
                return("Error: 1 Unauthorized");
            }
            catch (Exception ex)
            {
                var ctx = WebOperationContext.Current;
                if (ctx != null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.SeeOther;
                }
                return("Error: 2 General Error");
            }

            return(s3Key);
        }
Exemplo n.º 2
0
        public string MergeWithRuleSet(string key, string secretKey, string mergeId, string data)
        {
            string s3Key;

            try
            {
                string jsonString = data;
                //using (var sr = new StreamReader(data))
                //{
                //    jsonString = sr.ReadToEnd();
                //}

                s3Key = S3Interface.AddRuleSet(Guid.Parse(mergeId), jsonString, key);
            }
            catch (UnAuthorizedAccesssException)
            {
                var ctx = WebOperationContext.Current;
                if (ctx != null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Unauthorized;
                }
                return("Error: 1 Unauthorized");
            }
            catch (Exception)
            {
                var ctx = WebOperationContext.Current;
                if (ctx != null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.SeeOther;
                }
                return("Error: 2 General Error");
            }

            return(s3Key);
        }
Exemplo n.º 3
0
        //TESTING/DEMO ONLY!!!
        public string FireMergeEngine()
        {
            var readyToMerge = S3Interface.GetReadyToMerge();

            foreach (var m in readyToMerge)
            {
                var ccdList  = S3Interface.GetMergeSetCcds(Guid.Parse(m)).Select(x => XDocument.Parse(x)).ToList();
                var sRuleSet = S3Interface.GetMergeSetRules(Guid.Parse(m));

                RuleSet ruleSet;

                if (!sRuleSet.Contains("{\"UseDefault\": \"true\"}"))
                {
                    ruleSet = new RuleSet(sRuleSet);
                }
                else
                {
                    ruleSet = new RuleSet();
                    ruleSet.AddRule("StripText", 0, RuleType.PreFormat);
                    ruleSet.AddRule("PrimaryMergeRuleWithValidation", 0, RuleType.Primary);
                    ruleSet.AddRule("MedicationRule1", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("AlertsSection", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("SocialHistory_EtohUser", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("SocialHistory_SmokingConsolidation", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("TestProblemsDedup", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("AddFormatedText", 0, RuleType.PostFormat);
                }


                S3Interface.AddMergedZip(Guid.Parse(m), RunMerge.runMergeWithRuleSet(ccdList, ruleSet, Guid.Parse(m), ""));
            }

            return(string.Empty);
        }
Exemplo n.º 4
0
        public string MergeWithDefaultRules(string key, string secretKey, string mergeId)
        {
            string s3Key;

            try
            {
                const string jsonString = "{\"UseDefault\": \"true\"}";

                s3Key = S3Interface.AddRuleSet(Guid.Parse(mergeId), jsonString, key, true);
            }
            catch (UnAuthorizedAccesssException)
            {
                var ctx = WebOperationContext.Current;
                if (ctx != null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Unauthorized;
                }
                return("Error: 1 Unauthorized");
            }
            catch (Exception)
            {
                var ctx = WebOperationContext.Current;
                if (ctx != null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.SeeOther;
                }
                return("Error: 2 General Error");
            }

            return(s3Key);
        }
Exemplo n.º 5
0
        private void UpdateList()
        {
            var listOfCompletedMerges = S3Interface.GetCompletedMerges();
            var sb = new StringBuilder();

            sb.Append("<ul list-style-type:none;padding:0px;margin:0px;>");
            const string strRef = "<a href =\"#\" onclick=\"loadXml('{0}')\">CCD_{1}_{2}</a>";

            foreach (var s in from s in listOfCompletedMerges let lb = new LinkButton() select s)
            {
                sb.AppendFormat("<li style=\"background-image:url(images/sqorange.gif);background-repeat:no-repeat;background-position:40px 3px; padding-left:56px;list-style-type: none;\">{0}</li>", string.Format(strRef, s.Value, DateTime.Parse(s.Key).ToShortDateString(), DateTime.Parse(s.Key).ToShortTimeString()));
            }
            sb.Append("</ul>");
            divContent.InnerHtml = sb.ToString();
        }
Exemplo n.º 6
0
 public Stream GetMergedCcd(string key, string secretKey, string mergeId)
 {
     return(S3Interface.GetMergeSet(Guid.Parse(mergeId), key));
 }
Exemplo n.º 7
0
 public string MergeStatus(string key, string secretKey, string mergeId)
 {
     return(S3Interface.GetMergeStatus(Guid.Parse(mergeId)));
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            var readyToMerge = S3Interface.GetReadyToMerge();

            foreach (var m in readyToMerge)
            {
                var ccdList  = S3Interface.GetMergeSetCcds(Guid.Parse(m)).Select(x => XDocument.Parse(x)).ToList();
                var sRuleSet = S3Interface.GetMergeSetRules(Guid.Parse(m));

                RuleSet ruleSet;

                if (!sRuleSet.Contains("{\"UseDefault\": \"true\"}"))
                {
                    ruleSet = new RuleSet(sRuleSet);
                }
                else
                {
                    ruleSet = new RuleSet();
                    ruleSet.AddRule("StripText", 0, RuleType.PreFormat);
                    ruleSet.AddRule("PrimaryMergeRuleWithValidation", 0, RuleType.Primary);
                    ruleSet.AddRule("MedicationRule1", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("AlertsSection", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("SocialHistory_EtohUser", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("SocialHistory_SmokingConsolidation", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("TestProblemsDedup", 0, RuleType.DeDuplication);
                    ruleSet.AddRule("AddFormatedText", 0, RuleType.PostFormat);
                }


                S3Interface.AddMergedZip(Guid.Parse(m), RunMerge.runMergeWithRuleSet(ccdList, ruleSet, Guid.Parse(m), ""));
            }
            //var mergeList = S3Interface.GetReadyToMerge();

            //foreach (var m in mergeList)
            //{
            //    var xx = S3Interface.GetMergeSetCcds(Guid.Parse(m));

            //    foreach (var x in xx)
            //    {
            //        var test = XDocument.Parse(x);
            //    }
            //}



            //var xx = new testclass();

            //var xxx = xx.GetType().GetInterfaces().Where(x => x.GetInterfaces().Select(y => y.Name).Contains("IEnumerable"));

            //var testRuleSet = new RuleSet();

            //var postRules = new List<RuleDefinition>
            //                    {
            //                        new RuleDefinition
            //                            {RuleName = "PostTest1", RuleType = RuleType.PostFormat, RuleVersion = 0},
            //                        new RuleDefinition
            //                            {RuleName = "PostTest2", RuleType = RuleType.PostFormat, RuleVersion = 0}
            //                    };

            //var mergeRules = new List<RuleDefinition>
            //                    {
            //                        new RuleDefinition
            //                            {RuleName = "MergeTest1", RuleType = RuleType.DeDuplication, RuleVersion = 0},
            //                        new RuleDefinition
            //                            {RuleName = "MergeTest2", RuleType = RuleType.DeDuplication, RuleVersion = 0}
            //                    };

            //var preRules = new List<RuleDefinition>
            //                    {
            //                        new RuleDefinition
            //                            {RuleName = "PreTest1", RuleType = RuleType.PreFormat, RuleVersion = 0},
            //                        new RuleDefinition
            //                            {RuleName = "PreTest2", RuleType = RuleType.PreFormat, RuleVersion = 0}
            //                    };

            //testRuleSet.PostFormatRules = postRules;
            //testRuleSet.PreFormatRules = preRules;
            //testRuleSet.DeDuplicationRules = mergeRules;
            //testRuleSet.PrimaryRule = new RuleDefinition { RuleName = "PrimaryRule", RuleType = RuleType.Primary, RuleVersion = 0 };

            //var ruleSet = new RuleSet();
            //ruleSet.AddRule("StripText", 0, RuleType.PreFormat);
            //ruleSet.AddRule("PrimaryMergeRuleWithValidation", 0, RuleType.Primary);
            //ruleSet.AddRule("MedicationRule1", 0, RuleType.DeDuplication);
            //ruleSet.AddRule("AlertsSection", 0, RuleType.DeDuplication);
            //ruleSet.AddRule("SocialHistory_EtohUser", 0, RuleType.DeDuplication);
            //ruleSet.AddRule("SocialHistory_SmokingConsolidation", 0, RuleType.DeDuplication);
            //ruleSet.AddRule("TestProblemsDedup", 0, RuleType.DeDuplication);
            //ruleSet.AddRule("AddFormatedText", 0, RuleType.PostFormat);

            //var testJson = JsonConvert.SerializeObject(ruleSet);

            //StringBuilder sb = new StringBuilder(517);
            //sb.AppendLine(@"{");
            //sb.AppendLine(@"""PreFormatRules"":");
            //sb.AppendLine(@"[");
            //sb.AppendLine(@"{""RuleName"":""PreTest1"",""RuleVersion"":0,""GetRuleType"":10},");
            //sb.AppendLine(@"{""RuleName"":""PreTest2"",""RuleVersion"":0,""GetRuleType"":10}");
            //sb.AppendLine(@"],");
            //sb.AppendLine(@"""PrimaryRule"":{""RuleName"":""PrimaryRule"",""RuleVersion"":0,""GetRuleType"":20},""DeDuplicationRules"":");
            //sb.AppendLine(@"[");
            //sb.AppendLine(@"{""RuleName"":""MergeTest1"",""RuleVersion"":0,""GetRuleType"":30},");
            //sb.AppendLine(@"{""RuleName"":""MergeTest2"",""RuleVersion"":0,""GetRuleType"":30}");
            //sb.AppendLine(@"],");
            //sb.AppendLine(@"""PostFormatRules"":");
            //sb.AppendLine(@"[");
            //sb.AppendLine(@"{""RuleName"":""PostTest1"",""RuleVersion"":0,""GetRuleType"":40},");
            //sb.AppendLine(@"{""RuleName"":""PostTest2"",""RuleVersion"":0,""GetRuleType"":40}");
            //sb.AppendLine(@"]");
            //sb.AppendLine(@"}");

            //var xx = sb.ToString();

            //var ds = new RuleSet(sb.ToString());


            ////Create a ccd list of XDocuments
            //var ccdList = new List<XDocument>();

            //ccdList.Add(XDocument.Load(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_1.xml"));
            //ccdList.Add(XDocument.Load(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_2.xml"));
            //ccdList.Add(XDocument.Load(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_3.xml"));


            //XDocument xMaster = XDocument.Parse("<empty />");


            //var ruleList = new RuleList();

            //foreach (var i in ruleList.PreFormatRules)
            //{
            //    using (var xRule = RuleFactory.BuildRule(Guid.NewGuid(), i, ccdList, xMaster))
            //    {
            //        xRule.Merge();
            //        xMaster = xRule.GetMasterCcd();
            //    }
            //}

            //using (var xRule = RuleFactory.BuildRule(Guid.NewGuid(), ruleList.PrimaryRule, ccdList, xMaster))
            //{
            //    xRule.Merge();
            //    xMaster = xRule.GetMasterCcd();
            //}


            //foreach (var i in ruleList.MergeRules)
            //{
            //    using (var xRule = RuleFactory.BuildRule(Guid.NewGuid(), i, ccdList, xMaster))
            //    {
            //        var startTime = DateTime.Now;
            //        xRule.Merge();
            //        xMaster = xRule.GetMasterCcd();
            //        Console.WriteLine("RunTime: " + (DateTime.Now - startTime).TotalSeconds.ToString());
            //    }
            //}

            //foreach (var i in ruleList.PostFormatRules)
            //{
            //    using (var xRule = RuleFactory.BuildRule(Guid.NewGuid(), i, ccdList, xMaster))
            //    {
            //        xRule.Merge();
            //        xMaster = xRule.GetMasterCcd();
            //    }
            //}

            //Console.Write("Done");


            ////Run the format rule
            //var preRule = new StripText();
            //ccdList = preRule.FormatCCDs(ccdList);

            ////Run the primary rule
            //var priRule = new PrimaryMergeRule();
            //var masterCCD = priRule.MergeCCDs(ccdList, null);

            ////Run test consolidation rules
            //var testRule = new TestProblemsDedup();

            //masterCCD = testRule.MergeCCDs(ccdList, masterCCD);

            //var medRule = new MedicationRule1();
            //masterCCD = medRule.MergeCCDs(ccdList, masterCCD);

            //foreach (var ccd in ccdList)
            //{
            //    var compList = (from e in ccd.Descendants()
            //               where e.Name.LocalName == "component"
            //               where e.Descendants().Elements().Count(x =>
            //                                                          {
            //                                                              var xAttribute = x.Attribute("code");
            //                                                              return xAttribute != null && (x.Name.LocalName == "code" && xAttribute.Value == "11450-4");
            //                                                          }) > 0
            //               select e).ToList();

            //    compList.RemoveAt(0);



            //    foreach (var xe in compList)
            //    {
            //        var codes = (from e in xe.Descendants()
            //                    where e.Name.LocalName == "entry"
            //                    select e).ToList();

            //        Console.WriteLine("test");
            //    }

            //    Console.WriteLine("test");
            //}



            //foreach (var ccd in ccdList)
            //{
            //    //var xx = ccd.Descendants().Elements().Where(x => x.Name.LocalName == "table");
            //    ccd.Descendants().Elements().Where(x => x.Name.LocalName == "table").Remove();
            //}



            //var x = new RuleList();

            //foreach (var s in x.RuleObjects)
            //{
            //    var act = Activator.CreateInstance(s);

            //    Console.WriteLine(s.InvokeMember("RuleName", BindingFlags.InvokeMethod, null, act, null));
            //}

            //Console.WriteLine(x.PrimaryRule.InvokeMember("RuleName", BindingFlags.InvokeMethod, null, Activator.CreateInstance(x.PrimaryRule), null));


            ////var x = Deserialize<POCD_MT000040ClinicalDocument>(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_1.xml");

            ////Console.WriteLine(x.ToString());

            //var ccd1 = Deserialize<POCD_MT000040ClinicalDocument>(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_1.xml");
            //var ccd2 = Deserialize<POCD_MT000040ClinicalDocument>(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_2.xml");
            //var ccd3 = Deserialize<POCD_MT000040ClinicalDocument>(@"C:\Users\Jon\Dropbox\hhic2\CCD\HHIC_CCD_3.xml");

            //var ccdList = new List<POCD_MT000040ClinicalDocument> {ccd1, ccd2, ccd3};

            //var x = new PrimaryRule(ccdList).MasterCCD;


            Console.Read();
        }