public void setRelative(Person relative) { if (relative != null) { name.Text = relative.name; relationship.Text = relative.relationship; bloodline.Text = relative.bloodline; if (string.IsNullOrEmpty(bloodline.Text)) { bloodline.Visible = false; bloodlineHeader.Visible = false; } else { bloodline.Visible = true; bloodlineHeader.Visible = true; } age.Text = relative.age; } else { name.Text = ""; relationship.Text = ""; bloodline.Text = ""; bloodline.Visible = false; bloodlineHeader.Visible = false; age.Text = ""; } }
public void setRelative(Person relative) { if (relative != null) { name.Text = string.IsNullOrEmpty(relative.name)?"[Name not provided]":relative.name; relationship.Text = relative.relationship; } else { name.Text = ""; relationship.Text = ""; } }
/**************************************************************************************************/ public FamilyHistoryRelativeRow(Person person) { InitializeComponent(); relative = person; comboBox2.Items.Add(""); comboBox6.Items.Add(""); comboBox8.Items.Add(""); //foreach (DiseaseObject o in SessionManager.Instance.MetaData.Diseases) //{ // if (o.groupingName == "Breast/Ovarian") // { // comboBox2.Items.Add(o); // comboBox6.Items.Add(o); // comboBox8.Items.Add(o); // } //} SetDeleteButton(); }
/**************************************************************************************************/ public void SetActivePatient(string unitnum, int apptid) { if (activePatient != null) { activePatient.ReleaseListeners(this); activePatient.Tasks.ReleaseListeners(this); } activePatient = new Patient(unitnum); activePatient.apptid = apptid; selectedRelative = (Person)activePatient; if (HttpContext.Current == null) // Silicus: LoadObject has Async calls. activePatient.LoadObject(); if (NewActivePatient != null) NewActivePatient(this, new NewActivePatientEventArgs(activePatient, securityContext)); RelativeSelectedEventArgs args = new RelativeSelectedEventArgs(selectedRelative, securityContext); if (RelativeSelected != null) RelativeSelected(args); }
/**************************************************************************************************/ public void SetActivePatientNoCallback(string unitnum, int apptid) { activePatient = new Patient(unitnum); activePatient.apptid = apptid; selectedRelative = (Person)activePatient; if (activePatient.HraState != HraObject.States.Ready) { activePatient.BackgroundLoadWork(); activePatient.HraState = HraObject.States.Ready; } }
public void EditSurvey(RiskApps3.Model.PatientRecord.Patient proband, ViewModels.FamilyHistoryRelative obj) { RiskApps3.Model.PatientRecord.PastMedicalHistory pmh = new RiskApps3.Model.PatientRecord.PastMedicalHistory(proband); Person per = proband.FHx.Relatives.Where(p => p.relativeID == obj.RelativeId).FirstOrDefault(); per.vitalStatus = obj.VitalStatus; per.relationship = obj.Relationship; per.age = obj.RelativeAge; HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.updatedMembers.Add(per.GetMemberByName("vitalStatus")); //args.updatedMembers.Add(per.GetMemberByName("relationship")); args.updatedMembers.Add(per.GetMemberByName("age")); per.BackgroundPersistWork(args); relative = per; relative.PMH.BackgroundLoadWork(); pmh = relative.PMH; SessionManager.Instance.MetaData.Diseases.BackgroundListLoad(); relative.PMH.BackgroundLoadWork(); for (int i = 0; i < 3; i++) { ClincalObservation co = new ClincalObservation(); if (i < pmh.Observations.Count) { co = (ClincalObservation)pmh.Observations[i]; } switch (i) { case 0: if (co.instanceID != 0) { co.disease = obj.FirstDx; co.ageDiagnosis = obj.FirstAgeOnset; co.SetDiseaseDetails(); HraModelChangedEventArgs args1 = new HraModelChangedEventArgs(null); args1.updatedMembers.Add(co.GetMemberByName("disease")); args1.updatedMembers.Add(co.GetMemberByName("ageDiagnosis")); co.BackgroundPersistWork(args1); } else { ClincalObservation co1 = new ClincalObservation(pmh); co1.disease = obj.FirstDx; co1.ageDiagnosis = obj.FirstAgeOnset; co1.SetDiseaseDetails(); HraModelChangedEventArgs args1 = new HraModelChangedEventArgs(null); args1.updatedMembers.Add(co1.GetMemberByName("disease")); args1.updatedMembers.Add(co1.GetMemberByName("ageDiagnosis")); co1.BackgroundPersistWork(args1); pmh.Observations.AddToList(co1, args1); } break; case 1: if (co.instanceID != 0) { co.disease = obj.SecondDx; co.ageDiagnosis = obj.SecondAgeOnset; co.SetDiseaseDetails(); HraModelChangedEventArgs args1 = new HraModelChangedEventArgs(null); args1.updatedMembers.Add(co.GetMemberByName("disease")); args1.updatedMembers.Add(co.GetMemberByName("ageDiagnosis")); co.BackgroundPersistWork(args1); } else { ClincalObservation co1 = new ClincalObservation(pmh); co1.disease = obj.SecondDx; co1.ageDiagnosis = obj.SecondAgeOnset; co1.SetDiseaseDetails(); HraModelChangedEventArgs args1 = new HraModelChangedEventArgs(null); args1.updatedMembers.Add(co1.GetMemberByName("disease")); args1.updatedMembers.Add(co1.GetMemberByName("ageDiagnosis")); co1.BackgroundPersistWork(args1); pmh.Observations.AddToList(co1, args1); } break; case 2: if (co.instanceID != 0) { co.disease = obj.ThirdDx; co.ageDiagnosis = obj.ThirdAgeOnset; co.SetDiseaseDetails(); HraModelChangedEventArgs args1 = new HraModelChangedEventArgs(null); args1.updatedMembers.Add(co.GetMemberByName("disease")); args1.updatedMembers.Add(co.GetMemberByName("ageDiagnosis")); co.BackgroundPersistWork(args1); } else { ClincalObservation co1 = new ClincalObservation(pmh); co1.disease = obj.ThirdDx; co1.ageDiagnosis = obj.ThirdAgeOnset; co1.SetDiseaseDetails(); HraModelChangedEventArgs args1 = new HraModelChangedEventArgs(null); args1.updatedMembers.Add(co1.GetMemberByName("disease")); args1.updatedMembers.Add(co1.GetMemberByName("ageDiagnosis")); co1.BackgroundPersistWork(args1); pmh.Observations.AddToList(co1, args1); } break; default: break; } } }
/**************************************************************************************************/ private void InitSelectedRelative() { // get selected relative object from session manager selectedRelative = SessionManager.Instance.GetSelectedRelative(); if (selectedRelative != null) { selectedRelative.AddHandlersWithLoad(activeRelativeChanged, activeRelativeLoaded, null); FillControls(); } }
/// <summary> /// Traverse the owningFHx to see if this person is a parent. jdg 11/30/15 /// </summary> /// <param name="p">Person object</param> /// <returns>true if there are children, false otherwise</returns> private bool relativeHasChildren(Person p) { foreach (Person pp in p.owningFHx) { if((pp.fatherID == p.relativeID) || (pp.motherID == p.relativeID)) { return true; } } return false; }
/**************************************************************************************************/ public void SetSelection(Person person) { if (model != null) { model.Selected.Clear(); foreach (PedigreeIndividual pi in model.individuals) { if (pi.HraPerson == person) { pi.Selected = true; if (model.Selected.Contains(pi) == false) model.Selected.Add(pi); } else { pi.Selected = false; } } } }
/**************************************************************************************************/ private void InitSelectedRelative() { flowLayoutPanel1.Controls.Clear(); selectedRelative = SessionManager.Instance.GetSelectedRelative(); if (selectedRelative != null) { this.newTestButton.Enabled = true; selectedRelative.AddHandlersWithLoad(selectedRelativeChanged, selectedRelativeLoaded, null); } else { this.newTestButton.Enabled = false; relativeHeader1.setRelative(null); } }
/**********************************************************************/ public static void AddUnitnumToCommand(Person p, SqlCommand c) { c.Parameters.Add("@patientUnitnum", SqlDbType.NVarChar); if (p.relativeID != 1) c.Parameters["@patientUnitnum"].Value = p.owningFHx.proband.unitnum; else { Patient patient = (Patient)p; c.Parameters["@patientUnitnum"].Value = patient.unitnum; } }
public EthnicBackground(Person owner) { person = owner; constructor_args = new object[] {this}; }
public RiskProfile(Person owner) { OwningPerson = owner; if (owner is Patient) { BracproCancerRisk = new BracproCancerRiskList((Patient)owner); MmrproCancerRiskList = new MmrproCancerRiskList((Patient)owner); GailModel = new Gail((Patient)owner); ClausModel = new Claus((Patient)owner); TyrerCuzickModel = new TyrerCuzick((Patient)owner); TyrerCuzickModel_v7 = new TyrerCuzick_v7((Patient)owner); CCRATModel = new CCRAT((Patient)owner); NCCNGuideline = new NCCN((Patient)owner); } }
public void AddRelative(RiskApps3.Model.PatientRecord.Patient proband, ViewModels.FamilyHistoryRelative obj) { /*==============================*/ RiskApps3.Model.PatientRecord.FHx.FamilyHistory FHX = new RiskApps3.Model.PatientRecord.FHx.FamilyHistory(proband); proband.FHx.BackgroundListLoad(); string relationship = ""; string bloodline = ""; int count = 1; switch (obj.Relationship) { case "Son": case "Daughter": case "Brother": case "Sister": case "Cousin": case "Cousin (Male)": case "Cousin (Female)": case "Niece": case "Nephew": case "Other": case "Other (Male)": case "Other (Female)": relationship = obj.Relationship; break; case "Aunt - Maternal": relationship = "Aunt"; bloodline = "Maternal"; break; case "Aunt - Paternal": relationship = "Aunt"; bloodline = "Paternal"; break; case "Uncle - Maternal": relationship = "Uncle"; bloodline = "Maternal"; break; case "Uncle - Paternal": relationship = "Uncle"; bloodline = "Paternal"; break; } if (relationship.Length > 0) { string new_rel_type; List<Person> retval = new List<Person>(); RelationshipEnum re = Relationship.Parse(relationship); GenderEnum ge = Relationship.getGenderFromRelationshipType(re); if (Relationship.isOffspring(re)) { Person newSpouse = null; foreach (Person q in proband.FHx) { if (q.relationshipOther == "Spouse of Self") { newSpouse = q; break; } } if (newSpouse == null) { newSpouse = proband.FHx.CreateSpouse(proband); HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.updatedMembers.Add(newSpouse.GetMemberByName("relativeID")); // Edit And save args.updatedMembers.Add(newSpouse.GetMemberByName("relationship")); args.updatedMembers.Add(newSpouse.GetMemberByName("relationshipOther")); //args.updatedMembers.Add(newSpouse.GetMemberByName("bloodline")); args.updatedMembers.Add(newSpouse.GetMemberByName("motherID")); args.updatedMembers.Add(newSpouse.GetMemberByName("fatherID")); args.updatedMembers.Add(newSpouse.GetMemberByName("gender")); //args.updatedMembers.Add(newSpouse.GetMemberByName("vitalStatus")); args.updatedMembers.Add(newSpouse.GetMemberByName("twinID")); args.updatedMembers.Add(newSpouse.GetMemberByName("x_position")); args.updatedMembers.Add(newSpouse.GetMemberByName("y_position")); args.updatedMembers.Add(newSpouse.GetMemberByName("x_norm")); args.updatedMembers.Add(newSpouse.GetMemberByName("y_norm")); args.updatedMembers.Add(newSpouse.GetMemberByName("pedigreeGroup")); args.updatedMembers.Add(newSpouse.GetMemberByName("consanguineousSpouseID")); newSpouse.BackgroundPersistWork(args); // newSpouse.BackgroundPersistWork(); //this.AddToList(newSpouse, new HraModelChangedEventArgs(null)); } for (int i = 0; i < count; i++) { proband.FHx.BackgroundListLoad(); int nextID = proband.FHx.GetNewRelativeID(); Person newRel = new Person(proband.FHx); newRel.HraState = RiskApps3.Model.HraObject.States.Ready; newRel.relativeID = nextID; newRel.motherID = 0; newRel.fatherID = 0; newRel.owningFHx = proband.FHx; newRel.vitalStatus = "Alive"; newRel.gender = Gender.toString(ge); newRel.relationship = relationship; newRel.bloodline = bloodline; if (proband.gender == "Female") { newRel.motherID = proband.relativeID; newRel.fatherID = newSpouse.relativeID; } else { newRel.motherID = newSpouse.relativeID; newRel.fatherID = proband.relativeID; } HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.updatedMembers.Add(newRel.GetMemberByName("relativeID")); // Edit And save args.updatedMembers.Add(newRel.GetMemberByName("relationship")); args.updatedMembers.Add(newRel.GetMemberByName("bloodline")); args.updatedMembers.Add(newRel.GetMemberByName("motherID")); args.updatedMembers.Add(newRel.GetMemberByName("fatherID")); args.updatedMembers.Add(newRel.GetMemberByName("gender")); args.updatedMembers.Add(newRel.GetMemberByName("vitalStatus")); args.updatedMembers.Add(newRel.GetMemberByName("twinID")); args.updatedMembers.Add(newRel.GetMemberByName("x_position")); args.updatedMembers.Add(newRel.GetMemberByName("y_position")); args.updatedMembers.Add(newRel.GetMemberByName("x_norm")); args.updatedMembers.Add(newRel.GetMemberByName("y_norm")); args.updatedMembers.Add(newRel.GetMemberByName("pedigreeGroup")); args.updatedMembers.Add(newRel.GetMemberByName("consanguineousSpouseID")); newRel.BackgroundPersistWork(args); //this.AddToList(newRel, new HraModelChangedEventArgs(null)); retval.Add(newRel); } //AddChild(proband, false, count, ge); //List<Person> newFolks = AddChild(proband, false, count, ge); //foreach (Person np in newFolks) //{ // retval.Add(np); // //np.SignalModelChanged(new HraModelChangedEventArgs(null)); //} } else { for (int i = 0; i < count; i++) { int nextID = proband.FHx.GetNewRelativeID(); Person newRel = new Person(proband.FHx); newRel.HraState = RiskApps3.Model.HraObject.States.Ready; newRel.relativeID = nextID; newRel.motherID = 0; newRel.fatherID = 0; newRel.owningFHx = proband.FHx; newRel.vitalStatus = "Alive"; newRel.gender = Gender.toString(ge); newRel.relationship = relationship; newRel.bloodline = bloodline; proband.FHx.SetIDsFromRelationship(ref newRel); HraModelChangedEventArgs args = new HraModelChangedEventArgs(null); args.updatedMembers.Add(newRel.GetMemberByName("relativeID")); // Edit And save args.updatedMembers.Add(newRel.GetMemberByName("relationship")); args.updatedMembers.Add(newRel.GetMemberByName("bloodline")); args.updatedMembers.Add(newRel.GetMemberByName("motherID")); args.updatedMembers.Add(newRel.GetMemberByName("fatherID")); args.updatedMembers.Add(newRel.GetMemberByName("gender")); args.updatedMembers.Add(newRel.GetMemberByName("vitalStatus")); args.updatedMembers.Add(newRel.GetMemberByName("twinID")); args.updatedMembers.Add(newRel.GetMemberByName("x_position")); args.updatedMembers.Add(newRel.GetMemberByName("y_position")); args.updatedMembers.Add(newRel.GetMemberByName("x_norm")); args.updatedMembers.Add(newRel.GetMemberByName("y_norm")); args.updatedMembers.Add(newRel.GetMemberByName("pedigreeGroup")); args.updatedMembers.Add(newRel.GetMemberByName("consanguineousSpouseID")); newRel.BackgroundPersistWork(args); /* proband.FHx.AddToList(newRel, new HraModelChangedEventArgs(null)); */ retval.Add(newRel); } } } }
public List<ViewModels.FamilyHistoryRelative> GetFamilyHistoryRelative(string unitnum, int apptid) { string assignedBy = ""; if (SessionManager.Instance.ActiveUser != null) { if (string.IsNullOrEmpty(SessionManager.Instance.ActiveUser.ToString()) == false) { assignedBy = SessionManager.Instance.ActiveUser.ToString(); } } string _userlogin = SessionManager.Instance.ActiveUser.userLogin; SessionManager.Instance.SetActivePatient(unitnum, apptid); SessionManager.Instance.GetActivePatient().BackgroundLoadWork(); RiskApps3.Model.PatientRecord.Patient proband = SessionManager.Instance.GetActivePatient(); RiskApps3.Model.PatientRecord.PastMedicalHistory pmh = new RiskApps3.Model.PatientRecord.PastMedicalHistory(proband); RiskApps3.Model.PatientRecord.FHx.FamilyHistory FHX = new RiskApps3.Model.PatientRecord.FHx.FamilyHistory(proband) ; proband.FHx.BackgroundListLoad(); /* RiskApps3.Model.PatientRecord.Person relative1 = new RiskApps3.Model.PatientRecord.Person(proband.FHx); relative1.BackgroundLoadWork(); */ //RiskApps3.Model.PatientRecord.FHx.FamilyHistory proband = SessionManager.Instance.GetActivePatient().FHx; List<ViewModels.FamilyHistoryRelative> lst = new List<VM.FamilyHistoryRelative>(); //foreach (Person p in proband.FHx.Relatives) //foreach (Person p in FHX.Relatives) foreach (Person p in proband.FHx.Relatives) { ViewModels.FamilyHistoryRelative obj = new ViewModels.FamilyHistoryRelative(); //Person relative = p; relative = p; obj.Relationship = ""; // pmh = relative.PMH; if (string.IsNullOrEmpty(relative.bloodline) || relative.relationship.ToLower() == "mother" || relative.relationship.ToLower() == "father") { if (relative.relationship.ToLower() != "other") obj.Relationship = relative.relationship; } else { if (relative.bloodline.ToLower() != "unknown" && relative.bloodline.ToLower() != "both") obj.Relationship = relative.bloodline + " " + relative.relationship; else obj.Relationship = relative.relationship; } if (obj.Relationship.Length == 0) { if (!string.IsNullOrEmpty(relative.relationshipOther)) { obj.Relationship = relative.relationshipOther; } } obj.RelativeAge = relative.age; obj.VitalStatus = relative.vitalStatus; obj.RelativeId = relative.relativeID; relative.PMH.BackgroundLoadWork(); pmh = relative.PMH; obj.DeleteFlag = SetDeleteButtonFlag(relative); for (int i = 0; i < pmh.Observations.Count; i++) { ClincalObservation co = (ClincalObservation)pmh.Observations[i]; switch (i) { case 0: obj.FirstDx = co.disease; obj.FirstAgeOnset= co.ageDiagnosis; break; case 1: obj.SecondDx = co.disease; obj.SecondAgeOnset= co.ageDiagnosis; break; case 2: obj.ThirdDx = co.disease; obj.ThirdAgeOnset= co.ageDiagnosis; break; default: break; } } /**/ lst.Add(obj); } return lst; } public List<VM.Tasks> GetTasks(int InstitutionId, string unitnum) { if (InstitutionId != null) { _institutionId = InstitutionId; //SetUserSession(); Patient p = new Patient(); p.unitnum = unitnum; var list = new TaskList(p); list.BackgroundListLoad(); return list.FromRATaskList(); } return new List<VM.Tasks>(); } /// <summary> /// for loading Test patient page /// </summary> /// <returns></returns> public VM.TestPatient LoadCreateTestPatients() { VM.TestPatient tp = new VM.TestPatient(); TestPatientManager Tpm = new TestPatientManager(); tp.Surveys = Tpm.GetSurveys(); tp.Clinics = GetClinicList(); tp.InitateTestPatients = Tpm.InitiateTestPatients(); return tp; } /// <summary> /// To Show Risk Score on Click of Run Risk Models Button. It calculates Risk Score /// </summary> /// <param name="apptid">Appointment Id</param> /// <param name="MRN">MRN Number</param> /// <returns></returns> public VM.RiskScore RiskCalculateAndRunAutomation(int apptid, string MRN) { Patient proband = CalculateRiskAndRunAutomation(apptid, MRN); proband.RP.LoadFullObject(); VM.RiskScore RS = RiskScoreMapper.ToRiskScore(proband.RP); RS.ApptId = apptid; RS.MRN = MRN; return RS; } /// <summary> ///To show Risk Score on Click of Risk Calculation /// </summary> /// <param name="apptid">Appointment Id</param> /// <param name="MRN">MRN Number</param> /// <returns>Risk Score Model</returns> public VM.RiskScore RiskScore(int apptid, string MRN) { SessionManager.Instance.SetActivePatient(MRN, apptid); Patient proband = SessionManager.Instance.GetActivePatient(); proband.RP.LoadFullObject(); VM.RiskScore RS = RiskScoreMapper.ToRiskScore(proband.RP); RS.ApptId = apptid; RS.MRN = MRN; return RS; } /// <summary> /// To do process of Run Automation Documents /// </summary> /// <param name="InstitutionId">Institution Id</param> /// <param name="apptid">Appointment Id</param> /// <param name="MRN">MRN Number</param> /// <returns></returns> public FileInfo RunAutomationDocuments(int InstitutionId, int apptid, string MRN) { Patient proband = CalculateRiskAndRunAutomation(apptid, MRN); return proband.file; } /// <summary> /// To Save Appointments /// </summary> /// <param name="Appt">Appointment Object to Save</param> /// <param name="InstitutionId">Institution Id</param> public void SaveAppointments(VM.Appointment Appt, int InstitutionId) { SaveAppointments(Appt); UpdateMarkAsComplete(Appt, InstitutionId); } public string SaveImage(string base64, int _institutionId, string _userlogin, int apptid, string PedigreeImageSavePath) { string _ImagePath = string.Empty; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Convert.FromBase64String(base64))) { using (Bitmap bm2 = new Bitmap(ms)) { // PedigreeImagePath = System.Web.Serv string _ImageName = _institutionId.ToString() + "_" + _userlogin + "_" + apptid.ToString() + ".png"; bm2.Save(PedigreeImageSavePath + _ImageName); _ImagePath = _ImageName; } } return _ImagePath; } public void SaveSurvey(string unitnum, int apptid, ViewModels.FamilyHistoryRelative obj , int type ) { SessionManager.Instance.SetActivePatient(unitnum, apptid); SessionManager.Instance.GetActivePatient().BackgroundLoadWork(); RiskApps3.Model.PatientRecord.Patient proband = SessionManager.Instance.GetActivePatient(); proband.FHx.BackgroundListLoad(); if (type == 0) { AddRelative(proband, obj); } else if (type == 1) { EditSurvey(proband, obj); } else { DeleteSurvey(proband, obj); } } public bool SetDeleteButtonFlag(Person relative) { bool retval = true; if (relative == null) return false ; if (relative.relativeID < 8) { retval = false; } else { foreach (Person p in relative.owningFHx) { if (p.motherID == relative.relativeID || p.fatherID == relative.relativeID) { retval = false; break; } } } return retval; } public string ShowPedigreeImage(int _institutionId, string unitnum, int apptid, string PedigreeImageSavePath) { int Width = 625; int Height = 625; string _ImagePath = string.Empty; string assignedBy = ""; if (SessionManager.Instance.ActiveUser != null) { if (string.IsNullOrEmpty(SessionManager.Instance.ActiveUser.ToString()) == false) { assignedBy = SessionManager.Instance.ActiveUser.ToString(); } } string _userlogin = SessionManager.Instance.ActiveUser.userLogin; SessionManager.Instance.SetActivePatient(unitnum, apptid); RiskApps3.Model.PatientRecord.Patient proband = SessionManager.Instance.GetActivePatient(); // TODO: Check this!! PedigreeGenerator pg = new PedigreeGenerator(Width, Height, proband); Bitmap bmp; if (proband != null) { bmp = pg.GeneratePedigreeImage(proband); } else { bmp = pg.GeneratePedigreeImage(); } System.IO.MemoryStream stream = new System.IO.MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png); var base64Data = Convert.ToBase64String(stream.ToArray()); /* _ImagePath = SaveImage(base64Data, _institutionId, _userlogin, apptid, PedigreeImageSavePath); return _ImagePath; */ return base64Data; }
public AppointmentService(Person person) { relative = person; }
/**************************************************************************************************/ public void SetActiveRelative(HraView sender, Person person) { //Console.Out.WriteLine(DateTime.Now.ToLongTimeString() + "\tNew Active Relative " + person.relativeID.ToString() + " set by " + sender.ToString()); selectedRelative = person; if (RelativeSelected != null) { RelativeSelectedEventArgs args = new RelativeSelectedEventArgs(selectedRelative, securityContext); args.sendingView = sender; RelativeSelected(args); } }
public static Patient processHL7Import(int apptid, string hl7, string riskMeaningsXml, string HL7Relationships) { Patient targetPatient = null; StringReader sr = new StringReader(hl7); XmlTextReader tx = new XmlTextReader(sr); XPathDocument docNav = new XPathDocument(tx); XPathNavigator nav = docNav.CreateNavigator(); XPathNavigator patientNode = nav.SelectSingleNode("//patient"); StringReader riskMean_sr = new StringReader(riskMeaningsXml); XmlTextReader riskMean_tx = new XmlTextReader(riskMean_sr); XPathDocument riskMean_docNav = new XPathDocument(riskMean_tx); XPathNavigator riskMean_nav = riskMean_docNav.CreateNavigator(); XPathNavigator riskMean_rootNode = riskMean_nav.SelectSingleNode("//root"); StringReader relations_sr = new StringReader(HL7Relationships); XmlTextReader relations_tx = new XmlTextReader(relations_sr); XPathDocument relations_docNav = new XPathDocument(relations_tx); XPathNavigator relations_nav = relations_docNav.CreateNavigator(); XPathNavigator relations_rootNode = relations_nav.SelectSingleNode("//root"); //////////////////////////////////////////////// // Patient Node //////////////////////////////////////////////// if (patientNode != null) { //grab the unitnum and create new patient object //next line edited by PRB 2015.04.14; must include patientPerson at start to be looking at correct id string newMRN = patientNode.Evaluate("string(patientPerson/id/@extension)").ToString(); if (string.IsNullOrEmpty(newMRN) == false) { targetPatient = new Patient(newMRN); targetPatient.apptid = apptid; } else return targetPatient; XPathNavigator patientPerson = patientNode.SelectSingleNode("patientPerson"); if (patientPerson != null) { int nextRelIdIfNeeded = 1; Person p = targetPatient; ProcessPersonNode(patientNode, riskMean_rootNode, ref p, true, ref nextRelIdIfNeeded); targetPatient.FHx.Add(p); XPathNodeIterator relativesIter = patientPerson.Select("relative"); foreach (XPathNavigator relativeNode in relativesIter) { p = new Person(targetPatient.FHx); string hl7relCode = relativeNode.Evaluate("string(code/@code)").ToString(); string hraRelCode = relations_rootNode.Evaluate("string(Relationship[HL7Code/.='" + hl7relCode + "']/Mgh/.)").ToString(); string hraBloodlineCode = relations_rootNode.Evaluate("string(Relationship[HL7Code/.='" + hl7relCode + "']/MghBloodline/.)").ToString(); p.relationship = hraRelCode; p.bloodline = hraBloodlineCode; ProcessPersonNode(relativeNode, riskMean_rootNode, ref p, false, ref nextRelIdIfNeeded); targetPatient.FHx.Add(p); } Dictionary<int, int> idMap = new Dictionary<int, int>(); int new_rel_id = 8; foreach(Person rel in targetPatient.FHx) { switch(rel.relationship) { case "Self": idMap.Add(rel.relativeID, 1); break; case "Mother": idMap.Add(rel.relativeID, 2); break; case "Father": idMap.Add(rel.relativeID, 3); break; case "Grandmother": if (string.Compare(rel.bloodline, "maternal", true) == 0) { idMap.Add(rel.relativeID, 4); } else if (string.Compare(rel.bloodline, "paternal", true) == 0) { idMap.Add(rel.relativeID, 6); } break; case "Grandfather": if (string.Compare(rel.bloodline, "maternal", true) == 0) { idMap.Add(rel.relativeID, 5); } else if (string.Compare(rel.bloodline, "paternal", true) == 0) { idMap.Add(rel.relativeID, 7); } break; default: idMap.Add(rel.relativeID, new_rel_id); new_rel_id++; break; } } foreach (Person rel in targetPatient.FHx) { rel.relativeID = idMap[rel.relativeID]; if (rel.motherID > 0) rel.motherID = idMap[rel.motherID]; if (rel.fatherID > 0) rel.fatherID = idMap[rel.fatherID]; } targetPatient.FHx.AddCoreRelatives(); } } return targetPatient; }
/**************************************************************************************************/ internal void ClearActivePatient() { activePatient = null; selectedRelative = null; if (NewActivePatient != null) NewActivePatient(this, new NewActivePatientEventArgs(activePatient,securityContext)); }
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 InitSelectedRelative() { // get selected relative object from session manager if (selectedRelative != null) selectedRelative.ReleaseListeners(this); selectedRelative = SessionManager.Instance.GetSelectedRelative(); ClearUI(); if (selectedRelative != null) { selectedRelative.AddHandlersWithLoad(selectedRelativeChanged, selectedrelativeLoaded, null); selectedRelative.Ethnicity.AddHandlersWithLoad(EthnicityListChanged, EthnicityListLoaded, null); selectedRelative.Nationality.AddHandlersWithLoad(NationalityChanged, NationalityLoaded, null); } else { this.Enabled = false; } }
public NationalityList(Person owner) { person = owner; constructor_args = new object[] {this}; }
internal void SetPersonPosition(Person person) { foreach (PedigreeIndividual pi in model.individuals) { if (pi.HraPerson == person) { SetPersonFromHraValues(pi, model); } } }
/**************************************************************************************************/ private void SelectedIndividual(Person individual) { SessionManager.Instance.SetActiveRelative(this,individual); }
public RelativeSelectedEventArgs(Person p_selectedRelative, SecurityContext p_securityContext) : base(null) { selectedRelative = p_selectedRelative; }
public PastMedicalHistory(Person owner) { RelativeOwningPMH = owner; Observations = new ClinicalObservationList(this); GeneticTests = new GeneticTestList(this); }