private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (checkedListBox1.CheckedItems.Contains(checkedListBox1.SelectedItem))
            {
                List<int> descedants = new List<int>();
                descedants.Add(proband.relativeID);
                proband.owningFHx.GetDescendants(proband.relativeID, ref descedants);
                foreach (int i in descedants)
                {
                    Person p = proband.owningFHx.getRelative(i);
                    if (p != null)
                    {
                        Race r = new Race(p.Ethnicity);
                        r.race = checkedListBox1.SelectedItem.ToString();
                        p.Ethnicity.AddToList(r, new HraModelChangedEventArgs(this));
                    }
                }
            }
            else
            {
                Race doomed = null;
                foreach (Race r in proband.Ethnicity)
                {
                    if (string.Compare(checkedListBox1.SelectedItem.ToString(), r.race, true) == 0)
                    {
                        doomed = r;
                        break;
                    }

                }
                if (doomed != null)
                {
                    //proband.Ethnicity.RemoveFromList(doomed, SessionManager.Instance.securityContext);
                    proband.owningFHx.getRelative(1).Ethnicity.RemoveFromList(doomed, SessionManager.Instance.securityContext);
                }
            }
        }
Beispiel #2
0
        private static void ProcessPersonNode(XPathNavigator personNode, XPathNavigator riskMean_rootNode, ref Person targetPerson, bool isProband, ref int nextRelIdIfNeeded)
        {
            string dataroot;
            if (isProband)
                dataroot = "patientPerson";
            else
                dataroot = "relationshipHolder";

            XPathNavigator dataRootNode = personNode.SelectSingleNode(dataroot);

            /////////////////////////
            //Age
            /////////////////////////
            string age_val = personNode.Evaluate("string(subjectOf1/livingEstimatedAge/value/@value)").ToString();
            if (string.IsNullOrEmpty(age_val) == false)
            {
                targetPerson.age = age_val;
            }
            else
            {
                age_val = personNode.Evaluate("string(subjectOf1/deceasedEstimatedAge/value/@value)").ToString();
                if (string.IsNullOrEmpty(age_val) == false)
                {
                    targetPerson.age = age_val;
                }
            }

            if (String.IsNullOrEmpty(age_val))
            {
                //try to get age from the birthdate
                string birthDateRaw = personNode.Evaluate("string(patientPerson/birthTime/@value)").ToString();
                if (!string.IsNullOrEmpty(birthDateRaw))
                {
                    //convert the raw birthdate in YYYYMMDD format to the current age
                    string[] format = { "yyyyMMdd" };  //official HL7 date format
                    DateTime birthDate;
                    if (DateTime.TryParseExact(birthDateRaw,
                                               format,
                                               System.Globalization.CultureInfo.InvariantCulture,
                                               System.Globalization.DateTimeStyles.None,
                                               out birthDate))
                    {
                        DateTime today = DateTime.Today;
                        int age = today.Year - birthDate.Year;
                        if (birthDate > today.AddYears(-age)) age--;
                        targetPerson.age = age.ToString();
                    }
                }
            }

            //////////////////////////
            // other basics
            //////////////////////////

            //old way fails when relative Id isn't integer in source xml/hl7
            //targetPerson.relativeID = Convert.ToInt32(dataRootNode.Evaluate("string(id/@extension)").ToString());

            int number;
            bool resultRelId = Int32.TryParse(dataRootNode.Evaluate("string(id/@extension)").ToString(), out number);
            if (resultRelId)
            {
                targetPerson.relativeID = number;
            }
            else
            {
                targetPerson.relativeID = nextRelIdIfNeeded++;
            }

            targetPerson.name = dataRootNode.Evaluate("string(name/@formatted)").ToString();
            targetPerson.firstName = dataRootNode.Evaluate("string(name/@first)").ToString();
            targetPerson.lastName = dataRootNode.Evaluate("string(name/@last)").ToString();

            targetPerson.homephone = dataRootNode.Evaluate("string(telecom[@use='H']/@value)").ToString();
            targetPerson.workphone = dataRootNode.Evaluate("string(telecom[@use='WP']/@value)").ToString();

            targetPerson.gender = HL7FormatTranslator.GenderFromHL7(dataRootNode.Evaluate("string(administrativeGenderCode/@code)").ToString());
            targetPerson.dob = HL7FormatTranslator.DateFromHL7(dataRootNode.Evaluate("string(birthTime/@value)").ToString()); ;
            targetPerson.vitalStatus = HL7FormatTranslator.VitalStatusFromHL7(dataRootNode.Evaluate("string(deceasedInd/@value)").ToString());

            int temp_mom_id;
            int temp_dad_id;

            if (int.TryParse(dataRootNode.Evaluate("string(relative[code/@code='NMTH']/relationshipHolder/id/@extension)").ToString(), out temp_mom_id))
            {
                targetPerson.motherID = temp_mom_id;
            }
            if (int.TryParse(dataRootNode.Evaluate("string(relative[code/@code='NFTH']/relationshipHolder/id/@extension)").ToString(), out temp_dad_id))
            {
                targetPerson.fatherID = temp_dad_id;
            }

            //////////////////////////
            // ethnicity
            //////////////////////////

            XPathNodeIterator raceIter = dataRootNode.Select("raceCode");
            foreach (XPathNavigator raceNode in raceIter)
            {
                string code = raceNode.Evaluate("string(@code)").ToString();
                string displayName = raceNode.Evaluate("string(@displayName)").ToString();
                string hraRaceText = HL7FormatTranslator.RaceFromHL7(code, displayName);
                if (hraRaceText == "Ashkenazi")
                {
                    targetPerson.isAshkenazi = "Yes";
                }
                else if (hraRaceText == "Hispanic")
                {
                    targetPerson.isHispanic = "Yes";
                }
                else
                {
                    Race r = new Race();
                    r.race = hraRaceText;
                    targetPerson.Ethnicity.Add(r);
                }
            }

            //SG encodes above in ethnicGroupCode rather than raceCode, so we check these too
            XPathNodeIterator ethnicIter = dataRootNode.Select("ethnicGroupCode");
            foreach (XPathNavigator ethnicNode in ethnicIter)
            {
                string code = ethnicNode.Evaluate("string(@code)").ToString();
                string displayName = ethnicNode.Evaluate("string(@displayName)").ToString();
                string hraEthnicityText = HL7FormatTranslator.EthnicityFromHL7(code, displayName);
                if (hraEthnicityText == "Ashkenazi")
                {
                    targetPerson.isAshkenazi = "Yes";
                }
                else if (hraEthnicityText == "Hispanic or Latino")
                {
                    targetPerson.isHispanic = "Yes";
                }
                else if (hraEthnicityText == "not Hispanic or Latino")
                {
                    targetPerson.isHispanic = "No";
                }
                else
                {
                    Race r = new Race();
                    r.race = hraEthnicityText;
                    targetPerson.Ethnicity.Add(r);
                }
            }

            //////////////////////////
            // Clinical Observations
            //////////////////////////
            //PRB modified XPath in next to *not* include COs that are for cause of death, which SG duplicates from another CO with that same disease
            XPathNodeIterator coIter = personNode.Select(@"subjectOf2/clinicalObservation[not(sourceOf/@typeCode='CAUS')]");
            foreach (XPathNavigator coNode in coIter)
            {
                string coText = coNode.Evaluate("string(code/@displayName)").ToString();
                string coCode = coNode.Evaluate("string(code/@code)").ToString();
                string coCodeSystem = coNode.Evaluate("string(code/@codeSystemName)").ToString();
                string ageLowText = coNode.Evaluate("string(subject/dataEstimatedAge/value/low/@value)").ToString();
                string ageHighText = coNode.Evaluate("string(subject/dataEstimatedAge/value/high/@value)").ToString();
                string statusCode = coNode.Evaluate("string(statusCode/@code)").ToString();
                string coValue = coNode.Evaluate("string(code/qualifier/value/@code)").ToString();
                string coAgeDx = HL7FormatTranslator.GetIntFromHL7HighLow(ageLowText, ageHighText);

                string hra_tag = riskMean_rootNode.Evaluate("string(row[codeSystem/.='" + coCodeSystem + "'][code/.='" + coCode + "']/Mgh/.)").ToString();
                if (string.IsNullOrEmpty(hra_tag) == false)
                {
                    if (string.Compare(hra_tag, "Identical twin", true) == 0)
                    {
                        int temp;
                        if (int.TryParse(coValue, out temp))
                        {
                            targetPerson.twinID = temp;
                        }

                    }
                    else
                    {
                        if (targetPerson is Patient)
                        {
                            Patient p = (Patient)targetPerson;
                            bool result = processAsRiskFactorClinicalObservation(hra_tag, ref p, coAgeDx, statusCode, coValue);
                            if (!result)
                            {
                                ClincalObservation co = new ClincalObservation(targetPerson.PMH);
                                co.ClinicalObservation_disease = hra_tag;
                                co.ClinicalObservation_ageDiagnosis = coAgeDx;
                                targetPerson.PMH.Observations.Add(co);
                            }
                        }
                        else
                        {
                            ClincalObservation co = new ClincalObservation(targetPerson.PMH);
                            co.ClinicalObservation_disease = hra_tag;
                            co.ClinicalObservation_ageDiagnosis = coAgeDx;
                            targetPerson.PMH.Observations.Add(co);
                        }
                    }
                }
                else
                {
                    ClincalObservation co = new ClincalObservation(targetPerson.PMH);
                    co.ClinicalObservation_disease = coText;
                    co.ClinicalObservation_ageDiagnosis = coAgeDx;
                    targetPerson.PMH.Observations.Add(co);
                }
            }

            //////////////////////////
            // Cause of Death
            //////////////////////////
            XPathNavigator cdNav = personNode.SelectSingleNode(@"subjectOf2/clinicalObservation[sourceOf[@typeCode='CAUS']/clinicalObservation/code[(@displayName='death') or (@code='419620001')]]/code[1]");
            if (cdNav != null) {
                string cdText = cdNav.Evaluate("string(@displayName)").ToString();
                string cdCode = cdNav.Evaluate("string(@code)").ToString();
                string cdCodeSystem = cdNav.Evaluate("string(@codeSystemName)").ToString();
                string cd_hra_tag = riskMean_rootNode.Evaluate("string(row[codeSystem/.='" + cdCodeSystem + "'][code/.='" + cdCode + "']/Mgh/.)").ToString();
                if (string.IsNullOrEmpty(cd_hra_tag) == false)
                {
                    targetPerson.causeOfDeath = cd_hra_tag;
                }
                else
                {
                    targetPerson.causeOfDeath = cdText;
                }
            }

            //////////////////////////
            // Genetic Testing
            //////////////////////////

            //Panels first
            XPathNodeIterator gtIter = personNode.Select("subjectOf2/geneticLocus");
            List<GeneticTest> panels = new List<GeneticTest>();
            List<string> panelNames = new List<string>();

            foreach (XPathNavigator gtNode in gtIter)
            {
                string locusText = gtNode.Evaluate("string(text/.)").ToString();
                if (string.IsNullOrEmpty(locusText) == false)
                {
                    if (panelNames.Contains(locusText) == false)
                    {
                        GeneticTest new_panel = new GeneticTest(targetPerson.PMH);
                        new_panel.comments = locusText;
                        new_panel.GeneticTest_panelID = 34;
                        panels.Add(new_panel);
                        panelNames.Add(locusText);
                    }
                }
            }
            //then results
            foreach(GeneticTest panel in panels)
            {
                XPathNodeIterator resultIter = personNode.Select("subjectOf2/geneticLocus[text/.='" + panel.comments + "']");
                foreach (XPathNavigator resultNode in resultIter)
                {
                    string geneName = resultNode.Evaluate("string(value/@displayName)").ToString();
                    if (string.IsNullOrEmpty(geneName) == false)
                    {
                        GeneticTestResult result = new GeneticTestResult(panel);
                        result.geneName = geneName;

                        string significance = resultNode.Evaluate("string(component3/sequenceVariation/interpretationCode/@code)").ToString();
                        result.resultSignificance = significance;

                        panel.GeneticTestResults.Add(result);

                    }
                }
                targetPerson.PMH.GeneticTests.Add(panel);
            }
        }
Beispiel #3
0
        public bool Equals(Race p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (race == p.race);
        }