/// <summary> /// Prints a set of claims using a given database connection /// </summary> /// <param name="toPrint"></param> /// <param name="dbConnection"></param> public static void PrintClaims(List <claim> toPrint, SqlConnection dbConnection) { NHDG.NHDGCommon.Claims.ClaimBatch cb = new NHDG.NHDGCommon.Claims.ClaimBatch(); System.Data.SqlClient.SqlTransaction trans; string _errorClaims = string.Empty; try { trans = dbConnection.BeginTransaction(); } catch { MessageBox.Show("Could not connect to Dentrix to print claim."); return; } try { string _xmlPath = GetFileName(".xml", Application.StartupPath + "\\Processed XML\\Temp\\"); string _pdfPath = GetFileName(".pdf", Application.StartupPath + "\\Claims\\"); foreach (claim c in toPrint) { NHDG.NHDGCommon.Claims.Claim aClaim; try { if (C_DentalClaimTracker.Properties.Settings.Default.ShowPaymentLineOnSecondary) { aClaim = new NHDG.NHDGCommon.Claims.Claim(c, trans, false, true); } else { aClaim = new NHDG.NHDGCommon.Claims.Claim(c, trans, true, true); } CheckForEligibilityRestrictions(c, aClaim); // Special code for teeth aClaim.PutToothStringInTooth(); aClaim.CleanAddresses(); cb.Claims.Add(aClaim); } catch (Exception err) { string errDisplay = err.Message; Exception e = err.InnerException; while (e != null) { errDisplay += "\n)" + e.Message; e = e.InnerException; } _errorClaims = "\n" + c.created_on.Value.ToShortDateString() + ", " + c.PatientLastNameCommaFirst + "; " + c.LinkedCompany.name + "\nSystem error:" + errDisplay; } } if (cb.Claims.Count > 0) { NHDG.NHDGCommon.Utilities.SerializeToFile(cb, typeof(NHDG.NHDGCommon.Claims.ClaimBatch), _xmlPath); try { NHDG.ProphySplitter.ProphySplitter ps = new NHDG.ProphySplitter.ProphySplitter(); ps.PerformSplit(_xmlPath); } catch (Exception err) { MessageBox.Show("An error occurred splitting the procedures (for example, splitting D1110 into " + "multiple procedures. Please report the following error to a system administrator: \n\n" + err.Message, "Error Splitting"); } try { ProcedureCombiner pc = new ProcedureCombiner(); pc.Combine(_xmlPath); } catch (Exception err) { MessageBox.Show("An error occurred combining the procedures." + " Please report the following error to a system administrator: \n\n" + err.Message, "Error Combining"); } string workingDir = Application.StartupPath + "\\ada-form\\"; string fileToStart = "ruby"; string arguments = "ada_report.rb \"" + _xmlPath + "\" \"" + _pdfPath + "\""; Clipboard.SetText(fileToStart + " " + arguments); System.Diagnostics.ProcessStartInfo pi = new System.Diagnostics.ProcessStartInfo(fileToStart, arguments); pi.WorkingDirectory = workingDir; pi.UseShellExecute = true; System.Diagnostics.Process p = System.Diagnostics.Process.Start(pi); p.WaitForExit(45000); if (File.Exists(_pdfPath)) { System.Diagnostics.Process.Start(_pdfPath); } else { while (MessageBox.Show("The .pdf document appears to be taking a while to generate. Would you like to continue waiting?\n\nThis question appears every 45 seconds.", "PDF not generated", MessageBoxButtons.YesNo) == DialogResult.Yes) { p.WaitForExit(45000); if (File.Exists(_pdfPath)) { System.Diagnostics.Process.Start(_pdfPath); break; } } } } } catch (Exception err) { string innerText = ""; innerText += err.Message; Exception e = err; while (e.InnerException != null) { innerText += "\n\n" + e.InnerException.Message; e = e.InnerException; if (innerText.Length > 5000) // Just in case it's getting too long, break out { break; } } LoggingHelper.Log("Error printing claim in ClaimTrackerCommon.PrintClaims\n" + innerText, LogSeverity.Error); MessageBox.Show("An unexpected error occurred trying to print the claim.\n\n" + innerText, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (_errorClaims != string.Empty) { LoggingHelper.Log("Errors occurred printing claim in ClaimTrackerCommon.PrintClaims\n" + _errorClaims, LogSeverity.Error); MessageBox.Show("Some of the claims could not be printed.\n\n" + _errorClaims); } }
public static List <string> ConvertBatchToXML(NHDG.NHDGCommon.Claims.ClaimBatch toConvert, string targetFolder) { List <string> fileData = new List <string>(); XMLClaimData xh; foreach (NHDG.NHDGCommon.Claims.Claim aClaim in toConvert.Claims) { xh = new XMLClaimData(); claim localClaim = new claim(); localClaim.LoadWithDentrixIDs(aClaim.Identity.ClaimID.ToString(), aClaim.Identity.ClaimDB.ToString()); string claimtype; if (localClaim.claim_type == claim.ClaimTypes.Predeterm || localClaim.claim_type == claim.ClaimTypes.SecondaryPredeterm) { claimtype = "P"; } else { claimtype = "C"; } xh.CLAIM_TYPE = claimtype; // BILLING_PROVIDER xh.BILLING_LASTNAME = "NEW HAVEN DENTAL GROUP"; xh.BILLING_FIRSTNAME = ""; xh.BILLING_ADDRESS1 = "123 York St"; xh.BILLING_ADDRESS2 = "4L"; xh.BILLING_CITY = "New Haven"; xh.BILLING_STATE = "CT"; xh.BILLING_ZIP = "06511"; xh.BILLING_NPIN = "1609916089"; xh.BILLING_STATE_LICENCE = "03419"; xh.BILLING_TIN_SSN = "061025204"; xh.BILLING_PHONE = "203-781-8051"; xh.BILLING_ADDITIONAL_ID = ""; // PAYTO_PROVIDER xh.PAYTO_LASTNAME = CleanData(localClaim.doctor_last_name); xh.PAYTO_FIRSTNAME = CleanData(localClaim.doctor_first_name); xh.PAYTO_ADDRESS1 = CleanData(localClaim.doctor_address); xh.PAYTO_ADDRESS2 = CleanData(localClaim.doctor_address2); xh.PAYTO_CITY = CleanData(localClaim.doctor_city); xh.PAYTO_STATE = CleanData(localClaim.doctor_state); xh.PAYTO_ZIP = CleanData(localClaim.doctor_zip); xh.PAYTO_NPIN = CleanData(aClaim.BillingDentist.NPINumber); xh.PAYTO_STATE_LICENCE = ""; // *** xh.PAYTO_TIN = CleanData(aClaim.BillingDentist.TIN); xh.PAYTO_SSN = ""; // *** Do we need this? xh.PAYTO_PHONE = CleanData(localClaim.doctor_phone_number_object.FormattedPhone); xh.PAYTO_ADDITIONAL_ID = ""; // *** additional ID // RENDERING_PROVIDER xh.RENDERING_PROVIDER_LASTNAME = CleanData(localClaim.doctor_last_name); xh.RENDERING_PROVIDER_FIRSTNAME = CleanData(localClaim.doctor_first_name); xh.RENDERING_PROVIDER_SIGNATURE_DATE = ""; // *** Signature date xh.RENDERING_PROVIDER_ADDRESS1 = CleanData(localClaim.doctor_address); xh.RENDERING_PROVIDER_ADDRESS2 = CleanData(localClaim.doctor_address2); xh.RENDERING_PROVIDER_CITY = CleanData(localClaim.doctor_city); xh.RENDERING_PROVIDER_STATE = CleanData(localClaim.doctor_state); xh.RENDERING_PROVIDER_ZIP = CleanData(localClaim.doctor_zip); xh.RENDERING_PROVIDER_NPIN = CleanData(aClaim.BillingDentist.NPINumber); xh.RENDERING_PROVIDER_LICENSE_NUMBER = CleanData(aClaim.BillingDentist.License); if (localClaim.doctor_first_name.Contains("Eva")) // *** Hard-coded for the periodontist right now { xh.RENDERING_PROVIDER_SPECIALTY = "1223P0300X"; // Periodontics } else { xh.RENDERING_PROVIDER_SPECIALTY = "122300000X"; } xh.RENDERING_PROVIDER_PHONE = CleanData(localClaim.doctor_phone_number_object.FormattedPhone); xh.RENDERING_PROVIDER_ADDITIONAL_ID = ""; // *** additional ID // SUBSCRIBER xh.SUBSCRIBER_LASTNAME = CleanData(localClaim.subscriber_last_name); xh.SUBSCRIBER_FIRSTNAME = CleanData(localClaim.subscriber_first_name); xh.SUBSCRIBER_MIDDLENAME = CleanData(localClaim.subscriber_middle_initial); xh.SUBSCRIBER_SUFFIX = ""; xh.SUBSCRIBER_ADDRESS1 = CleanData(localClaim.subscriber_address); xh.SUBSCRIBER_ADDRESS2 = CleanData(localClaim.subscriber_address2); xh.SUBSCRIBER_CITY = CleanData(localClaim.subscriber_city); xh.SUBSCRIBER_STATE = CleanData(localClaim.subscriber_state); xh.SUBSCRIBER_ZIP = CleanData(localClaim.subscriber_zip); xh.SUBSCRIBER_DOB = ConvertDateTime(localClaim.subscriber_dob); xh.SUBSCRIBER_GENDER = ConvertGender(aClaim.Subscriber.Sex); xh.SUBSCRIBER_ID = CleanData(aClaim.Subscriber.ID); xh.SUBSCRIBER_GROUP_PLAN_NAME = CleanData(localClaim.subscriber_group_name); xh.SUBSCRIBER_GROUP_PLAN_NUMBER = CleanData(localClaim.subscriber_group_number); xh.SUBSCRIBER_EMPLOYER_NAME = CleanData(aClaim.Subscriber.Employer.Name); xh.SUBSCRIBER_INSURANCE_SEQUENCE = "P"; // *** Not sure how this should be used xh.SUBSCRIBER_SIGNATURE = "Yes"; xh.SUBSCRIBER_SIGNATURE_DATE = ""; // *** Another signature date field, not sure // PATIENT xh.PATIENT_RELATION = ConvertRelationship(aClaim.Patient.SubscriberRelationship); // *** Excel document lists this as subscriber_relation, do all relationships work the same way? xh.PATIENT_STUDENTSTATUS = CleanData(aClaim.Patient.StudentStatus); // We're ignoring this currently xh.PATIENT_LASTNAME = CleanData(localClaim.patient_last_name); xh.PATIENT_FIRSTNAME = CleanData(localClaim.patient_first_name); xh.PATIENT_MIDDLENAME = CleanData(localClaim.patient_middle_initial); xh.PATIENT_SUFFIX = ""; xh.PATIENT_ADDRESS1 = CleanData(localClaim.patient_address); xh.PATIENT_ADDRESS2 = CleanData(localClaim.patient_address2); xh.PATIENT_CITY = CleanData(localClaim.patient_city); xh.PATIENT_STATE = CleanData(localClaim.patient_state); xh.PATIENT_ZIP = CleanData(localClaim.patient_zip); xh.PATIENT_DOB = ConvertDateTime(localClaim.patient_dob); xh.PATIENT_GENDER = ConvertGender(aClaim.Patient.Sex); xh.PATIENT_ID = CleanData(aClaim.Patient.ID); xh.PATIENT_SIGNATURE = "Yes"; xh.PATIENT_SIGNATURE_DATE = ""; // *** Signature date // PRIMARY_PAYER // *** Primary payer section, not sure what this is xh.PRIMARY_PAYER_NAME = CleanData(localClaim.payer_name); xh.PRIMARY_PAYER_ID = CleanData(localClaim.payer_id); // This should be the electronic ID used in eclaims xh.PRIMARY_PAYER_ADDRESS1 = CleanData(aClaim.GeneralInformation.Carrier.Address.Street1); xh.PRIMARY_PAYER_ADDRESS2 = CleanData(aClaim.GeneralInformation.Carrier.Address.Street2); xh.PRIMARY_PAYER_CITY = CleanData(aClaim.GeneralInformation.Carrier.Address.City); xh.PRIMARY_PAYER_STATE = CleanData(aClaim.GeneralInformation.Carrier.Address.State); xh.PRIMARY_PAYER_ZIP = CleanData(aClaim.GeneralInformation.Carrier.Address.Zip); // OTHER_COVERAGE if (aClaim.OtherPolicy == null) { xh.OTHERPAYER_FLAG = "N"; } else { xh.OTHERPAYER_FLAG = "Y"; CommonFunctions.FormattedName subscriberName = CommonFunctions.GetFormattedName(aClaim.OtherPolicy.SubscriberName); xh.OTHER_SUBSCRIBER_LASTNAME = subscriberName.LastName; xh.OTHER_SUBSCRIBER_FIRSTNAME = subscriberName.FirstName; xh.OTHER_SUBSCRIBER_MIDDLENAME = subscriberName.MiddleInitial; xh.OTHER_SUBSCRIBER_SUFFIX = ""; xh.OTHER_SUBSCRIBER_DOB = ConvertToMercuryDateTime(aClaim.OtherPolicy.SubscriberBirthDate); xh.OTHER_SUBSCRIBER_GENDER = ConvertGender(aClaim.OtherPolicy.SubscriberSex); xh.OTHER_SUBSCRIBER_ID = CleanData(aClaim.OtherPolicy.SubscriberID); xh.OTHER_SUBSCRIBER_GROUP_PLAN_NAME = CleanData(aClaim.OtherPolicy.PlanName); xh.OTHER_SUBSCRIBER_GROUP_PLAN_NUMBER = CleanData(aClaim.OtherPolicy.PolicyNumber); xh.OTHER_SUBSCRIBER_RELATION = ConvertRelationshipString(aClaim.OtherPolicy.PatientRelationship); xh.OTHER_SUBSCRIBER_ADDRESS1 = CleanData(aClaim.OtherPolicy.SubscriberAddress.Street1); xh.OTHER_SUBSCRIBER_ADDRESS2 = CleanData(aClaim.OtherPolicy.SubscriberAddress.Street2); xh.OTHER_SUBSCRIBER_CITY = CleanData(aClaim.OtherPolicy.SubscriberAddress.City); xh.OTHER_SUBSCRIBER_STATE = CleanData(aClaim.OtherPolicy.SubscriberAddress.State); xh.OTHER_SUBSCRIBER_ZIP = CleanData(aClaim.OtherPolicy.SubscriberAddress.Zip); xh.OTHER_SUBSCRIBER_INSURANCE_SEQUENCE = "S"; // May need to look into this more xh.OTHER_SUBSCRIBER_COB_PAYER_PAID_AMT = ""; // Same as above - leaving this blank for now xh.OTHER_SUBSCRIBER_COB_PATIENT_RESP_AMT = ""; // Same as above - leaving this blank for now // *********************** Not sure what to fill in for this entire Other Payer section Dictionary <string, string> payerInfo = GetOtherPayerID(aClaim.OtherPolicy.PlanName); if (payerInfo != null) { xh.OTHERPAYER_NAME = payerInfo["name"]; xh.OTHERPAYER_ID = payerInfo["id"]; } else { xh.OTHERPAYER_NAME = CleanData(aClaim.OtherPolicy.PlanName); xh.OTHERPAYER_ID = CleanData(aClaim.OtherPolicy.SubscriberID); } xh.OTHERPAYER_ADDRESS1 = CleanData(aClaim.OtherPolicy.InsuranceAddress.Street1); xh.OTHERPAYER_ADDRESS2 = CleanData(aClaim.OtherPolicy.InsuranceAddress.Street2); xh.OTHERPAYER_CITY = CleanData(aClaim.OtherPolicy.InsuranceAddress.City); xh.OTHERPAYER_STATE = CleanData(aClaim.OtherPolicy.InsuranceAddress.State); xh.OTHERPAYER_ZIP = CleanData(aClaim.OtherPolicy.InsuranceAddress.Zip); xh.OTHERPAYER_CONTACT_NAME = ""; xh.OTHERPAYER_CONTACT_EMAIL = ""; xh.OTHERPAYER_CONTACT_TELEPHONE = ""; xh.OTHERPAYER_CONTACT_FAX = ""; xh.OTHERPAYER_CLAIM_PAID_DATE = ""; // ******************************************************************************************** } // CLAIM xh.CLAIM_NUMBER = localClaim.id.ToString(); xh.SERVICE_DATE = ConvertDateTime(localClaim.date_of_service); xh.PREDIDENTIFICATION = ""; // *** PRED Identification? xh.OTHERFEE = ""; // Ignore xh.TOTAL_AMOUNT = localClaim.amount_of_claim.ToString(); // ***** COME BACK TO THIS - Missing teeth // MISSING_TOOTHS // xh.MISSING_TOOTH = ""; // *** Diagnosis qualifier and diagnosis codes don't appear to be available xh.DIAG_QUALIFIER = ""; // For now, ignore // DIAGNOSIS_CODES xh.DIAGNOSIS_CODES_A = ""; xh.DIAGNOSIS_CODES_D = ""; xh.DIAGNOSIS_CODES_D = ""; xh.DIAGNOSIS_CODES_D = ""; xh.CLAIM_NOTES = ""; xh.PLACE_SERVICE = "OFF"; // Enclosures xh.ENCLOSURES_RADIOGRAPH = CleanData(aClaim.AncillaryData.NumRadiographsEnclosed.ToString()); xh.ENCLOSURES_ORAL_IMAGES = ""; // Ignore xh.ENCLOSURES_MODELS = ""; // Ignore xh.ORTHOCLAIM = CommonFunctions.ToYesNo(aClaim.AncillaryData.Orthodontics.TreatmentForOrthodontics)[0].ToString(); xh.APPLIANCE_PLACEMENT_DATE = ConvertToMercuryDateTime(aClaim.AncillaryData.Orthodontics.DateAppliancePlaced); if (ConvertEmptyToN(aClaim.AncillaryData.Prosthesis.InitialReplacement) == "N") { xh.PLACEMENT_TYPE = "Initial"; } else { xh.PLACEMENT_TYPE = "Replacement"; } xh.MONTHS_TREATMENT_REMAININT = CleanData(aClaim.AncillaryData.Orthodontics.RemainingMonths.ToString()); xh.REPLACEMENT_PROSTHESIS = ConvertEmptyToN(aClaim.AncillaryData.Prosthesis.InitialReplacement); xh.PROIR_PLACEMENT_DATE = ConvertToMercuryDateTime(aClaim.AncillaryData.Prosthesis.PriorPlacement); xh.OCCUPATIONAL_ILLNESS = "N"; // Ignore this, we track auto or other if (aClaim.BillingDentist.Accident.Type == NHDG.NHDGCommon.Claims.AccidentType.Automobile) { xh.AUTO_ACCIDENT = "Y"; xh.OTHER_ACCIDENT = "N"; } else if (aClaim.BillingDentist.Accident.Type == NHDG.NHDGCommon.Claims.AccidentType.Other) { xh.OTHER_ACCIDENT = "Y"; xh.AUTO_ACCIDENT = "N"; } else { xh.AUTO_ACCIDENT = "N"; xh.OTHER_ACCIDENT = "N"; } xh.ACCIDENT_DATE = aClaim.AncillaryData.DateOfAccident; xh.ACCIDENT_STATE = aClaim.AncillaryData.AccidentState; xh.ADMISSION_DATE = ""; // Ignore xh.TOT_TREATMENT_PERIOD = ""; // Ignore // We just won't have any attachments for now, can ask if this is important though // ATTACHMENTS xh.ATTACHMENT_ID = ""; // LINE_SERVICE foreach (NHDG.NHDGCommon.Claims.Treatment t in aClaim.TreatmentInformation.Treatments) { LineHelper lh = new LineHelper(); lh.SERVICE_DATE = ConvertToMercuryDateTime(t.ProcedureDate); lh.CAVITY_DESIGNATION = ""; // Ignore lh.TOOTH_SYSTEM = ""; // Ignore lh.PROCEDURE_CODE = t.ProcedureCode; lh.DIAGNOSIS_POINTER = ""; // *** Ignore for now, we're not using on ADA form lh.QUANTITY = t.Quantity; lh.PROCEDURE_DESCRIPTION = CleanData(t.Description); lh.FEE = t.Fee; lh.LINE_NOTES = ""; try { // teeth foreach (string aTooth in ConvertToothsToList(t.Tooth, t.ToothEnd)) { lh.InsertTooth(aTooth); } } catch (Exception ex) { C_DentalClaimTracker.LoggingHelper.Log(ex, false); // Send it anyway, but log an error here } // surfaces if (t.Surface != "") { foreach (char aChar in t.Surface.ToCharArray()) { lh.InsertSurface(aChar.ToString()); } } xh.InsertLineService(lh); } fileData.Add(xh.MainDocAsString); } return(fileData); }