private void butOK_Click(object sender,EventArgs e) { if(textDescription.Text=="") { MessageBox.Show(this,"Please enter a description."); return; } try { MedOrderCur.DateTimeOrder=PIn.DateT(textDateTime.Text); } catch { MessageBox.Show(this,"Please enter a Date Time with format DD/MM/YYYY HH:mm AM/PM"); } MedOrderCur.Description=textDescription.Text; MedOrderCur.IsDiscontinued=checkIsDiscontinued.Checked; if(comboProv.SelectedIndex==-1) { //don't make any changes to provnum. 0 is ok, but should never happen. ProvNum might also be for a hidden prov. } else { MedOrderCur.ProvNum=ProviderC.ListShort[comboProv.SelectedIndex].ProvNum; } if(IsNew) { MedicalOrders.Insert(MedOrderCur); EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.CPOE_RadOrdered; newMeasureEvent.PatNum=MedOrderCur.PatNum; newMeasureEvent.MoreInfo=""; newMeasureEvent.FKey=MedOrderCur.MedicalOrderNum; EhrMeasureEvents.Insert(newMeasureEvent); } else { MedicalOrders.Update(MedOrderCur); } DialogResult=DialogResult.OK; }
///<summary>When sent by email or exported, this records the event. It also recordes a request if needed.</summary> private void RecordRequestAndProvide() { //If there's not an event for a request within the last 5 days, automatically add one. bool requestExists=false; for(int i=0;i<listHistory.Count;i++) { if(listHistory[i].EventType!=EhrMeasureEventType.ElectronicCopyRequested) { continue; } if(listHistory[i].DateTEvent.Date >= DateTime.Today.AddDays(-5)) { requestExists=true; break; } } EhrMeasureEvent measureEvent; if(!requestExists) { measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now.AddMinutes(-1); measureEvent.EventType = EhrMeasureEventType.ElectronicCopyRequested; measureEvent.PatNum = PatCur.PatNum; measureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(measureEvent); } //Always add an event for providing the electronic copy measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now; measureEvent.EventType = EhrMeasureEventType.ElectronicCopyProvidedToPt; measureEvent.PatNum = PatCur.PatNum; measureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(measureEvent); FillGrid(); }
///<summary></summary> public static long Insert(EhrMeasureEvent ehrMeasureEvent){ if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){ ehrMeasureEvent.EhrMeasureEventNum=Meth.GetLong(MethodBase.GetCurrentMethod(),ehrMeasureEvent); return ehrMeasureEvent.EhrMeasureEventNum; } return Crud.EhrMeasureEventCrud.Insert(ehrMeasureEvent); }
private void gridEdu_CellClick(object sender,ODGridClickEventArgs e) { if(e.Col!=1) { return; } bool didPrint = false; try { FormEhrEduBrowser FormEDUB = new FormEhrEduBrowser(eduResourceList[e.Row].ResourceUrl); FormEDUB.ShowDialog(); didPrint = FormEDUB.DidPrint; //System.Diagnostics.Process.Start(eduResourceList[e.Row].ResourceUrl); } catch { MessageBox.Show("Link not found."); return; } if(didPrint) { EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.EducationProvided; newMeasureEvent.PatNum=patCur.PatNum; newMeasureEvent.MoreInfo=eduResourceList[e.Row].ResourceUrl; EhrMeasureEvents.Insert(newMeasureEvent); FillGridProvided(); } }
///<summary></summary> public static void Update(EhrMeasureEvent ehrMeasureEvent) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(),ehrMeasureEvent); return; } Crud.EhrMeasureEventCrud.Update(ehrMeasureEvent); }
///<summary></summary> public static long Insert(EhrMeasureEvent ehrMeasureEvent) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { ehrMeasureEvent.EhrMeasureEventNum = Meth.GetLong(MethodBase.GetCurrentMethod(), ehrMeasureEvent); return(ehrMeasureEvent.EhrMeasureEventNum); } return(Crud.EhrMeasureEventCrud.Insert(ehrMeasureEvent)); }
///<summary></summary> public static void Update(EhrMeasureEvent ehrMeasureEvent) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), ehrMeasureEvent); return; } Crud.EhrMeasureEventCrud.Update(ehrMeasureEvent); }
private void butRequest_Click(object sender,EventArgs e) { EhrMeasureEvent measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now.AddMinutes(-1); measureEvent.EventType = EhrMeasureEventType.ElectronicCopyRequested; measureEvent.PatNum = PatCur.PatNum; measureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(measureEvent); FillGrid(); }
private void butAddEvent_Click(object sender,EventArgs e) { EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.MedicationReconcile; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.MoreInfo=""; EhrMeasureEvents.Insert(newMeasureEvent); FillReconcilesGrid(); }
///<summary>Creates a measure event for the patient and event type passed in. Used by eServices.</summary> public static long CreateEventForPat(long patNum, EhrMeasureEventType measureEventType) { //No need to check RemotingRole; no call to db. EhrMeasureEvent measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now; measureEvent.EventType = measureEventType; measureEvent.PatNum = patNum; measureEvent.MoreInfo = ""; return(Insert(measureEvent)); }
///<summary>Generates a username and password if necessary for this patient. If the patient already has access to the Patient Portal or if they ///are not eligible to be given access, this will return null.</summary> public static UserWeb GetNewPatientPortalCredentials(Patient pat, bool doUpdateDatabase, out string passwordGenerated) { //No need to check RemotingRole; no call to db. passwordGenerated = ""; if (string.IsNullOrEmpty(PrefC.GetString(PrefName.PatientPortalURL))) { return(null); //Haven't set up patient portal yet. } string errors; if (!UserWebs.ValidatePatientAccess(pat, out errors)) { return(null); //Patient is missing necessary fields. } UserWeb userWeb = UserWebs.GetByFKeyAndType(pat.PatNum, UserWebFKeyType.PatientPortal); if (userWeb == null) { userWeb = new UserWeb(); userWeb.UserName = UserWebs.CreateUserNameFromPat(pat, UserWebFKeyType.PatientPortal); userWeb.FKey = pat.PatNum; userWeb.FKeyType = UserWebFKeyType.PatientPortal; userWeb.RequireUserNameChange = true; userWeb.Password = ""; userWeb.IsNew = true; if (doUpdateDatabase) { UserWebs.Insert(userWeb); } } if (!string.IsNullOrEmpty(userWeb.Password) && //If they already have access to the Patient Portal, return. !userWeb.RequirePasswordChange) //If they need to change their password, we are going to generate another password for them. { return(null); } if (string.IsNullOrEmpty(userWeb.Password) && //Only insert an EHR event if their password is blank (meaning they don't currently have access). doUpdateDatabase) { EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.OnlineAccessProvided; newMeasureEvent.PatNum = pat.PatNum; newMeasureEvent.MoreInfo = ""; EhrMeasureEvents.Insert(newMeasureEvent); } passwordGenerated = UserWebs.GenerateRandomPassword(8); userWeb.Password = Userods.HashPassword(passwordGenerated, false); userWeb.RequirePasswordChange = true; if (doUpdateDatabase) { UserWebs.Update(userWeb); } return(userWeb); }
private void butGiveAccess_Click(object sender,EventArgs e) { if(butGiveAccess.Text=="Provide Online Access") {//When form open opens with a blank password if(PrefC.GetString(PrefName.PatientPortalURL)=="") { //User probably hasn't set up the patient portal yet. MsgBox.Show(this,"Patient Facing URL is required to be set before granting online access. Click Setup to set the Patient Facing URL."); return; } string error=ValidatePatientAccess(); if(error!="") { MessageBox.Show(error); return; } Cursor=Cursors.WaitCursor; //1. Fill password. string passwordGenerated=GenerateRandomPassword(8); textOnlinePassword.Text=passwordGenerated; //2. Make the password editable in case they want to change it. textOnlinePassword.ReadOnly=false; //3. Save password to db. // We only save the hash of the generated password. string passwordHashed=Userods.EncryptPassword(passwordGenerated,false); PatCur.OnlinePassword=passwordHashed; Patients.Update(PatCur,PatOld); PatOld.OnlinePassword=passwordHashed;//Update PatOld in case the user changes password manually. //4. Insert EhrMeasureEvent EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.OnlineAccessProvided; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.MoreInfo=""; EhrMeasureEvents.Insert(newMeasureEvent); //5. Rename button butGiveAccess.Text="Remove Online Access"; Cursor=Cursors.Default; } else {//remove access Cursor=Cursors.WaitCursor; //1. Clear password textOnlinePassword.Text=""; //2. Make in uneditable textOnlinePassword.ReadOnly=true; //3. Save password to db PatCur.OnlinePassword=textOnlinePassword.Text; Patients.Update(PatCur,PatOld); PatOld.OnlinePassword=textOnlinePassword.Text;//Update PatOld in case the user changes password manually. //4. Rename button butGiveAccess.Text="Provide Online Access"; Cursor=Cursors.Default; } }
///<summary>Gets the MoreInfo column from the most recent event of the specified type. Returns blank if none exists.</summary> public static string GetLatestInfoByType(EhrMeasureEventType measureEventType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetString(MethodBase.GetCurrentMethod(), measureEventType)); } string command = "SELECT * FROM ehrmeasureevent WHERE EventType=" + POut.Int((int)measureEventType) + " ORDER BY DateTEvent DESC LIMIT 1"; EhrMeasureEvent measureEvent = Crud.EhrMeasureEventCrud.SelectOne(command); if (measureEvent == null) { return(""); } else { return(measureEvent.MoreInfo); } }
private void butExport_Click(object sender,EventArgs e) { string ccd=""; try { FormEhrExportCCD FormEEC=new FormEhrExportCCD(PatCur); FormEEC.ShowDialog(); if(FormEEC.DialogResult==DialogResult.OK) { ccd=FormEEC.CCD; } else { return; } } catch(Exception ex) { MessageBox.Show(ex.Message); return; } FolderBrowserDialog dlg=new FolderBrowserDialog(); dlg.SelectedPath=ImageStore.GetPatientFolder(PatCur,ImageStore.GetPreferredAtoZpath());//Default to patient image folder. DialogResult result=dlg.ShowDialog(); if(result!=DialogResult.OK) { return; } if(File.Exists(Path.Combine(dlg.SelectedPath,"ccd.xml"))){ if(MessageBox.Show("Overwrite existing ccd.xml?","",MessageBoxButtons.OKCancel)!=DialogResult.OK){ return; } } File.WriteAllText(Path.Combine(dlg.SelectedPath,"ccd.xml"),ccd); File.WriteAllText(Path.Combine(dlg.SelectedPath,"ccd.xsl"),FormEHR.GetEhrResource("CCD")); EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.ClinicalSummaryProvidedToPt; newMeasureEvent.PatNum = PatCur.PatNum; EhrMeasureEvents.Insert(newMeasureEvent); FillGridEHRMeasureEvents(); MessageBox.Show("Exported"); }
///<summary>Helper for GenerateCcdSectionSocialHistory(). Sort function. Currently sorts by date ascending.</summary> private int CompareEhrMeasureEvents(EhrMeasureEvent ehrMeasureEventL,EhrMeasureEvent ehrMeasureEventR) { if(ehrMeasureEventL.DateTEvent<ehrMeasureEventR.DateTEvent) { return -1; } else if(ehrMeasureEventL.DateTEvent>ehrMeasureEventR.DateTEvent) { return 1; } return 0;//equal }
///<summary>Helper for GenerateCCD(). Exports smoking and pregnancy information.</summary> private void GenerateCcdSectionSocialHistory(bool hasSocialHistory) { _w.WriteComment(@" ===================================================================================================== Social History ====================================================================================================="); List<EhrMeasureEvent> listEhrMeasureEventsFiltered; if(!hasSocialHistory) { listEhrMeasureEventsFiltered=new List<EhrMeasureEvent>(); } else { listEhrMeasureEventsFiltered=_listEhrMeasureEventsFiltered; } listEhrMeasureEventsFiltered.Sort(CompareEhrMeasureEvents); //The pattern for this section is special. We do not have any lists to use in this section. //The section will always be present with at least one entry, beacuse we know the patient smoking status (which includes the UnknownIfEver option). Start("component"); Start("section"); TemplateId("2.16.840.1.113883.10.20.22.2.17");//Social History section (page 311). Only one template. No entries are required. _w.WriteComment("Social History section template"); StartAndEnd("code","code","29762-2","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","Social History"); _w.WriteElementString("title","Social History"); Start("text");//The following text will be parsed as html with a style sheet to be human readable. if(listEhrMeasureEventsFiltered.Count>0 && hasSocialHistory) { Start("table","width","100%","border","1"); Start("thead"); Start("tr"); _w.WriteElementString("th","Social History Element"); _w.WriteElementString("th","Description"); _w.WriteElementString("th","Effective Dates"); End("tr"); End("thead"); Start("tbody"); for(int i=0;i<listEhrMeasureEventsFiltered.Count;i++) { Start("tr"); _w.WriteElementString("td","Smoking"); Snomed snomedSmoking=Snomeds.GetByCode(listEhrMeasureEventsFiltered[i].CodeValueResult); if(snomedSmoking==null) {//Could be null if the code was imported from another EHR. _w.WriteElementString("td",""); } else { _w.WriteElementString("td",snomedSmoking.SnomedCode+" - "+snomedSmoking.Description); } DateTime dateTimeLow=listEhrMeasureEventsFiltered[i].DateTEvent; DateTime dateTimeHigh=DateTime.Now; if(i<listEhrMeasureEventsFiltered.Count-1) {//There is another smoking event after this one (remember, they are sorted by date). dateTimeHigh=listEhrMeasureEventsFiltered[i+1].DateTEvent.AddDays(-1);//The day before the next smoking event. if(dateTimeHigh<dateTimeLow) { dateTimeHigh=dateTimeLow;//Just in case the user entered two measures for the same date. } } if(dateTimeLow.Year<1880) { if(dateTimeHigh.Year<1880) { _w.WriteElementString("td",""); } else { _w.WriteElementString("td",dateTimeHigh.ToString("yyyyMMdd")); } } else if(dateTimeHigh.Year<1880) { if(dateTimeLow.Year<1880) { _w.WriteElementString("td",""); } else { _w.WriteElementString("td",dateTimeLow.ToString("yyyyMMdd")); } } else { _w.WriteElementString("td",dateTimeLow.ToString("yyyyMMdd")+" to "+dateTimeHigh.ToString("yyyyMMdd")); } End("tr"); } End("tbody"); End("table"); } else { _w.WriteString("None"); } End("text"); if(listEhrMeasureEventsFiltered.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. EhrMeasureEvent eME=new EhrMeasureEvent(); listEhrMeasureEventsFiltered.Add(eME); } for(int i=0;i<listEhrMeasureEventsFiltered.Count;i++) { //Pregnancy Observation Template could easily be added in the future, but for now it is skipped (Page 453) Start("entry","typeCode","DRIV"); Start("observation","classCode","OBS","moodCode","EVN"); TemplateId("2.16.840.1.113883.10.20.22.4.78");//Smoking Status Observation Section (Page 519). _w.WriteComment("Smoking Status Observation Template"); StartAndEnd("code","code","ASSERTION","codeSystem","2.16.840.1.113883.5.4"); StartAndEnd("statusCode","code","completed");//Allowed values: completed. //The effectiveTime/low element must be present. If the patient is an ex-smoker (8517006), the effectiveTime/high element must also be present. For simplicity, we always export both low and high dates. DateTime dateTimeLow=listEhrMeasureEventsFiltered[i].DateTEvent; DateTime dateTimeHigh=DateTime.Now; if(i<listEhrMeasureEventsFiltered.Count-1) {//There is another smoking event after this one (remember, they are sorted by date). dateTimeHigh=listEhrMeasureEventsFiltered[i+1].DateTEvent.AddDays(-1);//The day before the next smoking event. if(dateTimeHigh<dateTimeLow) { dateTimeHigh=dateTimeLow;//Just in case the user entered two measures for the same date. } } Start("effectiveTime"); if(dateTimeLow.Year<1880) { StartAndEnd("low","nullFlavor","UNK"); } else { DateElement("low",dateTimeLow); } if(dateTimeHigh.Year<1880) { StartAndEnd("high","nullFlavor","UNK"); } else { DateElement("high",dateTimeHigh); } End("effectiveTime"); Start("value"); _w.WriteAttributeString("xsi","type",null,"CD"); Snomed snomedSmoking=Snomeds.GetByCode(listEhrMeasureEventsFiltered[i].CodeValueResult); if(snomedSmoking==null) { Attribs("nullFlavor","UNK"); } else { Attribs("code",snomedSmoking.SnomedCode,"displayName",snomedSmoking.Description,"codeSystem",strCodeSystemSnomed,"codeSystemName",strCodeSystemNameSnomed); } End("value"); End("observation"); End("entry"); } End("section"); End("component"); }
private void butExport_Click(object sender,EventArgs e) { //Generate the CCD first so that any validation errors are apparent and up front. //It is better to not let the user waste their time creating a referral if there is a basic validation issue with the CCD generation. string ccd=""; try { ccd=EhrCCD.GenerateSummaryOfCare(PatCur); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } FormReferralsPatient FormRP=new FormReferralsPatient(); FormRP.PatNum=PatCur.PatNum; FormRP.IsSelectionMode=true; if(FormRP.ShowDialog()==DialogResult.Cancel) { MessageBox.Show("Summary of Care not exported."); return; } FolderBrowserDialog dlg=new FolderBrowserDialog(); dlg.SelectedPath=ImageStore.GetPatientFolder(PatCur,ImageStore.GetPreferredAtoZpath());//Default to patient image folder. DialogResult result=dlg.ShowDialog(); if(result!=DialogResult.OK) { return; } if(File.Exists(Path.Combine(dlg.SelectedPath,"ccd.xml"))) { if(MessageBox.Show("Overwrite existing ccd.xml?","",MessageBoxButtons.OKCancel)!=DialogResult.OK) { return; } } File.WriteAllText(Path.Combine(dlg.SelectedPath,"ccd.xml"),ccd); File.WriteAllText(Path.Combine(dlg.SelectedPath,"ccd.xsl"),FormEHR.GetEhrResource("CCD")); EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = DateTime.Now; newMeasureEvent.EventType = EhrMeasureEventType.SummaryOfCareProvidedToDr; newMeasureEvent.PatNum = PatCur.PatNum; newMeasureEvent.FKey=FormRP.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason. long fkey=EhrMeasureEvents.Insert(newMeasureEvent); newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.FKey=fkey; newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDrElectronic; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.FKey=FormRP.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason. EhrMeasureEvents.Insert(newMeasureEvent); FillGridSent(); MessageBox.Show("Exported"); }
private void butAddTo_Click(object sender,EventArgs e) { if(!Security.IsAuthorized(Permissions.RefAttachAdd)) { return; } FormReferralSelect FormRS=new FormReferralSelect(); FormRS.IsSelectionMode=true; FormRS.ShowDialog(); if(FormRS.DialogResult!=DialogResult.OK) { return; } RefAttach refattach=new RefAttach(); refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum; refattach.PatNum=PatNum; refattach.IsFrom=false; refattach.RefDate=DateTimeOD.Today; if(FormRS.SelectedReferral.IsDoctor) { refattach.IsTransitionOfCare=true; } int order=0; for(int i=0;i<RefAttachList.Count;i++) { if(RefAttachList[i].ItemOrder > order) { order=RefAttachList[i].ItemOrder; } } refattach.ItemOrder=order+1; refattach.ProcNum=ProcNum; //We want to help EHR users meet their measures. Therefore, we are going to make an educated guess as to who is making this referral. //We are doing this for non-EHR users as well because we think it might be nice automation. long provNumLastAppt=Appointments.GetProvNumFromLastApptForPat(PatNum); if(Security.CurUser.ProvNum!=0) { refattach.ProvNum=Security.CurUser.ProvNum; } else if(provNumLastAppt!=0) { refattach.ProvNum=provNumLastAppt; } else { refattach.ProvNum=Patients.GetPat(PatNum).PriProv; } RefAttaches.Insert(refattach); SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd,PatNum,"Referred To "+Referrals.GetNameFL(refattach.ReferralNum)); if(PrefC.GetBool(PrefName.ShowFeatureEhr)) { FormRefAttachEdit FormRAE=new FormRefAttachEdit(); FormRAE.RefAttachCur=refattach; FormRAE.ShowDialog(); //In order to help offices meet EHR Summary of Care measure 1 of Core Measure 15 of 17, we are going to send a summary of care to the patient portal behind the scenes. //We can send the summary of care to the patient instead of to the Dr. because of the following point in the Additional Information section of the Core Measure: //"The EP can send an electronic or paper copy of the summary care record directly to the next provider or can provide it to the patient to deliver to the next provider, if the patient can reasonably expected to do so and meet Measure 1." //We will only send the summary of care if the ref attach is a TO referral and is a transition of care. if(FormRAE.DialogResult==DialogResult.OK && !refattach.IsFrom && refattach.IsTransitionOfCare) { try { //This is like FormEhrClinicalSummary.butSendToPortal_Click such that the email gets treated like a web mail. Patient PatCur=Patients.GetPat(PatNum); string strCcdValidationErrors=EhrCCD.ValidateSettings(); if(strCcdValidationErrors!="") { throw new Exception(); } strCcdValidationErrors=EhrCCD.ValidatePatient(PatCur); if(strCcdValidationErrors!="") { throw new Exception(); } Provider prov=null; if(Security.CurUser.ProvNum!=0) { prov=Providers.GetProv(Security.CurUser.ProvNum); } else { prov=Providers.GetProv(PatCur.PriProv); } EmailMessage msgWebMail=new EmailMessage();//New mail object msgWebMail.FromAddress=prov.GetFormalName();//Adding from address msgWebMail.ToAddress=PatCur.GetNameFL();//Adding to address msgWebMail.PatNum=PatCur.PatNum;//Adding patient number msgWebMail.SentOrReceived=EmailSentOrReceived.WebMailSent;//Setting to sent msgWebMail.ProvNumWebMail=prov.ProvNum;//Adding provider number msgWebMail.Subject="Referral To "+FormRS.SelectedReferral.GetNameFL(); msgWebMail.BodyText= "You have been referred to another provider. Your summary of care is attached.\r\n" +"You may give a copy of this summary of care to the referred provider if desired.\r\n" +"The contact information for the doctor you are being referred to is as follows:\r\n" +"\r\n"; //Here we provide the same information that would go out on a Referral Slip. //When the user prints a Referral Slip, the doctor referred to information is included and contains the doctor's name, address, and phone. msgWebMail.BodyText+="Name: "+FormRS.SelectedReferral.GetNameFL()+"\r\n"; if(FormRS.SelectedReferral.Address.Trim()!="") { msgWebMail.BodyText+="Address: "+FormRS.SelectedReferral.Address.Trim()+"\r\n"; if(FormRS.SelectedReferral.Address2.Trim()!="") { msgWebMail.BodyText+="\t"+FormRS.SelectedReferral.Address2.Trim()+"\r\n"; } msgWebMail.BodyText+="\t"+FormRS.SelectedReferral.City+" "+FormRS.SelectedReferral.ST+" "+FormRS.SelectedReferral.Zip+"\r\n"; } if(FormRS.SelectedReferral.Telephone!="") { msgWebMail.BodyText+="Phone: ("+FormRS.SelectedReferral.Telephone.Substring(0,3)+")"+FormRS.SelectedReferral.Telephone.Substring(3,3)+"-"+FormRS.SelectedReferral.Telephone.Substring(6)+"\r\n"; } msgWebMail.BodyText+= "\r\n" +"To view the Summary of Care for the referral to this provider:\r\n" +"1) Download all attachments to the same folder. Do not rename the files.\r\n" +"2) Open the ccd.xml file in an internet browser."; msgWebMail.MsgDateTime=DateTime.Now;//Message time is now msgWebMail.PatNumSubj=PatCur.PatNum;//Subject of the message is current patient string ccd=""; Cursor=Cursors.WaitCursor; ccd=EhrCCD.GenerateSummaryOfCare(Patients.GetPat(PatNum));//Create summary of care, can throw exceptions but they're caught below msgWebMail.Attachments.Add(EmailAttaches.CreateAttach("ccd.xml",Encoding.UTF8.GetBytes(ccd)));//Create summary of care attachment, can throw exceptions but caught below msgWebMail.Attachments.Add(EmailAttaches.CreateAttach("ccd.xsl",Encoding.UTF8.GetBytes(FormEHR.GetEhrResource("CCD"))));//Create xsl attachment, can throw exceptions EmailMessages.Insert(msgWebMail);//Insert mail into DB for patient portal EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDr; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.FKey=FormRAE.RefAttachCur.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason. EhrMeasureEvents.Insert(newMeasureEvent); } catch { //We are just trying to be helpful so it doesn't really matter if something failed above. //They can simply go to the EHR dashboard and send the summary of care manually like they always have. They will get detailed validation errors there. MsgBox.Show(this,Lan.g(this,"There was a problem automatically sending a summary of care. Please go to the EHR dashboard to send a summary of care to meet the summary of care core measure.")); } } } Cursor=Cursors.Default; FillGrid(); for(int i=0;i<RefAttachList.Count;i++) { if(RefAttachList[i].ReferralNum==refattach.ReferralNum) { gridMain.SetSelected(i,true); } } }
private void RxSelected(){ if(gridMain.GetSelectedIndex()==-1) { //this should never happen return; } RxDef RxDefCur=RxDefList[gridMain.GetSelectedIndex()]; if(PrefC.GetBool(PrefName.ShowFeatureEhr) && RxDefCur.RxCui==0) { string strMsgText=Lan.g(this,"The selected prescription is missing an RxNorm")+".\r\n" +Lan.g(this,"Prescriptions without RxNorms cannot be exported in EHR documents")+".\r\n" +Lan.g(this,"Edit RxNorm in Rx Template?"); if(MsgBox.Show(this,true,strMsgText)) { FormRxDefEdit form=new FormRxDefEdit(RxDefCur); form.ShowDialog(); RxDefCur=RxDefs.GetOne(RxDefCur.RxDefNum);//FormRxDefEdit does not modify the RxDefCur object, so we must get the updated RxCui from the db. } } //Alert if(!RxAlertL.DisplayAlerts(PatCur.PatNum,RxDefCur.RxDefNum)){ return; } //User OK with alert RxPat RxPatCur=new RxPat(); RxPatCur.RxDate=DateTime.Today; RxPatCur.PatNum=PatCur.PatNum; RxPatCur.Drug=RxDefCur.Drug; RxPatCur.IsControlled=RxDefCur.IsControlled; RxPatCur.Sig=RxDefCur.Sig; RxPatCur.Disp=RxDefCur.Disp; RxPatCur.Refills=RxDefCur.Refills; if(PrefC.GetBool(PrefName.RxSendNewToQueue)) { RxPatCur.SendStatus=RxSendStatus.InElectQueue; } else { RxPatCur.SendStatus=RxSendStatus.Unsent; } //Notes not copied: we don't want these kinds of notes cluttering things FormRxEdit FormE=new FormRxEdit(PatCur,RxPatCur); FormE.IsNew=true; FormE.ShowDialog(); if(FormE.DialogResult!=DialogResult.OK){ return; } bool isProvOrder=false; if(Security.CurUser.ProvNum!=0) {//The user who is currently logged in is a provider. isProvOrder=true; } _medOrderNum=MedicationPats.InsertOrUpdateMedOrderForRx(RxPatCur,RxDefCur.RxCui,isProvOrder);//RxDefCur.RxCui can be 0. EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.CPOE_MedOrdered; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.MoreInfo=""; newMeasureEvent.FKey=_medOrderNum; EhrMeasureEvents.Insert(newMeasureEvent); DialogResult=DialogResult.OK; }
private void butAssessed_Click(object sender,EventArgs e) { if(comboSmokeStatus.SelectedIndex==0) {//None MessageBox.Show("You must select a smoking status."); return; } DateTime dateTEntered=PIn.DateT(textDateAssessed.Text); for(int i=0;i<_ListEvents.Count;i++) { if(_ListEvents[i].DateTEvent.Date==dateTEntered.Date) { MessageBox.Show("A Tobacco Assessment entry already exists with the selected date."); return; } } EhrMeasureEvent meas=new EhrMeasureEvent(); meas.DateTEvent=dateTEntered; meas.EventType=EhrMeasureEventType.TobaccoUseAssessed; meas.PatNum=PatCur.PatNum; meas.CodeValueEvent=_ListAssessmentCodes[comboAssessmentType.SelectedIndex].CodeValue; meas.CodeSystemEvent=_ListAssessmentCodes[comboAssessmentType.SelectedIndex].CodeSystem; meas.CodeValueResult=_TobaccoCodeSelected; meas.CodeSystemResult="SNOMEDCT";//only allow SNOMEDCT codes for now. meas.MoreInfo=""; EhrMeasureEvents.Insert(meas); FillGrid(); }
private void butSendEmail_Click(object sender,EventArgs e) { FormReferralsPatient FormRP=new FormReferralsPatient(); FormRP.PatNum=PatCur.PatNum; FormRP.IsSelectionMode=true; if(FormRP.ShowDialog()==DialogResult.Cancel) { MessageBox.Show("Summary of Care not exported."); return; } string ccd=""; try { ccd=EhrCCD.GenerateSummaryOfCare(PatCur); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } Cursor=Cursors.WaitCursor; EmailAddress emailAddressFrom=EmailAddresses.GetByClinic(0);//Default for clinic/practice. EmailMessage emailMessage=new EmailMessage(); emailMessage.PatNum=PatCur.PatNum; emailMessage.MsgDateTime=DateTime.Now; emailMessage.SentOrReceived=EmailSentOrReceived.Neither;//To force FormEmailMessageEdit into "compose" mode. emailMessage.FromAddress=emailAddressFrom.EmailUsername;//Cannot be emailAddressFrom.SenderAddress, because it would cause encryption to fail. emailMessage.ToAddress="";//User must set inside of FormEmailMessageEdit emailMessage.Subject="Summary of Care"; emailMessage.BodyText="Summary of Care"; try { EmailMessages.CreateAttachmentFromText(emailMessage,ccd,"ccd.xml"); EmailMessages.CreateAttachmentFromText(emailMessage,FormEHR.GetEhrResource("CCD"),"ccd.xsl"); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show(ex.Message); return; } EmailMessages.Insert(emailMessage); FormEmailMessageEdit formE=new FormEmailMessageEdit(emailMessage); if(formE.ShowDialog()==DialogResult.OK) { EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDr; newMeasureEvent.PatNum=PatCur.PatNum; long fkey=EhrMeasureEvents.Insert(newMeasureEvent); newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.FKey=fkey; newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDrElectronic; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.FKey=FormRP.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason. EhrMeasureEvents.Insert(newMeasureEvent); FillGridSent(); } Cursor=Cursors.Default; }
private void butShowXhtml_Click(object sender,EventArgs e) { string ccd=""; try { FormEhrExportCCD FormEEC=new FormEhrExportCCD(PatCur); FormEEC.ShowDialog(); if(FormEEC.DialogResult==DialogResult.OK) { ccd=FormEEC.CCD; } else { return; } } catch(Exception ex) { MessageBox.Show(ex.Message); return; } bool didPrint=FormEhrSummaryOfCare.DisplayCCD(ccd); if(didPrint) { //we are printing a ccd so add new measure event. EhrMeasureEvent measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now; measureEvent.EventType = EhrMeasureEventType.ClinicalSummaryProvidedToPt; measureEvent.PatNum = PatCur.PatNum; EhrMeasureEvents.Insert(measureEvent); FillGridEHRMeasureEvents(); } }
private void butShowXhtml_Click(object sender,EventArgs e) { FormReferralsPatient FormRP=new FormReferralsPatient(); FormRP.PatNum=PatCur.PatNum; FormRP.IsSelectionMode=true; if(FormRP.ShowDialog()==DialogResult.Cancel) { MessageBox.Show("Summary of Care not shown."); return; } string ccd=""; try { ccd=EhrCCD.GenerateSummaryOfCare(PatCur); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } bool didPrint=DisplayCCD(ccd); if(didPrint) { //we are printing a ccd so add new measure event. EhrMeasureEvent measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now; measureEvent.EventType = EhrMeasureEventType.SummaryOfCareProvidedToDr; measureEvent.FKey=FormRP.RefAttachNum; measureEvent.PatNum = PatCur.PatNum; EhrMeasureEvents.Insert(measureEvent); FillGridSent(); } }
private void butSendEmail_Click(object sender,EventArgs e) { if(!Security.IsAuthorized(Permissions.EmailSend)) { return; } //Generate the CCD first so that any validation errors are apparent and up front. //It is better to not let the user waste their time creating a referral if there is a basic validation issue with the CCD generation. string ccd=""; try { ccd=EhrCCD.GenerateSummaryOfCare(PatCur); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } FormReferralsPatient FormRP=new FormReferralsPatient(); FormRP.PatNum=PatCur.PatNum; FormRP.IsSelectionMode=true; if(FormRP.ShowDialog()==DialogResult.Cancel) { MessageBox.Show("Summary of Care not exported."); return; } Cursor=Cursors.WaitCursor; EmailAddress emailAddressFrom=EmailAddresses.GetByClinic(0);//Default for clinic/practice. EmailMessage emailMessage=new EmailMessage(); emailMessage.PatNum=PatCur.PatNum; emailMessage.MsgDateTime=DateTime.Now; emailMessage.SentOrReceived=EmailSentOrReceived.Neither;//To force FormEmailMessageEdit into "compose" mode. emailMessage.FromAddress=emailAddressFrom.EmailUsername;//Cannot be emailAddressFrom.SenderAddress, because it would cause encryption to fail. emailMessage.ToAddress="";//User must set inside of FormEmailMessageEdit emailMessage.Subject="Summary of Care"; emailMessage.BodyText="Summary of Care"; try { emailMessage.Attachments.Add(EmailAttaches.CreateAttach("ccd.xml",Encoding.UTF8.GetBytes(ccd))); emailMessage.Attachments.Add(EmailAttaches.CreateAttach("ccd.xsl",Encoding.UTF8.GetBytes(FormEHR.GetEhrResource("CCD")))); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show(ex.Message); return; } EmailMessages.Insert(emailMessage); FormEmailMessageEdit formE=new FormEmailMessageEdit(emailMessage); if(formE.ShowDialog()==DialogResult.OK) { EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDr; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.FKey=FormRP.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason. EhrMeasureEvents.Insert(newMeasureEvent); newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDrElectronic; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.FKey=FormRP.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason. EhrMeasureEvents.Insert(newMeasureEvent); FillGridSent(); } Cursor=Cursors.Default; }
private void FormPatientSmoking_Load(object sender,EventArgs e) { PatOld=PatCur.Copy(); _TobaccoCodeSelected=PatCur.SmokingSnoMed; textDateAssessed.Text=DateTime.Now.ToString(); #region ComboSmokeStatus comboSmokeStatus.Items.Add("None");//First and default index //Smoking statuses add in the same order as they appear in the SmokingSnoMed enum (Starting at comboSmokeStatus index 1). Changes to the enum order will change the order added so they will always match for(int i=0;i<Enum.GetNames(typeof(SmokingSnoMed)).Length;i++) { //if snomed code exists in the snomed table, use the code - description for the combo box, otherwise use the original abbreviated description Snomed smokeCur=Snomeds.GetByCode(((SmokingSnoMed)i).ToString().Substring(1)); if(smokeCur!=null) { comboSmokeStatus.Items.Add(smokeCur.Description); } else { switch((SmokingSnoMed)i) { case SmokingSnoMed._266927001: comboSmokeStatus.Items.Add("UnknownIfEver"); break; case SmokingSnoMed._77176002: comboSmokeStatus.Items.Add("SmokerUnknownCurrent"); break; case SmokingSnoMed._266919005: comboSmokeStatus.Items.Add("NeverSmoked"); break; case SmokingSnoMed._8517006: comboSmokeStatus.Items.Add("FormerSmoker"); break; case SmokingSnoMed._428041000124106: comboSmokeStatus.Items.Add("CurrentSomeDay"); break; case SmokingSnoMed._449868002: comboSmokeStatus.Items.Add("CurrentEveryDay"); break; case SmokingSnoMed._428061000124105: comboSmokeStatus.Items.Add("LightSmoker"); break; case SmokingSnoMed._428071000124103: comboSmokeStatus.Items.Add("HeavySmoker"); break; } } } comboSmokeStatus.SelectedIndex=0;//None try { comboSmokeStatus.SelectedIndex=(int)Enum.Parse(typeof(SmokingSnoMed),"_"+_TobaccoCodeSelected,true)+1; } catch { //if not one of the statuses in the enum, get the Snomed object from the patient's current smoking snomed code Snomed smokeCur=Snomeds.GetByCode(_TobaccoCodeSelected); if(smokeCur!=null) {//valid snomed code, set the combo box text to this snomed description comboSmokeStatus.SelectedIndex=-1; comboSmokeStatus.Text=smokeCur.Description; } } #endregion //This takes a while the first time the window loads due to Code Systems. Cursor=Cursors.WaitCursor; FillGrid(); Cursor=Cursors.Default; #region ComboAssessmentType _ListAssessmentCodes=EhrCodes.GetForValueSetOIDs(new List<string> { "2.16.840.1.113883.3.526.3.1278" },true);//'Tobacco Use Screening' value set if(_ListAssessmentCodes.Count==0) {//This should only happen if the EHR.dll does not exist or if the codes in the ehrcode list do not exist in the corresponding table MsgBox.Show(this,"The codes used for Tobacco Use Screening assessments do not exist in the LOINC table in your database. You must run the Code System Importer tool in Setup | Chart | EHR to import this code set."); DialogResult=DialogResult.Cancel; return; } EhrMeasureEvent mostRecentAssessment=new EhrMeasureEvent(); for(int i=_ListEvents.Count-1;i>-1;i--) { if(_ListEvents[i].EventType==EhrMeasureEventType.TobaccoUseAssessed) { mostRecentAssessment=_ListEvents[i];//_ListEvents filled ordered by DateTEvent, most recent assessment is last one in the list of type assessed break; } } for(int i=0;i<_ListAssessmentCodes.Count;i++) { comboAssessmentType.Items.Add(_ListAssessmentCodes[i].Description); if(i==0) { comboAssessmentType.SelectedIndex=i;//default to the first one in the list, 'History of tobacco use Narrative' } if(mostRecentAssessment.CodeValueEvent==_ListAssessmentCodes[i].CodeValue && mostRecentAssessment.CodeSystemEvent==_ListAssessmentCodes[i].CodeSystem) { comboAssessmentType.SelectedIndex=i;//set to most recent assessment } } #endregion }
///<summary>Used when printing or emailing recall to make a commlog entry without any display. Only set isWebSched to true if this is a commlog associated to the GWT Web Sched app.</summary> public static void InsertForRecall(long patNum,CommItemMode _mode,int numberOfReminders,long defNumNewStatus,bool isWebSched,long userNum) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(),patNum,_mode,numberOfReminders,defNumNewStatus,isWebSched,userNum); return; } long recallType=Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL); string command; string datesql="CURDATE()"; if(DataConnection.DBtype==DatabaseType.Oracle){ datesql="(SELECT CURRENT_DATE FROM dual)"; } if(recallType!=0){ command="SELECT COUNT(*) FROM commlog WHERE "; command+=DbHelper.DtimeToDate("CommDateTime")+" = "+datesql; command+=" AND PatNum="+POut.Long(patNum)+" AND CommType="+POut.Long(recallType) +" AND Mode_="+POut.Long((int)_mode) +" AND SentOrReceived=1"; if(Db.GetCount(command)!="0"){ return; } } Commlog com=new Commlog(); com.PatNum=patNum; com.CommDateTime=DateTime.Now; com.CommType=recallType; com.Mode_=_mode; com.SentOrReceived=CommSentOrReceived.Sent; com.Note=""; if(numberOfReminders==0){ com.Note=Lans.g("FormRecallList","Recall reminder."); } else if(numberOfReminders==1) { com.Note=Lans.g("FormRecallList","Second recall reminder."); } else if(numberOfReminders==2) { com.Note=Lans.g("FormRecallList","Third recall reminder."); } else { com.Note=Lans.g("FormRecallList","Recall reminder:")+" "+(numberOfReminders+1).ToString(); } if(defNumNewStatus==0) { com.Note+=" "+Lans.g("Commlogs","Status None"); } else { com.Note+=" "+DefC.GetName(DefCat.RecallUnschedStatus,defNumNewStatus); } com.UserNum=userNum; com.IsWebSched=isWebSched; Insert(com); EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=com.CommDateTime; newMeasureEvent.EventType=EhrMeasureEventType.ReminderSent; newMeasureEvent.PatNum=com.PatNum; newMeasureEvent.MoreInfo=com.Note; EhrMeasureEvents.Insert(newMeasureEvent); }
private void comboSmokeStatus_SelectionChangeCommitted(object sender,EventArgs e) { if(comboSmokeStatus.SelectedIndex<=0) {//If None or text set to other selected Snomed code so -1, do not create an event return; } //SelectedIndex guaranteed to be greater than 0 _TobaccoCodeSelected=((SmokingSnoMed)comboSmokeStatus.SelectedIndex-1).ToString().Substring(1); DateTime dateTEntered=PIn.DateT(textDateAssessed.Text);//will be set to DateTime.Now when form loads //Automatically make an entry for(int i=0;i<_ListEvents.Count;i++) { if(_ListEvents[i].DateTEvent.Date==dateTEntered.Date) { return;//if assessment already exists for date set, do not auto insert } } //an entry for the date entered does not yet exist EhrMeasureEvent meas = new EhrMeasureEvent(); meas.DateTEvent=dateTEntered; meas.EventType=EhrMeasureEventType.TobaccoUseAssessed; meas.PatNum=PatCur.PatNum; meas.CodeValueEvent=_ListAssessmentCodes[comboAssessmentType.SelectedIndex].CodeValue; meas.CodeSystemEvent=_ListAssessmentCodes[comboAssessmentType.SelectedIndex].CodeSystem; meas.CodeValueResult=_TobaccoCodeSelected; meas.CodeSystemResult="SNOMEDCT";//only allow SNOMEDCT codes for now. meas.MoreInfo=""; EhrMeasureEvents.Insert(meas); FillGrid(); }
private void butSendToPortal_Click(object sender,EventArgs e) { //Validate string strCcdValidationErrors=EhrCCD.ValidateSettings(); if(strCcdValidationErrors!="") {//Do not even try to export if global settings are invalid. MessageBox.Show(strCcdValidationErrors);//We do not want to use translations here, because the text is dynamic. The errors are generated in the business layer, and Lan.g() is not available there. return; } strCcdValidationErrors=EhrCCD.ValidatePatient(PatCur);//Patient cannot be null, because a patient must be selected before the EHR dashboard will open. if(strCcdValidationErrors!="") { MessageBox.Show(strCcdValidationErrors);//We do not want to use translations here, because the text is dynamic. The errors are generated in the business layer, and Lan.g() is not available there. return; } Provider prov=null; if(Security.CurUser.ProvNum!=0) {//If the current user is a provider. prov=Providers.GetProv(Security.CurUser.ProvNum); } else { prov=Providers.GetProv(PatCur.PriProv);//PriProv is not 0, because EhrCCD.ValidatePatient() will block if PriProv is 0. } try { //Create the Clinical Summary. FormEhrExportCCD FormEEC=new FormEhrExportCCD(PatCur); FormEEC.ShowDialog(); if(FormEEC.DialogResult!=DialogResult.OK) {//Canceled return; } //Save the clinical summary (ccd.xml) and style sheet (ccd.xsl) as webmail message attachments. //TODO: It would be more patient friendly if we instead generated a PDF file containing the Clinical Summary printout, or if we simply displayed the Clinical Summary in the portal. //The CMS definition does not prohibit sending human readable files, and sending a PDF to the portal mimics printing the Clinical Summary and handing to patient. Random rnd=new Random(); string attachPath=EmailAttaches.GetAttachPath(); List<EmailAttach> listAttachments=new List<EmailAttach>(); EmailAttach attachCcd=new EmailAttach(); attachCcd.DisplayedFileName="ccd.xml"; attachCcd.ActualFileName=DateTime.Now.ToString("yyyyMMdd")+"_"+DateTime.Now.TimeOfDay.Ticks.ToString()+rnd.Next(1000).ToString()+".xml"; listAttachments.Add(attachCcd); File.WriteAllText(ODFileUtils.CombinePaths(attachPath,attachCcd.ActualFileName),FormEEC.CCD);//Save Clinical Summary to file in the email attachments folder. EmailAttach attachSs=new EmailAttach();//Style sheet attachment. attachSs.DisplayedFileName="ccd.xsl"; attachSs.ActualFileName=attachCcd.ActualFileName.Substring(0,attachCcd.ActualFileName.Length-4)+".xsl";//Same base name as the CCD. The base names must match or the file will not display properly in internet browsers. listAttachments.Add(attachSs); File.WriteAllText(ODFileUtils.CombinePaths(attachPath,attachSs.ActualFileName),FormEHR.GetEhrResource("CCD")); //Create and save the webmail message containing the attachments. EmailMessage msgWebMail=new EmailMessage(); msgWebMail.FromAddress=prov.GetFormalName(); msgWebMail.ToAddress=PatCur.GetNameFL(); msgWebMail.PatNum=PatCur.PatNum; msgWebMail.SentOrReceived=EmailSentOrReceived.WebMailSent; msgWebMail.ProvNumWebMail=prov.ProvNum; msgWebMail.Subject="Clinical Summary"; msgWebMail.BodyText="To view the clinical summary:\r\n1) Download all attachments to the same folder. Do not rename the files.\r\n2) Open the ccd.xml file in an internet browser."; msgWebMail.MsgDateTime=DateTime.Now; msgWebMail.PatNumSubj=PatCur.PatNum; msgWebMail.Attachments=listAttachments; EmailMessages.Insert(msgWebMail); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.ClinicalSummaryProvidedToPt; newMeasureEvent.PatNum=PatCur.PatNum; EhrMeasureEvents.Insert(newMeasureEvent); FillGridEHRMeasureEvents();//This will cause the measure event to show in the grid below the popup message on the next line. Reassures the user that the event was immediately recorded. MsgBox.Show(this,"Clinical Summary Sent"); }
private void butSend_Click(object sender,EventArgs e) { EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.ReminderSent; newMeasureEvent.PatNum=PatCur.PatNum; string moreInfo=""; if(gridMain.GetSelectedIndex() > -1) { moreInfo=gridMain.Rows[gridMain.GetSelectedIndex()].Cells[1].Text; } newMeasureEvent.MoreInfo=moreInfo; EhrMeasureEvents.Insert(newMeasureEvent); FillGridProvided(); }
private void butGiveAccess_Click(object sender,EventArgs e) { string interval=PrefC.GetStringSilent(PrefName.MobileSyncIntervalMinutes); if(interval=="" || interval=="0") {//not a paid customer or chooses not to synch MessageBox.Show("Synch must be setup first from the Tools menu, Mobile and Patient Portal Synch. Interval must not be blank or zero."); return; } //we won't check PrefName.MobileSyncWorkstationName because we are forcing the synch if(System.Environment.MachineName.ToUpper()!=PrefC.GetStringSilent(PrefName.MobileSyncWorkstationName).ToUpper()) { //Since GetStringSilent returns "" before OD is connected to db, this gracefully loops out if(!MsgBox.Show(this,MsgBoxButtons.OKCancel, "Warning. Workstation is not entered in the Tools menu, Mobile and Patient Portal Synch. No automatic synch is taking place. Continue anyway?")) { return; } } if(PrefC.GetDate(PrefName.MobileExcludeApptsBeforeDate).Year<1880) { MessageBox.Show("Full Synch must be run first first from the Tools menu, Mobile and Patient Portal Synch."); return; } if(butGiveAccess.Text=="Provide Online Access") {//When form open opens with a blank password Cursor=Cursors.WaitCursor; //1. Fill password. textOnlinePassword.Text=GenerateRandomPassword(8,10);//won't save until OK or Print //2. Fill link. textOnlineLink.Text=GetPatientPortalLink(); //3. Reset timestamps for this patient to trigger all their objects to upload with the next synch LabPanels.ResetTimeStamps(PatCur.PatNum); Diseases.ResetTimeStamps(PatCur.PatNum); Allergies.ResetTimeStamps(PatCur.PatNum); MedicationPats.ResetTimeStamps(PatCur.PatNum); Statements.ResetTimeStamps(PatCur.PatNum); Documents.ResetTimeStamps(PatCur.PatNum); //4. Make the password editable in case they want to change it. textOnlinePassword.ReadOnly=false; //5. Save password to db PatCur.OnlinePassword=textOnlinePassword.Text; Patients.Update(PatCur,PatOld); PatOld.OnlinePassword=textOnlinePassword.Text;//so that subsequent Updates will work. //6. Force a synch FormMobile.SynchFromMain(true); //7. Insert EhrMeasureEvent EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.OnlineAccessProvided; newMeasureEvent.PatNum=PatCur.PatNum; newMeasureEvent.MoreInfo=""; EhrMeasureEvents.Insert(newMeasureEvent); //8. Rename button butGiveAccess.Text="Remove Online Access"; Cursor=Cursors.Default; } else {//remove access Cursor=Cursors.WaitCursor; //1. Clear password textOnlinePassword.Text=""; //2. Make in uneditable textOnlinePassword.ReadOnly=true; //3. Save password to db PatCur.OnlinePassword=textOnlinePassword.Text; Patients.Update(PatCur,PatOld); PatOld.OnlinePassword=textOnlinePassword.Text; //5. Force a synch FormMobile.SynchFromMain(true); //no event to insert //6. Rename button butGiveAccess.Text="Provide Online Access"; Cursor=Cursors.Default; } }
private void butOK_Click(object sender, System.EventArgs e) { Patient PatOld=PatCur.Copy(); PatCur.Premed=checkPremed.Checked; PatCur.MedUrgNote=textMedUrgNote.Text; Patients.Update(PatCur,PatOld); PatientNoteCur.Medical=textMedical.Text; PatientNoteCur.Service=textService.Text; PatientNoteCur.MedicalComp=textMedicalComp.Text; PatientNotes.Update(PatientNoteCur, PatCur.Guarantor); //Insert an ehrmeasureevent for CurrentMedsDocumented if user selected Yes and there isn't one with today's date if(radioMedsDocumentedYes.Checked && _EhrMeasureEventNum==0) { EhrMeasureEvent ehrMeasureEventCur=new EhrMeasureEvent(); ehrMeasureEventCur.PatNum=PatCur.PatNum; ehrMeasureEventCur.DateTEvent=DateTime.Now; ehrMeasureEventCur.EventType=EhrMeasureEventType.CurrentMedsDocumented; ehrMeasureEventCur.CodeValueEvent="428191000124101";//SNOMEDCT code for document current meds procedure ehrMeasureEventCur.CodeSystemEvent="SNOMEDCT"; EhrMeasureEvents.Insert(ehrMeasureEventCur); } //No is selected, if no EhrNotPerformed item for current meds documented, launch not performed edit window to allow user to select valid reason. if(radioMedsDocumentedNo.Checked) { if(_EhrNotPerfNum==0) { FormEhrNotPerformedEdit FormNP=new FormEhrNotPerformedEdit(); FormNP.EhrNotPerfCur=new EhrNotPerformed(); FormNP.EhrNotPerfCur.IsNew=true; FormNP.EhrNotPerfCur.PatNum=PatCur.PatNum; FormNP.EhrNotPerfCur.ProvNum=PatCur.PriProv; FormNP.SelectedItemIndex=(int)EhrNotPerformedItem.DocumentCurrentMeds; FormNP.EhrNotPerfCur.DateEntry=DateTime.Today; FormNP.IsDateReadOnly=true; FormNP.ShowDialog(); if(FormNP.DialogResult==DialogResult.OK) {//if they just inserted a not performed item, set the private class-wide variable for the next if statement _EhrNotPerfNum=FormNP.EhrNotPerfCur.EhrNotPerformedNum; } } if(_EhrNotPerfNum>0 && _EhrMeasureEventNum>0) {//if not performed item is entered with today's date, delete existing performed item EhrMeasureEvents.Delete(_EhrMeasureEventNum); } } DialogResult=DialogResult.OK; }
private void butOK_Click(object sender,EventArgs e) { if(_listMedicationPatReconcile.Count==0) { if(!MsgBox.Show(this,true,"The reconcile list is empty which will cause all existing medications to be removed. Continue?")) { return; } } MedicationPat medP; bool isActive; //Discontinue any current medications that are not present in the reconcile list. for(int i=0;i<_listMedicationPatCur.Count;i++) {//Start looping through all current medications isActive=false; medP=_listMedicationPatCur[i]; for(int j=0;j<_listMedicationPatReconcile.Count;j++) {//Compare each reconcile medication to the current medication if(medP.RxCui > 0 && medP.RxCui==_listMedicationPatReconcile[j].RxCui && _listMedicationPatReconcile[j].MedicationNum==_listMedicationPatCur[i].MedicationNum) {//Has an RxNorm code and they are equal isActive=true; break; } } if(!isActive) {//Update current medications. _listMedicationPatCur[i].DateStop=DateTime.Now;//Set the current DateStop to today (to set the medication as discontinued) MedicationPats.Update(_listMedicationPatCur[i]); } } //Always update every current medication for the patient so that DateTStamp reflects the last reconcile date. if(_listMedicationPatCur.Count>0) { MedicationPats.ResetTimeStamps(_patCur.PatNum,true); } Medication med; int index; for(int j=0;j<_listMedicationPatReconcile.Count;j++) { index=ListMedicationPatNew.IndexOf(_listMedicationPatReconcile[j]); if(index<0) { continue; } if(_listMedicationPatReconcile[j]==ListMedicationPatNew[index]) { med=Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[j].RxCui); if(med==null) { med=new Medication(); med.MedName=ListMedicationPatNew[index].MedDescript; med.RxCui=ListMedicationPatNew[index].RxCui; ListMedicationPatNew[index].MedicationNum=Medications.Insert(med); med.GenericNum=med.MedicationNum; Medications.Update(med); } else { ListMedicationPatNew[index].MedicationNum=med.MedicationNum; } ListMedicationPatNew[index].ProvNum=0;//Since imported, set provnum to 0 so it does not affect CPOE. MedicationPats.Insert(ListMedicationPatNew[index]); } } EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.MedicationReconcile; newMeasureEvent.PatNum=_patCur.PatNum; newMeasureEvent.MoreInfo=""; EhrMeasureEvents.Insert(newMeasureEvent); for(int inter=0;inter<_listMedicationPatReconcile.Count;inter++) { if(CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS) { Medication medInter=Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[inter].RxCui); FormCDSIntervention FormCDSI=new FormCDSIntervention(); FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(medInter,_patCur); FormCDSI.ShowIfRequired(false); } } DialogResult=DialogResult.OK; }
public FormEhrMeasureEventEdit(EhrMeasureEvent measureEventCur) { InitializeComponent(); _measureEventCur=measureEventCur; }
private void butAdd_Click(object sender,EventArgs e) { FormEhrLabOrderEdit2014 FormLOE=new FormEhrLabOrderEdit2014(); FormLOE.EhrLabCur=new EhrLab(); FormLOE.EhrLabCur.PatNum=PatCur.PatNum; FormLOE.IsNew=true; FormLOE.ShowDialog(); if(FormLOE.DialogResult!=DialogResult.OK) { return; } EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent(); newMeasureEvent.DateTEvent=DateTime.Now; newMeasureEvent.EventType=EhrMeasureEventType.CPOE_LabOrdered;//default Loinc loinc=Loincs.GetByCode(FormLOE.EhrLabCur.UsiID); if(loinc!=null && loinc.ClassType=="RAD") {//short circuit logic newMeasureEvent.EventType=EhrMeasureEventType.CPOE_RadOrdered; } newMeasureEvent.PatNum=FormLOE.EhrLabCur.PatNum; newMeasureEvent.MoreInfo=""; newMeasureEvent.FKey=FormLOE.EhrLabCur.EhrLabNum; EhrMeasureEvents.Insert(newMeasureEvent); EhrLabs.SaveToDB(FormLOE.EhrLabCur); for(int i=0;i<FormLOE.EhrLabCur.ListEhrLabResults.Count;i++) { if(CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS) { FormCDSIntervention FormCDSI=new FormCDSIntervention(); FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(FormLOE.EhrLabCur.ListEhrLabResults[i],PatCur); FormCDSI.ShowIfRequired(false); } } FillGrid(); }
///<summary>Used when printing or emailing recall to make a commlog entry without any display. ///Set commSource to the corresponding entity that is making this recall. E.g. Web Sched. ///If the commSource is a 3rd party, set it to ProgramLink and make an overload that accepts the ProgramNum.</summary> public static Commlog InsertForRecall(long patNum, CommItemMode _mode, int numberOfReminders, long defNumNewStatus, CommItemSource commSource, long userNum, DateTime dateTimeNow) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <Commlog>(MethodBase.GetCurrentMethod(), patNum, _mode, numberOfReminders, defNumNewStatus, commSource, userNum, dateTimeNow)); } long recallType = Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL); string command; string datesql = "CURDATE()"; if (DataConnection.DBtype == DatabaseType.Oracle) { datesql = "(SELECT CURRENT_DATE FROM dual)"; } if (recallType != 0) { command = "SELECT * FROM commlog WHERE "; command += DbHelper.DtimeToDate("CommDateTime") + " = " + datesql; command += " AND PatNum=" + POut.Long(patNum) + " AND CommType=" + POut.Long(recallType) + " AND Mode_=" + POut.Long((int)_mode) + " AND SentOrReceived=1"; List <Commlog> listComms = Crud.CommlogCrud.SelectMany(command).OrderByDescending(x => x.CommDateTime).ToList(); if (listComms.Count > 0) { return(listComms[0]); } } Commlog com = new Commlog(); com.PatNum = patNum; com.CommDateTime = dateTimeNow; com.CommType = recallType; com.Mode_ = _mode; com.SentOrReceived = CommSentOrReceived.Sent; com.Note = ""; if (numberOfReminders == 0) { com.Note = Lans.g("FormRecallList", "Recall reminder."); } else if (numberOfReminders == 1) { com.Note = Lans.g("FormRecallList", "Second recall reminder."); } else if (numberOfReminders == 2) { com.Note = Lans.g("FormRecallList", "Third recall reminder."); } else { com.Note = Lans.g("FormRecallList", "Recall reminder:") + " " + (numberOfReminders + 1).ToString(); } if (defNumNewStatus == 0) { com.Note += " " + Lans.g("Commlogs", "Status None"); } else { com.Note += " " + Defs.GetName(DefCat.RecallUnschedStatus, defNumNewStatus); } com.UserNum = userNum; com.CommSource = commSource; com.CommlogNum = Insert(com); EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); newMeasureEvent.DateTEvent = com.CommDateTime; newMeasureEvent.EventType = EhrMeasureEventType.ReminderSent; newMeasureEvent.PatNum = com.PatNum; newMeasureEvent.MoreInfo = com.Note; EhrMeasureEvents.Insert(newMeasureEvent); return(com); }
private void butShowXhtml_Click(object sender,EventArgs e) { string ccd=""; try { ccd=EhrCCD.GenerateSummaryOfCare(PatCur); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } bool didPrint=DisplayCCD(ccd); if(didPrint) { //we are printing a ccd so add new measure event. EhrMeasureEvent measureEvent = new EhrMeasureEvent(); measureEvent.DateTEvent = DateTime.Now; measureEvent.EventType = EhrMeasureEventType.SummaryOfCareProvidedToDr; measureEvent.PatNum = PatCur.PatNum; EhrMeasureEvents.Insert(measureEvent); FillGridSent(); } }