///<summary>Inserts one ICD9 into the database. Provides option to use the existing priKey.</summary> internal static long Insert(ICD9 iCD9,bool useExistingPK) { if(!useExistingPK && PrefC.RandomKeys) { iCD9.ICD9Num=ReplicationServers.GetKey("icd9","ICD9Num"); } string command="INSERT INTO icd9 ("; if(useExistingPK || PrefC.RandomKeys) { command+="ICD9Num,"; } command+="ICD9Code,Description) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(iCD9.ICD9Num)+","; } command+= "'"+POut.String(iCD9.ICD9Code)+"'," +"'"+POut.String(iCD9.Description)+"')"; //DateTStamp can only be set by MySQL if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { iCD9.ICD9Num=Db.NonQ(command,true); } return iCD9.ICD9Num; }
///<summary>Inserts one ICD9 into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(ICD9 iCD9, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO icd9 ("; if (!useExistingPK && isRandomKeys) { iCD9.ICD9Num = ReplicationServers.GetKeyNoCache("icd9", "ICD9Num"); } if (isRandomKeys || useExistingPK) { command += "ICD9Num,"; } command += "ICD9Code,Description) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(iCD9.ICD9Num) + ","; } command += "'" + POut.String(iCD9.ICD9Code) + "'," + "'" + POut.String(iCD9.Description) + "')"; //DateTStamp can only be set by MySQL if (useExistingPK || isRandomKeys) { Db.NonQ(command); } else { iCD9.ICD9Num = Db.NonQ(command, true, "ICD9Num", "iCD9"); } return(iCD9.ICD9Num); }
///<summary>Inserts one ICD9 into the database. Provides option to use the existing priKey.</summary> internal static long Insert(ICD9 iCD9, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { iCD9.ICD9Num = ReplicationServers.GetKey("icd9", "ICD9Num"); } string command = "INSERT INTO icd9 ("; if (useExistingPK || PrefC.RandomKeys) { command += "ICD9Num,"; } command += "ICD9Code,Description) VALUES("; if (useExistingPK || PrefC.RandomKeys) { command += POut.Long(iCD9.ICD9Num) + ","; } command += "'" + POut.String(iCD9.ICD9Code) + "'," + "'" + POut.String(iCD9.Description) + "')"; //DateTStamp can only be set by MySQL if (useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { iCD9.ICD9Num = Db.NonQ(command, true); } return(iCD9.ICD9Num); }
///<summary>Updates one ICD9 in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables.</summary> internal static void Update(ICD9 iCD9, ICD9 oldICD9) { string command = ""; if (iCD9.ICD9Code != oldICD9.ICD9Code) { if (command != "") { command += ","; } command += "ICD9Code = '" + POut.String(iCD9.ICD9Code) + "'"; } if (iCD9.Description != oldICD9.Description) { if (command != "") { command += ","; } command += "Description = '" + POut.String(iCD9.Description) + "'"; } //DateTStamp can only be set by MySQL if (command == "") { return; } command = "UPDATE icd9 SET " + command + " WHERE ICD9Num = " + POut.Long(iCD9.ICD9Num); Db.NonQ(command); }
///<summary>Inserts one ICD9 into the database. Returns the new priKey.</summary> internal static long Insert(ICD9 iCD9) { if(DataConnection.DBtype==DatabaseType.Oracle) { iCD9.ICD9Num=DbHelper.GetNextOracleKey("icd9","ICD9Num"); int loopcount=0; while(loopcount<100){ try { return Insert(iCD9,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ iCD9.ICD9Num++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(iCD9,false); } }
///<summary>Inserts one ICD9 into the database. Returns the new priKey.</summary> internal static long Insert(ICD9 iCD9) { if (DataConnection.DBtype == DatabaseType.Oracle) { iCD9.ICD9Num = DbHelper.GetNextOracleKey("icd9", "ICD9Num"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(iCD9, true)); } catch (Oracle.DataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { iCD9.ICD9Num++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(iCD9, false)); } }
private void listValueType_SelectedIndexChanged(object sender, EventArgs e) { textValue.Text = ""; _loincValue = null; _snomedValue = null; _icd9Value = null; _icd10Value = null; SetFlags(); }
///<summary>Converts one ICD9 object to its mobile equivalent. Warning! CustomerNum will always be 0.</summary> internal static ICD9m ConvertToM(ICD9 iCD9) { ICD9m iCD9m = new ICD9m(); //CustomerNum cannot be set. Remains 0. iCD9m.ICD9Num = iCD9.ICD9Num; iCD9m.ICD9Code = iCD9.ICD9Code; iCD9m.Description = iCD9.Description; return(iCD9m); }
///<summary>Updates one ICD9 in the database.</summary> internal static void Update(ICD9 iCD9) { string command = "UPDATE icd9 SET " + "ICD9Code = '" + POut.String(iCD9.ICD9Code) + "', " + "Description= '" + POut.String(iCD9.Description) + "' " //DateTStamp can only be set by MySQL + "WHERE ICD9Num = " + POut.Long(iCD9.ICD9Num); Db.NonQ(command); }
private void butAdd_Click(object sender, EventArgs e) { changed = true; ICD9 icd9 = new ICD9(); FormIcd9Edit FormI = new FormIcd9Edit(icd9); FormI.IsNew = true; FormI.ShowDialog(); FillGrid(); }
private void butOK_Click(object sender, EventArgs e) { //not even visible unless IsSelectionMode if (listMain.SelectedIndex == -1) { MsgBox.Show(this, "Please select an item first."); return; } SelectedIcd9 = icd9List[listMain.SelectedIndex]; DialogResult = DialogResult.OK; }
///<summary>Converts a DataTable to a list of objects.</summary> public static List<ICD9> TableToList(DataTable table){ List<ICD9> retVal=new List<ICD9>(); ICD9 iCD9; for(int i=0;i<table.Rows.Count;i++) { iCD9=new ICD9(); iCD9.ICD9Num = PIn.Long (table.Rows[i]["ICD9Num"].ToString()); iCD9.ICD9Code = PIn.String(table.Rows[i]["ICD9Code"].ToString()); iCD9.Description= PIn.String(table.Rows[i]["Description"].ToString()); iCD9.DateTStamp = PIn.DateT (table.Rows[i]["DateTStamp"].ToString()); retVal.Add(iCD9); } return retVal; }
private void butPickValueIcd9_Click(object sender, EventArgs e) { FormIcd9s formI = new FormIcd9s(); formI.IsSelectionMode = true; if (formI.ShowDialog() == DialogResult.OK) { _icd9Value = formI.SelectedIcd9; textValue.Text = _icd9Value.Description; _strValCodeSystem = "ICD9"; labelValue.Text = _strValCodeSystem + " Value"; } }
///<summary>Returns true if Update(ICD9,ICD9) would make changes to the database. ///Does not make any changes to the database and can be called before remoting role is checked.</summary> public static bool UpdateComparison(ICD9 iCD9, ICD9 oldICD9) { if (iCD9.ICD9Code != oldICD9.ICD9Code) { return(true); } if (iCD9.Description != oldICD9.Description) { return(true); } //DateTStamp can only be set by MySQL return(false); }
///<summary>Inserts one ICD9 into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(ICD9 iCD9) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(iCD9, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { iCD9.ICD9Num = DbHelper.GetNextOracleKey("icd9", "ICD9Num"); //Cacheless method } return(InsertNoCache(iCD9, true)); } }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <ICD9> TableToList(DataTable table) { List <ICD9> retVal = new List <ICD9>(); ICD9 iCD9; foreach (DataRow row in table.Rows) { iCD9 = new ICD9(); iCD9.ICD9Num = PIn.Long(row["ICD9Num"].ToString()); iCD9.ICD9Code = PIn.String(row["ICD9Code"].ToString()); iCD9.Description = PIn.String(row["Description"].ToString()); iCD9.DateTStamp = PIn.DateT(row["DateTStamp"].ToString()); retVal.Add(iCD9); } return(retVal); }
///<summary>Converts a DataTable to a list of objects.</summary> internal static List <ICD9> TableToList(DataTable table) { List <ICD9> retVal = new List <ICD9>(); ICD9 iCD9; for (int i = 0; i < table.Rows.Count; i++) { iCD9 = new ICD9(); iCD9.ICD9Num = PIn.Long(table.Rows[i]["ICD9Num"].ToString()); iCD9.ICD9Code = PIn.String(table.Rows[i]["ICD9Code"].ToString()); iCD9.Description = PIn.String(table.Rows[i]["Description"].ToString()); iCD9.DateTStamp = PIn.DateT(table.Rows[i]["DateTStamp"].ToString()); retVal.Add(iCD9); } return(retVal); }
static List <ICD9> DataTableToIcd9(DataTable dtIcd9) { var icd9List = new List <ICD9>(); for (var index = 0; index < dtIcd9.Rows.Count; index++) { var rowIcd9 = dtIcd9.Rows[index]; var icd9 = new ICD9() { OPER_Code = rowIcd9["OPER_Code"].ToString(), OPER_Desc = rowIcd9["OPER_Desc"].ToString() }; icd9List.Add(icd9); } return(icd9List); }
private void listMain_DoubleClick(object sender, System.EventArgs e) { if (listMain.SelectedIndex == -1) { return; } if (IsSelectionMode) { SelectedIcd9 = icd9List[listMain.SelectedIndex]; DialogResult = DialogResult.OK; return; } /* Commented to prevent Icd9 edit window from being shown * changed=true; * FormIcd9Edit FormI=new FormIcd9Edit(icd9List[listMain.SelectedIndex]); * FormI.ShowDialog(); * if(FormI.DialogResult!=DialogResult.OK) { * return; * } * FillGrid(); */ }
private void FormEhrSettings_Load(object sender, EventArgs e) { if (PrefC.GetString(PrefName.SoftwareName) != "") { this.Text += " - " + PrefC.GetString(PrefName.SoftwareName); } checkAlertHighSeverity.Checked = PrefC.GetBool(PrefName.EhrRxAlertHighSeverity); comboMU2.Items.Add("Stage 1"); comboMU2.Items.Add("Stage 2"); comboMU2.Items.Add("Modified Stage 2"); comboMU2.SelectedIndex = PrefC.GetInt(PrefName.MeaningfulUseTwo); checkAutoWebmails.Checked = PrefC.GetBool(PrefName.AutomaticSummaryOfCareWebmail); FillRecEncCodesList(); FillDefaultEncCode(); #region DefaultPregnancyGroup FillRecPregCodesList(); string defaultPregCode = PrefC.GetString(PrefName.PregnancyDefaultCodeValue); string defaultPregCodeSystem = PrefC.GetString(PrefName.PregnancyDefaultCodeSystem); NewPregCodeSystem = defaultPregCodeSystem; OldPregListSelectedIdx = -1; int countNotInSnomedTable = 0; for (int i = 0; i < ListRecPregCodes.Count; i++) { if (i == 0) { comboPregCodes.Items.Add(ListRecPregCodes[i]); comboPregCodes.SelectedIndex = i; if (defaultPregCode == ListRecPregCodes[i]) { comboPregCodes.SelectedIndex = i; OldPregListSelectedIdx = i; } continue; } if (!Snomeds.CodeExists(ListRecPregCodes[i])) { countNotInSnomedTable++; continue; } comboPregCodes.Items.Add(ListRecPregCodes[i]); if (ListRecPregCodes[i] == defaultPregCode && defaultPregCodeSystem == "SNOMEDCT") { comboPregCodes.SelectedIndex = i; OldPregListSelectedIdx = i; labelPregWarning.Visible = false; textPregCodeDescript.Text = Snomeds.GetByCode(ListRecPregCodes[i]).Description; //Guaranteed to exist in snomed table from above check } } if (countNotInSnomedTable > 0) { MsgBox.Show(this, "The snomed table does not contain one or more codes from the list of recommended pregnancy codes. The snomed table should be updated by running the Code System Importer tool found in Setup | Chart | EHR."); } if (comboPregCodes.SelectedIndex == -1) //default preg code set to code not in recommended list and not 'none' { switch (defaultPregCodeSystem) { case "ICD9CM": ICD9 i9Preg = ICD9s.GetByCode(defaultPregCode); if (i9Preg != null) { textPregCodeValue.Text = i9Preg.ICD9Code; textPregCodeDescript.Text = i9Preg.Description; } break; case "SNOMEDCT": Snomed sPreg = Snomeds.GetByCode(defaultPregCode); if (sPreg != null) { textPregCodeValue.Text = sPreg.SnomedCode; textPregCodeDescript.Text = sPreg.Description; } break; case "ICD10CM": Icd10 i10Preg = Icd10s.GetByCode(defaultPregCode); if (i10Preg != null) { textPregCodeValue.Text = i10Preg.Icd10Code; textPregCodeDescript.Text = i10Preg.Description; } break; default: break; } } #endregion }
public static string Validate(Appointment appt) { StringBuilder sb = new StringBuilder(); Provider provFacility = Providers.GetProv(PrefC.GetInt(PrefName.PracticeDefaultProv)); if (!Regex.IsMatch(provFacility.NationalProvID, "^(80840)?[0-9]{10}$")) { WriteError(sb, "Invalid NPI for provider '" + provFacility.Abbr + "'"); } if (PrefC.HasClinicsEnabled && appt.ClinicNum != 0) //Using clinics and a clinic is assigned. { Clinic clinic = Clinics.GetClinic(appt.ClinicNum); if (clinic.Description == "") { WriteError(sb, "Missing clinic description for clinic attached to appointment."); } } else //Not using clinics for this patient { if (PrefC.GetString(PrefName.PracticeTitle) == "") { WriteError(sb, "Missing practice title."); } } Patient pat = Patients.GetPat(appt.PatNum); if (pat.PatStatus == PatientStatus.Deceased && pat.DateTimeDeceased.Year < 1880) { WriteError(sb, "Missing date time deceased."); } List <EhrAptObs> listObservations = EhrAptObses.Refresh(appt.AptNum); if (listObservations.Count == 0) { WriteError(sb, "Missing observation."); } for (int i = 0; i < listObservations.Count; i++) { EhrAptObs obs = listObservations[i]; if (obs.ValType == EhrAptObsType.Coded) { if (obs.ValCodeSystem.Trim().ToUpper() == "LOINC") { Loinc loincVal = Loincs.GetByCode(obs.ValReported); if (loincVal == null) { WriteError(sb, "Loinc code not found '" + loincVal.LoincCode + "'. Please add by going to Setup | Chart | EHR."); } } else if (obs.ValCodeSystem.Trim().ToUpper() == "SNOMEDCT") { Snomed snomedVal = Snomeds.GetByCode(obs.ValReported); if (snomedVal == null) { WriteError(sb, "Snomed code not found '" + snomedVal.SnomedCode + "'. Please add by going to Setup | Chart | EHR."); } } else if (obs.ValCodeSystem.Trim().ToUpper() == "ICD9") { ICD9 icd9Val = ICD9s.GetByCode(obs.ValReported); if (icd9Val == null) { WriteError(sb, "ICD9 code not found '" + icd9Val.ICD9Code + "'. Please add by going to Setup | Chart | EHR."); } } else if (obs.ValCodeSystem.Trim().ToUpper() == "ICD10") { Icd10 icd10Val = Icd10s.GetByCode(obs.ValReported); if (icd10Val == null) { WriteError(sb, "ICD10 code not found '" + icd10Val.Icd10Code + "'. Please add by going to Setup | Chart | EHR."); } } } else if (obs.ValType == EhrAptObsType.Numeric && obs.UcumCode != "") //We only validate the ucum code if it will be sent out. Blank units allowed. { Ucum ucum = Ucums.GetByCode(obs.UcumCode); if (ucum == null) { WriteError(sb, "Invalid unit code '" + obs.UcumCode + "' for observation (must be UCUM code)."); } } } return(sb.ToString()); }
///<summary>Observation/result segment. Used to transmit observations related to the patient and visit. Guide page 64.</summary> private void OBX() { List <EhrAptObs> listObservations = EhrAptObses.Refresh(_appt.AptNum); for (int i = 0; i < listObservations.Count; i++) { EhrAptObs obs = listObservations[i]; _seg = new SegmentHL7(SegmentNameHL7.OBX); _seg.SetField(0, "OBX"); _seg.SetField(1, (i + 1).ToString()); //OBX-1 Set ID - OBX. Required (length 1..4). Must start at 1 and increment. //OBX-2 Value Type. Required (length 1..3). Cardinality [1..1]. Identifies the structure of data in observation value OBX-5. Values allowed: TS=Time Stamp (Date and/or Time),TX=Text,NM=Numeric,CWE=Coded with exceptions,XAD=Address. if (obs.ValType == EhrAptObsType.Coded) { _seg.SetField(2, "CWE"); } else if (obs.ValType == EhrAptObsType.DateAndTime) { _seg.SetField(2, "TS"); } else if (obs.ValType == EhrAptObsType.Numeric) { _seg.SetField(2, "NM"); } else //obs.ValType==EhrAptObsType.Text { _seg.SetField(2, "TX"); } //OBX-3 Observation Identifier. Required (length up to 478). Cardinality [1..1]. Value set is HL7 table named "Observation Identifier". Type CE. We use LOINC codes because the testing tool used LOINC codes and so do vaccines. string obsIdCode = ""; string obsIdCodeDescript = ""; string obsIdCodeSystem = "LN"; if (obs.IdentifyingCode == EhrAptObsIdentifier.BodyTemp) { obsIdCode = "11289-6"; obsIdCodeDescript = "Body temperature:Temp:Enctrfrst:Patient:Qn:"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.CheifComplaint) { obsIdCode = "8661-1"; obsIdCodeDescript = "Chief complaint:Find:Pt:Patient:Nom:Reported"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.DateIllnessOrInjury) { obsIdCode = "11368-8"; obsIdCodeDescript = "Illness or injury onset date and time:TmStp:Pt:Patient:Qn:"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.OxygenSaturation) { obsIdCode = "59408-5"; obsIdCodeDescript = "Oxygen saturation:MFr:Pt:BldA:Qn:Pulse oximetry"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.PatientAge) { obsIdCode = "21612-7"; obsIdCodeDescript = "Age Time Patient Reported"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.PrelimDiag) { obsIdCode = "44833-2"; obsIdCodeDescript = "Diagnosis.preliminary:Imp:Pt:Patient:Nom:"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.TreatFacilityID) { obsIdCode = "SS001"; obsIdCodeDescript = "Treating Facility Identifier"; obsIdCodeSystem = "PHINQUESTION"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.TreatFacilityLocation) { obsIdCode = "SS002"; obsIdCodeDescript = "Treating Facility Location"; obsIdCodeSystem = "PHINQUESTION"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.TriageNote) { obsIdCode = "54094-8"; obsIdCodeDescript = "Triage note:Find:Pt:Emergency department:Doc:"; } else if (obs.IdentifyingCode == EhrAptObsIdentifier.VisitType) { obsIdCode = "SS003"; obsIdCodeDescript = "Facility / Visit Type"; obsIdCodeSystem = "PHINQUESTION"; } WriteCE(3, obsIdCode, obsIdCodeDescript, obsIdCodeSystem); //OBX-4 Observation Sub-ID. No longer used. //OBX-5 Observation Value. Required if known (length 1..99999). Value must match type in OBX-2. if (obs.ValType == EhrAptObsType.Address) { WriteXAD(5, _sendingFacilityAddress1, _sendingFacilityAddress2, _sendingFacilityCity, _sendingFacilityState, _sendingFacilityZip); } else if (obs.ValType == EhrAptObsType.Coded) { string codeDescript = ""; string codeSystemAbbrev = ""; if (obs.ValCodeSystem.Trim().ToUpper() == "LOINC") { Loinc loincVal = Loincs.GetByCode(obs.ValReported); codeDescript = loincVal.NameShort; codeSystemAbbrev = "LN"; } else if (obs.ValCodeSystem.Trim().ToUpper() == "SNOMEDCT") { Snomed snomedVal = Snomeds.GetByCode(obs.ValReported); codeDescript = snomedVal.Description; codeSystemAbbrev = "SCT"; } else if (obs.ValCodeSystem.Trim().ToUpper() == "ICD9") { ICD9 icd9Val = ICD9s.GetByCode(obs.ValReported); codeDescript = icd9Val.Description; codeSystemAbbrev = "I9"; } else if (obs.ValCodeSystem.Trim().ToUpper() == "ICD10") { Icd10 icd10Val = Icd10s.GetByCode(obs.ValReported); codeDescript = icd10Val.Description; codeSystemAbbrev = "I10"; } WriteCE(5, obs.ValReported.Trim(), codeDescript, codeSystemAbbrev); } else if (obs.ValType == EhrAptObsType.DateAndTime) { DateTime dateVal = DateTime.Parse(obs.ValReported.Trim()); string strDateOut = dateVal.ToString("yyyyMMdd"); //The testing tool threw errors when there were trailing zeros, even though technically valid. if (dateVal.Second > 0) { strDateOut += dateVal.ToString("HHmmss"); } else if (dateVal.Minute > 0) { strDateOut += dateVal.ToString("HHmm"); } else if (dateVal.Hour > 0) { strDateOut += dateVal.ToString("HH"); } _seg.SetField(5, strDateOut); } else if (obs.ValType == EhrAptObsType.Numeric) { _seg.SetField(5, obs.ValReported.Trim()); } else //obs.ValType==EhrAptObsType.Text { _seg.SetField(5, obs.ValReported); } //OBX-6 Units. Required if OBX-2 is NM=Numeric. Cardinality [0..1]. Type CE. The guide suggests value sets: Pulse Oximetry Unit, Temperature Unit, or Age Unit. However, the testing tool used UCUM, so we will use UCUM. if (obs.ValType == EhrAptObsType.Numeric) { if (String.IsNullOrEmpty(obs.UcumCode)) //If units are required but known, we must send a null flavor. { WriteCE(6, "UNK", "", "NULLFL"); } else { Ucum ucum = Ucums.GetByCode(obs.UcumCode); WriteCE(6, ucum.UcumCode, ucum.Description, "UCUM"); } } //OBX-7 References Range. No longer used. //OBX-8 Abnormal Flags. No longer used. //OBX-9 Probability. No longer used. //OBX-10 Nature of Abnormal Test. No longer used. _seg.SetField(11, "F"); //OBX-11 Observation Result Status. Required (length 1..1). Expected value is "F". //OBX-12 Effective Date of Reference Range. No longer used. //OBX-13 User Defined Access Checks. No longer used. //OBX-14 Date/Time of the Observation. Optional. //OBX-15 Producer's ID. No longer used. //OBX-16 Responsible Observer. No longer used. //OBX-17 Observation Method. No longer used. //OBX-18 Equipment Instance Identifier. No longer used. //OBX-19 Date/Time of the Analysis. No longer used. _msg.Segments.Add(_seg); } }
///<summary>Inserts one ICD9 into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(ICD9 iCD9) { return(InsertNoCache(iCD9, false)); }
///<summary>Inserts one ICD9 into the database. Returns the new priKey.</summary> public static long Insert(ICD9 iCD9) { return(Insert(iCD9, false)); }
///<summary>Converts one ICD9 object to its mobile equivalent. Warning! CustomerNum will always be 0.</summary> internal static ICD9m ConvertToM(ICD9 iCD9){ ICD9m iCD9m=new ICD9m(); //CustomerNum cannot be set. Remains 0. iCD9m.ICD9Num =iCD9.ICD9Num; iCD9m.ICD9Code =iCD9.ICD9Code; iCD9m.Description=iCD9.Description; return iCD9m; }
public FormIcd9Edit(ICD9 icd9Cur) { InitializeComponent(); Lan.F(this); Icd9Cur = icd9Cur; }
///<summary>Updates one ICD9 in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables.</summary> public static void Update(ICD9 iCD9,ICD9 oldICD9){ string command=""; if(iCD9.ICD9Code != oldICD9.ICD9Code) { if(command!=""){ command+=",";} command+="ICD9Code = '"+POut.String(iCD9.ICD9Code)+"'"; } if(iCD9.Description != oldICD9.Description) { if(command!=""){ command+=",";} command+="Description = '"+POut.String(iCD9.Description)+"'"; } //DateTStamp can only be set by MySQL if(command==""){ return; } command="UPDATE icd9 SET "+command +" WHERE ICD9Num = "+POut.Long(iCD9.ICD9Num); Db.NonQ(command); }
///<summary>Updates one ICD9 in the database.</summary> public static void Update(ICD9 iCD9){ string command="UPDATE icd9 SET " +"ICD9Code = '"+POut.String(iCD9.ICD9Code)+"', " +"Description= '"+POut.String(iCD9.Description)+"' " //DateTStamp can only be set by MySQL +"WHERE ICD9Num = "+POut.Long(iCD9.ICD9Num); Db.NonQ(command); }
private void FillGridObservations() { gridObservations.BeginUpdate(); gridObservations.ListGridColumns.Clear(); gridObservations.ListGridColumns.Add(new UI.GridColumn("Observation", 200)); //0 gridObservations.ListGridColumns.Add(new UI.GridColumn("Value Type", 200)); //1 gridObservations.ListGridColumns.Add(new UI.GridColumn("Value", 0)); //2 gridObservations.ListGridRows.Clear(); List <EhrAptObs> listEhrAptObses = EhrAptObses.Refresh(_appt.AptNum); for (int i = 0; i < listEhrAptObses.Count; i++) { EhrAptObs obs = listEhrAptObses[i]; UI.GridRow row = new UI.GridRow(); row.Tag = obs; row.Cells.Add(obs.IdentifyingCode.ToString()); //0 Observation if (obs.ValType == EhrAptObsType.Coded) { row.Cells.Add(obs.ValType.ToString() + " - " + obs.ValCodeSystem); //1 Value Type if (obs.ValCodeSystem == "LOINC") { Loinc loincValue = Loincs.GetByCode(obs.ValReported); row.Cells.Add(loincValue.NameShort); //2 Value } else if (obs.ValCodeSystem == "SNOMEDCT") { Snomed snomedValue = Snomeds.GetByCode(obs.ValReported); row.Cells.Add(snomedValue.Description); //2 Value } else if (obs.ValCodeSystem == "ICD9") { ICD9 icd9Value = ICD9s.GetByCode(obs.ValReported); row.Cells.Add(icd9Value.Description); //2 Value } else if (obs.ValCodeSystem == "ICD10") { Icd10 icd10Value = Icd10s.GetByCode(obs.ValReported); row.Cells.Add(icd10Value.Description); //2 Value } } else if (obs.ValType == EhrAptObsType.Address) { string sendingFacilityAddress1 = PrefC.GetString(PrefName.PracticeAddress); string sendingFacilityAddress2 = PrefC.GetString(PrefName.PracticeAddress2); string sendingFacilityCity = PrefC.GetString(PrefName.PracticeCity); string sendingFacilityState = PrefC.GetString(PrefName.PracticeST); string sendingFacilityZip = PrefC.GetString(PrefName.PracticeZip); if (PrefC.HasClinicsEnabled && _appt.ClinicNum != 0) //Using clinics and a clinic is assigned. { Clinic clinic = Clinics.GetClinic(_appt.ClinicNum); sendingFacilityAddress1 = clinic.Address; sendingFacilityAddress2 = clinic.Address2; sendingFacilityCity = clinic.City; sendingFacilityState = clinic.State; sendingFacilityZip = clinic.Zip; } row.Cells.Add(obs.ValType.ToString()); //1 Value Type row.Cells.Add(sendingFacilityAddress1 + " " + sendingFacilityAddress2 + " " + sendingFacilityCity + " " + sendingFacilityState + " " + sendingFacilityZip); //2 Value } else { row.Cells.Add(obs.ValType.ToString()); //1 Value Type row.Cells.Add(obs.ValReported); //2 Value } gridObservations.ListGridRows.Add(row); } gridObservations.EndUpdate(); }
private void FormEhrAptObsEdit_Load(object sender, EventArgs e) { _appt = Appointments.GetOneApt(_ehrAptObsCur.AptNum); comboObservationQuestion.Items.Clear(); string[] arrayQuestionNames = Enum.GetNames(typeof(EhrAptObsIdentifier)); for (int i = 0; i < arrayQuestionNames.Length; i++) { comboObservationQuestion.Items.Add(arrayQuestionNames[i]); EhrAptObsIdentifier ehrAptObsIdentifier = (EhrAptObsIdentifier)i; if (_ehrAptObsCur.IdentifyingCode == ehrAptObsIdentifier) { comboObservationQuestion.SelectedIndex = i; } } listValueType.Items.Clear(); string[] arrayValueTypeNames = Enum.GetNames(typeof(EhrAptObsType)); for (int i = 0; i < arrayValueTypeNames.Length; i++) { listValueType.Items.Add(arrayValueTypeNames[i]); EhrAptObsType ehrAptObsType = (EhrAptObsType)i; if (_ehrAptObsCur.ValType == ehrAptObsType) { listValueType.SelectedIndex = i; } } if (_ehrAptObsCur.ValType == EhrAptObsType.Coded) { _strValCodeSystem = _ehrAptObsCur.ValCodeSystem; if (_ehrAptObsCur.ValCodeSystem == "LOINC") { _loincValue = Loincs.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _loincValue.NameShort; } else if (_ehrAptObsCur.ValCodeSystem == "SNOMEDCT") { _snomedValue = Snomeds.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _snomedValue.Description; } else if (_ehrAptObsCur.ValCodeSystem == "ICD9") { _icd9Value = ICD9s.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _icd9Value.Description; } else if (_ehrAptObsCur.ValCodeSystem == "ICD10") { _icd10Value = Icd10s.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _icd10Value.Description; } } else { textValue.Text = _ehrAptObsCur.ValReported; } comboUnits.Items.Clear(); comboUnits.Items.Add("none"); comboUnits.SelectedIndex = 0; List <string> listUcumCodes = Ucums.GetAllCodes(); for (int i = 0; i < listUcumCodes.Count; i++) { string ucumCode = listUcumCodes[i]; comboUnits.Items.Add(ucumCode); if (ucumCode == _ehrAptObsCur.UcumCode) { comboUnits.SelectedIndex = i + 1; } } SetFlags(); }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Code", 70); gridMain.Columns.Add(col); col = new ODGridColumn("CodeSystem", 90); gridMain.Columns.Add(col); col = new ODGridColumn("Description", 200); gridMain.Columns.Add(col); string selectedValue = comboCodeSet.SelectedItem.ToString(); List <string> listValSetOIDs = new List <string>(); if (selectedValue == "All") { listValSetOIDs = new List <string>(dictValueCodeSets.Values); } else //this will limit the codes to only one value set oid { listValSetOIDs.Add(dictValueCodeSets[selectedValue]); } listCodes = EhrCodes.GetForValueSetOIDs(listValSetOIDs, true); //these codes will exist in the corresponding table or will not be in the list gridMain.Rows.Clear(); ODGridRow row; int selectedIdx = -1; for (int i = 0; i < listCodes.Count; i++) { row = new ODGridRow(); row.Cells.Add(listCodes[i].CodeValue); row.Cells.Add(listCodes[i].CodeSystem); //Retrieve description from the associated table string descript = ""; switch (listCodes[i].CodeSystem) { case "CPT": Cpt cCur = Cpts.GetByCode(listCodes[i].CodeValue); if (cCur != null) { descript = cCur.Description; } break; case "HCPCS": Hcpcs hCur = Hcpcses.GetByCode(listCodes[i].CodeValue); if (hCur != null) { descript = hCur.DescriptionShort; } break; case "ICD9CM": ICD9 i9Cur = ICD9s.GetByCode(listCodes[i].CodeValue); if (i9Cur != null) { descript = i9Cur.Description; } break; case "ICD10CM": Icd10 i10Cur = Icd10s.GetByCode(listCodes[i].CodeValue); if (i10Cur != null) { descript = i10Cur.Description; } break; case "RXNORM": descript = RxNorms.GetDescByRxCui(listCodes[i].CodeValue); break; case "SNOMEDCT": Snomed sCur = Snomeds.GetByCode(listCodes[i].CodeValue); if (sCur != null) { descript = sCur.Description; } break; } row.Cells.Add(descript); gridMain.Rows.Add(row); if (listCodes[i].CodeValue == InterventionCur.CodeValue && listCodes[i].CodeSystem == InterventionCur.CodeSystem) { selectedIdx = i; } } gridMain.EndUpdate(); if (selectedIdx > -1) { gridMain.SetSelected(selectedIdx, true); gridMain.ScrollToIndex(selectedIdx); } }
private void FormEhrSettings_Load(object sender, EventArgs e) { checkAlertHighSeverity.Checked = PrefC.GetBool(PrefName.EhrRxAlertHighSeverity); checkMU2.Checked = PrefC.GetBool(PrefName.MeaningfulUseTwo); #region DefaultEncounterGroup FillRecEncCodesList(); string defaultEncCode = PrefC.GetString(PrefName.CQMDefaultEncounterCodeValue); string defaultEncCodeSystem = PrefC.GetString(PrefName.CQMDefaultEncounterCodeSystem); NewEncCodeSystem = defaultEncCodeSystem; OldEncListSelectedIdx = -1; int countNotInSnomedTable = 0; for (int i = 0; i < ListRecEncCodes.Count; i++) { if (i == 0) { comboEncCodes.Items.Add(ListRecEncCodes[i]); comboEncCodes.SelectedIndex = i; if (defaultEncCode == ListRecEncCodes[i]) { comboEncCodes.SelectedIndex = i; OldEncListSelectedIdx = i; } continue; } if (!Snomeds.CodeExists(ListRecEncCodes[i])) { countNotInSnomedTable++; continue; } comboEncCodes.Items.Add(ListRecEncCodes[i]); if (ListRecEncCodes[i] == defaultEncCode && defaultEncCodeSystem == "SNOMEDCT") { comboEncCodes.SelectedIndex = i; OldEncListSelectedIdx = i; labelEncWarning.Visible = false; textEncCodeDescript.Text = Snomeds.GetByCode(ListRecEncCodes[i]).Description; //Guaranteed to exist in snomed table from above check } } if (countNotInSnomedTable > 0) { MsgBox.Show(this, "The snomed table does not contain one or more codes from the list of recommended encounter codes. The snomed table should be updated by running the Code System Importer tool found in Setup | EHR."); } if (comboEncCodes.SelectedIndex == -1) //default enc code set to code not in recommended list and not 'none' { switch (defaultEncCodeSystem) { case "CDT": textEncCodeValue.Text = ProcedureCodes.GetProcCode(defaultEncCode).ProcCode; //Will return a new ProcCode object, not null, if not found textEncCodeDescript.Text = ProcedureCodes.GetProcCode(defaultEncCode).Descript; break; case "CPT": Cpt cEnc = Cpts.GetByCode(defaultEncCode); if (cEnc != null) { textEncCodeValue.Text = cEnc.CptCode; textEncCodeDescript.Text = cEnc.Description; } break; case "SNOMEDCT": Snomed sEnc = Snomeds.GetByCode(defaultEncCode); if (sEnc != null) { textEncCodeValue.Text = sEnc.SnomedCode; textEncCodeDescript.Text = sEnc.Description; } break; case "HCPCS": Hcpcs hEnc = Hcpcses.GetByCode(defaultEncCode); if (hEnc != null) { textEncCodeValue.Text = hEnc.HcpcsCode; textEncCodeDescript.Text = hEnc.DescriptionShort; } break; } } #endregion #region DefaultPregnancyGroup FillRecPregCodesList(); string defaultPregCode = PrefC.GetString(PrefName.PregnancyDefaultCodeValue); string defaultPregCodeSystem = PrefC.GetString(PrefName.PregnancyDefaultCodeSystem); NewPregCodeSystem = defaultPregCodeSystem; OldPregListSelectedIdx = -1; countNotInSnomedTable = 0; for (int i = 0; i < ListRecPregCodes.Count; i++) { if (i == 0) { comboPregCodes.Items.Add(ListRecPregCodes[i]); comboPregCodes.SelectedIndex = i; if (defaultPregCode == ListRecPregCodes[i]) { comboPregCodes.SelectedIndex = i; OldPregListSelectedIdx = i; } continue; } if (!Snomeds.CodeExists(ListRecPregCodes[i])) { countNotInSnomedTable++; continue; } comboPregCodes.Items.Add(ListRecPregCodes[i]); if (ListRecPregCodes[i] == defaultPregCode && defaultPregCodeSystem == "SNOMEDCT") { comboPregCodes.SelectedIndex = i; OldPregListSelectedIdx = i; labelPregWarning.Visible = false; textPregCodeDescript.Text = Snomeds.GetByCode(ListRecPregCodes[i]).Description; //Guaranteed to exist in snomed table from above check } } if (countNotInSnomedTable > 0) { MsgBox.Show(this, "The snomed table does not contain one or more codes from the list of recommended pregnancy codes. The snomed table should be updated by running the Code System Importer tool found in Setup | EHR."); } if (comboPregCodes.SelectedIndex == -1) //default preg code set to code not in recommended list and not 'none' { switch (defaultPregCodeSystem) { case "ICD9CM": ICD9 i9Preg = ICD9s.GetByCode(defaultPregCode); if (i9Preg != null) { textPregCodeValue.Text = i9Preg.ICD9Code; textPregCodeDescript.Text = i9Preg.Description; } break; case "SNOMEDCT": Snomed sPreg = Snomeds.GetByCode(defaultPregCode); if (sPreg != null) { textPregCodeValue.Text = sPreg.SnomedCode; textPregCodeDescript.Text = sPreg.Description; } break; case "ICD10CM": Icd10 i10Preg = Icd10s.GetByCode(defaultPregCode); if (i10Preg != null) { textPregCodeValue.Text = i10Preg.Icd10Code; textPregCodeDescript.Text = i10Preg.Description; } break; default: break; } } #endregion }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Date", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Prov", 50); gridMain.Columns.Add(col); col = new ODGridColumn("Intervention Type", 115); gridMain.Columns.Add(col); col = new ODGridColumn("Code", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Code System", 85); gridMain.Columns.Add(col); col = new ODGridColumn("Code Description", 300); gridMain.Columns.Add(col); col = new ODGridColumn("Note", 100); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; #region Interventions listIntervention = Interventions.Refresh(PatCur.PatNum); for (int i = 0; i < listIntervention.Count; i++) { row = new ODGridRow(); row.Cells.Add(listIntervention[i].DateEntry.ToShortDateString()); row.Cells.Add(Providers.GetAbbr(listIntervention[i].ProvNum)); row.Cells.Add(listIntervention[i].CodeSet.ToString()); row.Cells.Add(listIntervention[i].CodeValue); row.Cells.Add(listIntervention[i].CodeSystem); //Description of Intervention--------------------------------------------- //to get description, first determine which table the code is from. Interventions are allowed to be SNOMEDCT, ICD9, ICD10, HCPCS, or CPT. string descript = ""; switch (listIntervention[i].CodeSystem) { case "SNOMEDCT": Snomed sCur = Snomeds.GetByCode(listIntervention[i].CodeValue); if (sCur != null) { descript = sCur.Description; } break; case "ICD9CM": ICD9 i9Cur = ICD9s.GetByCode(listIntervention[i].CodeValue); if (i9Cur != null) { descript = i9Cur.Description; } break; case "ICD10CM": Icd10 i10Cur = Icd10s.GetByCode(listIntervention[i].CodeValue); if (i10Cur != null) { descript = i10Cur.Description; } break; case "HCPCS": Hcpcs hCur = Hcpcses.GetByCode(listIntervention[i].CodeValue); if (hCur != null) { descript = hCur.DescriptionShort; } break; case "CPT": Cpt cptCur = Cpts.GetByCode(listIntervention[i].CodeValue); if (cptCur != null) { descript = cptCur.Description; } break; } row.Cells.Add(descript); row.Cells.Add(listIntervention[i].Note); row.Tag = listIntervention[i]; gridMain.Rows.Add(row); } #endregion #region MedicationPats listMedPats = MedicationPats.Refresh(PatCur.PatNum, true); if (listMedPats.Count > 0) { //The following medications are used as interventions for some measures. Include them in the intervention window if they belong to these value sets. //Above Normal Medications RxNorm Value Set, Below Normal Medications RxNorm Value Set, Tobacco Use Cessation Pharmacotherapy Value Set List <string> listVS = new List <string> { "2.16.840.1.113883.3.600.1.1498", "2.16.840.1.113883.3.600.1.1499", "2.16.840.1.113883.3.526.3.1190" }; List <EhrCode> listEhrMeds = EhrCodes.GetForValueSetOIDs(listVS, true); for (int i = listMedPats.Count - 1; i > -1; i--) { bool found = false; for (int j = 0; j < listEhrMeds.Count; j++) { if (listMedPats[i].RxCui.ToString() == listEhrMeds[j].CodeValue) { found = true; break; } } if (!found) { listMedPats.RemoveAt(i); } } } for (int i = 0; i < listMedPats.Count; i++) { row = new ODGridRow(); row.Cells.Add(listMedPats[i].DateStart.ToShortDateString()); row.Cells.Add(Providers.GetAbbr(listMedPats[i].ProvNum)); if (listMedPats[i].RxCui == 314153 || listMedPats[i].RxCui == 692876) { row.Cells.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Medication"); } else if (listMedPats[i].RxCui == 577154 || listMedPats[i].RxCui == 860215 || listMedPats[i].RxCui == 860221 || listMedPats[i].RxCui == 860225 || listMedPats[i].RxCui == 860231) { row.Cells.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Medication"); } else //There are 48 total medications that can be used as interventions. The remaining 41 medications are tobacco cessation medications { row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication"); } row.Cells.Add(listMedPats[i].RxCui.ToString()); row.Cells.Add("RXNORM"); //Medications that are used as interventions are all RxNorm codes, get description from that table string descript = RxNorms.GetDescByRxCui(listMedPats[i].RxCui.ToString()); row.Cells.Add(descript); row.Cells.Add(listMedPats[i].PatNote); row.Tag = listMedPats[i]; gridMain.Rows.Add(row); } #endregion gridMain.EndUpdate(); }