public GeneticTestingRowExpandable(GeneticTestingView geneticTestingView, GeneticTest geneticTest) { this.geneticTestingView = geneticTestingView; this.geneticTest = geneticTest; InitializeComponent(); string dateFormat = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern; if (dateFormat == "M/d/yyyy") { dateFormat = "MM/dd/yyyy"; } dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = dateFormat; if (!geneticTestingView.canModify) { dateTimePicker1.Enabled = false; testMonthComboBox.Enabled = false; testYearComboBox.Enabled = false; //statusComboBox.Enabled = false; deleteButton.Visible = false; addResultButton.Visible = false; } if (this.geneticTest.GeneticTestResults.Count > 0) { this.addResultButton.Enabled = true; this.addResultButton.Visible = true; } if (this.geneticTest.IsASOTest && this.geneticTest.GeneticTestResults.Count < 1) { this.addResultButton.Visible = true; this.addResultButton.Enabled = true; } else if(this.geneticTest.IsASOTest && this.geneticTest.GeneticTestResults.Count>0) { this.addResultButton.Visible = false; this.addResultButton.Enabled = false; } //if (geneticTest.panelID > 0) if (geneticTest.GeneticTestResults.Count > 0) { this.panelComboBox.Enabled = false; } this.geneticTest.AddHandlersWithLoad(GeneticTestChanged, null, GeneticTestPersisted); FillControls(); if (geneticTest.panelID > 0 && geneticTest.GeneticTestResults.Count == 0) { addResultRows(); addResultButton.Enabled = true; } }
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); } }
} // Default constructor for serialization public GeneticTestResult(GeneticTest geneticTest) { owningGeneticTest = geneticTest; }
/**************************************************************************************************/ private void AddGeneticTest_Click(object sender, EventArgs e) { GeneticTest geneticTest = new GeneticTest(pmh); geneticTest.status = "Pending"; HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.Persist = false; pmh.GeneticTests.AddToList(geneticTest, args); noLabel.Visible = false; }
void OrderRow_Finalized(object sender, OrdersView.FinalizedEventArgs e) { //Finalize has been clicked if (order.Order_finalized == 0) { order.Order_finalized = 1; Patient proband = SessionManager.Instance.GetActivePatient(); HraModelChangedEventArgs args = new HraModelChangedEventArgs(this.owningView); int panelID = SessionManager.Instance.MetaData.GeneticTests.GetPanelIDFromName(order.Order_orderDesc); if (panelID > 0) // a genetic test has been ordered { //add the pending gen test to the model PastMedicalHistory pmh = proband.PMH; //GeneticTest geneticTest = (GeneticTest)(pmh.GeneticTests.SingleOrDefault(v => ((GeneticTest)v).panelID == panelID && ((GeneticTest)v).status == "Pending" // && ((GeneticTest)v).GeneticTest_testYear == (order.Order_orderDate.Year).ToString() // && ((GeneticTest)v).GeneticTest_testMonth == (order.Order_orderDate.Month).ToString() // && ((GeneticTest)v).GeneticTest_testDay == (order.Order_orderDate.Day).ToString())); //if (geneticTest == null) //{ //duplicate pending tests are allowed, so ignore commented check above //also, no difference between all "Familial Known Genetic Test"s, regardless of group GeneticTest geneticTest = new GeneticTest(pmh); geneticTest.GeneticTest_status = "Pending"; geneticTest.GeneticTest_panelID = panelID; geneticTest.GeneticTest_testYear = (order.Order_orderDate.Year).ToString(); geneticTest.GeneticTest_testMonth = (order.Order_orderDate.Month).ToString(); geneticTest.GeneticTest_testDay = (order.Order_orderDate.Day).ToString(); pmh.GeneticTests.AddToList(geneticTest, args); //} //else //{ // geneticTest.SignalModelChanged(args); //} } else if (order.Order_orderDesc.Contains("mammo")) { BreastImagingStudy bis = new BreastImagingStudy(); bis.unitnum = proband.unitnum; bis.type = "MammographyHxView"; bis.date = DateTime.Today; bis.imagingType = "MammographyHxView"; bis.status = "Ordered"; proband.breastImagingHx.AddToList(bis, args); } else if (order.Order_orderDesc.Contains("MRI")) { BreastImagingStudy bis = new BreastImagingStudy(); bis.unitnum = proband.unitnum; bis.type = "MRI"; bis.date = DateTime.Today; bis.imagingType = "MRI"; bis.status = "Ordered"; bis.side = "Bilateral"; proband.breastImagingHx.AddToList(bis, args); } else if (order.Order_orderDesc.Contains("Transvaginal Sonography")) { TransvaginalImagingStudy tvs = new TransvaginalImagingStudy(); tvs.unitnum = proband.unitnum; tvs.type = "TVS"; tvs.date = DateTime.Today; tvs.imagingType = "TVS"; tvs.status = "Ordered"; proband.transvaginalImagingHx.AddToList(tvs, args); } else if (order.Order_orderDesc.Contains("CA-125")) { LabResult lr = new LabResult(); lr.unitnum = proband.unitnum; lr.date = DateTime.Today; lr.TestDesc = "CA125"; lr.status = "Ordered"; proband.labsHx.AddToList(lr, args); } } }
/**************************************************************************************************/ private void ProcessGeneticTest(GeneticTest gt) { string label = ""; lock (FamilialVariants) { FamilialVariants = this.proband.FHx.ReloadFamilialVariants(); label = this.proband.FHx.BuildFamilialVariantsLabel(); } pedigreeTitleBlock1.SetVariantLabel(label); }