using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; using Pluto.Api; using Sdaleo.Systems.Advantage; using Connector = PlutoServer.MSL.Connectors; namespace PlutoServer.MSL.Test { [TestFixture] public class MedisoftConnector { #region Medisoft Test Connection public const string MEDISOFT_KEY = "$616866C0D12EC1641A5#M"; public AdvantageCredential credential = new AdvantageCredential(@"\\10.97.156.4\Medidata\Tutor\mwddf.add", "user", "password", AdvantageCredential.ServerType.REMOTE); #endregion [SetUp] public void Init() { MSLSpecific.Setup_Test_Logger(); Connector.DBCache.IsMachine_Used_ForTesting = true; Connector.DBCache.TestMedisoftDBCredential = credential; } [Test] public void GetProviderList() { ProviderInfo1[] providers = Connector.MedisoftConnector.GetProviderList(MEDISOFT_KEY); Assert.NotNull(providers); if (providers != null) { Assert.True(providers.Length > 0); if (providers.Length > 0) { foreach (ProviderInfo1 info in providers) { // User ID must exist for provider Assert.IsNotNullOrEmpty(info.UserId); // Assume the provider has at least one name field filled out Assert.True(!String.IsNullOrEmpty(info.LastName) || !String.IsNullOrEmpty(info.FirstName) || !String.IsNullOrEmpty(info.MiddleName)); } } } } [Test] public void GetPatientList() { PatientInfo1[] patients = Connector.MedisoftConnector.GetPatientList(MEDISOFT_KEY, "", "", ""); Assert.NotNull(patients); if (patients != null) { Assert.True(patients.Length > 0); if (patients.Length > 0) { foreach (PatientInfo1 info in patients) { // Chart must exist for patients Assert.IsNotNullOrEmpty(info.ChartId); // Assume the patient has at least one name field filled out Assert.True(!String.IsNullOrEmpty(info.LastName) || !String.IsNullOrEmpty(info.FirstName) || !String.IsNullOrEmpty(info.MiddleName)); } } } } [Test] public void GetPatient_Doe_J() { PatientInfo1[] patients = Connector.MedisoftConnector.GetPatientList(MEDISOFT_KEY, "Doe", "J", ""); Assert.NotNull(patients); if (patients != null) { Assert.True(patients.Length > 0); if (patients.Length > 0) { foreach (PatientInfo1 info in patients) { // Chart must exist for patients Assert.IsNotNullOrEmpty(info.ChartId); // Assume the patient has at least one name field filled out Assert.True(!String.IsNullOrEmpty(info.LastName) || !String.IsNullOrEmpty(info.FirstName) || !String.IsNullOrEmpty(info.MiddleName)); // Check For John and Jane Doe if (info.LastName == "Doe") Assert.True(info.FirstName == "Jane" || info.FirstName == "John"); } } } } [Test] public void GetPatient_D() { PatientInfo1[] patients = Connector.MedisoftConnector.GetPatientList(MEDISOFT_KEY, "D", "", ""); Assert.NotNull(patients); if (patients != null) { Assert.True(patients.Length > 0); if (patients.Length > 0) { foreach (PatientInfo1 info in patients) { // Chart must exist for patients Assert.IsNotNullOrEmpty(info.ChartId); // Assume the patient has at least one name field filled out Assert.True(!String.IsNullOrEmpty(info.LastName) || !String.IsNullOrEmpty(info.FirstName) || !String.IsNullOrEmpty(info.MiddleName)); // Check to make sure last name contains a D Assert.True(info.LastName.ToUpper().Contains("D")); } } } } [Test] public void GetPatient_DOB() { PatientInfo1[] patients = Connector.MedisoftConnector.GetPatientList(MEDISOFT_KEY, "", "", "04/28/1962"); Assert.NotNull(patients); if (patients != null) { Assert.True(patients.Length == 1); if (patients.Length == 1) { foreach (PatientInfo1 info in patients) { // Chart must exist for patients Assert.IsNotNullOrEmpty(info.ChartId); // Assume the patient has at least one name field filled out Assert.True(!String.IsNullOrEmpty(info.LastName) || !String.IsNullOrEmpty(info.FirstName) || !String.IsNullOrEmpty(info.MiddleName)); // Check to make sure last name is DOE Assert.True(info.LastName.ToUpper() == "DOE"); // Check to make sure first name is Jane Assert.True(info.FirstName.ToUpper() == "JANE"); } } } } [Test] public void GetFacilitiesList() { FacilityInfo1[] facilities = Connector.MedisoftConnector.GetFacilitiesList(MEDISOFT_KEY); Assert.NotNull(facilities); if (facilities != null) { Assert.True(facilities.Length > 0); if (facilities.Length > 0) { foreach (FacilityInfo1 info in facilities) { // Code must exist for each facility Assert.IsNotNullOrEmpty(info.Code); // Assume the facility has at least a name Assert.True(!String.IsNullOrEmpty(info.Name)); } } } } [Test] public void GetDiagnosisList() { TerminologyInfo1[] diagnoses = Connector.MedisoftConnector.GetDiagnosisList(MEDISOFT_KEY, String.Empty); Assert.NotNull(diagnoses); if (diagnoses != null) { Assert.True(diagnoses.Length > 0); if (diagnoses.Length > 0) { foreach (TerminologyInfo1 info in diagnoses) { // Code must exist for each Diagnosis Assert.IsNotNullOrEmpty(info.Code); // Description must exist for each Diagnosis Assert.IsNotNullOrEmpty(info.Description); } } } } [Test] public void GetDiagnosis_1() { TerminologyInfo1[] diagnoses = Connector.MedisoftConnector.GetDiagnosisList(MEDISOFT_KEY, "1"); Assert.NotNull(diagnoses); if (diagnoses != null) { Assert.True(diagnoses.Length > 0); if (diagnoses.Length > 0) { foreach (TerminologyInfo1 info in diagnoses) { // Code must exist for each Diagnosis Assert.IsNotNullOrEmpty(info.Code); // Description must exist for each Diagnosis Assert.IsNotNullOrEmpty(info.Description); // Code or Description must contain a "1" Assert.True(info.Code.Contains("1") || info.Description.Contains("1")); } } } } [Test] public void GetDiagnosis_Dia() { TerminologyInfo1[] diagnoses = Connector.MedisoftConnector.GetDiagnosisList(MEDISOFT_KEY, "Dia"); Assert.NotNull(diagnoses); if (diagnoses != null) { Assert.True(diagnoses.Length > 0); if (diagnoses.Length > 0) { foreach (TerminologyInfo1 info in diagnoses) { // Code must exist for each Diagnosis Assert.IsNotNullOrEmpty(info.Code); // Description must exist for each Diagnosis Assert.IsNotNullOrEmpty(info.Description); // Code or Description must contain a "1" Assert.True(info.Code.Contains("Dia") || info.Description.Contains("Dia")); } } } } [Test] public void GetProcedureList() { TerminologyInfo1[] procedures = Connector.MedisoftConnector.GetProceduresList(MEDISOFT_KEY, String.Empty, String.Empty); Assert.NotNull(procedures); if (procedures != null) { Assert.True(procedures.Length > 0); if (procedures.Length > 0) { foreach (TerminologyInfo1 info in procedures) { // Code must exist for each procedures Assert.IsNotNullOrEmpty(info.Code); // Description must exist for each procedures Assert.IsNotNullOrEmpty(info.Description); } } } } [Test] public void GetProcedure_1() { TerminologyInfo1[] procedures = Connector.MedisoftConnector.GetProceduresList(MEDISOFT_KEY, String.Empty, "1"); Assert.NotNull(procedures); if (procedures != null) { Assert.True(procedures.Length > 0); if (procedures.Length > 0) { foreach (TerminologyInfo1 info in procedures) { // Code must exist for each procedures Assert.IsNotNullOrEmpty(info.Code); // Description must exist for each procedures Assert.IsNotNullOrEmpty(info.Description); // Code or Description must contain a "1" Assert.True(info.Code.Contains("1") || info.Description.Contains("1")); } } } } [Test] public void Authenticate_1() { UserInfo1 info = Connector.MedisoftConnector.AuthenticateUserLogin(MEDISOFT_KEY, "1", "1"); Assert.NotNull(info); if (info != null) { // Username must exist Assert.IsNotNullOrEmpty(info.UserName); // Name must exist Assert.IsNotNullOrEmpty(info.Name); } } [Test] public void Authenticate_98() { UserInfo1 info = Connector.MedisoftConnector.AuthenticateUserLogin(MEDISOFT_KEY, "98", "2"); Assert.Null(info); } /// /// Assumes that the User 1 has a Pin of 1234 (that is what should be setup in the UI by default) /// [Test] public void AuthenticatePin_1() { Assert.True(Connector.MedisoftConnector.PinIsSet(MEDISOFT_KEY, "1")); UserInfo1 info = Connector.MedisoftConnector.AuthenticateUserPIN(MEDISOFT_KEY, "1", "1234"); Assert.NotNull(info); if (info != null) { // Username must exist Assert.IsNotNullOrEmpty(info.UserName); // Name must exist Assert.IsNotNullOrEmpty(info.Name); } } /// /// Sets the Pin to an arbitrary value for User 1, and checks if that authenticates, then /// resets the pin back to the original value 1234 /// [Test] public void SetNAuthenticateNResetPin_1() { Assert.True(Connector.MedisoftConnector.CreatePin(MEDISOFT_KEY, "1", "9999")); UserInfo1 info = Connector.MedisoftConnector.AuthenticateUserPIN(MEDISOFT_KEY, "1", "9999"); Assert.NotNull(info); if (info != null) { // Username must exist Assert.IsNotNullOrEmpty(info.UserName); // Name must exist Assert.IsNotNullOrEmpty(info.Name); } Assert.True(Connector.MedisoftConnector.CreatePin(MEDISOFT_KEY, "1", "1234")); } /// /// Testing with 'blank' provider (none specified) /// [Test] public void GetAppointments_2012() { DateTime dtStart = new DateTime(2012, 01, 01, 0, 0, 0); DateTime dtEnd = new DateTime(2012, 12, 31, 23, 59, 59); ProviderInfo1 info = new ProviderInfo1(); info.UserId = ""; AppointmentInfo1[] appointments = Connector.MedisoftConnector.GetAppointments(MEDISOFT_KEY, new ProviderInfo1[] { info }, null, dtStart, dtEnd); Assert.NotNull(appointments); if (appointments != null) { Assert.True(appointments.Length > 0); if (appointments.Length > 0) { foreach (AppointmentInfo1 appt in appointments) { // Appt ID must be valid Assert.True(appt.Id > 0); // Appt Date must be valid Assert.True(appt.StartDateTime.Year == 2012); } } } } /// /// Testing with 'JM' provider (specified) /// [Test] public void GetAppointments_2012_JM() { DateTime dtStart = new DateTime(2012, 01, 01, 0, 0, 0); DateTime dtEnd = new DateTime(2012, 12, 31, 23, 59, 59); ProviderInfo1 info = new ProviderInfo1(); info.UserId = "JM"; AppointmentInfo1[] appointments = Connector.MedisoftConnector.GetAppointments(MEDISOFT_KEY, new ProviderInfo1[] { info }, null, dtStart, dtEnd); Assert.NotNull(appointments); if (appointments != null) { Assert.True(appointments.Length > 0); if (appointments.Length > 0) { foreach (AppointmentInfo1 appt in appointments) { // Appt ID must be valid Assert.True(appt.Id > 0); // Appt Date must be valid Assert.True(appt.StartDateTime.Year == 2012); // Provider must either be JM or blank Assert.True(appt.ProviderCode == "JM" || appt.ProviderCode == ""); } } } } /// /// Testing with 'blank' provider (none specified) /// [Test] public void GetAppointments_2013() { DateTime dtStart = new DateTime(2013, 01, 01, 0, 0, 0); DateTime dtEnd = new DateTime(2013, 12, 31, 23, 59, 59); ProviderInfo1 info = new ProviderInfo1(); info.UserId = ""; AppointmentInfo1[] appointments = Connector.MedisoftConnector.GetAppointments(MEDISOFT_KEY, new ProviderInfo1[] { info }, null, dtStart, dtEnd); Assert.NotNull(appointments); if (appointments != null) { Assert.True(appointments.Length > 0); if (appointments.Length > 0) { foreach (AppointmentInfo1 appt in appointments) { // Appt ID must be valid Assert.True(appt.Id > 0); // Appt Date must be valid Assert.True(appt.StartDateTime.Year == 2013); } } } } /// /// Testing with 'JM' provider (specified) /// [Test] public void GetAppointments_2013_JM() { DateTime dtStart = new DateTime(2013, 01, 01, 0, 0, 0); DateTime dtEnd = new DateTime(2013, 12, 31, 23, 59, 59); ProviderInfo1 info = new ProviderInfo1(); info.UserId = "JM"; AppointmentInfo1[] appointments = Connector.MedisoftConnector.GetAppointments(MEDISOFT_KEY, new ProviderInfo1[] { info }, null, dtStart, dtEnd); Assert.NotNull(appointments); if (appointments != null) { Assert.True(appointments.Length > 0); if (appointments.Length > 0) { foreach (AppointmentInfo1 appt in appointments) { // Appt ID must be valid Assert.True(appt.Id > 0); // Appt Date must be valid Assert.True(appt.StartDateTime.Year == 2013); // Provider must either be JM or blank Assert.True(appt.ProviderCode == "JM" || appt.ProviderCode == ""); } } } } [Test] public void GetAppointmentDetail_1() { AppointmentDetail1 detail = Connector.MedisoftConnector.GetAppointmentDetail(MEDISOFT_KEY, 1, true); Assert.NotNull(detail); if (detail != null) { Assert.NotNull(detail.PatientDetail); if (detail.PatientDetail != null) { Assert.IsNotNullOrEmpty(detail.PatientDetail.Patient.ChartId); Assert.IsTrue(detail.PatientDetail.Patient.ChartId == "AGADW000"); } } } [Test] public void GetAppointmentDetail_2() { AppointmentDetail1 detail = Connector.MedisoftConnector.GetAppointmentDetail(MEDISOFT_KEY, 2, true); Assert.NotNull(detail); if (detail != null) { Assert.NotNull(detail.PatientDetail); if (detail.PatientDetail != null) { Assert.IsNotNullOrEmpty(detail.PatientDetail.Patient.ChartId); Assert.IsTrue(detail.PatientDetail.Patient.ChartId == "AGADW000"); } } } [Test] public void GetPatientDetail_Dwight() { PatientDetail1 detail = Connector.MedisoftConnector.GetPatientDetail(MEDISOFT_KEY, null, "AGADW000", true); Assert.NotNull(detail); if (detail != null) { Assert.IsNotNullOrEmpty(detail.Patient.ChartId); Assert.IsTrue(detail.Patient.ChartId == "AGADW000"); Assert.IsTrue(detail.Patient.FirstName == "Dwight"); Assert.IsTrue(detail.Patient.LastName == "Again"); } } [Test] public void PostIntoPendingTransaction_1() { BillingPost1 bill = new BillingPost1(); bill.BirthDate = DateTime.MinValue; //bill.BirthDate = new DateTime(1963, 2, 2); bill.ChartID = "CATSA000"; bill.DateFrom = DateTime.Now; bill.PatientFirstName = "Sammy"; bill.PatientLastName = "Catera"; //bill.PatientSocialSecurity = "603-30-1930"; bill.PatientSocialSecurity = ""; bill.ProviderID = "AQZ"; bill.BillingDetails = new BillingDetail1[5] { new BillingDetail1(), new BillingDetail1(), new BillingDetail1(), new BillingDetail1(), new BillingDetail1() }; int nLength = bill.BillingDetails.Length; bill.BillingDetails[0].Units = 2; bill.BillingDetails[0].DiagnosisCodes = new string[] { "726.71" }; bill.BillingDetails[0].ProcedureCode = "99392"; bill.BillingDetails[1].BillingNote = "Doris Day"; bill.BillingDetails[2].BillingNote = "Doris Day"; bill.BillingDetails[3].Units = 4; bill.BillingDetails[3].DiagnosisCodes = new string[] { "726.71" }; bill.BillingDetails[3].ProcedureCode = "99392"; bill.BillingDetails[4].Units = 4; bill.BillingDetails[4].DiagnosisCodes = new string[] { "726.71" }; bill.BillingDetails[4].ProcedureCode = "99392"; bool bSuccess = Connector.MedisoftConnector.PostBilling(MEDISOFT_KEY, "1", bill); Assert.IsTrue(bSuccess); } } }