public GeneticTestingResultRow(GeneticTestResult geneticTestResult, bool canDelete) { this.geneticTestResult = geneticTestResult; this.geneticTestResult.AddHandlersWithLoad(TestResultChanged, null, null); InitializeComponent(); updateUI(); UIUtils.fillComboBoxFromLookups(resultSignificanceComboBox, "tblRiskGeneticTest", "resultSignificance", true); List <String> geneList = SessionManager.Instance.MetaData.GeneticTests.GetGenesInPanel(geneticTestResult.owningGeneticTest.panelID); UIUtils.fillComboBoxFromList(geneNameComboBox, geneList, false); FillDataFromTestResult(geneticTestResult); //deleteButton.Visible = canDelete; geneNameComboBox.Visible = canDelete; geneNameTextBox.Visible = !canDelete; populateMutationComboBoxes(); initialized = true; }
private void FillDataFromTestResult(GeneticTestResult geneticTestResult) { if (geneticTestResult != null) { if (this.InvokeRequired) { FillDataCallback fdc = new FillDataCallback(FillDataFromTestResult); object[] args = new object[1]; args[0] = geneticTestResult; this.Invoke(fdc, args); } else { if (!string.IsNullOrEmpty(geneticTestResult.geneName)) { geneNameComboBox.Text = geneticTestResult.geneName; geneNameTextBox.Text = geneticTestResult.geneName; } else { geneNameTextBox.ReadOnly = false; } mutationNameComboBox.Text = geneticTestResult.mutationName; mutationAAComboBox.Text = geneticTestResult.mutationAA; if (geneticTestResult.resultSignificance != null) { if (resultSignificanceComboBox.Items.Contains(geneticTestResult.resultSignificance) == false) { resultSignificanceComboBox.Items.Add(geneticTestResult.resultSignificance); } } resultSignificanceComboBox.Text = geneticTestResult.resultSignificance; allelicStateComboBox.Text = geneticTestResult.allelicState; commentsTextBox.Text = geneticTestResult.comments; var selection = SessionManager.Instance.MetaData.Mutations .Where(m => ((MutationObject)m).geneName == geneticTestResult.geneName && ((MutationObject)m).mutationDNA == geneticTestResult.mutationName); string lkpresultSignificance = selection.Select(m => ((MutationObject)m).significance).FirstOrDefault(); if (lkpresultSignificance != geneticTestResult.resultSignificance) { //BD - VariantSerive //label1.Visible = true; } else { label1.Visible = false; } } } }
public GeneticTestingASOResultRow(GeneticTestResult geneticTestResult, bool canDelete) { this.geneticTestResult = geneticTestResult; this.geneticTestResult.AddHandlersWithLoad(TestResultChanged, null, null); InitializeComponent(); updateUI(); List <String> geneList = SessionManager.Instance.MetaData.GeneticTests.GetGenesInPanel(geneticTestResult.owningGeneticTest.panelID); FillDataFromTestResult(geneticTestResult); //SaveASOData(); deleteButton.Visible = canDelete; }
public GeneticTestingASOResultRow(GeneticTestResult geneticTestResult, bool canDelete) { this.geneticTestResult = geneticTestResult; this.geneticTestResult.AddHandlersWithLoad(TestResultChanged, null, null); InitializeComponent(); updateUI(); List<String> geneList = SessionManager.Instance.MetaData.GeneticTests.GetGenesInPanel(geneticTestResult.owningGeneticTest.panelID); FillDataFromTestResult(geneticTestResult); //SaveASOData(); deleteButton.Visible = canDelete; }
private void addResultButton_Click(object sender, EventArgs e) { //handles the little '+' button GeneticTestResult geneticTestResult = new GeneticTestResult(geneticTest); geneticTestResult.testInstanceID = geneticTest.instanceID; geneticTest.GeneticTestResults.Add(geneticTestResult); Control toAdd = null; if (this.geneticTest.IsASOTest) { //make this load known mutations or throw the error message if ( !geneticTest.owningPMH.RelativeOwningPMH.owningFHx .HasUniqueNonNegativeGeneticTestResults( geneticTest.owningPMH.RelativeOwningPMH.relativeID)) { MessageBox.Show( "This option is only valid for family histories with a known mutation. " + "Please enter a positive mutation for a relative of this individual before proceeding.", "No known positive mutations in this family.", MessageBoxButtons.OK, MessageBoxIcon.Information); this.addResultButton.Visible = true; this.addResultButton.Enabled = true; return; } else { addResultRows(); } } else { toAdd = new GeneticTestingResultRow(geneticTestResult, true); } flowLayoutPanel1.Controls.Add(toAdd); DoScroll(ScrollEnum.Grow); }
private void FillDataFromTestResult(GeneticTestResult geneticTestResult) { if (geneticTestResult != null) { if (this.InvokeRequired) { FillDataCallback fdc = new FillDataCallback(FillDataFromTestResult); object[] args = new object[1]; args[0] = geneticTestResult; this.Invoke(fdc, args); } else { allelicStateComboBox.Text = geneticTestResult.allelicState; commentsTextBox.Text = geneticTestResult.comments; ASOInfoTextBox.Text = geneticTestResult.GetASOSummary(); ASOResultComboBox.Text = geneticTestResult.ASOResult; } } }
private void addResultRows() { HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.Persist = false; ClearExistingResults(); if (geneticTest.IsASOTest) { this.ResultSignificanceNegativeButton.Enabled = false; this.ResultSignificanceNegativeButton.Visible = false; List <GeneticTestResult> geneticTestResults = geneticTest.owningPMH.RelativeOwningPMH.owningFHx. GetUniqueNonNegativeGeneticTestResults( geneticTest.owningPMH.RelativeOwningPMH.relativeID); geneticTestResults.Sort(gtrc); if (geneticTestResults.Count > 0) { flowLayoutPanel1.Controls.Add(new GeneticTestingASOResultRowHeader()); this.ResultSignificanceNegativeButton.Visible = true; this.ResultSignificanceNegativeButton.Enabled = true; this.ResultSignificanceNegativeButton.Text = "Set results Not Found."; this.addResultButton.Visible = false; this.addResultButton.Enabled = false; } foreach (GeneticTestResult gtr in geneticTestResults) { GeneticTestResult geneticTestResult = new GeneticTestResult(geneticTest); geneticTestResult.geneName = gtr.geneName; geneticTestResult.testInstanceID = geneticTest.instanceID; geneticTestResult.ASOResultSignificance = gtr.resultSignificance; geneticTestResult.ASOMutationName = gtr.mutationName; geneticTestResult.ASOMutationAA = gtr.mutationAA; geneticTestResult.relativeIDofRelative = gtr.owningGeneticTest.owningPMH.RelativeOwningPMH.relativeID; geneticTestResult.instanceIDofRelative = gtr.owningGeneticTest.instanceID; geneticTestResult.ASOResult = "Unknown"; geneticTest.GeneticTestResults.Add(geneticTestResult); GeneticTestingASOResultRow row = new GeneticTestingASOResultRow(geneticTestResult, false); flowLayoutPanel1.Controls.Add(row); } } else { List <String> geneList = SessionManager.Instance.MetaData.GeneticTests.GetGenesInPanel(geneticTest.panelID); if (geneList.Count > 0) { flowLayoutPanel1.Controls.Add(new GeneticTestingResultRowHeader()); this.ResultSignificanceNegativeButton.Visible = true; this.ResultSignificanceNegativeButton.Enabled = true; } geneList.Sort(); foreach (String geneName in geneList) { GeneticTestResult gtr = geneticTest .GeneticTestResults .SingleOrDefault( r => ((GeneticTestResult)r).instanceID == geneticTest.instanceID && ((GeneticTestResult)r).instanceID != 0); if (gtr == null) { gtr = new GeneticTestResult(geneticTest); gtr.testInstanceID = geneticTest.instanceID; } gtr.geneName = geneName; //TODO turn genetic test results into HRAList and use AddToList geneticTest.GeneticTestResults.Add(gtr); Control gtrr = null; if (geneticTest.IsASOTest) { gtrr = new GeneticTestingASOResultRow(gtr, false); } else { gtrr = new GeneticTestingResultRow(gtr, false); } flowLayoutPanel1.Controls.Add(gtrr); } } DoScroll(ScrollEnum.Grow); }
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); } }
private void addResultRows() { HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.Persist = false; ClearExistingResults(); if (geneticTest.IsASOTest) { this.ResultSignificanceNegativeButton.Enabled = false; this.ResultSignificanceNegativeButton.Visible = false; List<GeneticTestResult> geneticTestResults = geneticTest.owningPMH.RelativeOwningPMH.owningFHx. GetUniqueNonNegativeGeneticTestResults( geneticTest.owningPMH.RelativeOwningPMH.relativeID); geneticTestResults.Sort(gtrc); if (geneticTestResults.Count > 0) { flowLayoutPanel1.Controls.Add(new GeneticTestingASOResultRowHeader()); this.ResultSignificanceNegativeButton.Visible = true; this.ResultSignificanceNegativeButton.Enabled = true; this.ResultSignificanceNegativeButton.Text = "Set results Not Found."; this.addResultButton.Visible = false; this.addResultButton.Enabled = false; } foreach (GeneticTestResult gtr in geneticTestResults) { GeneticTestResult geneticTestResult = new GeneticTestResult(geneticTest); geneticTestResult.geneName = gtr.geneName; geneticTestResult.testInstanceID = geneticTest.instanceID; geneticTestResult.ASOResultSignificance = gtr.resultSignificance; geneticTestResult.ASOMutationName = gtr.mutationName; geneticTestResult.ASOMutationAA = gtr.mutationAA; geneticTestResult.relativeIDofRelative = gtr.owningGeneticTest.owningPMH.RelativeOwningPMH.relativeID; geneticTestResult.instanceIDofRelative = gtr.owningGeneticTest.instanceID; geneticTestResult.ASOResult = "Unknown"; geneticTest.GeneticTestResults.Add(geneticTestResult); GeneticTestingASOResultRow row = new GeneticTestingASOResultRow(geneticTestResult, false); flowLayoutPanel1.Controls.Add(row); } } else { List<String> geneList = SessionManager.Instance.MetaData.GeneticTests.GetGenesInPanel(geneticTest.panelID); if (geneList.Count > 0) { flowLayoutPanel1.Controls.Add(new GeneticTestingResultRowHeader()); this.ResultSignificanceNegativeButton.Visible = true; this.ResultSignificanceNegativeButton.Enabled = true; } geneList.Sort(); foreach (String geneName in geneList) { GeneticTestResult gtr = geneticTest .GeneticTestResults .SingleOrDefault( r => ((GeneticTestResult)r).instanceID == geneticTest.instanceID && ((GeneticTestResult)r).instanceID!=0); if (gtr == null) { gtr = new GeneticTestResult(geneticTest); gtr.testInstanceID = geneticTest.instanceID; } gtr.geneName = geneName; //TODO turn genetic test results into HRAList and use AddToList geneticTest.GeneticTestResults.Add(gtr); Control gtrr = null; if (geneticTest.IsASOTest) { gtrr = new GeneticTestingASOResultRow(gtr, false); } else { gtrr = new GeneticTestingResultRow(gtr, false); } flowLayoutPanel1.Controls.Add(gtrr); } } DoScroll(ScrollEnum.Grow); }
/**************************************************************************************************/ private void LoadGeneticTestResults(string patient_unitnum, int relativeID, int instanceId) { using (SqlConnection connection = new SqlConnection(BCDB2.Instance.getConnectionString())) { connection.Open(); SqlCommand cmdProcedure = new SqlCommand("sp_3_LoadgeneticTestResults", connection); cmdProcedure.CommandType = CommandType.StoredProcedure; cmdProcedure.Parameters.Add("@unitnum", SqlDbType.NVarChar); cmdProcedure.Parameters["@unitnum"].Value = patient_unitnum; cmdProcedure.Parameters.Add("@apptid", SqlDbType.Int); cmdProcedure.Parameters["@apptid"].Value = owningPMH.RelativeOwningPMH.owningFHx.proband.apptid; cmdProcedure.Parameters.Add("@relId", SqlDbType.NVarChar); cmdProcedure.Parameters["@relId"].Value = relativeID; cmdProcedure.Parameters.Add("@instanceId", SqlDbType.Int); cmdProcedure.Parameters["@instanceId"].Value = instanceID; try { SqlDataReader reader = cmdProcedure.ExecuteReader(CommandBehavior.CloseConnection); if (reader != null) { while (reader.Read()) { GeneticTestResult geneticTestResult = new GeneticTestResult(this); for (int i = 0; i < reader.FieldCount; i++) { if (reader.IsDBNull(i) == false) { foreach (FieldInfo fi in geneticTestResult.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public)) { string name = fi.Name; if (name == reader.GetName(i)) { SetFieldInfoValue(fi, reader.GetValue(i), geneticTestResult); break; } } } } geneticTestResult.HraState = States.Ready; GeneticTestResults.Add(geneticTestResult); } reader.Close(); } } catch (Exception ex) { Logger.Instance.WriteToLog(ex.ToString()); } } }
public GeneticTestingResultRow(GeneticTestResult geneticTestResult, bool canDelete) { this.geneticTestResult = geneticTestResult; this.geneticTestResult.AddHandlersWithLoad(TestResultChanged, null, null); InitializeComponent(); updateUI(); UIUtils.fillComboBoxFromLookups(resultSignificanceComboBox, "tblRiskGeneticTest", "resultSignificance", true); List<String> geneList = SessionManager.Instance.MetaData.GeneticTests.GetGenesInPanel(geneticTestResult.owningGeneticTest.panelID); UIUtils.fillComboBoxFromList(geneNameComboBox,geneList,false); FillDataFromTestResult(geneticTestResult); //deleteButton.Visible = canDelete; geneNameComboBox.Visible = canDelete; geneNameTextBox.Visible = !canDelete; populateMutationComboBoxes(); initialized = true; }