///<summary></summary> public static long Insert(Cpt cpt) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { cpt.CptNum=Meth.GetLong(MethodBase.GetCurrentMethod(),cpt); return cpt.CptNum; } return Crud.CptCrud.Insert(cpt); }
///<summary>Updates an existing CPT code description if versionID is newer than current versionIDs. If versionID is different than existing versionIDs, it will be added to the comma delimited list.</summary> public static void UpdateDescription(string cptCode, string description, string versionID) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), cptCode, description, versionID); return; } Cpt cpt = Cpts.GetByCode(POut.String(cptCode)); string[] versionIDs = cpt.VersionIDs.Split(','); bool versionIDFound = false; string maxVersionID = ""; for (int i = 0; i < versionIDs.Length; i++) { if (string.Compare(versionIDs[i], maxVersionID) > 0) //Find max versionID in list { maxVersionID = versionIDs[i]; } if (versionIDs[i] == versionID) //Find if versionID is already in list { versionIDFound = true; } } if (!versionIDFound) //If the current version isn't already in the list { cpt.VersionIDs += ',' + versionID; //VersionID should never be blank for an existing code... should we check? } if (string.Compare(versionID, maxVersionID) >= 0) //If newest version { cpt.Description = description; } Crud.CptCrud.Update(cpt); }
///<summary></summary> public static long Insert(Cpt cpt) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { cpt.CptNum = Meth.GetLong(MethodBase.GetCurrentMethod(), cpt); return(cpt.CptNum); } return(Crud.CptCrud.Insert(cpt)); }
/////<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportCDT(string tempFileName) ... not necessary. ///<summary>Called after user provides resource file. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely. ///No UpdateExisting parameter because we force users to accept new descriptions.</summary> public static void ImportCpt(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated, string versionID) { if (tempFileName == null) { return; } Dictionary <string, string> dictCodes = Cpts.GetAll().ToDictionary(x => x.CptCode, x => x.Description); Regex regx = new Regex(@"^([\d]{4}[\d\w])\s+(.+?)$"); //Regex = "At the beginning of the string, find five numbers, followed by a white space (tab or space) followed by one or more characters (but as few as possible) to the end of the line." string[] lines = File.ReadAllLines(tempFileName); string[] arrayCpt; bool isHeader = true; Cpt cpt = new Cpt(); for (int i = 0; i < lines.Length; i++) //each loop should read exactly one line of code. and each line of code should be a unique code { if (quit) { return; } if (i % 100 == 0) { progress(i + 1, lines.Length); } if (isHeader) { if (!regx.IsMatch(lines[i])) //if(!lines[i].Contains("\t")) { { continue; //Copyright info is present at the head of the file. } isHeader = false; } arrayCpt = new string[2]; arrayCpt[0] = regx.Match(lines[i]).Groups[1].Value; //First five alphanumeric characters arrayCpt[1] = regx.Match(lines[i]).Groups[2].Value; //Everything after the 6th character if (dictCodes.Keys.Contains(arrayCpt[0])) //code already exists { Cpts.UpdateDescription(arrayCpt[0], arrayCpt[1], versionID); if (dictCodes[arrayCpt[0]] != arrayCpt[1]) //The description is different { numCodesUpdated++; } } else { cpt.CptCode = arrayCpt[0]; cpt.Description = arrayCpt[1]; cpt.VersionIDs = versionID; Cpts.Insert(cpt); numCodesImported++; } } }
///<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportCDT(string tempFileName) ... not necessary. ///<summary>Called after user provides resource file. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCpt(string tempFileName, ProgressArgs progress, ref bool quit) { if (tempFileName == null) { return; } HashSet <string> codeHash = new HashSet <string>(Cpts.GetAllCodes()); string[] lines = File.ReadAllLines(tempFileName); string[] arrayCpt; bool isHeader = true; Cpt cpt = new Cpt(); for (int i = 0; i < lines.Length; i++) //each loop should read exactly one line of code. and each line of code should be a unique code { if (quit) { return; } if (i % 100 == 0) { progress(i + 1, lines.Length); } if (isHeader) { if (!lines[i].Contains("\t")) { continue; //Copyright info is present at the head of the file. } isHeader = false; } arrayCpt = lines[i].Split('\t'); if (codeHash.Contains(arrayCpt[0])) //code already exists { continue; } cpt.CptCode = arrayCpt[0]; cpt.Description = arrayCpt[1]; Cpts.Insert(cpt); } }
///<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportCDT(string tempFileName) ... not necessary. ///<summary>Called after user provides resource file. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCpt(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Cpts.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayCpt; bool isHeader=true; Cpt cpt=new Cpt(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } if(isHeader) { if(!lines[i].Contains("\t")) { continue;//Copyright info is present at the head of the file. } isHeader=false; } arrayCpt=lines[i].Split('\t'); if(codeHash.Contains(arrayCpt[0])) {//code already exists continue; } cpt.CptCode =arrayCpt[0]; cpt.Description =arrayCpt[1]; Cpts.Insert(cpt); } }
///<summary>Sort function to put the codes that apply to the most number of CQM's at the top so the user can see which codes they should select.</summary> //private int SortMeasuresMet(ODGridRow row1,ODGridRow row2) { // //First sort by the number of measures the codes apply to in a comma delimited list // int diff=row2.Cells[2].Text.Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries).Length-row1.Cells[2].Text.Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries).Length; // if(diff!=0) { // return diff; // } // try { // //if the codes apply to the same number of CQMs, order by the code values // return PIn.Long(row1.Cells[0].Text).CompareTo(PIn.Long(row2.Cells[0].Text)); // } // catch(Exception ex) { // return 0; // } //} private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) { if(IsSelectionMode) { SelectedCpt=(Cpt)gridMain.Rows[e.Row].Tag; DialogResult=DialogResult.OK; return; } //changed=true; //FormSnomedEdit FormSE=new FormSnomedEdit((Snomed)gridMain.Rows[e.Row].Tag); //FormSE.ShowDialog(); //if(FormSE.DialogResult!=DialogResult.OK) { // return; //} //FillGrid(); }
/*private void butAdd_Click(object sender,EventArgs e) { //TODO: Either change to adding a snomed code instead of an ICD9 or don't allow users to add SNOMED codes other than importing. changed=true; Snomed snomed=new Snomed(); FormSnomedEdit FormI=new FormSnomedEdit(snomed); FormI.IsNew=true; FormI.ShowDialog(); FillGrid(); }*/ private void butOK_Click(object sender,EventArgs e) { //not even visible unless IsSelectionMode if(gridMain.GetSelectedIndex()==-1) { MsgBox.Show(this,"Please select an item first."); return; } SelectedCpt=(Cpt)gridMain.Rows[gridMain.GetSelectedIndex()].Tag; DialogResult=DialogResult.OK; }
///<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportCDT(string tempFileName) ... not necessary. ///<summary>Called after user provides resource file. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCpt(string tempFileName,ProgressArgs progress,ref bool quit,ref int numCodesImported,string versionID) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Cpts.GetAllCodes()); Regex regx=new Regex(@"^([\d]{4}[\d\w])\s+(.+?)$");//Regex = "At the beginning of the string, find five numbers, followed by a white space (tab or space) followed by one or more characters (but as few as possible) to the end of the line." string[] lines=File.ReadAllLines(tempFileName); string[] arrayCpt; bool isHeader=true; Cpt cpt=new Cpt(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } if(isHeader) { if(!regx.IsMatch(lines[i])) { //if(!lines[i].Contains("\t")) { continue;//Copyright info is present at the head of the file. } isHeader=false; } arrayCpt=new string[2]; arrayCpt[0]=regx.Match(lines[i]).Groups[1].Value;//First five alphanumeric characters arrayCpt[1]=regx.Match(lines[i]).Groups[2].Value;//Everything after the 6th character if(codeHash.Contains(arrayCpt[0])) {//code already exists Cpts.UpdateDescription(arrayCpt[0],arrayCpt[1],versionID); } else { cpt.CptCode =arrayCpt[0]; cpt.Description =arrayCpt[1]; cpt.VersionIDs =versionID; Cpts.Insert(cpt); numCodesImported++; } } }