Example #1
0
        private void butCopy_Click(object sender, EventArgs e)
        {
            if (grid1.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an internal HL7Def from the list on the left first.");
                return;
            }
            HL7Def hl7def = ListInternal[grid1.GetSelectedIndex()].Clone();

            hl7def.IsInternal = false;
            hl7def.IsEnabled  = false;
            long hl7DefNum = HL7Defs.Insert(hl7def);

            for (int m = 0; m < hl7def.hl7DefMessages.Count; m++)
            {
                hl7def.hl7DefMessages[m].HL7DefNum = hl7DefNum;
                long hl7DefMessageNum = HL7DefMessages.Insert(hl7def.hl7DefMessages[m]);
                for (int s = 0; s < hl7def.hl7DefMessages[m].hl7DefSegments.Count; s++)
                {
                    hl7def.hl7DefMessages[m].hl7DefSegments[s].HL7DefMessageNum = hl7DefMessageNum;
                    long hl7DefSegmentNum = HL7DefSegments.Insert(hl7def.hl7DefMessages[m].hl7DefSegments[s]);
                    for (int f = 0; f < hl7def.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields.Count; f++)
                    {
                        hl7def.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields[f].HL7DefSegmentNum = hl7DefSegmentNum;
                        HL7DefFields.Insert(hl7def.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields[f]);
                    }
                }
            }
            DataValid.SetInvalid(InvalidType.HL7Defs);
            FillGrid2();
            grid1.SetSelected(false);
        }
Example #2
0
        private void checkEnabled_Click(object sender, EventArgs e)
        {
            //security already checked when launching this form.  Only admin allowed.
            if (Security.CurUser.Password != "")
            {
                MsgBox.Show(this, "Admin password must be blank before this change can be made.");
                checkEnabled.Checked = !checkEnabled.Checked;
                return;
            }
            bool isHL7Enabled = HL7Defs.IsExistingHL7Enabled();

            if (isHL7Enabled && checkEnabled.Checked)
            {
                MsgBox.Show(this, "An HL7Def is enabled.  The enabled HL7 definition will control the HL7 messages not this program link.");
                textHL7Server.ReadOnly         = true;
                textHL7ServiceName.ReadOnly    = true;
                textHL7FolderIn.ReadOnly       = true;
                textHL7FolderOut.ReadOnly      = true;
                labelDefEnabledWarning.Visible = true;
            }
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning!  Read the manual carefully before turning this bridge on or off.  Make sure you understand the difference between the bridging modes and how it will affect patient accounts.  Continue anyway?"))
            {
                checkEnabled.Checked = !checkEnabled.Checked;
                return;
            }
            MsgBox.Show(this, "You will need to restart Open Dental to see the effects.");
        }
Example #3
0
		private void FillForm(){
			ProgramProperties.RefreshCache();
			PropertyList=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);
			textProgName.Text=ProgramCur.ProgName;
			textProgDesc.Text=ProgramCur.ProgDesc;
			checkEnabled.Checked=ProgramCur.Enabled;
			if(GetProp("HideChartRxButtons")=="1") {
				checkHideButChartRx.Checked=true;
			}
			else {
				checkHideButChartRx.Checked=false;
			}
			if(GetProp("ProcRequireSignature")=="1") {
				checkProcRequireSignature.Checked=true;
			}
			else {
				checkProcRequireSignature.Checked=false;
			}
			if(GetProp("ProcNotesNoIncomplete")=="1") {
				checkProcNotesNoIncomplete.Checked=true;
			}
			else {
				checkProcNotesNoIncomplete.Checked=false;
			}
			SetModeRadioButtons(GetProp("eClinicalWorksMode"));
			SetModeVisibilities();
			textECWServer.Text=GetProp("eCWServer");//this property will not exist if using Oracle, eCW will never use Oracle
			if(HL7Defs.IsExistingHL7Enabled()) {
				HL7Def def=HL7Defs.GetOneDeepEnabled();
				textHL7Server.Text=def.HL7Server;
				textHL7ServiceName.Text=def.HL7ServiceName;
				textHL7FolderIn.Text=def.OutgoingFolder;//because these are the opposite of the way they are in the HL7Def
				textHL7FolderOut.Text=def.IncomingFolder;
				checkQuadAsToothNum.Checked=def.IsQuadAsToothNum;
			}
			else {
				textHL7Server.Text=GetProp("HL7Server");//this property will not exist if using Oracle, eCW will never use Oracle
				textHL7ServiceName.Text=GetProp("HL7ServiceName");//this property will not exist if using Oracle, eCW will never use Oracle
				textHL7FolderIn.Text=PrefC.GetString(PrefName.HL7FolderIn);
				textHL7FolderOut.Text=PrefC.GetString(PrefName.HL7FolderOut);
				//if a def is enabled, the value associated with the def will override this setting
				checkQuadAsToothNum.Checked=GetProp("IsQuadAsToothNum")=="1";//this property will not exist if using Oracle, eCW will never use Oracle
			}
			textODServer.Text=MiscData.GetODServer();
			comboDefaultUserGroup.Items.Clear();
			_listUserGroups=UserGroups.GetList();
			for(int i=0;i<_listUserGroups.Count;i++) {
				comboDefaultUserGroup.Items.Add(_listUserGroups[i].Description);
				if(GetProp("DefaultUserGroup")==_listUserGroups[i].UserGroupNum.ToString()) {
					comboDefaultUserGroup.SelectedIndex=i;
				}
			}
			checkShowImages.Checked=GetProp("ShowImagesModule")=="1";
			checkFeeSchedules.Checked=GetProp("FeeSchedulesSetManually")=="1";
			textMedPanelURL.Text=GetProp("MedicalPanelUrl");//this property will not exist if using Oracle, eCW will never use Oracle
			checkLBSessionId.Checked=GetProp("IsLBSessionIdExcluded")=="1";
		}
Example #4
0
		private void FormEClinicalWorks_Load(object sender, System.EventArgs e) {
			FillForm();
			if(HL7Defs.IsExistingHL7Enabled()) {
				//Instead of using these, we will use the ones that are part of the HL7Def
				//These will be filled with those values.
				textHL7Server.ReadOnly=true;
				textHL7ServiceName.ReadOnly=true;
				textHL7FolderIn.ReadOnly=true;
				textHL7FolderOut.ReadOnly=true;
				labelDefEnabledWarning.Visible=true;
				checkQuadAsToothNum.Enabled=false;
			}
		}
Example #5
0
        /// <summary>Helper method to send given appt to the unscheduled list.
        /// Creates SecurityLogs and considers HL7.</summary>
        public static void SetApptUnschedHelper(Appointment appt, Patient pat = null, bool doFireApptEvent = true)
        {
            DateTime datePrevious = appt.DateTStamp;

            Appointments.SetAptStatus(appt, ApptStatus.UnschedList); //Appointments S-Class handles Signalods
            #region SecurityLogs
            if (appt.AptStatus != ApptStatus.Complete)               //seperate log entry for editing completed appts.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentMove, appt.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Sent to Unscheduled List",
                                          appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, appt.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Sent to Unscheduled List",
                                          appt.AptNum, datePrevious);
            }
            #endregion
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                if (pat == null)
                {
                    pat = Patients.GetPat(appt.PatNum);
                }
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            if (doFireApptEvent)
            {
                AppointmentEvent.Fire(ODEventType.AppointmentEdited, appt);
            }
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Example #6
0
        ///<summary>Returns null if no HL7 def is enabled or no ACK is defined in the enabled def.</summary>
        public static MessageHL7 GenerateACK(string controlId, bool isAck, string ackEvent)
        {
            MessageHL7 messageHL7 = new MessageHL7(MessageTypeHL7.ACK);

            messageHL7.ControlId = controlId;
            messageHL7.AckEvent  = ackEvent;
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);               //no def enabled, return null
            }
            //find an ACK message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.ACK && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    break;
                }
            }
            if (hl7DefMessage == null)           //ACK message type is not defined so do nothing and return
            {
                return(null);
            }
            //go through each segment in the def
            for (int s = 0; s < hl7DefMessage.hl7DefSegments.Count; s++)
            {
                SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[s].SegmentName);
                seg.SetField(0, hl7DefMessage.hl7DefSegments[s].SegmentName.ToString());
                for (int f = 0; f < hl7DefMessage.hl7DefSegments[s].hl7DefFields.Count; f++)
                {
                    string fieldName = hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FieldName;
                    if (fieldName == "")                   //If fixed text instead of field name just add text to segment
                    {
                        seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FixedText);
                    }
                    else
                    {
                        seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos, FieldConstructor.GenerateACK(hl7Def, fieldName, controlId, isAck, ackEvent));
                    }
                }
                messageHL7.Segments.Add(seg);
            }
            return(messageHL7);
        }
Example #7
0
		private void checkEnabled_Click(object sender,EventArgs e) {
			bool isHL7Enabled=HL7Defs.IsExistingHL7Enabled();
			if(isHL7Enabled && checkEnabled.Checked) {
				MsgBox.Show(this,"An HL7Def is enabled.  The enabled HL7 definition will control the HL7 messages not this program link.");
				textHL7Server.ReadOnly=true;
				textHL7ServiceName.ReadOnly=true;
				textHL7FolderIn.ReadOnly=true;
				textHL7FolderOut.ReadOnly=true;
				labelDefEnabledWarning.Visible=true;
				checkQuadAsToothNum.Enabled=false;
			}
			if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"Warning!  Read the manual carefully before turning this bridge on or off.  Make sure you understand the difference between the bridging modes and how it will affect patient accounts.  Continue anyway?")) {
				checkEnabled.Checked=!checkEnabled.Checked;
				return;
			}
			MsgBox.Show(this,"You will need to restart Open Dental to see the effects.");
		}
Example #8
0
        private void FillGrid2()
        {
            //Our strategy in this window and all sub windows is to get all data directly from the database.
            //If it's too slow in this window due to the 20-30 database calls per row in grid2, then we might later optimize to pull from the cache.
            ListCustom = HL7Defs.GetDeepCustomList();
            grid2.BeginUpdate();
            grid2.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Description"), 100);

            grid2.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Mode"), 40);
            grid2.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "In Folder / Socket"), 130);
            grid2.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Out Folder / Socket"), 130);
            grid2.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Enabled"), 35);
            grid2.Columns.Add(col);
            grid2.Rows.Clear();
            for (int i = 0; i < ListCustom.Count; i++)
            {
                ODGridRow row = new ODGridRow();
                row.Cells.Add(ListCustom[i].Description);
                row.Cells.Add(Lan.g("enumModeTxHL7", ListCustom[i].ModeTx.ToString()));
                if (ListCustom[i].ModeTx == ModeTxHL7.File)
                {
                    row.Cells.Add(ListCustom[i].IncomingFolder);
                    row.Cells.Add(ListCustom[i].OutgoingFolder);
                }
                else if (ListCustom[i].ModeTx == ModeTxHL7.TcpIp)
                {
                    row.Cells.Add(ListCustom[i].HL7Server + ":" + ListCustom[i].IncomingPort);
                    row.Cells.Add(ListCustom[i].OutgoingIpPort);
                }
                else                  //Sftp
                {
                    row.Cells.Add(ListCustom[i].SftpInSocket);
                    row.Cells.Add("N/A");
                }
                row.Cells.Add(ListCustom[i].IsEnabled?"X":"");
                grid2.Rows.Add(row);
            }
            grid2.EndUpdate();
        }
Example #9
0
        private void FillGrid1()
        {
            //Our strategy in this window and all sub windows is to get all data directly from the database (or internal).
            ListInternal = HL7Defs.GetDeepInternalList();
            grid1.BeginUpdate();
            grid1.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Description"), 100);

            grid1.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Mode"), 40);
            grid1.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "In Folder / Socket"), 130);
            grid1.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Out Folder / Socket"), 130);
            grid1.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Enabled"), 35);
            grid1.Columns.Add(col);
            grid1.Rows.Clear();
            for (int i = 0; i < ListInternal.Count; i++)
            {
                ODGridRow row = new ODGridRow();
                row.Cells.Add(ListInternal[i].Description);
                row.Cells.Add(Lan.g("enumModeTxHL7", ListInternal[i].ModeTx.ToString()));
                if (ListInternal[i].ModeTx == ModeTxHL7.File)
                {
                    row.Cells.Add(ListInternal[i].IncomingFolder);
                    row.Cells.Add(ListInternal[i].OutgoingFolder);
                }
                else if (ListInternal[i].ModeTx == ModeTxHL7.TcpIp)
                {
                    row.Cells.Add(ListInternal[i].HL7Server + ":" + ListInternal[i].IncomingPort);
                    row.Cells.Add(ListInternal[i].OutgoingIpPort);
                }
                else                  //Sftp
                {
                    row.Cells.Add(ListInternal[i].SftpInSocket);
                    row.Cells.Add("N/A");
                }
                row.Cells.Add(ListInternal[i].IsEnabled?"X":"");
                grid1.Rows.Add(row);
            }
            grid1.EndUpdate();
        }
Example #10
0
        ///<summary>Only use this constructor when generating a message instead of parsing a message.</summary>
        internal MessageHL7(MessageTypeHL7 msgType)
        {
            Segments   = new List <SegmentHL7>();
            MsgType    = msgType;
            ControlId  = "";
            AckCode    = "";
            AckEvent   = "";
            Delimiters = new char[] { '^', '~', '\\', '&' };       //this is the default delimiters
            //if def is enabled, set delimiters to user defined values
            HL7Def enabledDef = HL7Defs.GetOneDeepEnabled();

            if (enabledDef != null)
            {
                Delimiters    = new char[4];
                Delimiters[0] = enabledDef.ComponentSeparator.ToCharArray()[0];           //the enabled def is forced to have a component separator that is a single character
                Delimiters[1] = enabledDef.RepetitionSeparator.ToCharArray()[0];          //the enabled def is forced to have a repetition separator that is a single character
                Delimiters[2] = enabledDef.EscapeCharacter.ToCharArray()[0];              //the enabled def is forced to have an escape character that is a single character
                Delimiters[3] = enabledDef.SubcomponentSeparator.ToCharArray()[0];        //the enabled def is forced to have a subcomponent separator that is a single character
            }
        }
Example #11
0
 private void checkEnabled_Click(object sender, EventArgs e)
 {
     if (checkEnabled.Checked)
     {
         bool isHL7Enabled = HL7Defs.IsExistingHL7Enabled(HL7DefCur.HL7DefNum);
         if (isHL7Enabled)
         {
             checkEnabled.Checked = false;
             MsgBox.Show(this, "Only one HL7 process can be enabled.  Another HL7 definition is enabled.");
             return;
         }
         if (Programs.IsEnabled(ProgramName.eClinicalWorks))
         {
             MsgBox.Show(this, "The eClinicalWorks program link is enabled.  This definition will now control the HL7 messages.");
         }
     }
     else
     {
         //
     }
 }
Example #12
0
 private void FillForm()
 {
     ProgramProperties.RefreshCache();
     PropertyList         = ProgramProperties.GetListForProgram(ProgramCur.ProgramNum);
     textProgName.Text    = ProgramCur.ProgName;
     textProgDesc.Text    = ProgramCur.ProgDesc;
     checkEnabled.Checked = ProgramCur.Enabled;
     SetModeRadioButtons(GetProp("eClinicalWorksMode"));
     SetModeVisibilities();
     textECWServer.Text = GetProp("eCWServer");
     if (HL7Defs.IsExistingHL7Enabled())
     {
         HL7Def def = HL7Defs.GetOneDeepEnabled();
         textHL7Server.Text      = def.HL7Server;
         textHL7ServiceName.Text = def.HL7ServiceName;
         textHL7FolderIn.Text    = def.OutgoingFolder;           //because these are the opposite of the way they are in the HL7Def
         textHL7FolderOut.Text   = def.IncomingFolder;
     }
     else
     {
         textHL7Server.Text      = GetProp("HL7Server");
         textHL7ServiceName.Text = GetProp("HL7ServiceName");
         textHL7FolderIn.Text    = PrefC.GetString(PrefName.HL7FolderIn);
         textHL7FolderOut.Text   = PrefC.GetString(PrefName.HL7FolderOut);
     }
     textODServer.Text = MiscData.GetODServer();
     comboDefaultUserGroup.Items.Clear();
     for (int i = 0; i < UserGroups.List.Length; i++)
     {
         comboDefaultUserGroup.Items.Add(UserGroups.List[i].Description);
         if (GetProp("DefaultUserGroup") == UserGroups.List[i].UserGroupNum.ToString())
         {
             comboDefaultUserGroup.SelectedIndex = i;
         }
     }
     checkShowImages.Checked   = GetProp("ShowImagesModule") == "1";
     checkFeeSchedules.Checked = GetProp("FeeSchedulesSetManually") == "1";
     textMedPanelURL.Text      = GetProp("MedicalPanelUrl");
 }
Example #13
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     //This button is only enabled if this is a custom def.
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete entire HL7Def?"))
     {
         return;
     }
     for (int m = 0; m < HL7DefCur.hl7DefMessages.Count; m++)
     {
         for (int s = 0; s < HL7DefCur.hl7DefMessages[m].hl7DefSegments.Count; s++)
         {
             for (int f = 0; f < HL7DefCur.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields.Count; f++)
             {
                 HL7DefFields.Delete(HL7DefCur.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields[f].HL7DefFieldNum);
             }
             HL7DefSegments.Delete(HL7DefCur.hl7DefMessages[m].hl7DefSegments[s].HL7DefSegmentNum);
         }
         HL7DefMessages.Delete(HL7DefCur.hl7DefMessages[m].HL7DefMessageNum);
     }
     HL7Defs.Delete(HL7DefCur.HL7DefNum);
     DataValid.SetInvalid(InvalidType.HL7Defs);
     DialogResult = DialogResult.OK;
 }
Example #14
0
        public static void ProcessAck(MessageHL7 msg, bool isVerboseLogging)
        {
            IsVerboseLogging = isVerboseLogging;
            HL7Def def = HL7Defs.GetOneDeepEnabled();

            if (def == null)
            {
                throw new Exception("Could not process ACK.  No HL7 definition is enabled.");
            }
            HL7DefMessage hl7defmsg = null;

            for (int i = 0; i < def.hl7DefMessages.Count; i++)
            {
                if (def.hl7DefMessages[i].MessageType == MessageTypeHL7.ACK && def.hl7DefMessages[i].InOrOut == InOutHL7.Incoming)
                {
                    hl7defmsg = def.hl7DefMessages[i];
                    break;
                }
            }
            if (hl7defmsg == null)           //No incoming ACK defined, do nothing with it
            {
                throw new Exception("Could not process HL7 ACK message.  No definition for this type of message in the enabled HL7Def.");
            }
            for (int i = 0; i < hl7defmsg.hl7DefSegments.Count; i++)
            {
                try {
                    SegmentHL7 seg = msg.GetSegment(hl7defmsg.hl7DefSegments[i].SegmentName, !hl7defmsg.hl7DefSegments[i].IsOptional);
                    if (seg != null)                   //null if segment was not found but is optional
                    {
                        ProcessSeg(null, 0, hl7defmsg.hl7DefSegments[i], seg, msg);
                    }
                }
                catch (ApplicationException ex) {               //Required segment was missing, or other error.
                    throw new Exception("Could not process HL7 message.  " + ex);
                }
            }
        }
Example #15
0
 private void butOK_Click(object sender, EventArgs e)
 {
     //validation
     if (checkEnabled.Checked)
     {
         if (textHL7Server.Text == "")
         {
             MsgBox.Show(this, "HL7 Server may not be blank.");
             return;
         }
         if (textHL7ServiceName.Text == "")
         {
             MsgBox.Show(this, "HL7 Service Name may not be blank.");
             return;
         }
         if (comboModeTx.SelectedIndex == (int)ModeTxHL7.File)
         {
             if (textInPath.Text == "")
             {
                 MsgBox.Show(this, "The path for Incoming Folder is empty.");
                 return;
             }
             if (!Directory.Exists(textInPath.Text))
             {
                 MsgBox.Show(this, "The path for Incoming Folder is invalid.");
                 return;
             }
             if (textOutPath.Text == "")
             {
                 MsgBox.Show(this, "The path for Outgoing Folder is empty.");
                 return;
             }
             if (!Directory.Exists(textOutPath.Text))
             {
                 MsgBox.Show(this, "The path for Outgoing Folder is invalid.");
                 return;
             }
         }
         else                  //TcpIp mode
         {
             if (textInPort.Text == "")
             {
                 MsgBox.Show(this, "The Incoming Port is empty.");
                 return;
             }
             if (textOutPort.Text == "")
             {
                 MsgBox.Show(this, "The Outgoing IP:Port is empty.");
                 return;
             }
             string[] strIpPort = textOutPort.Text.Split(':');
             if (strIpPort.Length != 2)                   //there isn't a ':' in the IpPort field
             {
                 MsgBox.Show(this, "The Outgoing IP:Port field requires an IP address, followed by a colon, followed by a port number.");
                 return;
             }
             try {
                 System.Net.IPAddress.Parse(strIpPort[0]);
             }
             catch {
                 MsgBox.Show(this, "The Outgoing IP address is invalid.");
                 return;
             }
             try {
                 int.Parse(strIpPort[1]);
             }
             catch {
                 MsgBox.Show(this, "The Outgoing port must be a valid integer.");
                 return;
             }
             try {
                 int.Parse(textInPort.Text.ToString());
             }
             catch {
                 MsgBox.Show(this, "The Incoming port must be a valid integer.");
                 return;
             }
         }
     }
     HL7DefCur.HL7Server             = textHL7Server.Text;
     HL7DefCur.HL7ServiceName        = textHL7ServiceName.Text;
     HL7DefCur.IsInternal            = checkInternal.Checked;
     HL7DefCur.InternalType          = textInternalType.Text;
     HL7DefCur.InternalTypeVersion   = textInternalTypeVersion.Text;
     HL7DefCur.Description           = textDescription.Text;
     HL7DefCur.FieldSeparator        = textFieldSep.Text;
     HL7DefCur.RepetitionSeparator   = textRepSep.Text;
     HL7DefCur.ComponentSeparator    = textCompSep.Text;
     HL7DefCur.SubcomponentSeparator = textSubcompSep.Text;
     HL7DefCur.EscapeCharacter       = textEscChar.Text;
     HL7DefCur.Note   = textNote.Text;
     HL7DefCur.ModeTx = (ModeTxHL7)comboModeTx.SelectedIndex;
     if (radioHide.Checked)
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.Hide;
     }
     else if (radioShow.Checked)
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.Show;
     }
     else if (radioChange.Checked)
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.Change;
     }
     else              //must be ChangeAndAdd
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.ChangeAndAdd;
     }
     HL7DefCur.ShowAccount = checkShowAccount.Checked;
     HL7DefCur.ShowAppts   = checkShowAppts.Checked;
     if (comboModeTx.SelectedIndex == (int)ModeTxHL7.File)
     {
         HL7DefCur.IncomingFolder = textInPath.Text;
         HL7DefCur.OutgoingFolder = textOutPath.Text;
         HL7DefCur.IncomingPort   = "";
         HL7DefCur.OutgoingIpPort = "";
     }
     else              //TcpIp mode
     {
         HL7DefCur.IncomingPort   = textInPort.Text;
         HL7DefCur.OutgoingIpPort = textOutPort.Text;
         HL7DefCur.IncomingFolder = "";
         HL7DefCur.OutgoingFolder = "";
     }
     //save
     if (checkEnabled.Checked)
     {
         HL7DefCur.IsEnabled = true;
         if (checkInternal.Checked)
         {
             if (HL7Defs.GetInternalFromDb(HL7DefCur.InternalType) == null) //it's not in the database.
             {
                 HL7Defs.Insert(HL7DefCur);                                 //The user wants to enable this, so we will need to save this def to the db.
             }
             else
             {
                 HL7Defs.Update(HL7DefCur);
             }
         }
         else                  //all custom defs are already in the db.
         {
             HL7Defs.Update(HL7DefCur);
         }
     }
     else              //not enabled
     {
         if (HL7DefCur.IsInternal)
         {
             if (HL7DefCur.IsEnabled)                     //If def was enabled but user wants to disable
             {
                 if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Disable HL7Def?  Changes made will be lost.  Continue?"))
                 {
                     HL7Defs.Delete(HL7DefCur.HL7DefNum);
                 }
                 else                          //user selected Cancel
                 {
                     return;
                 }
             }
             else                      //was disabled and is still disabled
             {
                 if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Changes made will be lost.  Continue?"))
                 {
                     return;
                 }
                 //do nothing.  Changes will be lost.
             }
         }
         else                  //custom
                               //Disable the custom def
         {
             HL7DefCur.IsEnabled = false;
             HL7Defs.Update(HL7DefCur);
         }
     }
     DialogResult = DialogResult.OK;
 }
Example #16
0
        /// <summary>
        /// </summary>
        private Patient CreatePatient(String LastName, String FirstName, DateTime birthDate, WebSheets.SheetAndSheetField sAnds)
        {
            Patient newPat = new Patient();

            newPat.LName     = LastName;
            newPat.FName     = FirstName;
            newPat.Birthdate = birthDate;
            newPat.ClinicNum = sAnds.web_sheet.ClinicNum;
            if (PrefC.GetBool(PrefName.EasyNoClinics))
            {
                //Set the patients primary provider to the practice default provider.
                newPat.PriProv = Providers.GetDefaultProvider().ProvNum;
            }
            else              //Using clinics.
                              //Set the patients primary provider to the clinic default provider.
            {
                newPat.PriProv = Providers.GetDefaultProvider(Clinics.ClinicNum).ProvNum;
            }
            Type t = newPat.GetType();

            FieldInfo[] fi = t.GetFields();
            foreach (FieldInfo field in fi)
            {
                // find match for fields in Patients in the web_sheetfieldlist
                var WebSheetFieldList = sAnds.web_sheetfieldlist.Where(sf => sf.FieldName.ToLower() == field.Name.ToLower());
                if (WebSheetFieldList.Count() > 0)
                {
                    // this loop is used to fill a field that may generate mutiple values for a single field in the patient.
                    //for example the field gender has 2 eqivalent sheet fields in the web_sheetfieldlist
                    for (int i = 0; i < WebSheetFieldList.Count(); i++)
                    {
                        WebSheets.webforms_sheetfield sf = WebSheetFieldList.ElementAt(i);
                        String SheetWebFieldValue        = sf.FieldValue;
                        String RadioButtonValue          = sf.RadioButtonValue;
                        FillPatientFields(newPat, field, SheetWebFieldValue, RadioButtonValue);
                    }
                }
            }
            try{
                Patients.Insert(newPat, false);
                SecurityLogs.MakeLogEntry(Permissions.PatientCreate, newPat.PatNum, "Created from Web Forms.");
                //set Guarantor field the same as PatNum
                Patient patOld = newPat.Copy();
                newPat.Guarantor = newPat.PatNum;
                Patients.Update(newPat, patOld);
                //If there is an existing HL7 def enabled, send an ADT message if there is an outbound ADT message defined
                if (HL7Defs.IsExistingHL7Enabled())
                {
                    MessageHL7 messageHL7 = MessageConstructor.GenerateADT(newPat, newPat, EventTypeHL7.A04);                //patient is guarantor
                    //Will be null if there is no outbound ADT message defined, so do nothing
                    if (messageHL7 != null)
                    {
                        HL7Msg hl7Msg = new HL7Msg();
                        hl7Msg.AptNum    = 0;
                        hl7Msg.HL7Status = HL7MessageStatus.OutPending;                      //it will be marked outSent by the HL7 service.
                        hl7Msg.MsgText   = messageHL7.ToString();
                        hl7Msg.PatNum    = newPat.PatNum;
                        HL7Msgs.Insert(hl7Msg);
#if DEBUG
                        MessageBox.Show(this, messageHL7.ToString());
#endif
                    }
                }
            }
            catch (Exception e) {
                gridMain.EndUpdate();
                MessageBox.Show(e.Message);
            }
            return(newPat);
        }
Example #17
0
 private bool SaveToDb()
 {
     if ((radioModeTight.Checked || radioModeFull.Checked) && comboDefaultUserGroup.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please select a default user group first.");
         return(false);
     }
     if (checkEnabled.Checked)
     {
         if (textProgDesc.Text == "")
         {
             MsgBox.Show(this, "Description may not be blank.");
             return(false);
         }
         if (!HL7Defs.IsExistingHL7Enabled())
         {
             if ((radioModeTight.Checked || radioModeFull.Checked) && textHL7FolderIn.Text == "")
             {
                 MsgBox.Show(this, "HL7 in folder may not be blank.");
                 return(false);
             }
             if (textHL7FolderOut.Text == "")
             {
                 MsgBox.Show(this, "HL7 out folder may not be blank.");
                 return(false);
             }
             if (textHL7Server.Text == "")
             {
                 MsgBox.Show(this, "HL7 Server may not be blank.");
                 return(false);
             }
             if (textHL7ServiceName.Text == "")
             {
                 MsgBox.Show(this, "HL7 Service Name may not be blank.");
                 return(false);
             }
         }
     }
     ProgramCur.ProgDesc = textProgDesc.Text;
     ProgramCur.Enabled  = checkEnabled.Checked;
     Programs.Update(ProgramCur);
     Prefs.UpdateString(PrefName.HL7FolderOut, textHL7FolderOut.Text);
     ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HL7Server", textHL7Server.Text);           //this property will not exist if using Oracle, eCW will never use Oracle
     ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HL7ServiceName", textHL7ServiceName.Text); //this property will not exist if using Oracle, eCW will never use Oracle
     ProgramProperties.SetProperty(ProgramCur.ProgramNum, "MedicalPanelUrl", textMedPanelURL.Text);   //this property will not exist if using Oracle, eCW will never use Oracle
     if (checkLBSessionId.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "IsLBSessionIdExcluded", "1");
     }
     else
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "IsLBSessionIdExcluded", "0");
     }
     if (checkQuadAsToothNum.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "IsQuadAsToothNum", "1");              //this property will not exist if using Oracle, eCW will never use Oracle
     }
     else
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "IsQuadAsToothNum", "0");              //this property will not exist if using Oracle, eCW will never use Oracle
     }
     if (checkHideButChartRx.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HideChartRxButtons", "1");              //this property will not exist if using Oracle, eCW will never use Oracle
     }
     else
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HideChartRxButtons", "0");              //this property will not exist if using Oracle, eCW will never use Oracle
     }
     if (checkProcRequireSignature.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ProcRequireSignature", "1");
     }
     else
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ProcRequireSignature", "0");
     }
     if (checkProcNotesNoIncomplete.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ProcNotesNoIncomplete", "1");
     }
     else
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ProcNotesNoIncomplete", "0");
     }
     if (radioModeTight.Checked || radioModeFull.Checked)
     {
         if (radioModeTight.Checked)
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "0");                  //Tight
         }
         else
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "2");                //Full
         }
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eCWServer", textECWServer.Text);              //this property will not exist if using Oracle, eCW will never use Oracle
         Prefs.UpdateString(PrefName.HL7FolderIn, textHL7FolderIn.Text);
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "DefaultUserGroup",
                                       _listUserGroups[comboDefaultUserGroup.SelectedIndex].UserGroupNum.ToString());
         if (checkShowImages.Checked)
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "1");
         }
         else
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "0");
         }
         if (this.checkFeeSchedules.Checked)
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "1");
         }
         else
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "0");
         }
     }
     else if (radioModeStandalone.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "1");
         Prefs.UpdateString(PrefName.HL7FolderIn, "");
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "DefaultUserGroup", "0");
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "1");
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "0");
     }
     DataValid.SetInvalid(InvalidType.Programs, InvalidType.Prefs);
     return(true);
 }
Example #18
0
        ///<summary>Returns null if there is no DFT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateDFT(List <Procedure> procList, EventTypeHL7 eventType, Patient pat, Patient guar, long aptNum, string pdfDescription, string pdfDataString)   //add event (A04 etc) parameters later if needed
        //In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
        //On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
        {
            Provider    prov       = Providers.GetProv(Patients.GetProvNum(pat));
            Appointment apt        = Appointments.GetOneApt(aptNum);
            MessageHL7  messageHL7 = new MessageHL7(MessageTypeHL7.DFT);
            HL7Def      hl7Def     = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find a DFT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.DFT)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //DFT message type is not defined so do nothing and return
            {
                return(null);
            }
            for (int s = 0; s < hl7DefMessage.hl7DefSegments.Count; s++)
            {
                int countRepeat = 1;
                if (hl7DefMessage.hl7DefSegments[s].SegmentName == SegmentNameHL7.FT1)
                {
                    countRepeat = procList.Count;
                }
                //for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
                for (int repeat = 0; repeat < countRepeat; repeat++)           //FT1 is optional and can repeat so add as many FT1's as procs in procList
                //if(hl7DefMessage.hl7DefSegments[s].SegmentName==SegmentNameHL7.FT1) {
                {
                    if (hl7DefMessage.hl7DefSegments[s].SegmentName == SegmentNameHL7.FT1 && procList.Count > repeat)
                    {
                        prov = Providers.GetProv(procList[repeat].ProvNum);
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[s].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[s].SegmentName.ToString());
                    for (int f = 0; f < hl7DefMessage.hl7DefSegments[s].hl7DefFields.Count; f++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FixedText);
                        }
                        else
                        {
                            //seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,
                            //FieldConstructor.GenerateDFT(hl7Def,fieldName,pat,prov,procList[repeat],guar,apt,repeat+1,eventType,pdfDescription,pdfDataString));
                            Procedure proc = null;
                            if (procList.Count > repeat)                           //procList could be an empty list
                            {
                                proc = procList[repeat];
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,
                                         FieldConstructor.GenerateDFT(hl7Def, fieldName, pat, prov, proc, guar, apt, repeat + 1, eventType, pdfDescription, pdfDataString));
                        }
                    }
                    messageHL7.Segments.Add(seg);
                }
            }
            return(messageHL7);
        }
Example #19
0
 private bool SaveToDb()
 {
     if ((radioModeTight.Checked || radioModeFull.Checked) && comboDefaultUserGroup.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please select a default user group first.");
         return(false);
     }
     if (checkEnabled.Checked)
     {
         if (textProgDesc.Text == "")
         {
             MsgBox.Show(this, "Description may not be blank.");
             return(false);
         }
         if (!HL7Defs.IsExistingHL7Enabled())
         {
             if ((radioModeTight.Checked || radioModeFull.Checked) && textHL7FolderIn.Text == "")
             {
                 MsgBox.Show(this, "HL7 in folder may not be blank.");
                 return(false);
             }
             if (textHL7FolderOut.Text == "")
             {
                 MsgBox.Show(this, "HL7 out folder may not be blank.");
                 return(false);
             }
             if (textHL7Server.Text == "")
             {
                 MsgBox.Show(this, "HL7 Server may not be blank.");
                 return(false);
             }
             if (textHL7ServiceName.Text == "")
             {
                 MsgBox.Show(this, "HL7 Service Name may not be blank.");
                 return(false);
             }
         }
     }
     ProgramCur.ProgDesc = textProgDesc.Text;
     ProgramCur.Enabled  = checkEnabled.Checked;
     Programs.Update(ProgramCur);
     Prefs.UpdateString(PrefName.HL7FolderOut, textHL7FolderOut.Text);
     ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HL7Server", textHL7Server.Text);
     ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HL7ServiceName", textHL7ServiceName.Text);
     ProgramProperties.SetProperty(ProgramCur.ProgramNum, "MedicalPanelUrl", textMedPanelURL.Text);
     if (radioModeTight.Checked || radioModeFull.Checked)
     {
         if (radioModeTight.Checked)
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "0");                  //Tight
         }
         else
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "2");                  //Full
         }
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eCWServer", textECWServer.Text);
         Prefs.UpdateString(PrefName.HL7FolderIn, textHL7FolderIn.Text);
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "DefaultUserGroup",
                                       UserGroups.List[comboDefaultUserGroup.SelectedIndex].UserGroupNum.ToString());
         if (checkShowImages.Checked)
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "1");
         }
         else
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "0");
         }
         if (this.checkFeeSchedules.Checked)
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "1");
         }
         else
         {
             ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "0");
         }
     }
     else if (radioModeStandalone.Checked)
     {
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "1");
         Prefs.UpdateString(PrefName.HL7FolderIn, "");
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "DefaultUserGroup", "0");
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "1");
         ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "0");
     }
     DataValid.SetInvalid(InvalidType.Programs, InvalidType.Prefs);
     return(true);
 }
Example #20
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (!ValidateData())
     {
         return;
     }
     #region Set Values
     HL7DefCur.HL7Server      = textHL7Server.Text;
     HL7DefCur.HL7ServiceName = textHL7ServiceName.Text;
     HL7DefCur.IsInternal     = checkInternal.Checked;
     //this is read-only and cannot be changed, so no need to resave it.
     //HL7DefCur.InternalType=(HL7InternalType)Enum.Parse(typeof(HL7InternalType),textInternalType.Text);
     HL7DefCur.InternalTypeVersion   = textInternalTypeVersion.Text;
     HL7DefCur.Description           = textDescription.Text;
     HL7DefCur.FieldSeparator        = textFieldSep.Text;
     HL7DefCur.RepetitionSeparator   = textRepSep.Text;
     HL7DefCur.ComponentSeparator    = textCompSep.Text;
     HL7DefCur.SubcomponentSeparator = textSubcompSep.Text;
     HL7DefCur.EscapeCharacter       = textEscChar.Text;
     HL7DefCur.Note   = textNote.Text;
     HL7DefCur.ModeTx = (ModeTxHL7)comboModeTx.SelectedIndex;
     if (radioHide.Checked)
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.Hide;
     }
     else if (radioShow.Checked)
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.Show;
     }
     else if (radioChange.Checked)
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.Change;
     }
     else              //must be ChangeAndAdd
     {
         HL7DefCur.ShowDemographics = HL7ShowDemographics.ChangeAndAdd;
     }
     HL7DefCur.ShowAccount        = checkShowAccount.Checked;
     HL7DefCur.ShowAppts          = checkShowAppts.Checked;
     HL7DefCur.IsQuadAsToothNum   = checkQuadAsToothNum.Checked;
     HL7DefCur.HasLongDCodes      = checkLongDCodes.Checked;
     HL7DefCur.IsProcApptEnforced = checkProcsAppt.Checked;
     //clear all fields in order to save the relevant data in the proper fields and clear out data that may not be relevant for the Tx mode
     HL7DefCur.IncomingFolder = "";
     HL7DefCur.OutgoingFolder = "";
     HL7DefCur.IncomingPort   = "";
     HL7DefCur.OutgoingIpPort = "";
     HL7DefCur.SftpInSocket   = "";
     HL7DefCur.SftpUsername   = "";
     HL7DefCur.SftpPassword   = "";
     if (comboModeTx.SelectedIndex == (int)ModeTxHL7.File)
     {
         HL7DefCur.IncomingFolder = textInPathOrSocket.Text.Trim();
         HL7DefCur.OutgoingFolder = textOutPathSocketOrDir.Text.Trim();
     }
     else if (comboModeTx.SelectedIndex == (int)ModeTxHL7.TcpIp)
     {
         HL7DefCur.IncomingPort   = textInPathOrSocket.Text.Trim();
         HL7DefCur.OutgoingIpPort = textOutPathSocketOrDir.Text.Trim();
     }
     else if (comboModeTx.SelectedIndex == (int)ModeTxHL7.Sftp)
     {
         HL7DefCur.SftpInSocket   = textInPathOrSocket.Text.Trim();
         HL7DefCur.IncomingFolder = textOutPathSocketOrDir.Text.Trim();
         HL7DefCur.SftpUsername   = textSftpUsername.Text.Trim();
         HL7DefCur.SftpPassword   = textSftpPassword.Text.Trim();
     }
     if (comboLabImageCat.SelectedIndex >= 0)
     {
         HL7DefCur.LabResultImageCat = _listImageCatDefs[comboLabImageCat.SelectedIndex].DefNum;
     }
     #endregion Set Values
     #region Save
     if (checkEnabled.Checked)
     {
         HL7DefCur.IsEnabled = true;
         if (checkInternal.Checked)
         {
             if (HL7Defs.GetInternalFromDb(HL7DefCur.InternalType) == null) //it's not in the database.
             {
                 HL7Defs.Insert(HL7DefCur);                                 //The user wants to enable this, so we will need to save this def to the db.
             }
             else
             {
                 HL7Defs.Update(HL7DefCur);
             }
         }
         else                  //all custom defs are already in the db.
         {
             HL7Defs.Update(HL7DefCur);
         }
     }
     else              //not enabled
     {
         if (HL7DefCur.IsInternal)
         {
             if (HL7DefCur.IsEnabled)                     //If def was enabled but user wants to disable
             {
                 if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Disable HL7Def?  Changes made will be lost.  Continue?"))
                 {
                     HL7Defs.Delete(HL7DefCur.HL7DefNum);
                 }
                 else                          //user selected Cancel
                 {
                     return;
                 }
             }
             else                      //was disabled and is still disabled
             {
                 if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Changes made will be lost.  Continue?"))
                 {
                     return;
                 }
                 //do nothing.  Changes will be lost.
             }
         }
         else                  //custom
                               //Disable the custom def
         {
             HL7DefCur.IsEnabled = false;
             HL7Defs.Update(HL7DefCur);
         }
     }
     #endregion Save
     DialogResult = DialogResult.OK;
 }
Example #21
0
        ///<summary>Returns empty string if no duplicates, otherwise returns duplicate procedure information.  In all places where this is called, we are guaranteed to have the eCW bridge turned on.  So this is an eCW peculiarity rather than an HL7 restriction.  Other HL7 interfaces will not be checking for duplicate procedures unless we intentionally add that as a feature later.</summary>
        public static string ProcsContainDuplicates(List <Procedure> procs)
        {
            bool   hasLongDCodes = false;
            HL7Def defCur        = HL7Defs.GetOneDeepEnabled();

            if (defCur != null)
            {
                hasLongDCodes = defCur.HasLongDCodes;
            }
            string           info         = "";
            List <Procedure> procsChecked = new List <Procedure>();

            for (int i = 0; i < procs.Count; i++)
            {
                Procedure     proc        = procs[i];
                ProcedureCode procCode    = ProcedureCodes.GetProcCode(procs[i].CodeNum);
                string        procCodeStr = procCode.ProcCode;
                if (procCodeStr.Length > 5 &&
                    procCodeStr.StartsWith("D") &&
                    !hasLongDCodes)
                {
                    procCodeStr = procCodeStr.Substring(0, 5);
                }
                for (int j = 0; j < procsChecked.Count; j++)
                {
                    Procedure     procDup        = procsChecked[j];
                    ProcedureCode procCodeDup    = ProcedureCodes.GetProcCode(procsChecked[j].CodeNum);
                    string        procCodeDupStr = procCodeDup.ProcCode;
                    if (procCodeDupStr.Length > 5 &&
                        procCodeDupStr.StartsWith("D") &&
                        !hasLongDCodes)
                    {
                        procCodeDupStr = procCodeDupStr.Substring(0, 5);
                    }
                    if (procCodeDupStr != procCodeStr)
                    {
                        continue;
                    }
                    if (procDup.ToothNum != proc.ToothNum)
                    {
                        continue;
                    }
                    if (procDup.ToothRange != proc.ToothRange)
                    {
                        continue;
                    }
                    if (procDup.ProcFee != proc.ProcFee)
                    {
                        continue;
                    }
                    if (procDup.Surf != proc.Surf)
                    {
                        continue;
                    }
                    if (info != "")
                    {
                        info += ", ";
                    }
                    info += procCodeDupStr;
                }
                procsChecked.Add(proc);
            }
            if (info != "")
            {
                info = Lan.g("ProcedureL", "Duplicate procedures") + ": " + info;
            }
            return(info);
        }
Example #22
0
        public MessageHL7(string msgtext)
        {
            AckCode         = "";
            ControlId       = "";
            AckEvent        = "";
            originalMsgText = msgtext;
            Segments        = new List <SegmentHL7>();
            string[] rows = msgtext.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
            //We need to get the separator characters in order to create the field objects.
            //The separators are part of the MSH segment and we force users to leave them in position 1 for incoming messages.
            Delimiters = new char[] { '^', '~', '\\', '&' };       //this is the default, but we will get them from the MSH segment of the incoming message in case they are using something unique.
            //if def is enabled, set delimiters to user defined values
            HL7Def enabledDef = HL7Defs.GetOneDeepEnabled();

            if (enabledDef != null)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    //we're going to assume that the user has not inserted an escaped '|' before the second field of the message and just split by '|'s without
                    //checking for escaped '|'s.  Technically '\|' would be a literal pipe and should not indicate a new field, but we only want to retrieve the
                    //delimiters from MSH.1 and we require field 0 to be MSH and field 1 should be ^~\&.
                    string[] fields = rows[i].Split(new string[] { "|" }, StringSplitOptions.None);
                    if (fields.Length > 1 && fields[0] == "MSH" && fields[1].Length == 4)
                    {
                        //Encoding characters are in the following order:  component separator, repetition separator, escape character, subcomponent separator
                        Delimiters = fields[1].ToCharArray();                      //we force users to leave the delimiters in position 1 of the MSH segment
                        break;
                    }
                }
            }
            SegmentHL7 segment;

            for (int i = 0; i < rows.Length; i++)
            {
                segment = new SegmentHL7(rows[i], Delimiters);             //this creates the field objects.
                Segments.Add(segment);
                if (i == 0 && segment.Name == SegmentNameHL7.MSH)
                {
//js 7/3/12 Make this more intelligent because we also now need the suffix
                    string msgtype      = segment.GetFieldComponent(8, 0);            //We force the user to leave the 'messageType' field in this position, position 8 of the MSH segment
                    string evnttype     = segment.GetFieldComponent(8, 1);
                    string msgStructure = segment.GetFieldComponent(8, 2);
                    AckEvent = evnttype;                  //We will use this when constructing the acknowledgment to echo back to sender the same event type sent to us
                    //If message type or event type are not in this list, they will default to the not supported type and will not be processed
                    try {
                        MsgType = (MessageTypeHL7)Enum.Parse(typeof(MessageTypeHL7), msgtype, true);
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        MsgType = MessageTypeHL7.NotDefined;
                    }
                    try {
                        EventType = (EventTypeHL7)Enum.Parse(typeof(EventTypeHL7), evnttype, true);
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        EventType = EventTypeHL7.NotDefined;
                    }
                    try {
                        MsgStructure = (MessageStructureHL7)Enum.Parse(typeof(MessageStructureHL7), msgStructure, true);
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        MsgStructure = MessageStructureHL7.NotDefined;
                    }
                }
            }
        }
Example #23
0
        //Open \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
        //At the top of page 33, there are rules for the recipient.
        //Basically, they state that parsing should not fail just because there are extra unexpected items.
        //And parsing should also not fail if expected items are missing.

        public static void Process(MessageHL7 msg, bool isVerboseLogging)
        {
            HL7MsgCur           = new HL7Msg();
            HL7MsgCur.HL7Status = HL7MessageStatus.InFailed;          //it will be marked InProcessed once data is inserted.
            HL7MsgCur.MsgText   = msg.ToString();
            HL7MsgCur.PatNum    = 0;
            HL7MsgCur.AptNum    = 0;
            List <HL7Msg> hl7Existing = HL7Msgs.GetOneExisting(HL7MsgCur);

            if (hl7Existing.Count > 0)           //This message is already in the db
            {
                HL7MsgCur.HL7MsgNum = hl7Existing[0].HL7MsgNum;
                HL7Msgs.UpdateDateTStamp(HL7MsgCur);
                msg.ControlId = HL7Msgs.GetControlId(HL7MsgCur);
                return;
            }
            else
            {
                //Insert as InFailed until processing is complete.  Update once complete, PatNum will have correct value, AptNum will have correct value if SIU message or 0 if ADT, and status changed to InProcessed
                HL7Msgs.Insert(HL7MsgCur);
            }
            IsVerboseLogging = isVerboseLogging;
            IsNewPat         = false;
            HL7Def def = HL7Defs.GetOneDeepEnabled();

            if (def == null)
            {
                HL7MsgCur.Note = "Could not process HL7 message.  No HL7 definition is enabled.";
                HL7Msgs.Update(HL7MsgCur);
                throw new Exception("Could not process HL7 message.  No HL7 definition is enabled.");
            }
            HL7DefMessage hl7defmsg = null;

            for (int i = 0; i < def.hl7DefMessages.Count; i++)
            {
                if (def.hl7DefMessages[i].MessageType == msg.MsgType)               //&& def.hl7DefMessages[i].EventType==msg.EventType) { //Ignoring event type for now, we will treat all ADT's and SIU's the same
                {
                    hl7defmsg = def.hl7DefMessages[i];
                }
            }
            if (hl7defmsg == null)           //No message definition matches this message's MessageType and EventType
            {
                HL7MsgCur.Note = "Could not process HL7 message.  No definition for this type of message in the enabled HL7Def.";
                HL7Msgs.Update(HL7MsgCur);
                throw new Exception("Could not process HL7 message.  No definition for this type of message in the enabled HL7Def.");
            }
            string   chartNum      = null;
            long     patNum        = 0;
            DateTime birthdate     = DateTime.MinValue;
            string   patLName      = null;
            string   patFName      = null;
            bool     isExistingPID = false;      //Needed to add note to hl7msg table if there isn't a PID segment in the message.

            //Get patient in question, incoming messages must have a PID segment so use that to find the pat in question
            for (int s = 0; s < hl7defmsg.hl7DefSegments.Count; s++)
            {
                if (hl7defmsg.hl7DefSegments[s].SegmentName != SegmentNameHL7.PID)
                {
                    continue;
                }
                int pidOrder = hl7defmsg.hl7DefSegments[s].ItemOrder;
                //we found the PID segment in the def, make sure it exists in the msg
                if (msg.Segments.Count <= pidOrder ||           //If the number of segments in the message is less than the item order of the PID segment
                    msg.Segments[pidOrder].GetField(0).ToString() != "PID"                      //Or if the segment we expect to be the PID segment is not the PID segment
                    )
                {
                    break;
                }
                isExistingPID = true;
                for (int f = 0; f < hl7defmsg.hl7DefSegments[s].hl7DefFields.Count; f++)           //Go through fields of PID segment and get patnum, chartnum, patient name, and/or birthdate to locate patient
                {
                    if (hl7defmsg.hl7DefSegments[s].hl7DefFields[f].FieldName == "pat.ChartNumber")
                    {
                        int chartNumOrdinal = hl7defmsg.hl7DefSegments[s].hl7DefFields[f].OrdinalPos;
                        chartNum = msg.Segments[pidOrder].Fields[chartNumOrdinal].ToString();
                    }
                    else if (hl7defmsg.hl7DefSegments[s].hl7DefFields[f].FieldName == "pat.PatNum")
                    {
                        int patNumOrdinal = hl7defmsg.hl7DefSegments[s].hl7DefFields[f].OrdinalPos;
                        patNum = PIn.Long(msg.Segments[pidOrder].Fields[patNumOrdinal].ToString());
                    }
                    else if (hl7defmsg.hl7DefSegments[s].hl7DefFields[f].FieldName == "pat.birthdateTime")
                    {
                        int patBdayOrdinal = hl7defmsg.hl7DefSegments[s].hl7DefFields[f].OrdinalPos;
                        birthdate = FieldParser.DateTimeParse(msg.Segments[pidOrder].Fields[patBdayOrdinal].ToString());
                    }
                    else if (hl7defmsg.hl7DefSegments[s].hl7DefFields[f].FieldName == "pat.nameLFM")
                    {
                        int patNameOrdinal = hl7defmsg.hl7DefSegments[s].hl7DefFields[f].OrdinalPos;
                        patLName = msg.Segments[pidOrder].GetFieldComponent(patNameOrdinal, 0);
                        patFName = msg.Segments[pidOrder].GetFieldComponent(patNameOrdinal, 1);
                    }
                }
            }
            if (!isExistingPID)
            {
                HL7MsgCur.Note = "Could not process the HL7 message due to missing PID segment.";
                HL7Msgs.Update(HL7MsgCur);
                throw new Exception("Could not process HL7 message.  Could not process the HL7 message due to missing PID segment.");
            }
            //We now have patnum, chartnum, patname, and/or birthdate so locate pat
            Patient pat    = null;
            Patient patOld = null;

            if (patNum != 0)
            {
                pat = Patients.GetPat(patNum);
            }
            if (def.InternalType != "eCWStandalone" && pat == null)
            {
                IsNewPat = true;
            }
            //In eCWstandalone integration, if we couldn't locate patient by patNum or patNum was 0 then pat will still be null so try to locate by chartNum if chartNum is not null
            if (def.InternalType == "eCWStandalone" && chartNum != null)
            {
                pat = Patients.GetPatByChartNumber(chartNum);
            }
            //In eCWstandalone integration, if pat is still null we need to try to locate patient by name and birthdate
            if (def.InternalType == "eCWStandalone" && pat == null)
            {
                long patNumByName = Patients.GetPatNumByNameAndBirthday(patLName, patFName, birthdate);
                //If patNumByName is 0 we couldn't locate by patNum, chartNum or name and birthdate so this message must be for a new patient
                if (patNumByName == 0)
                {
                    IsNewPat = true;
                }
                else
                {
                    pat             = Patients.GetPat(patNumByName);
                    patOld          = pat.Copy();
                    pat.ChartNumber = chartNum;                  //from now on, we will be able to find pat by chartNumber
                    Patients.Update(pat, patOld);
                }
            }
            if (IsNewPat)
            {
                pat = new Patient();
                if (chartNum != null)
                {
                    pat.ChartNumber = chartNum;
                }
                if (patNum != 0)
                {
                    pat.PatNum    = patNum;
                    pat.Guarantor = patNum;
                }
                pat.PriProv     = PrefC.GetLong(PrefName.PracticeDefaultProv);
                pat.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            }
            else
            {
                patOld = pat.Copy();
            }
            //Update hl7msg table with correct PatNum for this message
            HL7MsgCur.PatNum = pat.PatNum;
            HL7Msgs.Update(HL7MsgCur);
            //If this is a message that contains an SCH segment, loop through to find the AptNum.  Pass it to the other segments that will need it.
            long aptNum = 0;

            for (int s = 0; s < hl7defmsg.hl7DefSegments.Count; s++)
            {
                if (hl7defmsg.hl7DefSegments[s].SegmentName != SegmentNameHL7.SCH)
                {
                    continue;
                }
                //we found the SCH segment
                int schOrder = hl7defmsg.hl7DefSegments[s].ItemOrder;
                for (int f = 0; f < hl7defmsg.hl7DefSegments[s].hl7DefFields.Count; f++)           //Go through fields of SCH segment and get AptNum
                {
                    if (hl7defmsg.hl7DefSegments[s].hl7DefFields[f].FieldName == "apt.AptNum")
                    {
                        int aptNumOrdinal = hl7defmsg.hl7DefSegments[s].hl7DefFields[f].OrdinalPos;
                        aptNum = PIn.Long(msg.Segments[schOrder].Fields[aptNumOrdinal].ToString());
                    }
                }
            }
            //We now have a patient object , either loaded from the db or new, and aptNum so process this message for this patient
            //We need to insert the pat to get a patnum so we can compare to guar patnum to see if relationship to guar is self
            if (IsNewPat)
            {
                if (isVerboseLogging)
                {
                    EventLog.WriteEntry("OpenDentHL7", "Inserted patient: " + pat.FName + " " + pat.LName, EventLogEntryType.Information);
                }
                if (pat.PatNum == 0)
                {
                    pat.PatNum = Patients.Insert(pat, false);
                }
                else
                {
                    pat.PatNum = Patients.Insert(pat, true);
                }
                patOld = pat.Copy();
            }
            for (int i = 0; i < hl7defmsg.hl7DefSegments.Count; i++)
            {
                try {
                    SegmentHL7 seg = msg.GetSegment(hl7defmsg.hl7DefSegments[i].SegmentName, !hl7defmsg.hl7DefSegments[i].IsOptional);
                    if (seg != null)                   //null if segment was not found but is optional
                    {
                        ProcessSeg(pat, aptNum, hl7defmsg.hl7DefSegments[i], seg, msg);
                    }
                }
                catch (ApplicationException ex) {               //Required segment was missing, or other error.
                    HL7MsgCur.Note = "Could not process this HL7 message.  " + ex;
                    HL7Msgs.Update(HL7MsgCur);
                    throw new Exception("Could not process HL7 message.  " + ex);
                }
            }
            //We have processed the message so now update or insert the patient
            if (pat.FName == "" || pat.LName == "")
            {
                EventLog.WriteEntry("OpenDentHL7", "Patient demographics not processed due to missing first or last name. PatNum:" + pat.PatNum.ToString()
                                    , EventLogEntryType.Information);
                HL7MsgCur.Note = "Patient demographics not processed due to missing first or last name. PatNum:" + pat.PatNum.ToString();
                HL7Msgs.Update(HL7MsgCur);
                return;
            }
            if (IsNewPat)
            {
                if (pat.Guarantor == 0)
                {
                    pat.Guarantor = pat.PatNum;
                    Patients.Update(pat, patOld);
                }
                else
                {
                    Patients.Update(pat, patOld);
                }
            }
            else
            {
                if (isVerboseLogging)
                {
                    EventLog.WriteEntry("OpenDentHL7", "Updated patient: " + pat.FName + " " + pat.LName, EventLogEntryType.Information);
                }
                Patients.Update(pat, patOld);
            }
            HL7MsgCur.HL7Status = HL7MessageStatus.InProcessed;
            HL7Msgs.Update(HL7MsgCur);
        }
Example #24
0
        ///<summary>Sets given appt.AptStatus to broken.
        ///Provide procCode that should be charted, can be null but will not chart a broken procedure.
        ///Also considers various broken procedure based prefs.
        ///Makes its own securitylog entries.</summary>
        public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode)
        {
            //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed.
            DateTime datePrevious    = appt.DateTStamp;
            bool     suppressHistory = false;

            if (procCode != null)
            {
                suppressHistory = (procCode.ProcCode.In("D9986", "D9987"));
            }
            Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods
            if (appt.AptStatus != ApptStatus.Complete)                           //seperate log entry for completed appointments.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            #region Charting the proc
            if (procCode != null)
            {
                switch (procCode.ProcCode)
                {
                case "D9986":                        //Missed
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed);
                    break;

                case "D9987":                        //Cancelled
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled);
                    break;
                }
                Procedure procedureCur = new Procedure();
                procedureCur.PatNum       = pat.PatNum;
                procedureCur.ProvNum      = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum);
                procedureCur.CodeNum      = procCode.CodeNum;
                procedureCur.ProcDate     = DateTime.Today;
                procedureCur.DateEntryC   = DateTime.Now;
                procedureCur.ProcStatus   = ProcStat.C;
                procedureCur.ClinicNum    = appt.ClinicNum;
                procedureCur.UserNum      = Security.CurUser.UserNum;
                procedureCur.Note         = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                procedureCur.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);              //Default proc place of service for the Practice is used.
                List <InsSub>  listInsSubs    = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
                List <InsPlan> listInsPlans   = InsPlans.RefreshForSubList(listInsSubs);
                List <PatPlan> listPatPlans   = PatPlans.Refresh(pat.PatNum);
                InsPlan        insPlanPrimary = null;
                InsSub         insSubPrimary  = null;
                if (listPatPlans.Count > 0)
                {
                    insSubPrimary  = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs);
                    insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans);
                }
                double procFee;
                long   feeSch;
                if (insPlanPrimary == null || procCode.NoBillIns)
                {
                    feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, procedureCur.ProvNum);
                }
                else                  //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns
                {
                    feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, procedureCur.ProvNum);
                }
                procFee = Fees.GetAmount0(procedureCur.CodeNum, feeSch, procedureCur.ClinicNum, procedureCur.ProvNum);
                if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical)         //PPO
                {
                    double provFee = Fees.GetAmount0(procedureCur.CodeNum, Providers.GetProv(procedureCur.ProvNum).FeeSched, procedureCur.ClinicNum,
                                                     procedureCur.ProvNum);
                    procedureCur.ProcFee = Math.Max(provFee, procFee);
                }
                else
                {
                    procedureCur.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    procedureCur.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(procedureCur);
                //Now make a claimproc if the patient has insurance.  We do this now for consistency because a claimproc could get created in the future.
                List <Benefit>   listBenefits          = Benefits.Refresh(listPatPlans, listInsSubs);
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(procedureCur.ProcNum);
                Procedures.ComputeEstimates(procedureCur, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                FormProcBroken FormPB = new FormProcBroken(procedureCur);
                FormPB.IsNew = true;
                FormPB.ShowDialog();
            }
            #endregion
            #region BrokenApptAdjustment
            if (PrefC.GetBool(PrefName.BrokenApptAdjustment))
            {
                Adjustment AdjustmentCur = new Adjustment();
                AdjustmentCur.DateEntry = DateTime.Today;
                AdjustmentCur.AdjDate   = DateTime.Today;
                AdjustmentCur.ProcDate  = DateTime.Today;
                AdjustmentCur.ProvNum   = appt.ProvNum;
                AdjustmentCur.PatNum    = pat.PatNum;
                AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType);
                AdjustmentCur.ClinicNum = appt.ClinicNum;
                FormAdjust FormA = new FormAdjust(pat, AdjustmentCur);
                FormA.IsNew = true;
                FormA.ShowDialog();
            }
            #endregion
            #region BrokenApptCommLog
            if (PrefC.GetBool(PrefName.BrokenApptCommLog))
            {
                Commlog CommlogCur = new Commlog();
                CommlogCur.PatNum       = pat.PatNum;
                CommlogCur.CommDateTime = DateTime.Now;
                CommlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                CommlogCur.Note         = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                CommlogCur.Mode_        = CommItemMode.None;
                CommlogCur.UserNum      = Security.CurUser.UserNum;
                FormCommItem FormCI = new FormCommItem();
                FormCI.ShowDialog(new CommItemModel()
                {
                    CommlogCur = CommlogCur
                }, new CommItemController(FormCI)
                {
                    IsNew = true
                });
            }
            #endregion
            AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum);
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Example #25
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound DFT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateDFT(List <Procedure> listProcs, EventTypeHL7 eventType, Patient pat, Patient guar, long aptNum, string pdfDescription, string pdfDataString)
        {
            //In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
            //On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
            MessageHL7 msgHl7 = new MessageHL7(MessageTypeHL7.DFT);
            HL7Def     hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find a DFT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.DFT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //DFT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            Appointment    apt          = Appointments.GetOneApt(aptNum);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int repeatCount = 1;
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1)
                {
                    repeatCount = listProcs.Count;
                }
                else if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    repeatCount = listPatPlans.Count;
                }
                //for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
                //or the patient does not have any current insplans for IN1 segments
                for (int j = 0; j < repeatCount; j++)           //FT1 is optional and can repeat so add as many FT1's as procs in procList, IN1 is optional and can repeat as well, repeat for the number of patplans in patplanList
                {
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1 && listProcs.Count > j)
                    {
                        prov = Providers.GetProv(listProcs[j].ProvNum);
                    }
                    Procedure proc = null;
                    if (listProcs.Count > j)                   //procList could be an empty list
                    {
                        proc = listProcs[j];
                    }
                    PatPlan patPlanCur = null;
                    InsPlan insPlanCur = null;
                    InsSub  insSubCur  = null;
                    Carrier carrierCur = null;
                    Patient subscriber = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                    {
                        patPlanCur = listPatPlans[j];
                        insSubCur  = InsSubs.GetOne(patPlanCur.InsSubNum);
                        insPlanCur = InsPlans.RefreshOne(insSubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insPlanCur.CarrierNum);
                        subscriber = Patients.GetPat(insSubCur.Subscriber);
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int f = 0; f < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; f++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patPlanCur, insSubCur, insPlanCur, carrierCur, listPatPlans.Count, subscriber);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateField(hl7Def, fieldName, MessageTypeHL7.DFT, pat, prov, proc, guar, apt, j + 1, eventType,
                                                                            pdfDescription, pdfDataString, MessageStructureHL7.DFT_P03, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, fieldValue);
                        }
                    }
                    msgHl7.Segments.Add(seg);
                }
            }
            return(msgHl7);
        }
Example #26
0
        ///<summary>Uses sheet framework to generate a PDF file, save it to patient's image folder, and attempt to launch file with defualt reader.
        ///If using ImagesStoredInDB it will not launch PDF. If no valid patient is selected you cannot perform this action.</summary>
        private void butPDF_Click(object sender, EventArgs e)
        {
            if (PatCur == null)           //not attached to a patient when form loaded and they haven't selected a patient to attach to yet
            {
                MsgBox.Show(this, "The Medical Lab must be attached to a patient before the PDF can be saved.");
                return;
            }
            if (PatCur.PatNum > 0 && _medLabCur.PatNum != PatCur.PatNum)         //save the current patient attached to the MedLab if it has been changed
            {
                MoveLabsAndImagesHelper();
            }
            Cursor = Cursors.WaitCursor;
            SheetDef sheetDef = SheetUtil.GetMedLabResultsSheetDef();
            Sheet    sheet    = SheetUtil.CreateSheet(sheetDef, _medLabCur.PatNum);

            SheetFiller.FillFields(sheet, null, null, _medLabCur);
            //create the file in the temp folder location, then import so it works when storing images in the db
            string tempPath = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), _medLabCur.PatNum.ToString() + ".pdf");

            SheetPrinting.CreatePdf(sheet, tempPath, null, _medLabCur);
            HL7Def defCur   = HL7Defs.GetOneDeepEnabled(true);
            long   category = defCur.LabResultImageCat;

            if (category == 0)
            {
                category = Defs.GetFirstForCategory(DefCat.ImageCats, true).DefNum;             //put it in the first category.
            }
            //create doc--------------------------------------------------------------------------------------
            OpenDentBusiness.Document docc = null;
            try {
                docc = ImageStore.Import(tempPath, category, Patients.GetPat(_medLabCur.PatNum));
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Error saving document.");
                return;
            }
            finally {
                //Delete the temp file since we don't need it anymore.
                try {
                    File.Delete(tempPath);
                }
                catch {
                    //Do nothing.  This file will likely get cleaned up later.
                }
            }
            docc.Description = Lan.g(this, "MedLab Result");
            docc.DateCreated = DateTime.Now;
            Documents.Update(docc);
            string filePathAndName = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                string patFolder = ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath());
                filePathAndName = ODFileUtils.CombinePaths(patFolder, docc.FileName);
            }
            else if (CloudStorage.IsCloudStorage)
            {
                FormProgress FormP = new FormProgress();
                FormP.DisplayText          = "Downloading...";
                FormP.NumberFormat         = "F";
                FormP.NumberMultiplication = 1;
                FormP.MaxVal = 100;              //Doesn't matter what this value is as long as it is greater than 0
                FormP.TickMS = 1000;
                OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(
                    ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath())
                    , docc.FileName
                    , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                if (FormP.ShowDialog() == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                filePathAndName = PrefC.GetRandomTempFile(Path.GetExtension(docc.FileName));
                File.WriteAllBytes(filePathAndName, state.FileContent);
            }
            Cursor = Cursors.Default;
            if (filePathAndName != "")
            {
                Process.Start(filePathAndName);
            }
            SecurityLogs.MakeLogEntry(Permissions.SheetEdit, sheet.PatNum, sheet.Description + " from " + sheet.DateTimeSheet.ToShortDateString() + " pdf was created");
            DialogResult = DialogResult.OK;
        }
Example #27
0
        ///<summary>Creates a single recall appointment. If it's from a double click, then it will end up on that spot in the Appts module.  If not, it will end up on the pinboard with StringDateJumpTo as due date to jump to.  ListAptNumsSelected will contain the AptNum of the new appointment.</summary>
        public void MakeRecallAppointment()
        {
            List <InsSub>  listInsSubs  = InsSubs.RefreshForFam(_famCur);
            List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs);
            Appointment    apt          = null;
            DateTime       dateTimeApt  = DateTime.MinValue;

            if (this.IsInitialDoubleClick)
            {
                dateTimeApt = DateTimeClicked;
            }
            try{
                apt = AppointmentL.CreateRecallApt(_patCur, listInsPlans, -1, listInsSubs, dateTimeApt);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            DateTime datePrevious = apt.DateTStamp;

            ListAptNumsSelected.Add(apt.AptNum);
            if (IsInitialDoubleClick)
            {
                Appointment oldApt = apt.Copy();
                if (_patCur.AskToArriveEarly > 0)
                {
                    apt.DateTimeAskedToArrive = apt.AptDateTime.AddMinutes(-_patCur.AskToArriveEarly);
                    MessageBox.Show(Lan.g(this, "Ask patient to arrive") + " " + _patCur.AskToArriveEarly
                                    + " " + Lan.g(this, "minutes early at") + " " + apt.DateTimeAskedToArrive.ToShortTimeString() + ".");
                }
                apt.AptStatus = ApptStatus.Scheduled;
                apt.ClinicNum = _patCur.ClinicNum;
                apt.Op        = OpNumClicked;
                apt           = Appointments.AssignFieldsForOperatory(apt);
                //Use apt.ClinicNum because it was just set based on Op.ClinicNum in AssignFieldsForOperatory().
                if (!AppointmentL.IsSpecialtyMismatchAllowed(_patCur.PatNum, apt.ClinicNum))
                {
                    return;
                }
                Appointments.Update(apt, oldApt);
                _otherResult = OtherResult.CreateNew;
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCreate, apt.PatNum, apt.AptDateTime.ToString(), apt.AptNum, datePrevious);
                //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
                if (HL7Defs.IsExistingHL7Enabled())
                {
                    //S12 - New Appt Booking event
                    MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(_patCur, _famCur.GetPatient(_patCur.Guarantor), EventTypeHL7.S12, apt);
                    //Will be null if there is no outbound SIU message defined, so do nothing
                    if (messageHL7 != null)
                    {
                        HL7Msg hl7Msg = new HL7Msg();
                        hl7Msg.AptNum    = apt.AptNum;
                        hl7Msg.HL7Status = HL7MessageStatus.OutPending;                      //it will be marked outSent by the HL7 service.
                        hl7Msg.MsgText   = messageHL7.ToString();
                        hl7Msg.PatNum    = _patCur.PatNum;
                        HL7Msgs.Insert(hl7Msg);
#if DEBUG
                        MessageBox.Show(this, messageHL7.ToString());
#endif
                    }
                }
                DialogResult = DialogResult.OK;
                return;
            }
            //not initialClick
            _otherResult = OtherResult.PinboardAndSearch;
            Recall recall = Recalls.GetRecallProphyOrPerio(_patCur.PatNum);          //shouldn't return null.
            if (recall.DateDue < DateTime.Today)
            {
                StringDateJumpTo = DateTime.Today.ToShortDateString();              //they are overdue
            }
            else
            {
                StringDateJumpTo = recall.DateDue.ToShortDateString();
            }
            //no securitylog entry needed here.  That will happen when it's dragged off pinboard.
            DialogResult = DialogResult.OK;
        }
Example #28
0
        ///<summary>Sets given appt.AptStatus to broken.
        ///Provide procCode that should be charted, can be null but will not chart a broken procedure.
        ///Also considers various broken procedure based prefs.
        ///Makes its own securitylog entries.</summary>
        public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode)
        {
            //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed.
            DateTime datePrevious    = appt.DateTStamp;
            bool     suppressHistory = false;

            if (procCode != null)
            {
                suppressHistory = (procCode.ProcCode.In("D9986", "D9987"));
            }
            Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods
            if (appt.AptStatus != ApptStatus.Complete)                           //seperate log entry for completed appointments.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            List <Procedure> listProcedures = new List <Procedure>();
            //splits should only exist on procs if they are using tp pre-payments
            List <PaySplit> listSplitsForApptProcs = new List <PaySplit>();
            bool            isNonRefundable        = false;
            double          brokenProcAmount       = 0;
            Procedure       brokenProcedure        = new Procedure();
            bool            wasBrokenProcDeleted   = false;
            if (PrefC.GetYN(PrefName.PrePayAllowedForTpProcs))
            {
                listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false);
                if (listProcedures.Count > 0)
                {
                    listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList());
                }
            }
            #region Charting the proc
            if (procCode != null)
            {
                switch (procCode.ProcCode)
                {
                case "D9986":                        //Missed
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed);
                    break;

                case "D9987":                        //Cancelled
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled);
                    break;
                }
                brokenProcedure.PatNum       = pat.PatNum;
                brokenProcedure.ProvNum      = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum);
                brokenProcedure.CodeNum      = procCode.CodeNum;
                brokenProcedure.ProcDate     = DateTime.Today;
                brokenProcedure.DateEntryC   = DateTime.Now;
                brokenProcedure.ProcStatus   = ProcStat.C;
                brokenProcedure.ClinicNum    = appt.ClinicNum;
                brokenProcedure.UserNum      = Security.CurUser.UserNum;
                brokenProcedure.Note         = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                brokenProcedure.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);              //Default proc place of service for the Practice is used.
                List <InsSub>  listInsSubs    = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
                List <InsPlan> listInsPlans   = InsPlans.RefreshForSubList(listInsSubs);
                List <PatPlan> listPatPlans   = PatPlans.Refresh(pat.PatNum);
                InsPlan        insPlanPrimary = null;
                InsSub         insSubPrimary  = null;
                if (listPatPlans.Count > 0)
                {
                    insSubPrimary  = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs);
                    insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans);
                }
                double procFee;
                long   feeSch;
                if (insPlanPrimary == null || procCode.NoBillIns)
                {
                    feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, brokenProcedure.ProvNum);
                }
                else                  //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns
                {
                    feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, brokenProcedure.ProvNum);
                }
                procFee = Fees.GetAmount0(brokenProcedure.CodeNum, feeSch, brokenProcedure.ClinicNum, brokenProcedure.ProvNum);
                if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical)         //PPO
                {
                    double provFee = Fees.GetAmount0(brokenProcedure.CodeNum, Providers.GetProv(brokenProcedure.ProvNum).FeeSched, brokenProcedure.ClinicNum,
                                                     brokenProcedure.ProvNum);
                    brokenProcedure.ProcFee = Math.Max(provFee, procFee);
                }
                else if (listSplitsForApptProcs.Count > 0 && PrefC.GetBool(PrefName.TpPrePayIsNonRefundable) && procCode.ProcCode == "D9986")
                {
                    //if there are pre-payments, non-refundable pre-payments is turned on, and the broken appointment is a missed code then auto-fill
                    //the window with the sum of the procs for the appointment. Transfer money below after broken procedure is confirmed by the user.
                    brokenProcedure.ProcFee = listSplitsForApptProcs.Sum(x => x.SplitAmt);
                    isNonRefundable         = true;
                }
                else
                {
                    brokenProcedure.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    brokenProcedure.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(brokenProcedure);
                //Now make a claimproc if the patient has insurance.  We do this now for consistency because a claimproc could get created in the future.
                List <Benefit>   listBenefits          = Benefits.Refresh(listPatPlans, listInsSubs);
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(brokenProcedure.ProcNum);
                Procedures.ComputeEstimates(brokenProcedure, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                FormProcBroken FormPB = new FormProcBroken(brokenProcedure, isNonRefundable);
                FormPB.IsNew = true;
                FormPB.ShowDialog();
                brokenProcAmount     = FormPB.AmountTotal;
                wasBrokenProcDeleted = FormPB.IsProcDeleted;
            }
            #endregion
            #region BrokenApptAdjustment
            if (PrefC.GetBool(PrefName.BrokenApptAdjustment))
            {
                Adjustment AdjustmentCur = new Adjustment();
                AdjustmentCur.DateEntry = DateTime.Today;
                AdjustmentCur.AdjDate   = DateTime.Today;
                AdjustmentCur.ProcDate  = DateTime.Today;
                AdjustmentCur.ProvNum   = appt.ProvNum;
                AdjustmentCur.PatNum    = pat.PatNum;
                AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType);
                AdjustmentCur.ClinicNum = appt.ClinicNum;
                FormAdjust FormA = new FormAdjust(pat, AdjustmentCur);
                FormA.IsNew = true;
                FormA.ShowDialog();
            }
            #endregion
            #region BrokenApptCommLog
            if (PrefC.GetBool(PrefName.BrokenApptCommLog))
            {
                Commlog commlogCur = new Commlog();
                commlogCur.PatNum       = pat.PatNum;
                commlogCur.CommDateTime = DateTime.Now;
                commlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                commlogCur.Note         = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                commlogCur.Mode_        = CommItemMode.None;
                commlogCur.UserNum      = Security.CurUser.UserNum;
                commlogCur.IsNew        = true;
                FormCommItem FormCI = new FormCommItem(commlogCur);
                FormCI.ShowDialog();
            }
            #endregion
            #region Transfer money from TP Procedures if necessary
            //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure.
            if (isNonRefundable && !wasBrokenProcDeleted && listSplitsForApptProcs.Count > 0)
            {
                //transfer what the user specified in the broken appointment window.
                //transfer up to the amount specified by the user
                foreach (Procedure proc in listProcedures)
                {
                    if (brokenProcAmount == 0)
                    {
                        break;
                    }
                    List <PaySplit> listSplitsForAppointmentProcedure = listSplitsForApptProcs.FindAll(x => x.ProcNum == proc.ProcNum);
                    foreach (PaySplit split in listSplitsForAppointmentProcedure)
                    {
                        if (brokenProcAmount == 0)
                        {
                            break;
                        }
                        double amt = Math.Min(brokenProcAmount, split.SplitAmt);
                        Payments.CreateTransferForTpProcs(proc, new List <PaySplit> {
                            split
                        }, brokenProcedure, amt);
                        double amtPaidOnApt = listSplitsForApptProcs.Sum(x => x.SplitAmt);
                        if (amtPaidOnApt > amt)
                        {
                            //If the original prepayment amount is greater than the amt being specified for the appointment break, transfer
                            //the difference to an Unallocated Unearned Paysplit on the account.
                            double remainingAmt = amtPaidOnApt - amt;
                            //We have to create a new transfer payment here to correlate to the split.
                            Payment txfrPayment = new Payment();
                            txfrPayment.PayAmt    = 0;
                            txfrPayment.PayDate   = DateTime.Today;
                            txfrPayment.ClinicNum = split.ClinicNum;
                            txfrPayment.PayNote   = "Automatic transfer from treatment planned procedure prepayment.";
                            txfrPayment.PatNum    = split.PatNum;                       //ultimately where the payment ends up.
                            txfrPayment.PayType   = 0;
                            Payments.Insert(txfrPayment);
                            PaymentEdit.IncomeTransferData transferData = PaymentEdit.IncomeTransferData.CreateTransfer(split, txfrPayment.PayNum, true, remainingAmt);
                            PaySplit offset         = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum != 0);
                            long     offsetSplitNum = PaySplits.Insert(offset);                      //Get the FSplitNum from the offset
                            PaySplit allocation     = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum == 0);
                            allocation.FSplitNum = offsetSplitNum;
                            PaySplits.Insert(allocation);                            //Insert so the split is now up to date
                            SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, txfrPayment.PatNum, "Automatic transfer of funds for treatment plan procedure pre-payments.");
                        }
                        brokenProcAmount -= amt;
                    }
                }
            }
            //if broken appointment procedure was deleted (user cancelled out of the window) just keep money on the original procedure.
            #endregion
            AppointmentEvent.Fire(ODEventType.AppointmentEdited, appt);
            AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum);
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Example #29
0
        ///<summary>Gets the patient info from the MedLab.OriginalPIDSegments.  Returns null if there is an error processing the PID segments.</summary>
        private List <string[]> GetPatInfoFromPidSegments()
        {
            List <string[]> listPats  = new List <string[]>();
            HL7Def          hl7DefCur = HL7Defs.GetOneDeepEnabled(true);

            if (hl7DefCur == null)
            {
                MsgBox.Show(this, "There must be an enabled MedLab HL7 interface in order to parse the message details.");
                return(null);
            }
            HL7DefMessage hl7defmsg = null;

            for (int i = 0; i < hl7DefCur.hl7DefMessages.Count; i++)
            {
                //for now there are only incoming ORU messages supported, so there should only be one defined message type and it should be inbound
                if (hl7DefCur.hl7DefMessages[i].MessageType == MessageTypeHL7.ORU && hl7DefCur.hl7DefMessages[i].InOrOut == InOutHL7.Incoming)
                {
                    hl7defmsg = hl7DefCur.hl7DefMessages[i];
                    break;
                }
            }
            if (hl7defmsg == null)
            {
                MsgBox.Show(this, "There must be a message definition for an inbound ORU message in order to parse this message.");
                return(null);
            }
            //for MedLab interfaces, we limit the ability to rearrange the message structure, so the PID segment is always in position 1
            if (hl7defmsg.hl7DefSegments.Count < 2)
            {
                MsgBox.Show(this, "The message definition for an inbound ORU message does not have the correct number of segments.");
                return(null);
            }
            HL7DefSegment pidSegDef = hl7defmsg.hl7DefSegments[1];

            if (pidSegDef.SegmentName != SegmentNameHL7.PID)
            {
                MsgBox.Show(this, "The message definition for an inbound ORU message does not have the PID segment as the second segment.");
                return(null);
            }
            for (int i = 0; i < ListMedLabs.Count; i++)
            {
                string[]        fields     = ListMedLabs[i].OriginalPIDSegment.Split(new string[] { "|" }, StringSplitOptions.None);
                List <FieldHL7> listFields = new List <FieldHL7>();
                for (int j = 0; j < fields.Length; j++)
                {
                    listFields.Add(new FieldHL7(fields[j]));
                }
                string patName   = "";
                string birthdate = "";
                string gender    = "";
                string ssn       = "";
                for (int j = 0; j < pidSegDef.hl7DefFields.Count; j++)
                {
                    int itemOrder = pidSegDef.hl7DefFields[j].OrdinalPos;
                    if (itemOrder > listFields.Count - 1)
                    {
                        continue;
                    }
                    switch (pidSegDef.hl7DefFields[j].FieldName)
                    {
                    case "pat.nameLFM":
                        patName = listFields[itemOrder].GetComponentVal(1);
                        if (patName != "" && listFields[itemOrder].GetComponentVal(2) != "")
                        {
                            patName += " ";
                        }
                        patName += listFields[itemOrder].GetComponentVal(2);
                        if (patName != "" && listFields[itemOrder].GetComponentVal(0) != "")
                        {
                            patName += " ";
                        }
                        patName += listFields[itemOrder].GetComponentVal(0);
                        continue;

                    case "patBirthdateAge":
                        //LabCorp sends the birthdate and age in years, months, and days like yyyyMMdd^YYY^MM^DD
                        birthdate = FieldParser.DateTimeParse(listFields[itemOrder].GetComponentVal(0)).ToShortDateString();
                        continue;

                    case "pat.Gender":
                        gender = Lan.g("enumPatientGender", FieldParser.GenderParse(listFields[itemOrder].GetComponentVal(0)).ToString());
                        continue;

                    case "pat.SSN":
                        if (listFields[itemOrder].GetComponentVal(0).Length > 3)
                        {
                            ssn  = "***-**-";
                            ssn += listFields[itemOrder].GetComponentVal(0).Substring(listFields[itemOrder].GetComponentVal(0).Length - 4, 4);
                        }
                        continue;

                    default:
                        continue;
                    }
                }
                bool isDuplicate = false;
                for (int j = 0; j < listPats.Count; j++)
                {
                    if (listPats[j].Length < 4)                   //should never happen
                    {
                        continue;
                    }
                    if (listPats[j][0] == patName && listPats[j][1] == birthdate && listPats[j][2] == gender && listPats[j][3] == ssn)
                    {
                        isDuplicate = true;
                    }
                }
                if (!isDuplicate)
                {
                    listPats.Add(new string[] { patName, birthdate, gender, ssn });
                }
            }
            return(listPats);
        }
Example #30
0
        ///<summary>Returns null if no HL7 def is enabled or no SRR is defined in the enabled def.  An SRR - Schedule Request Response message is sent when an SRM - Schedule Request Message is received.  The SRM is acknowledged just like any inbound message, but the SRR notifies the placer application that the requested modification took place.  Currently the only appointment modifications allowed are updating the appt note, setting the dentist and hygienist, updating the confirmation status, and changing the ClinicNum.  Setting the appointment status to Broken is also supported.</summary>
        public static MessageHL7 GenerateSRR(Patient pat, Appointment apt, EventTypeHL7 eventType, string controlId, bool isAck, string ackEvent)
        {
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find an outbound SRR message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.SRR && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    break;
                }
            }
            if (hl7DefMessage == null)           //SRR message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            MessageHL7 msgHl7  = new MessageHL7(MessageTypeHL7.SRR);
            Provider   provPri = Providers.GetProv(apt.ProvNum);

            //go through each segment in the def
            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                List <Provider> listProvs = new List <Provider>();
                listProvs.Add(provPri);
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.AIP && apt.ProvHyg > 0)
                {
                    listProvs.Add(Providers.GetProv(apt.ProvHyg));
                }
                for (int j = 0; j < listProvs.Count; j++)           //AIP will be repeated if there is a dentist and a hygienist on the appt
                {
                    Provider   prov = listProvs[j];
                    SegmentHL7 seg  = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int k = 0; k < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; k++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.MSA)
                            {
                                fieldValue = FieldConstructor.GenerateFieldACK(hl7Def, fieldName, controlId, isAck, ackEvent);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateFieldSRR(hl7Def, fieldName, pat, prov, apt, j + 1, eventType, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, fieldValue);
                        }
                    }
                    msgHl7.Segments.Add(seg);
                }
            }
            return(msgHl7);
        }