Exemplo n.º 1
0
        ///<summary>Returns the name of the disease, whether hidden or not.</summary>
        public static string GetName(long diseaseDefNum)
        {
            //No need to check RemotingRole; no call to db.
            DiseaseDef diseaseDef = GetFirstOrDefault(x => x.DiseaseDefNum == diseaseDefNum);

            return(diseaseDef == null ? "" : diseaseDef.DiseaseName);
        }
Exemplo n.º 2
0
        ///<summary>Surround with try/catch, because it will throw an exception if any patient is using this def.</summary>
        public static void Delete(DiseaseDef def)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), def);
                return;
            }
            string command = "SELECT LName,FName,patient.PatNum FROM patient,disease WHERE "
                             + "patient.PatNum=disease.PatNum "
                             + "AND disease.DiseaseDefNum='" + POut.Long(def.DiseaseDefNum) + "' "
                             + "GROUP BY patient.PatNum";
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                string s = Lans.g("DiseaseDef", "Not allowed to delete. Already in use by ") + table.Rows.Count.ToString()
                           + " " + Lans.g("DiseaseDef", "patients, including") + " \r\n";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 5)
                    {
                        break;
                    }
                    s += table.Rows[i][0].ToString() + ", " + table.Rows[i][1].ToString() + "\r\n";
                }
                throw new ApplicationException(s);
            }
            command = "DELETE FROM diseasedef WHERE DiseaseDefNum =" + POut.Long(def.DiseaseDefNum);
            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.DiseaseDef, def.DiseaseDefNum);
        }
Exemplo n.º 3
0
		///<summary></summary>
		public static void Update(DiseaseDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
				return;
			}
			Crud.DiseaseDefCrud.Update(def);
		}
Exemplo n.º 4
0
		///<summary></summary>
		public static long Insert(DiseaseDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				def.DiseaseDefNum=Meth.GetLong(MethodBase.GetCurrentMethod(),def);
				return def.DiseaseDefNum;
			}
			return Crud.DiseaseDefCrud.Insert(def);
		}
Exemplo n.º 5
0
 ///<summary>Surround with try/catch, because it will throw an exception if any patient is using this def.</summary>
 public static void Delete(DiseaseDef def)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
         return;
     }
     string command="SELECT LName,FName,patient.PatNum FROM patient,disease WHERE "
         +"patient.PatNum=disease.PatNum "
         +"AND disease.DiseaseDefNum='"+POut.Long(def.DiseaseDefNum)+"' "
         +"GROUP BY patient.PatNum";
     DataTable table=Db.GetTable(command);
     if(table.Rows.Count>0){
         string s=Lans.g("DiseaseDef","Not allowed to delete. Already in use by ")+table.Rows.Count.ToString()
             +" "+Lans.g("DiseaseDef","patients, including")+" \r\n";
         for(int i=0;i<table.Rows.Count;i++){
             if(i>5){
                 break;
             }
             s+=table.Rows[i][0].ToString()+", "+table.Rows[i][1].ToString()+"\r\n";
         }
         throw new ApplicationException(s);
     }
     command="DELETE FROM diseasedef WHERE DiseaseDefNum ="+POut.Long(def.DiseaseDefNum);
     Db.NonQ(command);
     DeletedObjects.SetDeleted(DeletedObjectType.DiseaseDef,def.DiseaseDefNum);
 }
Exemplo n.º 6
0
        public static bool ContainsIcd10(string icd10Code, long excludeDefNum)
        {
            //No need to check RemotingRole; no call to db.
            DiseaseDef diseaseDef = GetFirstOrDefault(x => x.Icd10Code == icd10Code && x.DiseaseDefNum != excludeDefNum);

            return(diseaseDef != null);
        }
Exemplo n.º 7
0
        ///<summary>Returns the diseaseDefNum that exactly matches the specified string.  Will return 0 if no match.
        ///Set matchHidden to true to match hidden diseasedefs as well.</summary>
        public static long GetNumFromName(string diseaseName, bool matchHidden)
        {
            //No need to check RemotingRole; no call to db.
            DiseaseDef diseaseDef = _diseaseDefCache.GetFirstOrDefault(x => x.DiseaseName == diseaseName, !matchHidden);

            return((diseaseDef == null) ? 0 : diseaseDef.DiseaseDefNum);
        }
Exemplo n.º 8
0
 ///<summary>Sorts alphabetically by DiseaseName, then by PK.</summary>
 public static int SortAlphabetically(DiseaseDef x, DiseaseDef y)
 {
     if (x.DiseaseName != y.DiseaseName)
     {
         return(x.DiseaseName.CompareTo(y.DiseaseName));
     }
     return(x.DiseaseDefNum.CompareTo(y.DiseaseDefNum));
 }
Exemplo n.º 9
0
 public static int SortItemOrder(DiseaseDef x, DiseaseDef y)
 {
     if (x.ItemOrder != y.ItemOrder)
     {
         return(x.ItemOrder.CompareTo(y.ItemOrder));
     }
     return(x.DiseaseDefNum.CompareTo(y.DiseaseDefNum));
 }
Exemplo n.º 10
0
        ///<summary>Used by MoveUp and MoveDown.</summary>
        private static void SetOrder(int mySelNum, int myItemOrder)
        {
            //No need to check RemotingRole; no call to db.
            DiseaseDef temp = ListLong[mySelNum];

            temp.ItemOrder = myItemOrder;
            DiseaseDefs.Update(temp);
        }
Exemplo n.º 11
0
 ///<summary></summary>
 public static void Update(DiseaseDef def)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), def);
         return;
     }
     Crud.DiseaseDefCrud.Update(def);
 }
Exemplo n.º 12
0
 private void butAdd_Click(object sender, System.EventArgs e)
 {
     DiseaseDef def=new DiseaseDef();
     def.ItemOrder=DiseaseDefs.ListLong.Length;
     FormDiseaseDefEdit FormD=new FormDiseaseDefEdit(def);
     FormD.IsNew=true;
     FormD.ShowDialog();
     FillGrid();
 }
Exemplo n.º 13
0
		///<summary></summary>
		public FormDiseaseDefEdit(DiseaseDef diseaseDefCur)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			Lan.F(this);
			DiseaseDefCur=diseaseDefCur;
		}
Exemplo n.º 14
0
 ///<summary></summary>
 public static long Insert(DiseaseDef def)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         def.DiseaseDefNum = Meth.GetLong(MethodBase.GetCurrentMethod(), def);
         return(def.DiseaseDefNum);
     }
     return(Crud.DiseaseDefCrud.Insert(def));
 }
Exemplo n.º 15
0
        /*
         * ///<summary>IComparable.CompareTo implementation.  This is used to order disease lists.</summary>
         * public int CompareTo(object obj) {
         *      if(!(obj is DiseaseDef)) {
         *              throw new ArgumentException("object is not a DiseaseDef");
         *      }
         *      DiseaseDef diseaseDef=(DiseaseDef)obj;
         *      return 0;
         *      //need to fix:
         *      //return DiseaseDefs.GetOrder(DiseaseDefNum).CompareTo(DiseaseDefs.GetOrder(diseaseDef.DiseaseDefNum));
         * }*/

        ///<summary></summary>
        public DiseaseDef Copy()
        {
            DiseaseDef d = new DiseaseDef();

            d.DiseaseDefNum = DiseaseDefNum;
            d.DiseaseName   = DiseaseName;
            d.ItemOrder     = ItemOrder;
            d.IsHidden      = IsHidden;
            return(d);
        }
Exemplo n.º 16
0
        ///<summary>Returns the DiseaseDefNum based on SNOMEDCode.  If no match or if SnomedCode is an empty string returns 0.  Only matches SNOMEDCode, not ICD9 or ICD10.</summary>
        public static long GetNumFromSnomed(string SnomedCode)
        {
            //No need to check RemotingRole; no call to db.
            if (SnomedCode == "")
            {
                return(0);
            }
            DiseaseDef diseaseDef = GetFirstOrDefault(x => x.SnomedCode == SnomedCode);

            return(diseaseDef == null ? 0 : diseaseDef.DiseaseDefNum);
        }
Exemplo n.º 17
0
        ///<summary>Returns the name of the disease based on SNOMEDCode, then if no match tries ICD9Code, then if no match returns empty string. Used in EHR Patient Lists.</summary>
        public static string GetNameByCode(string SNOMEDorICD9Code)
        {
            //No need to check RemotingRole; no call to db.
            DiseaseDef diseaseDef = GetFirstOrDefault(x => x.SnomedCode == SNOMEDorICD9Code);

            if (diseaseDef != null)
            {
                return(diseaseDef.DiseaseName);
            }
            diseaseDef = GetFirstOrDefault(x => x.ICD9Code == SNOMEDorICD9Code);
            return(diseaseDef == null ? "" : diseaseDef.DiseaseName);
        }
		private void FormFamilyHealthEdit_Load(object sender,EventArgs e) {
			string[] familyRelationships=Enum.GetNames(typeof(FamilyRelationship));
			for(int i=0;i<familyRelationships.Length;i++) {
				listRelationship.Items.Add(Lan.g("enumFamilyRelationship",familyRelationships[i]));
			}
			listRelationship.SelectedIndex=(int)FamilyHealthCur.Relationship;
			if(FamilyHealthCur.IsNew) {
				return; //Don't need to set any of the info below.  All null.
			}
			DisDefCur=DiseaseDefs.GetItem(FamilyHealthCur.DiseaseDefNum);
			//Validation is done when deleting diseaseDefs to make sure they are not in use by FamilyHealths.
			textProblem.Text=DisDefCur.DiseaseName;
			textSnomed.Text=DisDefCur.SnomedCode;
			textName.Text=FamilyHealthCur.PersonName;
		}
		private void butPick_Click(object sender,EventArgs e) {
			FormDiseaseDefs FormD=new FormDiseaseDefs();
			FormD.IsSelectionMode=true;
			FormD.ShowDialog();
			if(FormD.DialogResult!=DialogResult.OK) {
				return;
			}
			DiseaseDef disDef=DiseaseDefs.GetItem(FormD.SelectedDiseaseDefNum);
			if(disDef.SnomedCode=="") {
				MsgBox.Show(this,"Selection must have a SNOMED CT code associated");
				return;
			}
			textProblem.Text=disDef.DiseaseName;
			textSnomed.Text=disDef.SnomedCode;
			DisDefCur=disDef;
		}
Exemplo n.º 20
0
        ///<summary>Returns the DiseaseDefNum based on SNOMEDCode, then if no match tries ICD9Code, then if no match tries ICD10Code, then if no match returns 0. Used in EHR Patient Lists and when automatically inserting pregnancy Dx from FormVitalsignEdit2014.  Will match hidden diseases.</summary>
        public static long GetNumFromCode(string CodeValue)
        {
            //No need to check RemotingRole; no call to db.
            DiseaseDef diseaseDef = GetFirstOrDefault(x => x.SnomedCode == CodeValue);

            if (diseaseDef != null)
            {
                return(diseaseDef.DiseaseDefNum);
            }
            diseaseDef = GetFirstOrDefault(x => x.ICD9Code == CodeValue);
            if (diseaseDef != null)
            {
                return(diseaseDef.DiseaseDefNum);
            }
            diseaseDef = GetFirstOrDefault(x => x.Icd10Code == CodeValue);
            return(diseaseDef == null ? 0 : diseaseDef.DiseaseDefNum);
        }
Exemplo n.º 21
0
		private void butAdd_Click(object sender,System.EventArgs e) {
			if(!Security.IsAuthorized(Permissions.ProblemEdit)) {
				return;
			}
			DiseaseDef def=new DiseaseDef();
			def.ItemOrder=_listDiseaseDefs.Count;
			FormDiseaseDefEdit FormD=new FormDiseaseDefEdit(def);//also sets ItemOrder correctly if using alphabetical during the insert diseaseDef call.
			FormD.IsNew=true;
			FormD.ShowDialog();
			//Security log entry made inside that form.
			if(FormD.DialogResult!=DialogResult.OK) {
				return;
			}
			//Need to invalidate cache for selection mode so that the new problem shows up.
			if(IsSelectionMode) {
				DataValid.SetInvalid(InvalidType.Diseases);  
			}
			//Items are already in the right order in the DB, re-order in memory list to match
			for(int i=0;i<_listDiseaseDefs.Count;i++) {
				if(_listDiseaseDefs[i].ItemOrder>=def.ItemOrder) {
					_listDiseaseDefs[i].ItemOrder++;
				}
			}
			_listDiseaseDefs.Add(def);
			_listDiseaseDefs.Sort(DiseaseDefs.SortItemOrder);
			//RefreshList();
			IsChanged=true;
			FillGrid();
		}
Exemplo n.º 22
0
		private void FillExistingGrid() {
			gridProbExisting.BeginUpdate();
			gridProbExisting.Columns.Clear();
			ODGridColumn col=new ODGridColumn("Last Modified",100,HorizontalAlignment.Center);
			gridProbExisting.Columns.Add(col);
			col=new ODGridColumn("Date Start",100,HorizontalAlignment.Center);
			gridProbExisting.Columns.Add(col);
			col=new ODGridColumn("Problem Name",200);
			gridProbExisting.Columns.Add(col);
			col=new ODGridColumn("Status",80,HorizontalAlignment.Center);
			gridProbExisting.Columns.Add(col);
			gridProbExisting.Rows.Clear();
			_listProblemCur=Diseases.Refresh(_patCur.PatNum,true);
			List<long> problemDefNums=new List<long>();
			for(int h=0;h<_listProblemCur.Count;h++) {
				if(_listProblemCur[h].DiseaseDefNum > 0) {
					problemDefNums.Add(_listProblemCur[h].DiseaseDefNum);
				}
			}
			_listProblemDefCur=DiseaseDefs.GetMultDiseaseDefs(problemDefNums);
			ODGridRow row;
			DiseaseDef disD;
			for(int i=0;i<_listProblemCur.Count;i++) {
				row=new ODGridRow();
				disD=new DiseaseDef();
				disD=DiseaseDefs.GetItem(_listProblemCur[i].DiseaseDefNum);
				row.Cells.Add(_listProblemCur[i].DateTStamp.ToShortDateString());
				if(_listProblemCur[i].DateStart.Year<1880) {
					row.Cells.Add("");
				}
				else {
					row.Cells.Add(_listProblemCur[i].DateStart.ToShortDateString());
				}
				if(disD.DiseaseName==null) {
					row.Cells.Add("");
				}
				else {
					row.Cells.Add(disD.DiseaseName);
				}
				if(_listProblemCur[i].ProbStatus==ProblemStatus.Active) {
					row.Cells.Add("Active");
				}
				else if(_listProblemCur[i].ProbStatus==ProblemStatus.Resolved) {
					row.Cells.Add("Resolved");
				}
				else {
					row.Cells.Add("Inactive");
				}
				gridProbExisting.Rows.Add(row);
			}
			gridProbExisting.EndUpdate();
		}
Exemplo n.º 23
0
		private void FillReconcileGrid() {
			gridProbReconcile.BeginUpdate();
			gridProbReconcile.Columns.Clear();
			ODGridColumn col=new ODGridColumn("Last Modified",130,HorizontalAlignment.Center);
			gridProbReconcile.Columns.Add(col);
			col=new ODGridColumn("Date Start",100,HorizontalAlignment.Center);
			gridProbReconcile.Columns.Add(col);
			col=new ODGridColumn("Problem Name",260);
			gridProbReconcile.Columns.Add(col);
			col=new ODGridColumn("Notes",300);
			gridProbReconcile.Columns.Add(col);
			col=new ODGridColumn("Status",80,HorizontalAlignment.Center);
			gridProbReconcile.Columns.Add(col);
			col=new ODGridColumn("Is Incoming",50,HorizontalAlignment.Center);
			gridProbReconcile.Columns.Add(col);
			gridProbReconcile.Rows.Clear();
			ODGridRow row;
			DiseaseDef disD;
			for(int i=0;i<_listProblemReconcile.Count;i++) {
				row=new ODGridRow();
				disD=new DiseaseDef();
				if(_listProblemReconcile[i].IsNew) {
					//To find the disease def for new disease, get the index of the matching problem in ListProblemNew, and use that index in ListProblemDefNew because they are 1 to 1 lists.
					disD=ListProblemDefNew[ListProblemNew.IndexOf(_listProblemReconcile[i])];
				}
				for(int j=0;j<_listProblemDefCur.Count;j++) {
					if(_listProblemReconcile[i].DiseaseDefNum > 0 && _listProblemReconcile[i].DiseaseDefNum==_listProblemDefCur[j].DiseaseDefNum) {
						disD=_listProblemDefCur[j];//Gets the diseasedef matching the disease so we can use it to populate the grid
						break;
					}
				}
				row.Cells.Add(DateTime.Now.ToShortDateString());
				if(_listProblemReconcile[i].DateStart.Year<1880) {
					row.Cells.Add("");
				}
				else {
					row.Cells.Add(_listProblemReconcile[i].DateStart.ToShortDateString());
				}
				if(disD.DiseaseName==null) {
					row.Cells.Add("");
				}
				else {
					row.Cells.Add(disD.DiseaseName);
				}
				if(_listProblemReconcile[i]==null) {
					row.Cells.Add("");
				}
				else {
					row.Cells.Add(_listProblemReconcile[i].PatNote);
				}
				if(_listProblemReconcile[i].ProbStatus==ProblemStatus.Active) {
					row.Cells.Add("Active");
				}
				else if(_listProblemReconcile[i].ProbStatus==ProblemStatus.Resolved) {
					row.Cells.Add("Resolved");
				}
				else {
					row.Cells.Add("Inactive");
				}
				row.Cells.Add(_listProblemReconcile[i].IsNew?"X":"");
				gridProbReconcile.Rows.Add(row);
			}
			gridProbReconcile.EndUpdate();
		}
Exemplo n.º 24
0
Arquivo: EhrCCD.cs Projeto: mnisl/OD
		///<summary>Fills listDiseases and listDiseaseDef using the information found in the CCD document xmlDocCcd.  Does NOT insert any records into the db.</summary>
		public static void GetListDiseases(XmlDocument xmlDocCcd,List<Disease> listDiseases,List<DiseaseDef> listDiseaseDef) {
			//The length of listDiseases and listDiseaseDef will be the same. The information in listDiseaseDef might have duplicates.
			//Neither list of objects will be inserted into the db, so there will be no primary or foreign keys.
			List<XmlNode> listProblemActTemplate=GetNodesByTagNameAndAttributes(xmlDocCcd,"templateId","root","2.16.840.1.113883.10.20.22.4.3");// problem act template.
			List<XmlNode> listProbs=GetParentNodes(listProblemActTemplate);
			for(int i=0;i<listProbs.Count;i++) {
				//We have to start fairly high in the tree so that we can get the effective time if it is available.
				List<XmlNode> xmlNodeEffectiveTimes=GetNodesByTagNameAndAttributes(listProbs[i],"effectiveTime");
				DateTime dateTimeEffectiveLow=DateTime.MinValue;
				DateTime dateTimeEffectiveHigh=DateTime.MinValue;
				if(xmlNodeEffectiveTimes.Count>0) {
					XmlNode xmlNodeEffectiveTime=xmlNodeEffectiveTimes[0];
					dateTimeEffectiveLow=GetEffectiveTimeLow(xmlNodeEffectiveTime);
					dateTimeEffectiveHigh=GetEffectiveTimeHigh(xmlNodeEffectiveTime);
				}
				List<XmlNode> listProblemObservTemplate=GetNodesByTagNameAndAttributes(listProbs[i],"templateId","root","2.16.840.1.113883.10.20.22.4.4");// problem act template.
				List<XmlNode> listProbObs=GetParentNodes(listProblemObservTemplate);
				List<XmlNode> listTypeCodes=GetNodesByTagNameAndAttributesFromList(listProbObs,"code");
				List<XmlNode> listCodes=GetNodesByTagNameAndAttributesFromList(listProbObs,"value");
				if(listCodes[0].Attributes["nullFlavor"]!=null) {
					continue;
				}
				string probType=listTypeCodes[0].Attributes["code"].Value;
				string probCode=listCodes[0].Attributes["code"].Value;
				string probName=listCodes[0].Attributes["displayName"].Value;
				List<XmlNode> listStatusObservTemplate=GetNodesByTagNameAndAttributes(listProbs[i],"templateId","root","2.16.840.1.113883.10.20.22.4.6");// Status Observation template.
				List<XmlNode> listStatusObs=GetParentNodes(listStatusObservTemplate);
				List<XmlNode> listActive=GetNodesByTagNameAndAttributesFromList(listStatusObs,"value");
				Disease dis=new Disease();
				dis.SnomedProblemType=probType;
				dis.DateStart=dateTimeEffectiveLow;
				dis.IsNew=true;
				if(listActive.Count>0 && listActive[0].Attributes["code"].Value=="55561003") {//Active (qualifier value)
					dis.ProbStatus=ProblemStatus.Active;
				}
				else if(listActive.Count>0 && listActive[0].Attributes["code"].Value=="413322009") {//Problem resolved (finding)
					dis.ProbStatus=ProblemStatus.Resolved;
					dis.DateStop=dateTimeEffectiveHigh;
				}
				else {
					dis.ProbStatus=ProblemStatus.Inactive;
					dis.DateStop=dateTimeEffectiveHigh;
				}
				listDiseases.Add(dis);
				DiseaseDef disD=new DiseaseDef();
				disD.IsHidden=false;
				disD.IsNew=true;
				disD.SnomedCode=probCode;
				disD.DiseaseName=probName;
				listDiseaseDef.Add(disD);
			}
		}
Exemplo n.º 25
0
Arquivo: EhrCCD.cs Projeto: mnisl/OD
		///<summary>Helper for GenerateCCD().</summary>
		private void GenerateCcdSectionFunctionalStatus(bool hasFunctionalStatus) {
			_w.WriteComment(@"
=====================================================================================================
Functional and Cognitive Status
=====================================================================================================");
			List<Disease> listProblemsFiltered;
			if(!hasFunctionalStatus) {
				listProblemsFiltered=new List<Disease>();
			}
			else {
				listProblemsFiltered=_listProblemsFuncFiltered;
			}
			Start("component");
			Start("section");
			TemplateId("2.16.840.1.113883.10.20.22.2.14");//Functional Status section. There is only one allowed template id.
			_w.WriteComment("Functional Status section template");//(Page 232)
			StartAndEnd("code","code","47420-5","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","Functional Status");
			_w.WriteElementString("title","Functional Status");
			Start("text");//The following text will be parsed as html with a style sheet to be human readable.
			if(listProblemsFiltered.Count>0 && hasFunctionalStatus) {
				Start("table","width","100%","border","1");
				Start("thead");
				Start("tr");
				_w.WriteElementString("th","Condition");
				_w.WriteElementString("th","Effective Dates");
				_w.WriteElementString("th","Condition Status");
				End("tr");
				End("thead");
				Start("tbody");
				for(int i=0;i<listProblemsFiltered.Count;i++) {
					DiseaseDef diseaseDef=null;
					Snomed snomedProblem=null;
					if(listProblemsFiltered[i].DiseaseDefNum>0) {
						diseaseDef=DiseaseDefs.GetItem(listProblemsFiltered[i].DiseaseDefNum);
						if(diseaseDef!=null && !String.IsNullOrEmpty(diseaseDef.SnomedCode)) {
							snomedProblem=Snomeds.GetByCode(diseaseDef.SnomedCode);
						}
					}
					Start("tr");
					if(diseaseDef==null || snomedProblem==null) {
						_w.WriteElementString("td","");
					}
					else {
						_w.WriteElementString("td",snomedProblem.SnomedCode+" - "+snomedProblem.Description);
					}
					if(listProblemsFiltered[i].FunctionStatus==FunctionalStatus.FunctionalResult || listProblemsFiltered[i].FunctionStatus==FunctionalStatus.CognitiveResult) {
						DateText("td",listProblemsFiltered[i].DateStart);
					}
					else {//functional problem and cognitive problem
						if(listProblemsFiltered[i].DateStop.Year>1880) {
							_w.WriteElementString("td",listProblemsFiltered[i].DateStart.ToString("yyyyMMdd")+" to "+listProblemsFiltered[i].DateStop.ToString("yyyyMMdd"));
						}
						else {
							DateText("td",listProblemsFiltered[i].DateStart);
						}
					}
					_w.WriteElementString("td","Completed");
					End("tr");
				}
				End("tbody");
				End("table");
			}
			else {
				_w.WriteString("None");
			}
			End("text");
			if(listProblemsFiltered.Count==0) {//If there are no entries in the filtered list, then we want to add a dummy entry since at least one is required.
				Disease dis=new Disease();
				dis.FunctionStatus=FunctionalStatus.FunctionalProblem;//Just needs a version other than problem.
				listProblemsFiltered.Add(dis);
			}
			for(int i=0;i<listProblemsFiltered.Count;i++) {
				DiseaseDef diseaseDef=null;
				Snomed snomedProblem=null;
				if(listProblemsFiltered[i].PatNum!=0) {
					diseaseDef=DiseaseDefs.GetItem(listProblemsFiltered[i].DiseaseDefNum);
					snomedProblem=Snomeds.GetByCode(diseaseDef.SnomedCode);
				}
				if(diseaseDef==null) {
					diseaseDef=new DiseaseDef();
				}
				if(snomedProblem==null) {
					snomedProblem=new Snomed();
				}
				Start("entry","typeCode","DRIV");
				Start("observation","classCode","OBS","moodCode","EVN");
				if(listProblemsFiltered[i].FunctionStatus==FunctionalStatus.FunctionalResult) {
					TemplateId("2.16.840.1.113883.10.20.22.4.67");//(Page 383)
					_w.WriteComment("Functional Status Result Observation");
					Guid();
					StartAndEnd("code","code","54744-8","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					StartAndEnd("statusCode","code","completed");
					if(listProblemsFiltered[i].DateStart.Year<1880) {
						StartAndEnd("effectiveTime","nullFlavor","UNK");
					}
					else {
						DateElement("effectiveTime",listProblemsFiltered[i].DateStart);
					}
					if(String.IsNullOrEmpty(snomedProblem.SnomedCode)) {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("nullFlavor","UNK");
						End("value");
					}
					else {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("code",snomedProblem.SnomedCode,"displayName",snomedProblem.Description,"codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
						End("value");
					}
				}
				else if(listProblemsFiltered[i].FunctionStatus==FunctionalStatus.CognitiveResult) {
					TemplateId("2.16.840.1.113883.10.20.22.4.74");//(Page 342)
					_w.WriteComment("Cognitive Status Result Observation");
					Guid();
					StartAndEnd("code","code","5249-2","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc);
					StartAndEnd("statusCode","code","completed");
					if(listProblemsFiltered[i].DateStart.Year<1880) {
						StartAndEnd("effectiveTime","nullFlavor","UNK");
					}
					else {
						DateElement("effectiveTime",listProblemsFiltered[i].DateStart);
					}
					if(String.IsNullOrEmpty(snomedProblem.SnomedCode)) {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("nullFlavor","UNK");
						End("value");
					}
					else {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("code",snomedProblem.SnomedCode,"displayName",snomedProblem.Description,"codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
						End("value");
					}
				}
				else if(listProblemsFiltered[i].FunctionStatus==FunctionalStatus.FunctionalProblem) {
					TemplateId("2.16.840.1.113883.10.20.22.4.68");//(Page 379)
					_w.WriteComment("Functional Status Problem Observation");
					Guid();
					StartAndEnd("code","code","404684003","codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed,"displayName","Finding of Functional Performance and Activity");
					StartAndEnd("statusCode","code","completed");
					Start("effectiveTime");
					if(listProblemsFiltered[i].DateStart.Year<1880) {
						StartAndEnd("low","nullFlavor","UNK");
					}
					else {
						DateElement("low",listProblemsFiltered[i].DateStart);
					}
					//"If the problem is known to be resolved, but the date of resolution is not known, then the high element SHALL be present, and 
					//the nullFlavor attribute SHALL be set to 'UNK'. Therefore, the existence of an high element within a problem does indicate that the problem has been resolved."
					if(listProblemsFiltered[i].DateStop.Year<1880) {
						StartAndEnd("high","nullFlavor","UNK");
					}
					else {
						DateElement("high",listProblemsFiltered[i].DateStop);
					}
					End("effectiveTime");
					if(String.IsNullOrEmpty(snomedProblem.SnomedCode)) {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("nullFlavor","UNK");
						End("value");
					}
					else {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("code",snomedProblem.SnomedCode,"displayName",snomedProblem.Description,"codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
						End("value");
					}
				}
				else if(listProblemsFiltered[i].FunctionStatus==FunctionalStatus.CognitiveProblem) {
					TemplateId("2.16.840.1.113883.10.20.22.4.73");//(Page 336)
					_w.WriteComment("Cognitive Status Problem Observation");
					Guid();
					StartAndEnd("code","code","373930000","codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed,"displayName","Cognitive Function Finding");
					StartAndEnd("statusCode","code","completed");
					//"If the problem is known to be resolved, but the date of resolution is not known, then the high element SHALL be present, and 
					//the nullFlavor attribute SHALL be set to 'UNK'. Therefore, the existence of a high element within a problem does indicate that the problem has been resolved."
					Start("effectiveTime");
					if(listProblemsFiltered[i].DateStart.Year<1880) {
						StartAndEnd("low","nullFlavor","UNK");
					}
					else {
						DateElement("low",listProblemsFiltered[i].DateStart);
					}
					if(listProblemsFiltered[i].DateStop.Year<1880) {
						StartAndEnd("high","nullFlavor","UNK");
					}
					else {
						DateElement("high",listProblemsFiltered[i].DateStop);
					}
					End("effectiveTime");
					if(String.IsNullOrEmpty(snomedProblem.SnomedCode)) {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("nullFlavor","UNK");
						End("value");
					}
					else {
						Start("value");
						_w.WriteAttributeString("xsi","type",null,"CD");
						Attribs("code",snomedProblem.SnomedCode,"displayName",snomedProblem.Description,"codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed);
						End("value");
					}
				}
				End("observation");
				End("entry");
			}
			End("section");
			End("component");
		}
Exemplo n.º 26
0
		private void butAdd_Click(object sender,System.EventArgs e) {
			if(!Security.IsAuthorized(Permissions.ProblemEdit)) {
				return;
			}
			DiseaseDef def=new DiseaseDef();
			def.ItemOrder=DiseaseDefs.ListLong.Length;
			FormDiseaseDefEdit FormD=new FormDiseaseDefEdit(def);
			FormD.IsNew=true;
			FormD.ShowDialog();
			//Security log entry made inside that form.
			if(FormD.DialogResult!=DialogResult.OK) {
				return;
			}
			IsChanged=true;
			FillGrid();
		}
Exemplo n.º 27
0
Arquivo: EhrCCD.cs Projeto: mnisl/OD
		///<summary>Helper for GenerateCCD().  Problem section.</summary>
		private void GenerateCcdSectionProblems(bool hasProblem) {
			_w.WriteComment(@"
=====================================================================================================
Problems
=====================================================================================================");
			string snomedProblemType="55607006";
			List<Disease> listProblemsFiltered;
			if(!hasProblem) {
				listProblemsFiltered=new List<Disease>();
			}
			else {
				listProblemsFiltered=_listProblemsFiltered;
			}
			string status="Inactive";
			string statusCode="73425007";
			string statusOther="active";
			Start("component");
			Start("section");
			TemplateId("2.16.840.1.113883.10.20.22.2.5.1");//Problems section with coded entries required.
			_w.WriteComment("Problems section template");
			StartAndEnd("code","code","11450-4","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","Problem list");
			_w.WriteElementString("title","Problems");
			Start("text");//The following text will be parsed as html with a style sheet to be human readable.
			if(listProblemsFiltered.Count>0 && hasProblem) {
				Start("table","width","100%","border","1");
				Start("thead");
				Start("tr");
				_w.WriteElementString("th","Problem");
				_w.WriteElementString("th","Date Start");
				_w.WriteElementString("th","Date End");
				_w.WriteElementString("th","Status");
				End("tr");
				End("thead");
				Start("tbody");
				for(int i=0;i<listProblemsFiltered.Count;i++) {
					DiseaseDef diseaseDef;
					if(listProblemsFiltered[i].DiseaseDefNum==0) {
						diseaseDef=new DiseaseDef();
					}
					else {
						diseaseDef=DiseaseDefs.GetItem(listProblemsFiltered[i].DiseaseDefNum);
					}
					Start("tr");
					if(String.IsNullOrEmpty(diseaseDef.SnomedCode)) {
						_w.WriteElementString("td","");
					}
					else {
						_w.WriteElementString("td",diseaseDef.SnomedCode+" - "+diseaseDef.DiseaseName);
					}
					if(listProblemsFiltered[i].DateStart.Year<1880) {
						_w.WriteElementString("td","");//Directions
					}
					else {
						DateText("td",listProblemsFiltered[i].DateStart);//Start Date
					}
					if(listProblemsFiltered[i].DateStop.Year<1880) {
						_w.WriteElementString("td","");//Directions
					}
					else {
						DateText("td",listProblemsFiltered[i].DateStop);//End Date
					}
					if(listProblemsFiltered[i].ProbStatus==ProblemStatus.Active) {
						status="Active";
						statusCode="55561003";
						statusOther="active";
					}
					else if(listProblemsFiltered[i].ProbStatus==ProblemStatus.Inactive) {
						status="Inactive";
						statusCode="73425007";
						statusOther="completed";
					}
					else {
						status="Resolved";
						statusCode="413322009";
						statusOther="completed";
					}
					_w.WriteElementString("td",status);
					End("tr");
				}
				End("tbody");
				End("table");
			}
			else {
				_w.WriteString("None");
			}
			End("text");
			//Start("text");
			//StartAndEnd("content","ID","problems");
			//Start("list","listType","ordered");
			//for(int i=0;i<listProblemsFiltered.Count;i++) {//Fill Problems Table
			//	DiseaseDef diseaseDef=DiseaseDefs.GetItem(listProblemsFiltered[i].DiseaseDefNum);
			//	Start("item");
			//	_w.WriteString(diseaseDef.SnomedCode+" - "+diseaseDef.DiseaseName+" : "+"Status - ");
			//	if(listProblemsFiltered[i].ProbStatus==ProblemStatus.Active) {
			//		_w.WriteString("Active");
			//		status="Active";
			//		statusCode="55561003";
			//		statusOther="active";
			//	}
			//	else if(listProblemsFiltered[i].ProbStatus==ProblemStatus.Inactive) {
			//		_w.WriteString("Inactive");
			//		status="Inactive";
			//		statusCode="73425007";
			//		statusOther="completed";
			//	}
			//	else {
			//		_w.WriteString("Resolved");
			//		status="Resolved";
			//		statusCode="413322009";
			//		statusOther="completed";
			//	}
			//	End("item");
			//}
			//End("list");
			//End("text");
			if(listProblemsFiltered.Count==0) {//If there are no entries in the filtered list, then we want to add a dummy entry since at least one is required.
				Disease dis=new Disease();
				listProblemsFiltered.Add(dis);
			}
			for(int i=0;i<listProblemsFiltered.Count;i++) {//Fill Problems Info
				DiseaseDef diseaseDef;
				if(listProblemsFiltered[i].DiseaseDefNum==0) {
					diseaseDef=new DiseaseDef();
				}
				else {
					diseaseDef=DiseaseDefs.GetItem(listProblemsFiltered[i].DiseaseDefNum);
				}
				Start("entry","typeCode","DRIV");
				Start("act","classCode","ACT","moodCode","EVN");
				_w.WriteComment("Problem Concern Act template");//Concern Act Section
				TemplateId("2.16.840.1.113883.10.20.22.4.3");
				Guid();
				StartAndEnd("code","code","CONC","codeSystem","2.16.840.1.113883.5.6","displayName","Concern");
				StartAndEnd("statusCode","code",statusOther);//Allowed values: active, suspended, aborted, completed.
				Start("effectiveTime");
				if(listProblemsFiltered[i].DateStart.Year<1880) {
					StartAndEnd("low","nullFlavor","UNK");
				}
				else {
					DateElement("low",listProblemsFiltered[i].DateStart);
				}
				if(listProblemsFiltered[i].DateStop.Year<1880) {
					StartAndEnd("high","nullFlavor","UNK");
				}
				else {
					DateElement("high",listProblemsFiltered[i].DateStop);
				}
				End("effectiveTime");
				Start("entryRelationship","typeCode","SUBJ");
				Start("observation","classCode","OBS","moodCode","EVN");
				_w.WriteComment("Problem Observation template");//Observation Section
				TemplateId("2.16.840.1.113883.10.20.22.4.4");
				Guid();
				StartAndEnd("code","code",snomedProblemType,"codeSystem",strCodeSystemSnomed,"displayName","Problem");
				StartAndEnd("statusCode","code","completed");//Allowed values: completed.
				Start("effectiveTime");
				if(listProblemsFiltered[i].DateStart.Year<1880) {
					StartAndEnd("low","nullFlavor","UNK");
				}
				else {
					DateElement("low",listProblemsFiltered[i].DateStart);
				}
				End("effectiveTime");
				Start("value");
				_w.WriteAttributeString("xsi","type",null,"CD");
				if(String.IsNullOrEmpty(diseaseDef.SnomedCode)) {
					Attribs("nullFlavor","UNK");
				}
				else {
					Attribs("code",diseaseDef.SnomedCode,"codeSystem",strCodeSystemSnomed,"displayName",diseaseDef.DiseaseName);
				}
				End("value");
				Start("entryRelationship","typeCode","REFR");
				Start("observation","classCode","OBS","moodCode","EVN");
				_w.WriteComment("Status Observation template");//Status Observation Section
				TemplateId("2.16.840.1.113883.10.20.22.4.6");
				Start("code");
				_w.WriteAttributeString("xsi","type",null,"CE");
				Attribs("code","33999-4","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","Status");
				End("code");
				StartAndEnd("statusCode","code","completed");//Allowed values: completed.
				Start("value");
				_w.WriteAttributeString("xsi","type",null,"CD");
				Attribs("code",statusCode,"codeSystem",strCodeSystemSnomed,"displayName",status);
				End("value");
				End("observation");
				End("entryRelationship");
				End("observation");
				End("entryRelationship");
				End("act");
				End("entry");
			}
			End("section");
			End("component");
		}
Exemplo n.º 28
0
		///<summary>Surround with try/catch, because it will throw an exception if any patient is using this def.</summary>
		public static void Delete(DiseaseDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
				return;
			}
			if(PrefC.GetLong(PrefName.ProblemsIndicateNone)==def.DiseaseDefNum) {
				throw new ApplicationException(Lans.g("DiseaseDef","Not allowed to delete. In use as preference \"ProblemsIndicateNone\" in Setup>>Modules."));
			}
			//Validate patient attached
			string command="SELECT LName,FName,patient.PatNum FROM patient,disease WHERE "
				+"patient.PatNum=disease.PatNum "
				+"AND disease.DiseaseDefNum='"+POut.Long(def.DiseaseDefNum)+"' ";
			if(DataConnection.DBtype==DatabaseType.MySql) {
				command+="GROUP BY patient.PatNum";
			}
			else {//Oracle
				command+="GROUP BY LName,FName,patient.PatNum";
			}
			DataTable table=Db.GetTable(command);
			if(table.Rows.Count>0){
				string s=Lans.g("DiseaseDef","Not allowed to delete. Already in use by ")+table.Rows.Count.ToString()
					+" "+Lans.g("DiseaseDef","patients, including")+" \r\n";
				for(int i=0;i<table.Rows.Count;i++){
					if(i>5){
						break;
					}
					s+=table.Rows[i][0].ToString()+", "+table.Rows[i][1].ToString()+"\r\n";
				}
				throw new ApplicationException(s);
			}
			//Validate edu resource attached
			command="SELECT COUNT(*) FROM eduresource WHERE eduresource.DiseaseDefNum='"+POut.Long(def.DiseaseDefNum)+"'";
			int num=PIn.Int(Db.GetCount(command));
			if(num>0) {
				string s=Lans.g("DiseaseDef","Not allowed to delete.  Already attached to an EHR educational resource.");
				throw new ApplicationException(s);
			}
			//Validate family health history attached
			command="SELECT LName,FName,patient.PatNum FROM patient,familyhealth "
				+"WHERE patient.PatNum=familyhealth.PatNum "
				+"AND familyhealth.DiseaseDefNum='"+POut.Long(def.DiseaseDefNum)+"' ";
			if(DataConnection.DBtype==DatabaseType.MySql) {
				command+="GROUP BY patient.PatNum";
			}
			else {//Oracle
				command+="GROUP BY LName,FName,patient.PatNum";
			}
			table=Db.GetTable(command);
			if(table.Rows.Count>0) {
				string s=Lans.g("DiseaseDef","Not allowed to delete. Already in use by")+" "+table.Rows.Count.ToString()
					+" "+Lans.g("DiseaseDef","patients' family history, including")+": \r\n";
				for(int i=0;i<table.Rows.Count;i++) {
					if(i>5) {
						break;
					}
					s+="#"+table.Rows[i]["PatNum"].ToString()+" "+table.Rows[i]["LName"].ToString()+", "+table.Rows[i]["FName"].ToString()+"\r\n";
				}
				throw new ApplicationException(s);
			}
			//End of validation
			command="DELETE FROM diseasedef WHERE DiseaseDefNum ="+POut.Long(def.DiseaseDefNum);
			Db.NonQ(command);
		}
Exemplo n.º 29
0
        ///<summary>Surround with try/catch, because it will throw an exception if any patient is using this def.</summary>
        public static void Delete(DiseaseDef def)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), def);
                return;
            }
            if (PrefC.GetLong(PrefName.ProblemsIndicateNone) == def.DiseaseDefNum)
            {
                throw new ApplicationException(Lans.g("DiseaseDef", "Not allowed to delete. In use as preference \"ProblemsIndicateNone\" in Setup>>Modules."));
            }
            //Validate patient attached
            string command = "SELECT LName,FName,patient.PatNum FROM patient,disease WHERE "
                             + "patient.PatNum=disease.PatNum "
                             + "AND disease.DiseaseDefNum='" + POut.Long(def.DiseaseDefNum) + "' ";

            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                command += "GROUP BY patient.PatNum";
            }
            else              //Oracle
            {
                command += "GROUP BY LName,FName,patient.PatNum";
            }
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                string s = Lans.g("DiseaseDef", "Not allowed to delete. Already in use by ") + table.Rows.Count.ToString()
                           + " " + Lans.g("DiseaseDef", "patients, including") + " \r\n";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 5)
                    {
                        break;
                    }
                    s += table.Rows[i][0].ToString() + ", " + table.Rows[i][1].ToString() + "\r\n";
                }
                throw new ApplicationException(s);
            }
            //Validate edu resource attached
            command = "SELECT COUNT(*) FROM eduresource WHERE eduresource.DiseaseDefNum='" + POut.Long(def.DiseaseDefNum) + "'";
            int num = PIn.Int(Db.GetCount(command));

            if (num > 0)
            {
                string s = Lans.g("DiseaseDef", "Not allowed to delete.  Already attached to an EHR educational resource.");
                throw new ApplicationException(s);
            }
            //Validate family health history attached
            command = "SELECT LName,FName,patient.PatNum FROM patient,familyhealth "
                      + "WHERE patient.PatNum=familyhealth.PatNum "
                      + "AND familyhealth.DiseaseDefNum='" + POut.Long(def.DiseaseDefNum) + "' ";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                command += "GROUP BY patient.PatNum";
            }
            else              //Oracle
            {
                command += "GROUP BY LName,FName,patient.PatNum";
            }
            table = Db.GetTable(command);
            if (table.Rows.Count > 0)
            {
                string s = Lans.g("DiseaseDef", "Not allowed to delete. Already in use by") + " " + table.Rows.Count.ToString()
                           + " " + Lans.g("DiseaseDef", "patients' family history, including") + ": \r\n";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 5)
                    {
                        break;
                    }
                    s += "#" + table.Rows[i]["PatNum"].ToString() + " " + table.Rows[i]["LName"].ToString() + ", " + table.Rows[i]["FName"].ToString() + "\r\n";
                }
                throw new ApplicationException(s);
            }
            //End of validation
            command = "DELETE FROM diseasedef WHERE DiseaseDefNum =" + POut.Long(def.DiseaseDefNum);
            Db.NonQ(command);
        }
Exemplo n.º 30
0
		private void butDelete_Click(object sender,EventArgs e) {
			if(IsNew){
				DialogResult=DialogResult.Cancel;
				return;
			}
			try{
				DiseaseDefs.Delete(DiseaseDefCur);
				SecurityLogs.MakeLogEntry(Permissions.ProblemEdit,0,DiseaseDefCur.DiseaseName+" deleted.");
				DiseaseDefCur=null;//Flags this disease for removal in outside forms.
				DialogResult=DialogResult.OK;
			}
			catch(ApplicationException ex){
				MessageBox.Show(ex.Message);
			}
		}
Exemplo n.º 31
0
		///<summary></summary>
		public static long Insert(DiseaseDef def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				def.DiseaseDefNum=Meth.GetLong(MethodBase.GetCurrentMethod(),def);
				return def.DiseaseDefNum;
			}
			long retVal=Crud.DiseaseDefCrud.Insert(def);
			if(!PrefC.GetBool(PrefName.ProblemListIsAlpabetical)){
				//Not alphabetizing problem list, just return inserted index.
				return retVal;
			}
			//ProblemListIsAlpabetical==TRUE
			def.DiseaseDefNum=retVal;
			List<DiseaseDef> listDD=new List<DiseaseDef>();
			listDD.AddRange(ListLong);
			listDD.Add(def);
			listDD.Sort(DiseaseDefs.SortAlphabetically);
			def.ItemOrder=listDD.IndexOf(def);
			string command="UPDATE diseasedef SET ItemOrder=ItemOrder+1 WHERE ItemOrder>="+POut.Int(def.ItemOrder);
			Db.NonQ(command);
			DiseaseDefs.Update(def);//Updates item order.
			return retVal;
		}
Exemplo n.º 32
0
		///<summary>Sorts alphabetically by DiseaseName, then by PK.</summary>
		public static int SortAlphabetically(DiseaseDef x,DiseaseDef y) {
			if(x.DiseaseName!=y.DiseaseName) {
				return x.DiseaseName.CompareTo(y.DiseaseName);
			}
			return x.DiseaseDefNum.CompareTo(y.DiseaseDefNum);
		}
Exemplo n.º 33
0
		///<summary>Sets the pregnancy code and description text box with either the attached pregnancy dx if exists or the default preg dx set in FormEhrSettings or a manually selected def.  If the pregnancy diseasedef with the default pregnancy code and code system does not exist, it will be inserted.  The pregnancy problem will be inserted when closing if necessary.</summary>
		private void SetPregCodeAndDescript() {
			labelPregNotice.Text=pregDefaultText;
			pregDisDefNumCur=0;//this will be set to the correct problem def at the end of this function and will be the def of the problem we will insert/attach this exam to
			string pregCode="";
			string descript="";
			Disease disCur=null;
			DiseaseDef disdefCur=null;
			DateTime examDate=PIn.Date(textDateTaken.Text);//this may be different than the saved Vitalsign.DateTaken if user edited
			#region Get DiseaseDefNum from attached pregnancy problem
			if(VitalsignCur.PregDiseaseNum>0) {//already pointing to a disease, get that one
				disCur=Diseases.GetOne(VitalsignCur.PregDiseaseNum);//get disease this vital sign is pointing to, see if it exists
				if(disCur==null) {
					VitalsignCur.PregDiseaseNum=0;
				}
				else {
					if(examDate.Year<1880 || disCur.DateStart>examDate.Date || (disCur.DateStop.Year>1880 && disCur.DateStop<examDate.Date)) {
						VitalsignCur.PregDiseaseNum=0;
						disCur=null;
					}
					else {
						disdefCur=DiseaseDefs.GetItem(disCur.DiseaseDefNum);
						if(disdefCur==null) {
							VitalsignCur.PregDiseaseNum=0;
							disCur=null;
						}
						else {//disease points to valid def
							pregDisDefNumCur=disdefCur.DiseaseDefNum;
						}
					}
				}
			}
			#endregion
			if(VitalsignCur.PregDiseaseNum==0) {//not currently attached to a disease
				#region Get DiseaseDefNum from existing pregnancy problem
				if(examDate.Year>1880) {//only try to find existing problem if a valid exam date is entered before checking the box, otherwise we do not know what date to compare to the active dates of the pregnancy dx
					List<DiseaseDef> listPregDisDefs=DiseaseDefs.GetAllPregDiseaseDefs();
					List<Disease> listPatDiseases=Diseases.Refresh(VitalsignCur.PatNum,true);
					for(int i=0;i<listPatDiseases.Count;i++) {//loop through all diseases for this patient, shouldn't be very many
						if(listPatDiseases[i].DateStart>examDate.Date //startdate for current disease is after the exam date set in form
							|| (listPatDiseases[i].DateStop.Year>1880 && listPatDiseases[i].DateStop<examDate.Date))//or current disease has a stop date and stop date before exam date
						{
							continue;
						}
						for(int j=0;j<listPregDisDefs.Count;j++) {//loop through preg disease defs in the db, shouldn't be very many
							if(listPatDiseases[i].DiseaseDefNum!=listPregDisDefs[j].DiseaseDefNum) {//see if this problem is a pregnancy problem
								continue;
							}
							if(disCur==null || listPatDiseases[i].DateStart>disCur.DateStart) {//if we haven't found a disease match yet or this match is more recent (later start date)
								disCur=listPatDiseases[i];
								break;
							}
						}
					}
				}
				if(disCur!=null) {
					pregDisDefNumCur=disCur.DiseaseDefNum;
					VitalsignCur.PregDiseaseNum=disCur.DiseaseNum;
				}
				#endregion
				else {//we are going to insert either the default pregnancy problem or a manually selected problem
					#region Get DiseaseDefNum from global default pregnancy problem
					//if preg dx doesn't exist, use the default pregnancy code if set to something other than blank or 'none'
					pregCode=PrefC.GetString(PrefName.PregnancyDefaultCodeValue);//could be 'none' which disables the automatic dx insertion
					string pregCodeSys=PrefC.GetString(PrefName.PregnancyDefaultCodeSystem);//if 'none' for code, code system will default to 'SNOMEDCT', display will be ""
					if(pregCode!="" && pregCode!="none") {//default pregnancy code set to a code other than 'none', should never be blank, we set in ConvertDB and don't allow blank
						pregDisDefNumCur=DiseaseDefs.GetNumFromCode(pregCode);//see if the code is attached to a valid diseasedef
						if(pregDisDefNumCur==0) {//no diseasedef in db for the default code, create and insert def
							disdefCur=new DiseaseDef();
							disdefCur.DiseaseName="Pregnant";
							switch(pregCodeSys) {
								case "ICD9CM":
									disdefCur.ICD9Code=pregCode;
									break;
								case "ICD10CM":
									disdefCur.Icd10Code=pregCode;
									break;
								case "SNOMEDCT":
									disdefCur.SnomedCode=pregCode;
									break;
							}
							pregDisDefNumCur=DiseaseDefs.Insert(disdefCur);
							DiseaseDefs.RefreshCache();
							DataValid.SetInvalid(InvalidType.Diseases);
							SecurityLogs.MakeLogEntry(Permissions.ProblemEdit,0,disdefCur.DiseaseName+" added.");
						}
					}
					#endregion
					#region Get DiseaseDefNum from manually selected pregnancy problem
					else if(pregCode=="none") {//if pref for default preg dx is 'none', make user choose a problem from list
						FormDiseaseDefs FormDD=new FormDiseaseDefs();
						FormDD.IsSelectionMode=true;
						FormDD.IsMultiSelect=false;
						FormDD.ShowDialog();
						if(FormDD.DialogResult!=DialogResult.OK) {
							checkPregnant.Checked=false;
							textPregCode.Clear();
							textPregCodeDescript.Clear();
							labelPregNotice.Visible=false;
							butChangeDefault.Text="Change Default";
							return;
						}
						labelPregNotice.Text=pregManualText;
						pregDisDefNumCur=FormDD.SelectedDiseaseDefNum;
					}
					#endregion
				}
			}
			#region Set description and code from DiseaseDefNum
			if(pregDisDefNumCur==0) {
				textPregCode.Clear();
				textPregCodeDescript.Clear();
				labelPregNotice.Visible=false;
				return;
			}
			disdefCur=DiseaseDefs.GetItem(pregDisDefNumCur);
			if(disdefCur.ICD9Code!="") {
				ICD9 i9Preg=ICD9s.GetByCode(disdefCur.ICD9Code);
				if(i9Preg!=null) {
					pregCode=i9Preg.ICD9Code;
					descript=i9Preg.Description;
				}
			}
			else if(disdefCur.Icd10Code!="") {
				Icd10 i10Preg=Icd10s.GetByCode(disdefCur.Icd10Code);
				if(i10Preg!=null) {
					pregCode=i10Preg.Icd10Code;
					descript=i10Preg.Description;
				}
			}
			else if(disdefCur.SnomedCode!="") {
				Snomed sPreg=Snomeds.GetByCode(disdefCur.SnomedCode);
				if(sPreg!=null) {
					pregCode=sPreg.SnomedCode;
					descript=sPreg.Description;
				}
			}
			if(pregCode=="none" || pregCode=="") {
				descript=disdefCur.DiseaseName;
			}
			#endregion
			textPregCode.Text=pregCode;
			textPregCodeDescript.Text=descript;
		}
Exemplo n.º 34
0
		public static int SortItemOrder(DiseaseDef x,DiseaseDef y) {
			if(x.ItemOrder!=y.ItemOrder) {
				return x.ItemOrder.CompareTo(y.ItemOrder);
			}
			return x.DiseaseDefNum.CompareTo(y.DiseaseDefNum);
		}