public OptionDiseaseForm(Disease disease) { InitializeComponent(); Application.Idle += new EventHandler(Application_Idle); fDisease = disease.Copy(); NameBox.Text = fDisease.Name; LevelBox.Text = fDisease.Level; ImproveBox.Text = fDisease.ImproveDC; MaintainBox.Text = fDisease.MaintainDC; DetailsBox.Text = fDisease.Details; update_list(); }
public static void ProcessPRB(Patient pat,HL7DefSegment segDef,SegmentHL7 seg,MessageHL7 msg) { int probActionOrder=-1; int probCodeOrder=-1; int probStartDateOrder=-1; int probStopDateOrder=-1; int probUniqueIdOrder=-1; for(int i=0;i<segDef.hl7DefFields.Count;i++) { int itemOrder=segDef.hl7DefFields[i].OrdinalPos; switch(segDef.hl7DefFields[i].FieldName) { case "problemAction": probActionOrder=itemOrder; continue; case "problemCode": probCodeOrder=itemOrder; continue; case "problemStartDate": probStartDateOrder=itemOrder; continue; case "problemStopDate": probStopDateOrder=itemOrder; continue; case "problemUniqueId": probUniqueIdOrder=itemOrder; continue; default: continue; } } //we need these 3 items defined in order to process the problem if(probActionOrder<0 || probCodeOrder<0 || probUniqueIdOrder<0) { EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. The segment must have an action, code, and unique ID defined.",EventLogEntryType.Information); return; } //get values from defined locations within the segment and validate info //We only add or update problems. Other actions like delete or correct are not yet supported if(seg.GetFieldComponent(probActionOrder).ToLower()!="ad" && seg.GetFieldComponent(probActionOrder).ToLower()!="up") { EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. The action codes supported are 'AD' for add or 'UP' for update.",EventLogEntryType.Information); return; } long probDefNum=DiseaseDefs.GetNumFromSnomed(PIn.String(seg.GetFieldComponent(probCodeOrder,0))); //The problem must be a SNOMEDCT code, identified by the coding system table 0396 value "SNM" in component 3 of the CWE problem code field //There must be a disease def setup with the SNOMEDCT code in the problem list or we will ignore this problem if(seg.GetFieldComponent(probCodeOrder,2).ToLower()!="snm" || probDefNum==0) { EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. " +"The code is not attached to an existing problem definition or is not a SNOMEDCT code.",EventLogEntryType.Information); return; } string probIdExternal=seg.GetFieldComponent(probUniqueIdOrder,0); string probRootExternal=seg.GetFieldComponent(probUniqueIdOrder,2); if(probIdExternal=="" || probRootExternal=="") { EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. " +" The problem does not have a unique ID with assigning authority root.",EventLogEntryType.Information); return; } //If problem external ID and root is in the database, but is used to identify an object other than a problem, do not process the segment OIDExternal probOidExt=OIDExternals.GetByRootAndExtension(probRootExternal,probIdExternal); if(probOidExt!=null && probOidExt.IDType!=IdentifierType.Problem) { EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. " +"The problem has a unique ID with assigning authority root that has already been used to identify an object of type " +probOidExt.IDType.ToString()+".",EventLogEntryType.Information); return; } long diseaseNum=0; if(probOidExt!=null) {//exists in oidexternal table and is of type Problem, so IDInternal is a DiseaseNum diseaseNum=probOidExt.IDInternal; } Disease probCur=new Disease(); probCur.DiseaseNum=diseaseNum;//probNum could be 0 if new //The problem referenced by the external root and ID is already linked in the oidexternal table, get the problem to update //Also make sure the problem linked by oidexternal table is for the patient identified in the PID segment if(diseaseNum!=0) { probCur=Diseases.GetOne(diseaseNum); if(probCur==null || probCur.PatNum!=pat.PatNum) {//should never be null if in the oidexternal table EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. " +"The problem referenced and the patient in the PID segment do not match.",EventLogEntryType.Information); return; } } DateTime dateProbStart=DateTime.MinValue; if(probStartDateOrder>-1) { dateProbStart=FieldParser.DateTimeParse(seg.GetFieldComponent(probStartDateOrder)); } DateTime dateProbStop=DateTime.MinValue; if(probStopDateOrder>-1) { dateProbStop=FieldParser.DateTimeParse(seg.GetFieldComponent(probStopDateOrder)); } //The patient may already have an active problem with this DiseaseDefNum, but it is not referenced by this problem GUID //Mark the existing problem inactive and add a new one with StartDate of today //Add an entry in the oidexternal table that will point the problem GUID to this new problem. List<Disease> listProbsForPat=Diseases.GetDiseasesForPatient(pat.PatNum,probDefNum,true); int markedInactiveCount=0; for(int p=0;p<listProbsForPat.Count;p++) { if(listProbsForPat[p].DiseaseNum==diseaseNum) {//probNum may be 0 if there was not an existing problem referenced by the GUID in the message continue; } listProbsForPat[p].ProbStatus=ProblemStatus.Inactive; Diseases.Update(listProbsForPat[p]); markedInactiveCount++; } if(_isVerboseLogging && markedInactiveCount>0) { EventLog.WriteEntry("OpenDentHL7","Updated "+markedInactiveCount.ToString()+" problems to a status of inactive due to an incoming PRB segment.",EventLogEntryType.Information); } Disease probOld=probCur.Copy(); probCur.PatNum=pat.PatNum; probCur.DiseaseDefNum=probDefNum; probCur.ProbStatus=ProblemStatus.Active; probCur.DateStart=dateProbStart;//could be '0001-01-01' if not present or not the correct format, handled by FieldParser.DateTimeParse probCur.DateStop=dateProbStop;//could be '0001-01-01' if not present or not the correct format, handled by FieldParser.DateTimeParse if(probCur.DiseaseNum==0) {//new problem //insert new problem probCur.DiseaseNum=Diseases.Insert(probCur); if(_isVerboseLogging) { EventLog.WriteEntry("OpenDentHL7","Inserted a new problem for patient "+pat.GetNameFLnoPref()+" due to an incoming PRB segment.",EventLogEntryType.Information); } //using DiseaseNum from newly inserted problem, link to the external GUID and root in the oidexternals table probOidExt=new OIDExternal(); probOidExt.IDType=IdentifierType.Problem; probOidExt.IDInternal=probCur.DiseaseNum; probOidExt.IDExternal=probIdExternal; probOidExt.rootExternal=probRootExternal; OIDExternals.Insert(probOidExt); if(_isVerboseLogging) { EventLog.WriteEntry("OpenDentHL7","Added an external problem ID to the oidexternals table due to an incoming PRB segment.\r\nDiseaesNum: " +probCur.DiseaseNum.ToString()+", External problem ID: "+probOidExt.IDExternal+", External root: "+probOidExt.rootExternal+".",EventLogEntryType.Information); } } else {//the segment is for an existing problem, update fields if necessary Diseases.Update(probCur,probOld); if(_isVerboseLogging) { EventLog.WriteEntry("OpenDentHL7","Updated an existing problem for patient "+pat.GetNameFLnoPref()+" due to an incoming PRB segment.",EventLogEntryType.Information); } } return; }