public WebServiceResponse AddClientDiagnosis(string SystemCode, string UserName, string Password, ClientDiagnosisObject ClientDiagnosisInfo, string ClientID, string EpisodeNumber) {
     object[] results = this.Invoke("AddClientDiagnosis", new object[] {
                 SystemCode,
                 UserName,
                 Password,
                 ClientDiagnosisInfo,
                 ClientID,
                 EpisodeNumber});
     return ((WebServiceResponse)(results[0]));
 }
 /// <remarks/>
 public void EditClientDiagnosisAsync(string SystemCode, string UserName, string Password, ClientDiagnosisObject ClientDiagnosisInfo, string ClientID, string EpisodeNumber, string UniqueID, object userState) {
     if ((this.EditClientDiagnosisOperationCompleted == null)) {
         this.EditClientDiagnosisOperationCompleted = new System.Threading.SendOrPostCallback(this.OnEditClientDiagnosisOperationCompleted);
     }
     this.InvokeAsync("EditClientDiagnosis", new object[] {
                 SystemCode,
                 UserName,
                 Password,
                 ClientDiagnosisInfo,
                 ClientID,
                 EpisodeNumber,
                 UniqueID}, this.EditClientDiagnosisOperationCompleted, userState);
 }
 /// <remarks/>
 public void EditClientDiagnosisAsync(string SystemCode, string UserName, string Password, ClientDiagnosisObject ClientDiagnosisInfo, string ClientID, string EpisodeNumber, string UniqueID) {
     this.EditClientDiagnosisAsync(SystemCode, UserName, Password, ClientDiagnosisInfo, ClientID, EpisodeNumber, UniqueID, null);
 }
 /// <remarks/>
 public void AddClientDiagnosisAsync(string SystemCode, string UserName, string Password, ClientDiagnosisObject ClientDiagnosisInfo, string ClientID, string EpisodeNumber) {
     this.AddClientDiagnosisAsync(SystemCode, UserName, Password, ClientDiagnosisInfo, ClientID, EpisodeNumber, null);
 }
        private OptionObject UpdateDiagnosis(OptionObject optionObject, string scriptName)
        {
            /* scriptname delimited by commas as follows:
             * #1 : scriptName
             * #2 : draft/final/PA field
             * #3 : draft/final/PA value
             * #4 : date field
             * #5 : time field
             * #6 : axis I dx field
             * #7 : diagnosing practitioner field
             */
            var returnOptionObject = new OptionObject();
            try
            {
                var fieldList = scriptName.Split(',').ToList().Skip(1);
                var noteStatusField = new FieldObject { FieldNumber = fieldList.ElementAt(0) };
                var statusNeeded = fieldList.ElementAt(1);
                var dateField = new FieldObject { FieldNumber = fieldList.ElementAt(2) };
                var timeField = new FieldObject { FieldNumber = fieldList.ElementAt(3) };
                var axisIdx = new FieldObject { FieldNumber = fieldList.ElementAt(4) };
                var practitioner = new FieldObject { FieldNumber = fieldList.ElementAt(5) };

                var clientDiagnosisObj = new ClientDiagnosis.ClientDiagnosisObject();
                foreach (var form in optionObject.Forms)
                {
                    foreach (var field in form.CurrentRow.Fields)
                    {
                        if (field.FieldNumber.Equals(dateField.FieldNumber))
                            clientDiagnosisObj.DateOfDiagnosis = DateTime.Parse(field.FieldValue);
                        if (field.FieldNumber.Equals(timeField.FieldNumber))
                            clientDiagnosisObj.TimeOfDiagnosis = field.FieldValue;
                        if (field.FieldNumber.Equals(axisIdx.FieldNumber))
                            clientDiagnosisObj.DiagnosisAxisI1 = field.FieldValue;
                        if (field.FieldNumber.Equals(practitioner.FieldNumber))
                            clientDiagnosisObj.DiagnosingPractitioner = field.FieldValue;
                        if (field.FieldNumber.Equals(noteStatusField.FieldNumber))
                            noteStatusField.FieldValue = field.FieldValue;
                    }
                }
                if (noteStatusField.FieldValue.Equals(statusNeeded))
                {
                    clientDiagnosisObj.TypeOfDiagnosis = previousDiagnosisExist(optionObject) == null ? "A" : "U";
                    clientDiagnosisObj.DateOfDiagnosisSpecified = true;
                    clientDiagnosisObj.PrincipalDiagnosis = clientDiagnosisObj.DiagnosisAxisI1;
                    returnOptionObject.ErrorCode = 4;
                    if (clientDiagnosisObj.TypeOfDiagnosis.Equals("U"))
                    {
                        returnOptionObject.ErrorMesg = "The Diagnosis entered will be added to the client's record " +
                            "and become the client's new Diagnosis";
                    }
                }
            }
            catch (Exception e)
            {
            }
            returnOptionObject.EntityID = optionObject.EntityID;
            returnOptionObject.OptionId = optionObject.OptionId;
            returnOptionObject.SystemCode = optionObject.SystemCode;
            returnOptionObject.Facility = optionObject.Facility;
            return returnOptionObject;
        }
 private ClientDiagnosis.ClientDiagnosisObject previousDiagnosisExist(OptionObject optionObject)
 {
     var dxObj = new ClientDiagnosis.ClientDiagnosisObject();
     var connectionString = ConfigurationManager.ConnectionStrings["CacheODBC"].ConnectionString;
     var commandText = "SELECT TOP(1) history_diagnosis.diagnosis_type_value, " +
                         "history_diagnosis.diagnosis_type_code," +
                         "history_diagnosis.date_of_diagnosis, " +
                         "history_diagnosis.time_of_diagnosis," +
                         "history_diagnosis.axis_I_diag_code_1," +
                         "history_diagnosis.axis_I_diag_value_1," +
                         "history_diagnosis.principal_diagnosis_code," +
                         "history_diagnosis.principal_diagnosis_value," +
                         "history_diagnosis.diagnosing_practitioner_code," +
                         "history_diagnosis.diagnosing_practitioner_value " +
                         "FROM SYSTEM.history_diagnosis " +
                         "WHERE PATID=? AND EPISODE_NUMBER=? " +
                         "ORDER BY history_diagnosis.date_of_diagnosis ASC";
     try
     {
         using (var connection = new OdbcConnection(connectionString))
         {
             connection.Open();
             using (var dbcommand = new OdbcCommand(commandText, connection))
             {
                 var dbparameter1 = new OdbcParameter("PATID", optionObject.EntityID);
                 dbcommand.Parameters.Add(dbparameter1);
                 var dbparameter2 = new OdbcParameter("EPISODE_NUMBER", optionObject.EpisodeNumber);
                 dbcommand.Parameters.Add(dbparameter2);
                 using (var reader = dbcommand.ExecuteReader())
                 {
                     if (reader.Read())
                     {
                         dxObj.TypeOfDiagnosis = "(" + reader["diagnosis_type_code"].ToString() + ") " + reader["diagnosis_type_value"].ToString();
                         dxObj.DateOfDiagnosis = DateTime.Parse(reader["date_of_diagnosis"].ToString());
                         dxObj.TimeOfDiagnosis = reader["time_of_diagnosis"].ToString();
                         dxObj.DiagnosisAxisI1 = "(" + reader["axis_I_diag_code_1"].ToString() + ") " + reader["axis_I_diag_value_1"].ToString();
                         dxObj.PrincipalDiagnosis = "(" + reader["principal_diagnosis_code"].ToString() + ") " + reader["principal_diagnosis_value"].ToString();
                         dxObj.DiagnosingPractitioner = "(" + reader["diagnosing_practitioner_code"].ToString() + ") " + reader["diagnosing_practitioner_value"].ToString();
                     }
                     else
                     {
                         dxObj = null;
                     }
                 }
             }
             connection.Close();
         }
     }
     catch (Exception e)
     {
     }
     return dxObj;
 }