Esempio n. 1
0
		private void FormEvaluations_Load(object sender,EventArgs e) {
			_userProv=Providers.GetProv(Security.CurUser.ProvNum);
			//_userProv will only be allowed to be null if the user is an admin. Checking for null in this block is not necessary.
			if(!Security.IsAuthorized(Permissions.AdminDentalEvaluations,true)) {
				//Admins are allowed to look at and edit all evaluations, but they cannot add new evaluations
				//This could easily be added in the future if desired.
				groupAdmin.Visible=false;
			}
			else {
				butAdd.Visible=false;
			}
			comboCourse.Items.Add("All");
			for(int i=0;i<SchoolCourses.List.Length;i++) {
				comboCourse.Items.Add(SchoolCourses.List[i].CourseID);
			}
			comboCourse.SelectedIndex=0;
			_listInstructor=Providers.GetInstructors();
			comboInstructor.Items.Add("All");
			for(int i=0;i<_listInstructor.Count;i++) {
				comboInstructor.Items.Add(_listInstructor[i].GetLongDesc());
			}
			comboInstructor.SelectedIndex=0;
			textDateStart.Text=DateTime.Today.ToShortDateString();
			textDateEnd.Text=DateTime.Today.ToShortDateString();
			FillGrid();
		}
Esempio n. 2
0
 ///<summary>StringBuilder does not get altered if no invalid data.</summary>
 public static void BillProv(Provider billProv,StringBuilder strb)
 {
     if(billProv.LName=="") {
         Comma(strb);
         strb.Append("Billing Prov LName");
     }
     if(!billProv.IsNotPerson && billProv.FName=="") {//if is a person, first name cannot be blank.
         Comma(strb);
         strb.Append("Billing Prov FName");
     }
     if(billProv.SSN.Length<2) {
         Comma(strb);
         strb.Append("Billing Prov SSN");
     }
     if(billProv.NationalProvID.Length<2) {
         Comma(strb);
         strb.Append("Billing Prov NPI");
     }
     /* This was causing problems when dummy providers were used for office and no license number was applicable.
      * Delta carriers key off this number and start assigning to wrong provider. Customer: ATD.
     if(billProv.StateLicense=="") {
         if(strb.Length!=0) {
             strb.Append(",");
         }
         strb.Append("Billing Prov Lic #");
     }*/
 }
Esempio n. 3
0
 ///<summary>Returns the Provider Taxonomy code for the given specialty.</summary>
 public static string GetTaxonomy(Provider provider)
 {
     //must return a string with length of at least one char.
     if(provider.TaxonomyCodeOverride!=""){
         return provider.TaxonomyCodeOverride;
     }
     string spec=" ";
     switch(provider.Specialty) {
         case DentalSpecialty.General: spec="1223G0001X"; break;
         case DentalSpecialty.Hygienist: spec="124Q00000X"; break;//?
         case DentalSpecialty.PublicHealth: spec="1223D0001X"; break;
         case DentalSpecialty.Endodontics: spec="1223E0200X"; break;
         case DentalSpecialty.Pathology: spec="1223P0106X"; break;
         case DentalSpecialty.Radiology: spec="1223D0008X"; break;
         case DentalSpecialty.Surgery: spec="1223S0112X"; break;
         case DentalSpecialty.Ortho: spec="1223X0400X"; break;
         case DentalSpecialty.Pediatric: spec="1223P0221X"; break;
         case DentalSpecialty.Perio: spec="1223P0300X"; break;
         case DentalSpecialty.Prosth: spec="1223P0700X"; break;
         case DentalSpecialty.Denturist: spec=" "; break;
         case DentalSpecialty.Assistant: spec=" "; break;
         case DentalSpecialty.LabTech: spec=" "; break;
     }
     return spec;
 }
Esempio n. 4
0
		///<summary></summary>
		public static long Insert(Provider provider){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				provider.ProvNum=Meth.GetLong(MethodBase.GetCurrentMethod(),provider);
				return provider.ProvNum;
			}
			return Crud.ProviderCrud.Insert(provider);
		}
Esempio n. 5
0
		private static Provider CreateProvider(string fName,string lName,string npi,string officeNum,string abbr) {
			Provider prov=null;
			int maxItemOrder=0;
			for(int i=0;i<ProviderC.ListLong.Count;i++) {
				if(ProviderC.ListLong[i].NationalProvID=="" || ProviderC.ListLong[i].NationalProvID==npi) {
					prov=ProviderC.ListLong[i];
				}
				if(ProviderC.ListLong[i].ItemOrder>maxItemOrder) {
					maxItemOrder=ProviderC.ListLong[i].ItemOrder;
				}
			}
			bool updateProv=(prov!=null);
			if(prov==null) {
				prov=new Provider();
			}
			prov.IsHidden=false;
			prov.IsCDAnet=true;
			prov.FName=fName;
			prov.LName=lName;
			prov.NationalProvID=npi;
			prov.CanadianOfficeNum=officeNum;
			prov.Abbr=abbr;
			prov.FeeSched=53;
			prov.ItemOrder=maxItemOrder+1;
			if(updateProv) {
				Providers.Update(prov);
			}
			else {
				Providers.Insert(prov);
			}
			Providers.RefreshCache();
			return prov;
		}
Esempio n. 6
0
		///<summary></summary>
		public static void Update(Provider provider){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				Meth.GetVoid(MethodBase.GetCurrentMethod(),provider);
				return;
			}
			Crud.ProviderCrud.Update(provider);
		}
Esempio n. 7
0
		///<summary>Only used from FormProvEdit if user clicks cancel before finishing entering a new provider.</summary>
		public static void Delete(Provider prov){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),prov);
				return;
			}
			string command="DELETE from provider WHERE provnum = '"+prov.ProvNum.ToString()+"'";
 			Db.NonQ(command);
		}
Esempio n. 8
0
		///<summary>Increments all (privider.ItemOrder)s that are >= the ItemOrder of the provider passed in 
		///but does not change the item order of the provider passed in.</summary>
		public static void MoveDownBelow(Provider provider) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				provider.ProvNum=Meth.GetLong(MethodBase.GetCurrentMethod(),provider);
			}
			//Add 1 to all item orders equal to or greater than new provider's item order
			Db.NonQ("UPDATE provider SET ItemOrder=ItemOrder+1"
				+" WHERE ProvNum!="+provider.ProvNum
				+" AND ItemOrder>="+provider.ItemOrder);
		}
Esempio n. 9
0
		///<summary>StringBuilder does not get altered if no invalid data.</summary>
		public static void BillProv(Provider billProv,StringBuilder strb) {
			if(billProv.LName=="") {
				Comma(strb);
				strb.Append("Billing Prov LName");
			}
			if(!billProv.IsNotPerson && billProv.FName=="") {//if is a person, first name cannot be blank.
				Comma(strb);
				strb.Append("Billing Prov FName");
			}
			if(!Regex.IsMatch(billProv.SSN,"^[0-9]{9}$")) {//must be exactly 9 in length (no dashes)
				Comma(strb);
				strb.Append("Billing Prov SSN/TIN must be a 9 digit number");
			}
			if(!Regex.IsMatch(billProv.NationalProvID,"^(80840)?[0-9]{10}$")) {
				Comma(strb);
				strb.Append("Billing Prov NPI must be a 10 digit number with an optional prefix of 80840");
			}
			if(billProv.TaxonomyCodeOverride.Length>0 && billProv.TaxonomyCodeOverride.Length!=10) {
				Comma(strb);
				strb.Append("Billing Prov Taxonomy Code must be 10 characters");
			}
			//Always check provider name variables regardless of IsNotPerson.
			if(!billProv.IsNotPerson) {//The first name and middle name are only required if the billing provider is a person. For an organization, these fields are never sent.
				string fNameInvalidChars=GetNonAN(billProv.FName);
				if(fNameInvalidChars!="") {
					Comma(strb);
					strb.Append("Billing Prov First Name contains invalid characters: "+fNameInvalidChars);
				}
				string middleInvalidChars=GetNonAN(billProv.MI);
				if(middleInvalidChars!="") {
					Comma(strb);
					strb.Append("Billing Prov MI contains invalid characters: "+middleInvalidChars);
				}
			}
			string lNameInvalidChars=GetNonAN(billProv.LName);
			if(lNameInvalidChars!="") {
				Comma(strb);
				strb.Append("Billing Prov Last Name contains invalid characters: "+lNameInvalidChars);
			}
			/* This was causing problems when dummy providers were used for office and no license number was applicable.
			 * Delta carriers key off this number and start assigning to wrong provider. Customer: ATD.
			if(billProv.StateLicense=="") {
				if(strb.Length!=0) {
					strb.Append(",");
				}
				strb.Append("Billing Prov Lic #");
			}*/
		}
Esempio n. 10
0
		private void FormProvStudentEdit_Load(object sender,EventArgs e) {
			_existingUser=new Userod();
			//Load the Combo Box
			for(int i=0;i<SchoolClasses.List.Length;i++) {
				comboClass.Items.Add(SchoolClasses.GetDescript(SchoolClasses.List[i]));
			}
			comboClass.SelectedIndex=0;
			//Create a provider object if none has been provided
			if(ProvStudent==null) {
				ProvStudent=new Provider();
			}
			//From the add button - Select as much pre-given info as possible
			if(ProvStudent.IsNew) {
				labelPassDescription.Visible=false;
				_autoUserName=Providers.GetNextAvailableProvNum();
				textUserName.Text=POut.Long(_autoUserName);//User-names are suggested to be the ProvNum of the provider.  This can be changed at will.
				for(int i=0;i<SchoolClasses.List.Length-1;i++) {
					if(SchoolClasses.List[i].SchoolClassNum!=ProvStudent.SchoolClassNum) {
						continue;
					}
					comboClass.SelectedIndex=i;
					break;
				}
				textFirstName.Text=ProvStudent.FName;
				textLastName.Text=ProvStudent.LName;
			}
			//Double-Clicking an existing student
			else {
				_isGeneratingAbbr=false;
				for(int i=0;i<SchoolClasses.List.Length-1;i++) {
					if(SchoolClasses.List[i].SchoolClassNum!=ProvStudent.SchoolClassNum) {
						continue;
					}
					comboClass.SelectedIndex=i;
					break;
				}
				textAbbr.Text=ProvStudent.Abbr;
				textFirstName.Text=ProvStudent.FName;
				textLastName.Text=ProvStudent.LName;
				List<Userod> userList=Providers.GetAttachedUsers(ProvStudent.ProvNum);
				if(userList.Count>0) {
					textUserName.Text=userList[0].UserName;//Should always happen if they are a student.
					_existingUser=userList[0];
				}
				textProvNum.Text=POut.Long(ProvStudent.ProvNum);
			}
		}
Esempio n. 11
0
		private void FormEvaluationEdit_Load(object sender,EventArgs e) {
			//This window fills all necessary data on load. This eliminates the need for multiple calls to the database.
			textDate.Text=_evalCur.DateEval.ToShortDateString();
			textTitle.Text=_evalCur.EvalTitle;
			_evalGradeScale=GradingScales.GetOne(_evalCur.GradingScaleNum);
			_listEvalGradeItems=GradingScaleItems.Refresh(_evalCur.GradingScaleNum);
			textGradeScaleName.Text=_evalGradeScale.Description;
			_provInstructor=Providers.GetProv(_evalCur.InstructNum);
			textInstructor.Text=_provInstructor.GetLongDesc();
			_provStudent=Providers.GetProv(_evalCur.StudentNum);
			if(_provStudent!=null) {
				textStudent.Text=_provStudent.GetLongDesc();
			}
			textCourse.Text=SchoolCourses.GetDescript(_evalCur.SchoolCourseNum);
			textGradeNumberOverride.Text=_evalCur.OverallGradeNumber.ToString();
			textGradeShowingOverride.Text=_evalCur.OverallGradeShowing;
			_listEvalCrits=EvaluationCriterions.Refresh(_evalCur.EvaluationNum);
			for(int i=0;i<_listEvalCrits.Count;i++) {
				if(_listEvalCrits[i].IsCategoryName) {
					continue;
				}
				GradingScale critGradeScale=GradingScales.GetOne(_listEvalCrits[i].GradingScaleNum);
				if(!_critGradeScales.ContainsKey(critGradeScale.GradingScaleNum)) {
					_critGradeScales.Add(critGradeScale.GradingScaleNum,critGradeScale);
				}
				if(!_critGradeItems.ContainsKey(critGradeScale.GradingScaleNum)) {
					_critGradeItems.Add(critGradeScale.GradingScaleNum,GradingScaleItems.Refresh(critGradeScale.GradingScaleNum));
				}
			}
			FillGridCriterion();
			RecalculateGrades();
			//Since there is no override column in the database, we check for equality of the calculated grade and the grade on the evaluation.
			//If they are different then the grade was overwritten at some point.
			if(textGradeNumber.Text==textGradeNumberOverride.Text) {
				textGradeNumberOverride.Text="";
			}
			if(textGradeShowing.Text==textGradeShowingOverride.Text) {
				textGradeShowingOverride.Text="";
			}
		}
Esempio n. 12
0
		///<summary>A generic function that is reused because there are many identical provider NM1 segments within the X12 specification.</summary>
		private static void WriteNM1Provider(string entityIdentifierCode,StreamWriter sw,Provider prov) {
			WriteNM1Provider(entityIdentifierCode,sw,prov.FName,prov.MI,prov.LName,prov.NationalProvID,prov.IsNotPerson);
		}
Esempio n. 13
0
		///<summary>This is depedent only on the electronic payor id # rather than the clearinghouse. Used for billing prov and also for treating prov.</summary>
		private static void WriteProv_REFG2orLU(StreamWriter sw,Provider prov,string payorID) {
			string segmentType="G2";
			string provID="";
			ElectID electID=ElectIDs.GetID(payorID);
			if(electID!=null && electID.IsMedicaid) {
				provID=prov.MedicaidID;
			}
			else {
				ProviderIdent[] provIdents=ProviderIdents.GetForPayor(prov.ProvNum,payorID);
				//Should always return 1 or 0 values unless user set it up wrong.
				if(provIdents.Length>0) {
					if(provIdents[0].SuppIDType==ProviderSupplementalID.SiteNumber) {
						segmentType="LU";
					}
					provID=provIdents[0].IDNumber;
				}
			}
			if(provID!="") {
				sw.Write("REF"+s
		      +segmentType+s//REF01 2/3 Reference Identification Qualifier: G2=all payers including Medicare, Medicaid, Blue Cross, etc. LU=Location Number.
		      +Sout(provID,50));//REF02 1/50 Reference Identification:
		    EndSegment(sw);//REF03 and REF04 are not used.
			}
		}
Esempio n. 14
0
		private void Init(){
			InitializeComponent();
			breakLinePen.Width=2;
			if(etrans.PatNum!=0) { //Some transactions are not patient specific.
				patient=Patients.GetPat(etrans.PatNum);
				patPlansForPat=PatPlans.Refresh(etrans.PatNum);
				claim=Claims.GetClaim(etrans.ClaimNum);
				primaryCarrier=Carriers.GetCarrier(etrans.CarrierNum);
				if(claim==null) {//for eligibility
					//Get primary info
					insSub=InsSubs.GetSub(etrans.InsSubNum,new List<InsSub>());
					subscriber=Patients.GetPat(insSub.Subscriber);
					insplan=InsPlans.GetPlan(etrans.PlanNum,new List<InsPlan>());
					patPlanPri=PatPlans.GetFromList(patPlansForPat,insSub.InsSubNum);
				}
				else {
					//Get primary info
					insSub=InsSubs.GetSub(claim.InsSubNum,new List<InsSub>());
					subscriber=Patients.GetPat(insSub.Subscriber);
					insplan=InsPlans.GetPlan(claim.PlanNum,new List<InsPlan>());
					patPlanPri=PatPlans.GetFromList(patPlansForPat,insSub.InsSubNum);
					//Get secondary info
					if(claim.InsSubNum2!=0) {
						patPlanSec=PatPlans.GetFromList(patPlansForPat,claim.InsSubNum2);
						insSub2=InsSubs.GetSub(claim.InsSubNum2,new List<InsSub>());
						subscriber2=Patients.GetPat(insSub2.Subscriber);
						insplan2=InsPlans.GetPlan(claim.PlanNum2,new List<InsPlan>());
						secondaryCarrier=Carriers.GetCarrier(insplan2.CarrierNum);
					}
					//Provider info
					provTreat=Providers.GetProv(claim.ProvTreat);
					provBill=Providers.GetProv(claim.ProvBill);
					//Claim related info
					claimprocs=ClaimProcs.RefreshForClaim(claim.ClaimNum);
					long clinicNum=0;
					for(int i=0;i<claimprocs.Count;i++) {
						if(claimprocs[i].ClinicNum!=0) {
							clinicNum=claimprocs[i].ClinicNum;
							break;
						}
					}
					if(clinicNum!=0) {
						clinic=Clinics.GetClinic(clinicNum);
					}
					else if(!PrefC.GetBool(PrefName.EasyNoClinics) && Clinics.List.Length>0) {
						clinic=Clinics.List[0];
					}
				}
				if(provTreat==null) {
					provTreat=Providers.GetProv(Patients.GetProvNum(patient));
				}
				if(provBill==null) {
					provBill=Providers.GetProv(Patients.GetProvNum(patient));
				}
				List<Procedure> procsAll=Procedures.Refresh(etrans.PatNum);
				extracted=Procedures.GetCanadianExtractedTeeth(procsAll);
			}
			if(MessageText==null || MessageText.Length<23) {
				throw new Exception("CCD message format too short: "+MessageText);
			}
			formData=new CCDFieldInputter(MessageText);//Input the fields of the given message.
			CCDField languageOfInsured=formData.GetFieldById("G27");
			if(languageOfInsured!=null) {
				if(languageOfInsured.valuestr=="F") {
					isFrench=true;
				}
			}
			else if(subscriber!=null && subscriber.Language=="fr") {
				isFrench=true;
			}
			formatVersionNumber=formData.GetFieldById("A03").valuestr;//Must always exist so no error checking here.
			transactionCode=formData.GetFieldById("A04").valuestr;//Must always exist so no error checking here.
			if(formatVersionNumber=="04") {//FormId field does not exist in version 02 in any of the message texts.
				CCDField formIdField=formData.GetFieldById("G42");//Usually exists in version 04 response messages.
				//Only a few response transactions don't define field G42. So far, those are transactions 15 (Summary Reconciliation), 16 (Payment Reconciliation) and 24 (Email).
				//In these cases, we simply do not use the formId field later on in the display code.
				if(formIdField!=null) {
					formId=formIdField.valuestr;
				}
			}
			else {//Version 02
				//Since there is no FormID field in version 02, we figure out what the formId should be based on the transaction type.
				if(transactionCode=="10") {//Eligibility Response.
					formId="08";//Eligibility Form
				}
				else if(transactionCode=="11") {//Claim Response.
					formId="03";//Claim Acknowledgement Form
				}
				else if(transactionCode=="21") {//EOB
					formId="01";//EOB Form
					CCDField g02=formData.GetFieldById("G02");
					if(g02!=null && g02.valuestr=="Y") {
						formId="04";//Employer Certified.
					}
				}
				else if(transactionCode=="13") {//Response to Pre-Determination.
					formId="06";//Pre-Determination Acknowledgement Form
				}
				else if(transactionCode=="12") { //Reversal response
					//There is no standard form for a reversal response, but we print the reversal response later on based on the transactioncode so we don't need to do anything here.
				}
				else {
					throw new Exception("Unhandled transactionCode '"+transactionCode+"' for version 02 message.");
				}
			}
			CCDField status=formData.GetFieldById("G05");
			if(status!=null && status.valuestr!=null) {
				responseStatus=status.valuestr.ToUpper();
			}
			transactionCode=formData.GetFieldById("A04").valuestr;
			predetermination=(transactionCode=="23"||transactionCode=="13");//Be sure to list all predetermination response types here!
			if(copiesToPrint<=0) { //Show the form on screen if there are no copies to print.
				ShowDisplayMessages();
				CCDField fieldPayTo=formData.GetFieldById("F01");
				if(fieldPayTo!=null) {
					bool paySubscriber=(fieldPayTo.valuestr=="1");//same for version 02 and version 04
					//Typically, insurance companies in Canada prefer to pay the subscriber instead of the dentist.
					if(AssignmentOfBenefits()) {//The insurance plan is set to pay the dentist
						if(paySubscriber) {//The carrier has decided to pay the subscriber.
							MsgBox.Show("Canadian","INFORMATION: The carrier changed the payee from the dentist to the subscriber.");//This check was required for certification.
						}
					}
					else {//The insurance plan is set to pay the subscriber
						if(!paySubscriber) {//The carrier has decided to pay the dentist.
							MsgBox.Show("Canadian","INFORMATION: The carrier changed the payee from the subscriber to the dentist.");//This check was required for certification.
						}
					}
				}
				CCDField paymentAdjustmentAmount=formData.GetFieldById("G33");
				if(paymentAdjustmentAmount!=null) {
					if(paymentAdjustmentAmount.valuestr.Substring(1)!="000000") {
						MessageBox.Show(Lan.g(this,"Payment adjustment amount")+": "+RawMoneyStrToDisplayMoney(paymentAdjustmentAmount.valuestr));
					}
				}
				if(autoPrint) {
					if(responseStatus!="R") { //We are not required to automatically print rejection notices.
						//Automatically print a patient copy only. We are never required to autoprint a dentist copy, but it can be done manually instead.
						new FormCCDPrint(etrans.Copy(),MessageText,1,false,true);
					}
				}
				if(formId=="05") { //Manual claim form
					Canadian.ShowManualClaimForm(claim);
					Close();
				}
				else {
					pd=CreatePrintDocument();
					printPreviewControl1.Document=pd;//Setting the document causes system to call pd_PrintPage, which will print the document in the preview window.
					ShowDialog();
				}
			}
			else {
				pd=CreatePrintDocument();
				if(formId=="05") { //Manual claim form
#if DEBUG
					Canadian.ShowManualClaimForm(claim);
#else
					Canadian.PrintManualClaimForm(claim);//Send the print job to the physical printer.
#endif
				}
				else {
#if DEBUG
					new FormCCDPrint(etrans.Copy(),MessageText,0,false,patientCopy);//Show the form on the screen.
#else
					pd.Print();//Send the print job to the physical printer.
#endif
				}
				//Print the remaining copies recursively.
				if(copiesToPrint>=2) {
					new FormCCDPrint(etrans.Copy(),MessageText,copiesToPrint-1,false,patientCopy);
				}
			}
			CCDField embeddedTransaction=formData.GetFieldById("G40");
			if(embeddedTransaction!=null) {
				new FormCCDPrint(etrans.Copy(),embeddedTransaction.valuestr,copiesToPrint,autoPrint,patientCopy);
			}
		}
Esempio n. 15
0
 public static string Validate(Clearinghouse clearhouse,Carrier carrier,Provider billProv,Clinic clinic,InsPlan insPlan,Patient subscriber,InsSub insSub)
 {
     StringBuilder strb=new StringBuilder();
     X12Validate.ISA(clearhouse,strb);
     X12Validate.Carrier(carrier,strb);
     if(carrier.ElectID.Length<2) {
         if(strb.Length!=0) {
             strb.Append(",");
         }
         strb.Append("Electronic ID");
     }
     if(billProv.SSN.Length!=9) {
         if(strb.Length!=0) {
             strb.Append(",");
         }
         strb.Append("Prov TIN 9 digits");
     }
     X12Validate.BillProv(billProv,strb);
     if(clinic==null) {
         X12Validate.PracticeAddress(strb);
     }
     else {
         X12Validate.Clinic(clinic,strb);
     }
     if(insSub.SubscriberID.Length<2) {
         if(strb.Length!=0) {
             strb.Append(",");
         }
         strb.Append("SubscriberID");
     }
     if(subscriber.Birthdate.Year<1880) {
         if(strb.Length!=0) {
             strb.Append(",");
         }
         strb.Append("Subscriber Birthdate");
     }
     if(insPlan.GroupNum=="") {
         if(strb.Length!=0) {
             strb.Append(",");
         }
         strb.Append("Group Number");
     }
     return strb.ToString();
 }
Esempio n. 16
0
		///<summary>listQMs will be a list of 9 QualityMeasure objects for the selected CQMs.
		///Those objects will have every encounter, procedure, problem, etc. required for creating the category I and category III QRDA documents.
		///Category I is the patient level documents, and will be one document for every patient in the initial patient population for the specific measure.
		///Each encounter, procedure, etc. may appear in the Category I document multiple times if, for instance, the encounter falls into more than one value set
		///and qualifies the patient for inclusion in multiple measures.
		///The Category I files will be zipped per measure, so a patient's file be in the zip for every measure to which they belong.
		///The Category III document contains the aggregate information for each of the selected measures.</summary>
		public static void GenerateQRDA(List<QualityMeasure> listQMs,long provNum,DateTime dateStart,DateTime dateEnd,string folderRoot) {
			//Set global variables for use by the GenerateCatOne and GenerateCatThree functions
			if(listQMs==null || listQMs.Count==0) {//this should never happen
				throw new ApplicationException("No measures to report on.");
			}
			string strErrors=ValidateSettings();
			if(strErrors!="") {
				throw new ApplicationException(strErrors);
			}
			_provOutQrda=Providers.GetProv(provNum);
			if(_provOutQrda==null) {
				throw new ApplicationException("Invalid provider selected.");
			}
			_strOIDInternalRoot=OIDInternals.GetForType(IdentifierType.Root).IDRoot;
			_strOIDInternalCQMRoot=OIDInternals.GetForType(IdentifierType.CqmItem).IDRoot;
			if(_strOIDInternalCQMRoot=="") {
				throw new ApplicationException("Internal CQM item OID root is missing.  Go to Setup | EHR and add OIDs.");
			}
			_strOIDInternalProvRoot=OIDInternals.GetForType(IdentifierType.Provider).IDRoot;
			if(_strOIDInternalProvRoot=="") {
				throw new ApplicationException("Internal Provider OID root is missing.  Go to Setup | EHR and add OIDs.");
			}
			_strOIDInternalPatRoot=OIDInternals.GetForType(IdentifierType.Patient).IDRoot;
			if(_strOIDInternalPatRoot=="") {
				throw new ApplicationException("Internal Patient OID root is missing.  Go to Setup | EHR and add OIDs.");
			}
			_hashQrdaGuids=new HashSet<string>();//The GUIDs are only used to uniquely identify the documents themselves, for other IDs we are using the OIDInternal root and extension
			//create a list of all CQM indexes that are considered stratifications or additional populations of a measure
			//these will be skipped for certain circumstances, like when listing all of the eMeasures or creating certain sections of the QRDA
			_listExtraPopIndxs=new List<int>();
			_listExtraPopIndxs.Add((int)QualityType2014.CariesPrevent_1);
			_listExtraPopIndxs.Add((int)QualityType2014.CariesPrevent_2);
			_listExtraPopIndxs.Add((int)QualityType2014.CariesPrevent_2);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightAdult);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_1_2);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_1_3);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_2_1);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_2_2);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_2_3);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_3_1);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_3_2);
			_listExtraPopIndxs.Add((int)QualityType2014.WeightChild_3_3);
			GenerateQRDACatOne(listQMs,dateStart,dateEnd,folderRoot);
			GenerateQRDACatThree(listQMs,dateStart,dateEnd,folderRoot);
		}
Esempio n. 17
0
		private void FormEHR_Shown(object sender,EventArgs e) {
			ResultOnClosing=EhrFormResult.None;
			PatCur=Patients.GetPat(PatNum);
			ProvPat=Providers.GetProv(PatCur.PriProv);
			labelProvPat.Text=ProvPat.GetLongDesc();
			if(ProvPat.EhrKey=="") {
				labelProvPat.Text+=" (no ehr provider key entered)";
			}
			if(Security.CurUser.ProvNum==0) {
				labelProvUser.Text="none";
			}
			else {
				Provider provUser=Providers.GetProv(Security.CurUser.ProvNum);
				labelProvUser.Text=Providers.GetLongDesc(provUser.ProvNum);
				if(provUser.EhrKey=="") {
					labelProvUser.Text+=" (no ehr provider key entered)";
				}
			}
			FillGridMu();
			if(OnShowLaunchOrders) {
				//LaunchOrdersWindow();
				OnShowLaunchOrders=false;
			}
			if(ProvPat.EhrKey=="") {
				MessageBox.Show("No ehr provider key entered for this patient's primary provider.");
			}
		}
Esempio n. 18
0
		///<summary>Rendering provider specialty information. The loop has different numbers in med/dent. Not used in inst.</summary>
		private static void WritePRV_PE(StreamWriter sw,Provider provTreat) {
			//2310B PRV: PE (dental) Rendering Provider Specialty Information.
			sw.Write("PRV"+s
				+"PE"+s//PRV01 1/3 Provider Code: PE=Performing.
				+"PXC"+s//PRV02 2/3 Reference Identification Qualifier: PXC=Health Care Provider Taxonomy Code.
				+X12Generator.GetTaxonomy(provTreat));//PRV03 1/50 Reference Identification: Taxonomy Code.
			EndSegment(sw);//PRV04 through PRV06 are not used.
		}
Esempio n. 19
0
		private void butAdd_Click(object sender, System.EventArgs e) {
			FormProvEdit FormPE=new FormProvEdit();
			FormPE.ProvCur=new Provider();
			FormPE.ProvCur.IsNew=true;
			FormProvStudentEdit FormPSE=new FormProvStudentEdit();
			FormPSE.ProvStudent=new Provider();
			FormPSE.ProvStudent.IsNew=true;
			Provider provCur=new Provider();
			if(groupDentalSchools.Visible) {
				//Dental schools do not worry about item orders.
				if(radioStudents.Checked) {
					if(!Security.IsAuthorized(Permissions.AdminDentalStudents)) {
						return;
					}
					if(comboClass.SelectedIndex==0) {
						MsgBox.Show(this,"A class must be selected from the drop down box before a new student can be created");
						return;
					}
					FormPSE.ProvStudent.SchoolClassNum=SchoolClasses.List[comboClass.SelectedIndex-1].SchoolClassNum;
					FormPSE.ProvStudent.FName=textFirstName.Text;
					FormPSE.ProvStudent.LName=textLastName.Text;
				}
				if(radioInstructors.Checked && !Security.IsAuthorized(Permissions.AdminDentalInstructors)) {
					return;
				}
				FormPE.ProvCur.IsInstructor=radioInstructors.Checked;
				FormPE.ProvCur.FName=textFirstName.Text;
				FormPE.ProvCur.LName=textLastName.Text;
			}
			else {//Not using Dental Schools feature.
				Cache.Refresh(InvalidType.Providers);//Refresh the cache to get current information for the item orders
				if(gridMain.SelectedIndices.Length>0) {//place new provider after the first selected index. No changes are made to DB until after provider is actually inserted.
					FormPE.ProvCur.ItemOrder=Providers.GetProv(PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["ProvNum"].ToString())).ItemOrder;//now two with this itemorder
				}
				else if(gridMain.Rows.Count>0) {
					FormPE.ProvCur.ItemOrder=Providers.GetProv(PIn.Long(table.Rows[gridMain.Rows.Count-1]["ProvNum"].ToString())).ItemOrder;
				}
				else {
					FormPE.ProvCur.ItemOrder=0;
				}
			}
			if(!radioStudents.Checked) {
				if(radioInstructors.Checked && PrefC.GetLong(PrefName.SecurityGroupForInstructors)==0) {
					MsgBox.Show(this,"Security Group for Instructors must be set from the Dental School Setup window before adding instructors.");
					return;
				}
				FormPE.IsNew=true;
				FormPE.ShowDialog();
				if(FormPE.DialogResult!=DialogResult.OK) {
					return;
				}
				provCur=FormPE.ProvCur;
			}
			else {
				if(radioStudents.Checked && PrefC.GetLong(PrefName.SecurityGroupForStudents)==0) {
					MsgBox.Show(this,"Security Group for Students must be set from the Dental School Setup window before adding students.");
					return;
				}
				FormPSE.ShowDialog();
				if(FormPSE.DialogResult!=DialogResult.OK) {
					return;
				}
				provCur=FormPSE.ProvStudent;
			}
			//new provider has already been inserted into DB from above
			Providers.MoveDownBelow(provCur);//safe to run even if none selected.
			changed=true;
			Cache.Refresh(InvalidType.Providers);//This refresh may be unnecessary, but it is here for safety reasons
			FillGrid();
			gridMain.ScrollToEnd();//should change this to scroll to the same place as before.
			for(int i=0;i<table.Rows.Count;i++) {//ProviderC.ListLong.Count;i++) {
				if(table.Rows[i]["ProvNum"].ToString()==provCur.ProvNum.ToString()) {
					//ProviderC.ListLong[i].ProvNum==FormP.ProvCur.ProvNum) {
					gridMain.SetSelected(i,true);
					break;
				}
			}
		}
Esempio n. 20
0
 ///<summary>Returns the list of etrans requests. The etrans.AckEtransNum can be used to get the etrans ack. The following are the only possible formats that can be returned in the acks: 21 EOB Response, 11 Claim Ack, 14 Outstanding Transactions Response, 23 Predetermination EOB, 13 Predetermination Ack, 24 E-Mail Response. Set version2 to true if version 02 request and false for version 04 request. Set sendToItrans to true only when sending to carrier 999999 representing the entire ITRANS network. When version2 is false and sendToItrans is false then carrier must be set to a valid Canadian carrier, otherwise it can be set to null. Prov must be validated as a CDANet provider before calling this function.</summary>
 public static List<Etrans> GetOutstandingTransactions(bool version2,bool sendToItrans,Carrier carrier,Provider prov)
 {
     List<Etrans> etransAcks=new List<Etrans>();
     Clearinghouse clearhouse=Canadian.GetClearinghouse();
     if(clearhouse==null) {
         throw new ApplicationException("Canadian clearinghouse not found.");
     }
     string saveFolder=clearhouse.ExportPath;
     if(!Directory.Exists(saveFolder)) {
         throw new ApplicationException(saveFolder+" not found.");
     }
     //We are required to send the request for outstanding transactions over and over until we get back an outstanding transactions ack format (Transaction type 14), because
     //there may be more than one item in the mailbox and we can only get one item at time.
     bool exit=false;
     do {
         StringBuilder strb=new StringBuilder();
         Etrans etrans=null;
         if(version2 || sendToItrans) {
             etrans=Etranss.CreateCanadianOutput(0,0,0,clearhouse.ClearinghouseNum,EtransType.RequestOutstand_CA,0,0);
         }
         else {
             if((carrier.CanadianSupportedTypes&CanSupTransTypes.RequestForOutstandingTrans_04)!=CanSupTransTypes.RequestForOutstandingTrans_04) {
                 throw new ApplicationException("The carrier does not support request for outstanding transactions.");
             }
             etrans=Etranss.CreateCanadianOutput(0,carrier.CarrierNum,carrier.CanadianNetworkNum,
                 clearhouse.ClearinghouseNum,EtransType.RequestOutstand_CA,0,0);
         }
         //A01 transaction prefix 12 AN
         if(version2 || sendToItrans) {
             strb.Append("            ");
         }
         else {
             if(carrier.CanadianNetworkNum==0) {
                 throw new ApplicationException("Carrier network not set.");
             }
             CanadianNetwork network=CanadianNetworks.GetNetwork(carrier.CanadianNetworkNum);
             strb.Append(Canadian.TidyAN(network.CanadianTransactionPrefix,12));
         }
         //A02 office sequence number 6 N
         strb.Append(Canadian.TidyN(etrans.OfficeSequenceNumber,6));
         //A03 format version number 2 N
         if(version2) {
             strb.Append("02");
         }
         else {
             strb.Append("04");
         }
         //A04 transaction code 2 N
         strb.Append("04");//outstanding transactions request
         if(!version2) {//version 04
             //A05 carrier id number 6 N
             if(sendToItrans) {
                 strb.Append("999999");
             }
             else {
                 strb.Append(carrier.ElectID);//already validated as 6 digit number.
             }
         }
         //A06 software system id 3 AN
         strb.Append(Canadian.SoftwareSystemId());
         if(!version2) { //version 04
             //A10 encryption method 1 N
             if(sendToItrans) {
                 strb.Append("1");
             }
             else {
                 strb.Append(carrier.CanadianEncryptionMethod);//validated in UI
             }
         }
         //A07 message length N4
         if(!version2) { //version 04
             strb.Append(Canadian.TidyN("64",5));
         }
         else {
             strb.Append(Canadian.TidyN("42",4));
         }
         if(!version2) { //version 04
             //A09 carrier transaction counter 5 N
             strb.Append(Canadian.TidyN(etrans.CarrierTransCounter,5));
         }
         //According to the documentation for the outstanding transactions ack format, B01 only has to be a valid provider for the practice,
         //and that will trigger acknowledgements for all providers of the practice. I am assuming here that the same is true for the
         //billing provider in field B03, because there is no real reason to limit the request to any particular provider.
         //B01 CDA provider number 9 AN
         strb.Append(Canadian.TidyAN(prov.NationalProvID,9));//already validated
         //B02 (treating) provider office number 4 AN
         strb.Append(Canadian.TidyAN(prov.CanadianOfficeNum,4));//already validated
         if(!version2) { //version 04
             //B03 billing provider number 9 AN
             //might need to account for possible 5 digit prov id assigned by carrier
             strb.Append(Canadian.TidyAN(prov.NationalProvID,9));//already validated
         }
         string result="";
         bool resultIsError=false;
         try {
             result=Canadian.PassToIca(strb.ToString(),clearhouse);
         }
         catch(ApplicationException ex) {
             result=ex.Message;
             resultIsError=true;
             //Etranss.Delete(etrans.EtransNum);//we don't want to do this, because we want the incremented etrans.OfficeSequenceNumber to be saved
             //Attach an ack indicating failure.
         }
         //Attach an ack to the etrans
         Etrans etransAck=new Etrans();
         etransAck.PatNum=etrans.PatNum;
         etransAck.PlanNum=etrans.PlanNum;
         etransAck.InsSubNum=etrans.InsSubNum;
         etransAck.CarrierNum=etrans.CarrierNum;
         etransAck.DateTimeTrans=DateTime.Now;
         CCDFieldInputter fieldInputter=null;
         if(resultIsError) {
             etransAck.Etype=EtransType.AckError;
             etrans.Note="failed";
         }
         else {
             if(result.Substring(12).StartsWith("NO MORE ITEMS")) {
                 etransAck.Etype=EtransType.OutstandingAck_CA;
                 exit=true;
             }
             else {
                 fieldInputter=new CCDFieldInputter(result);
                 CCDField fieldG05=fieldInputter.GetFieldById("G05");
                 if(fieldG05!=null) {
                     etransAck.AckCode=fieldG05.valuestr;
                 }
                 etransAck.Etype=fieldInputter.GetEtransType();
             }
         }
         Etranss.Insert(etransAck);
         Etranss.SetMessage(etransAck.EtransNum,result);
         etrans.AckEtransNum=etransAck.EtransNum;
         Etranss.Update(etrans);
         Etranss.SetMessage(etrans.EtransNum,strb.ToString());
         etransAcks.Add(etransAck);
         if(resultIsError) {
             throw new ApplicationException(result);
         }
         if(fieldInputter==null) { //happens in version 02 when a terminating message containing the text "NO MORE ITEMS" is received.
             break;
         }
         CCDField fieldA04=fieldInputter.GetFieldById("A04");//message format
         if(version2) {
             //In this case, there are only 4 possible responses: EOB, Claim Ack, Claim Ack with an error code, or Claim Ack with literal "NO MORE ITEMS" starting at character 13.
             if(fieldA04.valuestr=="11") {
                 CCDField fieldG08=fieldInputter.GetFieldById("G08");
                 if(fieldG08!=null && (fieldG08.valuestr=="004" || fieldG08.valuestr=="049")) { //Exit conditions specified in the documentation.
                     etransAck.Etype=EtransType.OutstandingAck_CA;
                     exit=true;
                 }
             }
         }
         else { //version 04
             //Remember, the only allowed response transaction types are: 21 EOB Response, 11 Claim Ack, 14 Outstanding Transactions Response, 23 Predetermination EOB, 13 Predetermination Ack, 24 E-Mail Response
             if(fieldA04.valuestr=="14") {//Outstanding Transaction Ack Format
                 CCDField fieldG05=fieldInputter.GetFieldById("G05");//response status
                 if(fieldG05.valuestr=="R") { //We only expect the result to be 'R' or 'X' as specified in the documentation.
                     CCDField fieldG07=fieldInputter.GetFieldById("G07");//disposition message
                     CCDField fieldG08=fieldInputter.GetFieldById("G08");//error code
                     MessageBox.Show(Lan.g("","Failed to receive outstanding transactions. Messages from CDANet")+": "+Environment.NewLine+
                         fieldG07.valuestr.Trim()+Environment.NewLine+((fieldG08!=null)?CCDerror.message(Convert.ToInt32(fieldG08.valuestr),false):""));
                 }
                 etransAck.Etype=EtransType.OutstandingAck_CA;
                 exit=true;
             }
         }
         //Field A02 exists in all of the possible formats (21,11,14,23,13,24).
         CCDField fieldA02=fieldInputter.GetFieldById("A02");//office sequence number
         //We use the Office Sequence Number to find the original etrans entry so that we can discover which patient the response is referring to.
         Etrans etranOriginal=Etranss.GetForSequenceNumberCanada(fieldA02.valuestr);
         if(etranOriginal!=null) { //Null will happen when testing, but should not happen in production.
             etrans.PatNum=etranOriginal.PatNum;
             etrans.PlanNum=etranOriginal.PlanNum;
             etrans.InsSubNum=etranOriginal.InsSubNum;
             etrans.ClaimNum=etranOriginal.ClaimNum;
             Etranss.Update(etrans);
             etransAck.PatNum=etranOriginal.PatNum;
             etransAck.PlanNum=etranOriginal.PlanNum;
             etransAck.InsSubNum=etranOriginal.InsSubNum;
             etransAck.ClaimNum=etranOriginal.ClaimNum;
             Etranss.Update(etransAck);
             if(!exit) {
                 if(etransAck.ClaimNum!=0) {
                     Claim claim=Claims.GetClaim(etransAck.ClaimNum);
                     if(etransAck.AckCode=="A") {
                         claim.ClaimStatus="R";
                         claim.DateReceived=MiscData.GetNowDateTime();
                     }
                     else if(etransAck.AckCode=="H" || etransAck.AckCode=="B" || etransAck.AckCode=="C" || etransAck.AckCode=="N") {
                         claim.ClaimStatus="S";
                     }
                     else if(etransAck.AckCode=="M") {
                         Canadian.PrintManualClaimForm(claim);
                     }
                     Claims.Update(claim);
                 }
             }
         }
         if(!exit) {
             try {
                 new FormCCDPrint(etrans,result,true);
             }
             catch(Exception ex) {
                 MessageBox.Show(Lan.g("CanadianOutput","Failed to display one of the ROT responses")+": "+Environment.NewLine+ex.ToString());
             }
         }
     } while(!exit);
     return etransAcks;
 }
Esempio n. 21
0
		///<summary>Only called from Chart for now.  No validation is performed here.  Validate before calling.  There are many validtion checks, including the NPI must be exactly 10 digits.</summary>
		public static string BuildClickThroughXml(Provider prov,Employee emp,Patient pat) {
			NCScript ncScript=new NCScript();
			ncScript.Credentials=new CredentialsType();
			ncScript.Credentials.partnerName=NewCropPartnerName;
			ncScript.Credentials.name=NewCropAccountName;
			ncScript.Credentials.password=NewCropAccountPasssword;
			ncScript.Credentials.productName=NewCropProductName;
			ncScript.Credentials.productVersion=NewCropProductVersion;
			ncScript.UserRole=new UserRoleType();
			if(emp==null) {
				ncScript.UserRole.user=UserType.LicensedPrescriber;
				ncScript.UserRole.role=RoleType.doctor;
			}
			else {
				ncScript.UserRole.user=UserType.Staff;
				ncScript.UserRole.role=RoleType.nurse;
			}
			ncScript.Destination=new DestinationType();
			ncScript.Destination.requestedPage=RequestedPageType.compose;//This is the tab that the user will want 90% of the time.
			string practiceTitle=PrefC.GetString(PrefName.PracticeTitle);//May be blank.
			string practicePhone=PrefC.GetString(PrefName.PracticePhone);//Validated to be 10 digits within the chart.
			string practiceFax=PrefC.GetString(PrefName.PracticeFax);//Validated to be 10 digits within the chart.
			string practiceAddress=PrefC.GetString(PrefName.PracticeAddress);//Validated to exist in chart.
			string practiceAddress2=PrefC.GetString(PrefName.PracticeAddress2);//May be blank.
			string practiceCity=PrefC.GetString(PrefName.PracticeCity);//Validated to exist in chart.
			string practiceState=PrefC.GetString(PrefName.PracticeST);//Validated to be a US state code in chart.
			string practiceZip=Regex.Replace(PrefC.GetString(PrefName.PracticeZip),"[^0-9]*","");//Zip with all non-numeric characters removed. Validated to be 9 digits in chart.
			string practiceZip4=practiceZip.Substring(5);//Last 4 digits of zip.
			practiceZip=practiceZip.Substring(0,5);//First 5 digits of zip.
			string country="US";//Always United States for now.
			//if(CultureInfo.CurrentCulture.Name.Length>=2) {
			//  country=CultureInfo.CurrentCulture.Name.Substring(CultureInfo.CurrentCulture.Name.Length-2);
			//}
			ncScript.Account=new AccountTypeRx();
			//Each LicensedPrescriberID must be unique within an account. Since we send ProvNum for LicensedPrescriberID, each OD database must have a unique AccountID.
			ncScript.Account.ID=PrefC.GetString(PrefName.NewCropAccountId);//Customer account number then a dash then a random alpha-numeric string of 3 characters, followed by 2 digits.
			ncScript.Account.accountName=practiceTitle;//May be blank.
			ncScript.Account.siteID="1";//Always send 1.  For each AccountID/SiteID pair, a separate database will be created in NewCrop.
			ncScript.Account.AccountAddress=new AddressType();
			ncScript.Account.AccountAddress.address1=practiceAddress;//Validated to exist in chart.
			ncScript.Account.AccountAddress.address2=practiceAddress2;//May be blank.
			ncScript.Account.AccountAddress.city=practiceCity;//Validated to exist in chart.
			ncScript.Account.AccountAddress.state=practiceState;//Validated to be a US state code in chart.
			ncScript.Account.AccountAddress.zip=practiceZip;//Validated to be 9 digits in chart. First 5 digits go in this field.
			ncScript.Account.AccountAddress.zip4=practiceZip4;//Validated to be 9 digits in chart. Last 4 digits go in this field.
			ncScript.Account.AccountAddress.country=country;//Validated above.
			ncScript.Account.accountPrimaryPhoneNumber=practicePhone;//Validated to be 10 digits within the chart.
			ncScript.Account.accountPrimaryFaxNumber=practiceFax;//Validated to be 10 digits within the chart.
			ncScript.Location=new LocationType();
			if(PrefC.GetBool(PrefName.EasyNoClinics) || pat.ClinicNum==0) { //No clinics.
				ncScript.Location.ID="0";//Always 0, since clinicnums must be >= 1, will never overlap with a clinic if the office turns clinics on after first use.
				ncScript.Location.locationName=practiceTitle;//May be blank.
				ncScript.Location.LocationAddress=new AddressType();
				ncScript.Location.LocationAddress.address1=practiceAddress;//Validated to exist in chart.
				ncScript.Location.LocationAddress.address2=practiceAddress2;//May be blank.
				ncScript.Location.LocationAddress.city=practiceCity;//Validated to exist in chart.
				ncScript.Location.LocationAddress.state=practiceState;//Validated to be a US state code in chart.
				ncScript.Location.LocationAddress.zip=practiceZip;//Validated to be 9 digits in chart. First 5 digits go in this field.
				ncScript.Location.LocationAddress.zip4=practiceZip4;//Validated to be 9 digits in chart. Last 4 digits go in this field.
				ncScript.Location.LocationAddress.country=country;//Validated above.
				ncScript.Location.primaryPhoneNumber=practicePhone;//Validated to be 10 digits within the chart.
				ncScript.Location.primaryFaxNumber=practiceFax;//Validated to be 10 digits within the chart.
				ncScript.Location.pharmacyContactNumber=practicePhone;//Validated to be 10 digits within the chart.
			}
			else { //Using clinics.
				Clinic clinic=Clinics.GetClinic(pat.ClinicNum);
				ncScript.Location.ID=clinic.ClinicNum.ToString();//A positive integer.
				ncScript.Location.locationName=clinic.Description;//May be blank.
				ncScript.Location.LocationAddress=new AddressType();
				ncScript.Location.LocationAddress.address1=clinic.Address;//Validated to exist in chart.
				ncScript.Location.LocationAddress.address2=clinic.Address2;//May be blank.
				ncScript.Location.LocationAddress.city=clinic.City;//Validated to exist in chart.
				ncScript.Location.LocationAddress.state=clinic.State;//Validated to be a US state code in chart.
				string clinicZip=Regex.Replace(clinic.Zip,"[^0-9]*","");//Zip with all non-numeric characters removed. Validated to be 9 digits in chart.
				string clinicZip4=clinicZip.Substring(5);//Last 4 digits of zip.
				clinicZip=clinicZip.Substring(0,5);//First 5 digits of zip.
				ncScript.Location.LocationAddress.zip=clinicZip;//Validated to be 9 digits in chart. First 5 digits go in this field.
				ncScript.Location.LocationAddress.zip4=clinicZip4;//Validated to be 9 digits in chart. Last 4 digits go in this field.
				ncScript.Location.LocationAddress.country=country;//Validated above.
				ncScript.Location.primaryPhoneNumber=clinic.Phone;//Validated to be 10 digits within the chart.
				ncScript.Location.primaryFaxNumber=clinic.Fax;//Validated to be 10 digits within the chart.
				ncScript.Location.pharmacyContactNumber=clinic.Phone;//Validated to be 10 digits within the chart.
			}
			ncScript.LicensedPrescriber=new LicensedPrescriberType();
			//Each unique provider ID sent to NewCrop will cause a billing charge.
			//Some customer databases have provider duplicates, because they have one provider record per clinic with matching NPIs.
			//We send NPI as the ID to prevent extra NewCrop charges.
			//Conversation with NewCrop:
			//Question: If one of our customers clicks through to NewCrop with 2 different LicensedPrescriber.ID values, 
			//          but with the same provider name and NPI, will Open Dental be billed twice or just one time for the NPI used?
			//Answer:   "They would be billed twice. The IDs you send us should always be maintained and unique. 
			//          Users are always identified by LicensedPrescriber ID, since their name or credentials could potentially change."
			ncScript.LicensedPrescriber.ID=prov.NationalProvID;
			//UPIN is obsolete
			ncScript.LicensedPrescriber.LicensedPrescriberName=new PersonNameType();
			ncScript.LicensedPrescriber.LicensedPrescriberName.last=prov.LName.Trim();//Cannot be blank.
			ncScript.LicensedPrescriber.LicensedPrescriberName.first=prov.FName.Trim();//Cannot be blank.
			ncScript.LicensedPrescriber.LicensedPrescriberName.middle=prov.MI;//May be blank.
			ncScript.LicensedPrescriber.LicensedPrescriberName.suffix=PersonNameSuffix.DDS;//There is no blank or none option, so we have to pick a default value. DDS=0, so would be default anyway.
			string[] suffixes=prov.Suffix.ToUpper().Split(' ','.');
			for(int i=0;i<suffixes.Length;i++) {
				if(suffixes[i]=="I") {
					ncScript.LicensedPrescriber.LicensedPrescriberName.suffix=PersonNameSuffix.I;
					break;
				}
				else if(suffixes[i]=="II") {
					ncScript.LicensedPrescriber.LicensedPrescriberName.suffix=PersonNameSuffix.II;
					break;
				}
				else if(suffixes[i]=="III") {
					ncScript.LicensedPrescriber.LicensedPrescriberName.suffix=PersonNameSuffix.III;
					break;
				}
				else if(suffixes[i]=="JR") {
					ncScript.LicensedPrescriber.LicensedPrescriberName.suffix=PersonNameSuffix.Jr;
					break;
				}
				else if(suffixes[i]=="SR") {
					ncScript.LicensedPrescriber.LicensedPrescriberName.suffix=PersonNameSuffix.Sr;
					break;
				}
			}
			if(prov.DEANum.ToLower()=="none") {
				ncScript.LicensedPrescriber.dea="NONE";
			}
			else {
				ncScript.LicensedPrescriber.dea=prov.DEANum;
			}
			ncScript.LicensedPrescriber.licenseState=prov.StateWhereLicensed;//Validated to be a US state code in the chart.
			ncScript.LicensedPrescriber.licenseNumber=prov.StateLicense;//Validated to exist in chart.
			ncScript.LicensedPrescriber.npi=prov.NationalProvID;//Validated to be 10 digits in chart.
			//ncScript.LicensedPrescriber.freeformCredentials=;//This is where DDS and DMD should go, but we don't support this yet. Probably not necessary anyway.
			if(emp!=null) {
				ncScript.Staff=new StaffType();
				ncScript.Staff.ID="emp"+emp.EmployeeNum.ToString();//A positive integer. Returned in the ExternalUserID field when retreiving prescriptions from NewCrop. Also, provider ID is returned in the same field if a provider created the prescription, so that we can create a distintion between employee IDs and provider IDs.
				ncScript.Staff.StaffName=new PersonNameType();
				ncScript.Staff.StaffName.first=emp.FName;//First name or last name will not be blank. Validated in Chart.
				ncScript.Staff.StaffName.last=emp.LName;//First name or last name will not be blank. Validated in Chart.
				ncScript.Staff.StaffName.middle=emp.MiddleI;//May be blank.
			}
			ncScript.Patient=new PatientType();
			ncScript.Patient.ID=pat.PatNum.ToString();//A positive integer.
			ncScript.Patient.PatientName=new PersonNameType();
			ncScript.Patient.PatientName.last=pat.LName;//Validated to exist in Patient Edit window.
			ncScript.Patient.PatientName.first=pat.FName;//May be blank.
			ncScript.Patient.PatientName.middle=pat.MiddleI;//May be blank.
			ncScript.Patient.medicalRecordNumber=pat.PatNum.ToString();//A positive integer.
			//NewCrop specifically requested that we do not send SSN.
			//ncScript.Patient.socialSecurityNumber=Regex.Replace(pat.SSN,"[^0-9]*","");//Removes all non-numerical characters.
			ncScript.Patient.PatientAddress=new AddressOptionalType();
			ncScript.Patient.PatientAddress.address1=pat.Address;//May be blank.
			ncScript.Patient.PatientAddress.address2=pat.Address2;//May be blank.
			ncScript.Patient.PatientAddress.city=pat.City;//May be blank.
			ncScript.Patient.PatientAddress.state=pat.State;//May be blank. Validated in chart to be blank or to be a valid US state code.
			ncScript.Patient.PatientAddress.zip=pat.Zip;//May be blank.
			ncScript.Patient.PatientAddress.country=country;//Validated above.
			ncScript.Patient.PatientContact=new ContactType();
			ncScript.Patient.PatientContact.homeTelephone=pat.HmPhone;//May be blank. Does not need to be 10 digits.
			ncScript.Patient.PatientCharacteristics=new PatientCharacteristicsType();
			ncScript.Patient.PatientCharacteristics.dob=pat.Birthdate.ToString("yyyyMMdd");//DOB must be in CCYYMMDD format.
			if(pat.Gender==PatientGender.Male) {
				ncScript.Patient.PatientCharacteristics.gender=GenderType.M;
			}
			else if(pat.Gender==PatientGender.Female) {
				ncScript.Patient.PatientCharacteristics.gender=GenderType.F;
			}
			else {
				ncScript.Patient.PatientCharacteristics.gender=GenderType.U;
			}
			ncScript.Patient.PatientCharacteristics.genderSpecified=true;
			//NewCrop programmer's comments regarding other fields we are not currently using (these fields are sent back when fetching prescriptions in the Chart):
			//ExternalPrescriptionId = your unique identifier for the prescription, only to be used if you are generating the prescription on your own UI.
			//	This is referenced by NewCrop, and cannot be populated with any other value. 
			//EncounterIdentifier = unique ID for the patient visit (e.g. John Doe, 11/11/2013).
			//	This is used by NewCrop for reporting events against a visit, but otherwise does not impact the session. 
			//EpisodeIdentifier = unique ID for the patient’s issue (e.g. John Doe’s broken leg) which may include multiple visits.
			//	Currently not used by NewCrop except for being echoed back; it is possible this functionality would be expanded in the future based on its intent as noted. 
			//ExternalSource = a codified field noting the origin of the prescription. This may not be used.
			//Serialize
			MemoryStream memoryStream=new MemoryStream();
			XmlSerializer xmlSerializer=new XmlSerializer(typeof(NCScript));
			xmlSerializer.Serialize(memoryStream,ncScript);
			byte[] memoryStreamInBytes=memoryStream.ToArray();
			return Encoding.UTF8.GetString(memoryStreamInBytes,0,memoryStreamInBytes.Length);
		}
Esempio n. 22
0
 ///<summary>Each payment reconciliation request can return up to 9 pages. This function will return one etrans ack for each page in the result, since each page must be requested individually. Only for version 04, no such transaction exists for version 02. The provTreat and provBilling must be validated as CDANet providers before calling this function.</summary>
 public static List<Etrans> GetPaymentReconciliations(Carrier carrier,Provider provTreat,Provider provBilling,DateTime reconciliationDate)
 {
     Clearinghouse clearhouse=Canadian.GetClearinghouse();
     if(clearhouse==null) {
         throw new ApplicationException("Canadian clearinghouse not found.");
     }
     string saveFolder=clearhouse.ExportPath;
     if(!Directory.Exists(saveFolder)) {
         throw new ApplicationException(saveFolder+" not found.");
     }
     List<Etrans> etransAcks=new List<Etrans>();
     int pageNumber=1;
     int totalPages=1;
     do{
         StringBuilder strb=new StringBuilder();
         if((carrier.CanadianSupportedTypes&CanSupTransTypes.RequestForPaymentReconciliation_06)!=CanSupTransTypes.RequestForPaymentReconciliation_06) {
             throw new ApplicationException("The carrier does not support payment reconciliation transactions.");
         }
         if(carrier.CanadianNetworkNum==0) {
             throw new ApplicationException("Carrier network not set.");
         }
         CanadianNetwork network=CanadianNetworks.GetNetwork(carrier.CanadianNetworkNum);
         Etrans etrans=Etranss.CreateCanadianOutput(0,carrier.CarrierNum,carrier.CanadianNetworkNum,clearhouse.ClearinghouseNum,EtransType.RequestPay_CA,0,0);
         //A01 transaction prefix 12 AN
         strb.Append(Canadian.TidyAN(network.CanadianTransactionPrefix,12));
         //A02 office sequence number 6 N
         strb.Append(Canadian.TidyN(etrans.OfficeSequenceNumber,6));
         //A03 format version number 2 N
         strb.Append("04");
         //A04 transaction code 2 N
         strb.Append("06");//payment reconciliation request
         //A05 carrier id number 6 N
         if(network.CanadianIsRprHandler) {
             strb.Append("999999");//Always 999999 if the network handles the RPR requests instead of the carriers in the network.
         }
         else {
             strb.Append(carrier.ElectID);//already validated as 6 digit number.
         }
         //A06 software system id 3 AN
         strb.Append(Canadian.SoftwareSystemId());
         //A10 encryption method 1 N
         if(carrier!=null) {
             strb.Append(carrier.CanadianEncryptionMethod);//validated in UI
         }
         else {
             strb.Append("1");//No encryption when sending to a network.
         }
         //A07 message length N4
         strb.Append(Canadian.TidyN("77",5));
         //A09 carrier transaction counter 5 N
         strb.Append(Canadian.TidyN(etrans.CarrierTransCounter,5));
         //B01 CDA provider number 9 AN
         strb.Append(Canadian.TidyAN(provTreat.NationalProvID,9));//already validated
         //B02 (treating) provider office number 4 AN
         strb.Append(Canadian.TidyAN(provTreat.CanadianOfficeNum,4));//already validated
         //B03 billing provider number 9 AN
         //might need to account for possible 5 digit prov id assigned by carrier
         strb.Append(Canadian.TidyAN(provBilling.NationalProvID,9));//already validated
         //B04 billing provider office number 4 AN
         strb.Append(Canadian.TidyAN(provBilling.CanadianOfficeNum,4));//already validated
         //F33 Reconciliation Date 8 N
         strb.Append(reconciliationDate.ToString("yyyyMMdd"));
         //F38 Current Reconciliation Page Number N 1
         strb.Append(Canadian.TidyN(pageNumber,1));
         //End of message construction.
         string result="";
         bool resultIsError=false;
         try {
             result=Canadian.PassToIca(strb.ToString(),clearhouse);
         }
         catch(ApplicationException ex) {
             result=ex.Message;
             resultIsError=true;
             //Etranss.Delete(etrans.EtransNum);//we don't want to do this, because we want the incremented etrans.OfficeSequenceNumber to be saved
             //Attach an ack indicating failure.
         }
         //Attach an ack to the etrans
         Etrans etransAck=new Etrans();
         etransAck.PatNum=etrans.PatNum;
         etransAck.PlanNum=etrans.PlanNum;
         etransAck.InsSubNum=etrans.InsSubNum;
         etransAck.CarrierNum=etrans.CarrierNum;
         etransAck.DateTimeTrans=DateTime.Now;
         CCDFieldInputter fieldInputter=null;
         if(resultIsError) {
             etransAck.Etype=EtransType.AckError;
             etrans.Note="failed";
         }
         else {
             fieldInputter=new CCDFieldInputter(result);
             CCDField fieldG05=fieldInputter.GetFieldById("G05");
             if(fieldG05!=null) {
                 etransAck.AckCode=fieldG05.valuestr;
             }
             etransAck.Etype=fieldInputter.GetEtransType();
         }
         Etranss.Insert(etransAck);
         Etranss.SetMessage(etransAck.EtransNum,result);
         etrans.AckEtransNum=etransAck.EtransNum;
         Etranss.Update(etrans);
         Etranss.SetMessage(etrans.EtransNum,strb.ToString());
         etransAcks.Add(etransAck);
         if(resultIsError) {
             throw new ApplicationException(result);
         }
         CCDField fieldG62=fieldInputter.GetFieldById("G62");//Last reconciliation page number.
         totalPages=PIn.Int(fieldG62.valuestr);
         new FormCCDPrint(etrans,result,true);
         pageNumber++;
     } while(pageNumber<=totalPages);
     return etransAcks;
 }
Esempio n. 23
0
		public static string SendProviderColor(Provider prov) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetString(MethodBase.GetCurrentMethod(),prov);
			}
			if(prov.ProvColor.ToArgb()==Color.Fuchsia.ToArgb()) {
				return "fuchsiaOK";
			}
			return "error";
		}
Esempio n. 24
0
 //THIS TRANSACTION TYPE IS NOT USED BY ANY CANADIAN CARRIERS, AND IS NOT PART OF CERTIFICATION, EVEN THOUGH IT IS IN THE SPECIFICATIONS. WE NEED TO FIX BELOW COMMENTS AND MAKE THIS CODE FUNCTION MORE LIKE THE GetPaymentReconciliations() FUNCTION ABOVE.
 ///<summary>Does not exist in version 02 so only supported for version 04. Returns the request Etrans record. Usually pass in a carrier with network null.  If sending to a network, carrier will be null and we still don't see anywhere in the message format to specify network.  We expect to get clarification on this issue later. Validate provTreat as a CDANet provider before calling this function.</summary>
 public static Etrans GetSummaryReconciliation(Carrier carrier,CanadianNetwork network,Provider provTreat,DateTime reconciliationDate)
 {
     Clearinghouse clearhouse=Canadian.GetClearinghouse();
     if(clearhouse==null) {
         throw new ApplicationException("Canadian clearinghouse not found.");
     }
     string saveFolder=clearhouse.ExportPath;
     if(!Directory.Exists(saveFolder)) {
         throw new ApplicationException(saveFolder+" not found.");
     }
     StringBuilder strb=new StringBuilder();
     Etrans etrans=null;
     if(carrier!=null) {
         if((carrier.CanadianSupportedTypes&CanSupTransTypes.RequestForSummaryReconciliation_05)!=CanSupTransTypes.RequestForSummaryReconciliation_05) {
             throw new ApplicationException("The carrier does not support summary reconciliation transactions.");
         }
         etrans=Etranss.CreateCanadianOutput(0,carrier.CarrierNum,carrier.CanadianNetworkNum,
             clearhouse.ClearinghouseNum,EtransType.RequestSumm_CA,0,0);
     }
     else {//Assume network!=null
         etrans=Etranss.CreateCanadianOutput(0,0,network.CanadianNetworkNum,
             clearhouse.ClearinghouseNum,EtransType.RequestSumm_CA,0,0);
     }
     //A01 transaction prefix 12 AN
     strb.Append(Canadian.TidyAN(network.CanadianTransactionPrefix,12));
     //A02 office sequence number 6 N
     strb.Append(Canadian.TidyN(etrans.OfficeSequenceNumber,6));
     //A03 format version number 2 N
     strb.Append("04");
     //A04 transaction code 2 N
     strb.Append("05");//payment reconciliation request
     //A05 carrier id number 6 N
     if(carrier!=null) {
         strb.Append(carrier.ElectID);//already validated as 6 digit number.
     }
     else { //Assume network!=null
         strb.Append("999999");//Always 999999 when sending to a network.
     }
     //A06 software system id 3 AN
     strb.Append(Canadian.SoftwareSystemId());
     //A10 encryption method 1 N
     if(carrier!=null) {
         strb.Append(carrier.CanadianEncryptionMethod);//validated in UI
     }
     else { //Assume network!=null
         strb.Append("1");//No encryption when sending to a network.
     }
     //A07 message length N4
     strb.Append(Canadian.TidyN("63",5));
     //A09 carrier transaction counter 5 N
     strb.Append(Canadian.TidyN(etrans.CarrierTransCounter,5));
     //B01 CDA provider number 9 AN
     strb.Append(Canadian.TidyAN(provTreat.NationalProvID,9));//already validated
     //B02 (treating) provider office number 4 AN
     strb.Append(Canadian.TidyAN(provTreat.CanadianOfficeNum,4));//already validated
     //F33 Reconciliation Date 8 N
     strb.Append(reconciliationDate.ToString("yyyyMMdd"));
     //End of message construction.
     string result="";
     bool resultIsError=false;
     try {
         if(carrier!=null) {
             result=Canadian.PassToIca(strb.ToString(),clearhouse);
         }
         else { //Assume network!=null
             result=Canadian.PassToIca(strb.ToString(),clearhouse);
         }
     }
     catch(ApplicationException ex) {
         result=ex.Message;
         resultIsError=true;
         //Etranss.Delete(etrans.EtransNum);//we don't want to do this, because we want the incremented etrans.OfficeSequenceNumber to be saved
         //Attach an ack indicating failure.
     }
     //Attach an ack to the etrans
     Etrans etransAck=new Etrans();
     etransAck.PatNum=etrans.PatNum;
     etransAck.PlanNum=etrans.PlanNum;
     etransAck.InsSubNum=etrans.InsSubNum;
     etransAck.CarrierNum=etrans.CarrierNum;
     etransAck.DateTimeTrans=DateTime.Now;
     CCDFieldInputter fieldInputter=null;
     if(resultIsError) {
         etransAck.Etype=EtransType.AckError;
         etrans.Note="failed";
     }
     else {
         fieldInputter=new CCDFieldInputter(result);
         CCDField fieldG05=fieldInputter.GetFieldById("G05");
         if(fieldG05!=null) {
             etransAck.AckCode=fieldG05.valuestr;
         }
         etransAck.Etype=fieldInputter.GetEtransType();
     }
     Etranss.Insert(etransAck);
     Etranss.SetMessage(etransAck.EtransNum,result);
     etrans.AckEtransNum=etransAck.EtransNum;
     Etranss.Update(etrans);
     Etranss.SetMessage(etrans.EtransNum,strb.ToString());
     if(resultIsError) {
         throw new ApplicationException(result);
     }
     new FormCCDPrint(etrans,result,true);
     return etrans;
 }
Esempio n. 25
0
        ///<summary>In progress.  Probably needs a different name.  Info must be validated first.</summary>
        public static string GenerateMessageText(Clearinghouse clearhouse,Carrier carrier,Provider billProv,Clinic clinic,InsPlan insPlan,Patient subscriber,InsSub insSub)
        {
            int batchNum=Clearinghouses.GetNextBatchNumber(clearhouse);
            string groupControlNumber=batchNum.ToString();//Must be unique within file.  We will use batchNum
            int transactionNum=1;
            StringBuilder strb=new StringBuilder();
            //Interchange Control Header
            strb.AppendLine("ISA*00*          *"//ISA01,ISA02: 00 + 10 spaces
                +"00*          *"//ISA03,ISA04: 00 + 10 spaces
                +clearhouse.ISA05+"*"//ISA05: Sender ID type: ZZ=mutually defined. 30=TIN. Validated
                +X12Generator.GetISA06(clearhouse)+"*"//ISA06: Sender ID(TIN). Or might be TIN of Open Dental
                +clearhouse.ISA07+"*"//ISA07: Receiver ID type: ZZ=mutually defined. 30=TIN. Validated
                +Sout(clearhouse.ISA08,15,15)+"*"//ISA08: Receiver ID. Validated to make sure length is at least 2.
                +DateTime.Today.ToString("yyMMdd")+"*"//ISA09: today's date
                +DateTime.Now.ToString("HHmm")+"*"//ISA10: current time
                +"U*00401*"//ISA11 and ISA12.
                //ISA13: interchange control number, right aligned:
                +batchNum.ToString().PadLeft(9,'0')+"*"
                +"0*"//ISA14: no acknowledgment requested
                +clearhouse.ISA15+"*"//ISA15: T=Test P=Production. Validated.
                +":~");//ISA16: use ':'
            //Functional Group Header
            strb.AppendLine("GS*HS*"//GS01: HS for 270 benefit inquiry
                +X12Generator.GetGS02(clearhouse)+"*"//GS02: Senders Code. Sometimes Jordan Sparks.  Sometimes the sending clinic.
                +Sout(clearhouse.GS03,15,2)+"*"//GS03: Application Receiver's Code
                +DateTime.Today.ToString("yyyyMMdd")+"*"//GS04: today's date
                +DateTime.Now.ToString("HHmm")+"*"//GS05: current time
                +groupControlNumber+"*"//GS06: Group control number. Max length 9. No padding necessary.
                +"X*"//GS07: X
                +"004010X092~");//GS08: Version
            //Beginning of transaction--------------------------------------------------------------------------------
            int seg=0;//count segments for the ST-SE transaction
            //Transaction Set Header
            //ST02 Transact. control #. Must be unique within ISA
            seg++;
            strb.AppendLine("ST*270*"//ST01
                +transactionNum.ToString().PadLeft(4,'0')+"~");//ST02
            seg++;
            strb.AppendLine("BHT*0022*13*"//BHT02: 13=request
                +transactionNum.ToString().PadLeft(4,'0')+"*"//BHT03. Can be same as ST02
                +DateTime.Now.ToString("yyyyMMdd")+"*"//BHT04: Date
                +DateTime.Now.ToString("HHmmss")+"~");//BHT05: Time, BHT06: not used
            //HL Loops-----------------------------------------------------------------------------------------------
            int HLcount=1;
            //2000A HL: Information Source--------------------------------------------------------------------------
            seg++;
            strb.AppendLine("HL*"+HLcount.ToString()+"*"//HL01: Heirarchical ID.  Here, it's always 1.
                +"*"//HL02: No parent. Not used
                +"20*"//HL03: Heirarchical level code. 20=Information source
                +"1~");//HL04: Heirarchical child code. 1=child HL present
            //2100A NM1
            seg++;
            strb.AppendLine("NM1*PR*"//NM101: PR=Payer
                +"2*"//NM102: 2=Non person
                +Sout(carrier.CarrierName,35)+"*"//NM103: Name Last.
                +"****"//NM104-07 not used
                +"PI*"//NM108: PI=PayorID
                +Sout(carrier.ElectID,80,2)+"~");//NM109: PayorID. Validated to be at least length of 2.
            HLcount++;
            //2000B HL: Information Receiver------------------------------------------------------------------------
            seg++;
            strb.AppendLine("HL*"+HLcount.ToString()+"*"//HL01: Heirarchical ID.  Here, it's always 2.
                +"1*"//HL02: Heirarchical parent id number.  1 in this simple message.
                +"21*"//HL03: Heirarchical level code. 21=Information receiver
                +"1~");//HL04: Heirarchical child code. 1=child HL present
            seg++;
            //2100B NM1: Information Receiver Name
            strb.AppendLine("NM1*1P*"//NM101: 1P=Provider
                +(billProv.IsNotPerson?"2":"1")+"*"//NM102: 1=person,2=non-person
                +Sout(billProv.LName,35)+"*"//NM103: Last name
                +Sout(billProv.FName,25)+"*"//NM104: First name
                +Sout(billProv.MI,25,1)+"*"//NM105: Middle name
                +"*"//NM106: not used
                +"*"//NM107: Name suffix. not used
                +"XX*"//NM108: ID code qualifier. 24=EIN. 34=SSN, XX=NPI
                +Sout(billProv.NationalProvID,80)+"~");//NM109: ID code. NPI validated
            //2100B REF: Information Receiver ID
            seg++;
            strb.Append("REF*");
            if(billProv.UsingTIN) {
                strb.Append("TJ*");//REF01: qualifier. TJ=Federal TIN
            }
            else {//SSN
                strb.Append("SY*");//REF01: qualifier. SY=SSN
            }
            strb.AppendLine(Sout(billProv.SSN,30)+"~");//REF02: ID
            //2100B N3: Information Receiver Address
            seg++;
            if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
                strb.Append("N3*"+Sout(PrefC.GetString(PrefName.PracticeBillingAddress),55));//N301: Address
            }
            else if(clinic==null) {
                strb.Append("N3*"+Sout(PrefC.GetString(PrefName.PracticeAddress),55));//N301: Address
            }
            else {
                strb.Append("N3*"+Sout(clinic.Address,55));//N301: Address
            }
            if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
                if(PrefC.GetString(PrefName.PracticeBillingAddress2)=="") {
                    strb.AppendLine("~");
                }
                else {
                    //N302: Address2. Optional.
                    strb.AppendLine("*"+Sout(PrefC.GetString(PrefName.PracticeBillingAddress2),55)+"~");
                }
            }
            else if(clinic==null) {
                if(PrefC.GetString(PrefName.PracticeAddress2)=="") {
                    strb.AppendLine("~");
                }
                else {
                    //N302: Address2. Optional.
                    strb.AppendLine("*"+Sout(PrefC.GetString(PrefName.PracticeAddress2),55)+"~");
                }
            }
            else {
                if(clinic.Address2=="") {
                    strb.AppendLine("~");
                }
                else {
                    //N302: Address2. Optional.
                    strb.AppendLine("*"+Sout(clinic.Address2,55)+"~");
                }
            }
            //2100B N4: Information Receiver City/State/Zip
            seg++;
            if(PrefC.GetBool(PrefName.UseBillingAddressOnClaims)) {
                strb.AppendLine("N4*"+Sout(PrefC.GetString(PrefName.PracticeBillingCity),30)+"*"//N401: City
                    +Sout(PrefC.GetString(PrefName.PracticeBillingST),2)+"*"//N402: State
                    +Sout(PrefC.GetString(PrefName.PracticeBillingZip).Replace("-",""),15)+"~");//N403: Zip
            }
            else if(clinic==null) {
                strb.AppendLine("N4*"+Sout(PrefC.GetString(PrefName.PracticeCity),30)+"*"//N401: City
                    +Sout(PrefC.GetString(PrefName.PracticeST),2)+"*"//N402: State
                    +Sout(PrefC.GetString(PrefName.PracticeZip).Replace("-",""),15)+"~");//N403: Zip
            }
            else {
                strb.AppendLine("N4*"+Sout(clinic.City,30)+"*"//N401: City
                    +Sout(clinic.State,2)+"*"//N402: State
                    +Sout(clinic.Zip.Replace("-",""),15)+"~");//N403: Zip
            }
            //2100B PRV: Information Receiver Provider Info
            seg++;
            //PRV*PE*ZZ*1223G0001X~
            strb.AppendLine("PRV*PE*"//PRV01: Provider Code. PE=Performing.  There are many other choices.
                +"ZZ*"//PRV02: ZZ=Mutually defined = health care provider taxonomy code
                +X12Generator.GetTaxonomy(billProv)+"~");//PRV03: Specialty code
            HLcount++;
            //2000C HL: Subscriber-----------------------------------------------------------------------------------
            seg++;
            strb.AppendLine("HL*"+HLcount.ToString()+"*"//HL01: Heirarchical ID.  Here, it's always 3.
                +"2*"//HL02: Heirarchical parent id number.  2 in this simple message.
                +"22*"//HL03: Heirarchical level code. 22=Subscriber
                +"0~");//HL04: Heirarchical child code. 0=no child HL present (no dependent)
            //2000C TRN: Subscriber Trace Number
            seg++;
            strb.AppendLine("TRN*1*"//TRN01: Trace Type Code.  1=Current Transaction Trace Numbers
                +"1*"//TRN02: Trace Number.  We don't really have a good primary key yet.  Keep it simple. Use 1.
                +"1"+billProv.SSN+"~");//TRN03: Entity Identifier. First digit is 1=EIN.  Next 9 digits are EIN.  Length validated.
            //2100C NM1: Subscriber Name
            seg++;
            strb.AppendLine("NM1*IL*"//NM101: IL=Insured or Subscriber
                +"1*"//NM102: 1=Person
                +Sout(subscriber.LName,35)+"*"//NM103: LName
                +Sout(subscriber.FName,25)+"*"//NM104: FName
                +Sout(subscriber.MiddleI,25)+"*"//NM105: MiddleName
                +"*"//NM106: not used
                +"*"//NM107: suffix. Not present in Open Dental yet.
                +"MI*"//NM108: MI=MemberID
                +Sout(insSub.SubscriberID.Replace("-",""),80)+"~");//NM109: Subscriber ID. Validated to be L>2.
            //2100C REF: Subscriber Additional Information.  Without this, old plans seem to be frequently returned.
            seg++;
            strb.AppendLine("REF*6P*"//REF01: 6P=GroupNumber
                +Sout(insPlan.GroupNum,30)+"~");//REF02: Supplemental ID. Validated.
            //2100C DMG: Subscriber Demographic Information
            seg++;
            strb.AppendLine("DMG*D8*"//DMG01: Date Time Period Qualifier.  D8=CCYYMMDD
                +subscriber.Birthdate.ToString("yyyyMMdd")+"~");//DMG02: Subscriber birthdate.  Validated
                //DMG03: Gender code.  Situational.  F or M.  Since this was left out in the example,
                //and since we don't want to send the wrong gender, we will not send this element.
            //2100C DTP: Subscriber Date.  Deduced through trial and error that this is required by EHG even though not by X12 specs.
            seg++;
            strb.AppendLine("DTP*307*"//DTP01: Qualifier.  307=Eligibility
                +"D8*"//DTP02: Format Qualifier.
                +DateTime.Today.ToString("yyyyMMdd")+"~");//DTP03: Date
            //2110C EQ: Subscriber Eligibility or Benefit Enquiry Information
            //We can loop this 99 times to request very specific benefits.
            //strb.AppendLine("EQ*30~");//EQ01: 30=General Coverage
            seg++;
            strb.AppendLine("EQ*23~");//Diagnostic
            seg++;
            strb.AppendLine("EQ*4~");//Diagnostic Xray
            seg++;
            strb.AppendLine("EQ*41~");//Routine Preventive
            seg++;
            strb.AppendLine("EQ*25~");//Restorative
            seg++;
            strb.AppendLine("EQ*26~");//Endo
            seg++;
            strb.AppendLine("EQ*24~");//Perio
            seg++;
            strb.AppendLine("EQ*40~");//Oral Surgery
            seg++;
            strb.AppendLine("EQ*36~");//Crowns
            seg++;
            strb.AppendLine("EQ*39~");//Prosth
            seg++;
            strb.AppendLine("EQ*27~");//Maxillofacial Prosth
            seg++;
            strb.AppendLine("EQ*37~");//Accident
            seg++;
            strb.AppendLine("EQ*38~");//Ortho
            seg++;
            strb.AppendLine("EQ*28~");//Adjunctive
            //
            //2000D If we add a dependent loop it would go here.  It would be about 20 lines.
            //2100D, etc
            //EQ series, etc.
            //Not allowed to send this unless subscriber and dependent are different
            //We would also have to add code to process the EBs which distinguishes between subscribers and dependents.
            //
            //Transaction Trailer
            seg++;
            strb.AppendLine("SE*"
                +seg.ToString()+"*"//SE01: Total segments, including ST & SE
                +transactionNum.ToString().PadLeft(4,'0')+"~");
            //End of transaction--------------------------------------------------------------------------------------
            //Functional Group Trailer
            strb.AppendLine("GE*"+transactionNum.ToString()+"*"//GE01: Number of transaction sets included
                +groupControlNumber+"~");//GE02: Group Control number. Must be identical to GS06
            //Interchange Control Trailer
            strb.AppendLine("IEA*1*"//IEA01: number of functional groups
                +batchNum.ToString().PadLeft(9,'0')+"~");//IEA02: Interchange control number
            return strb.ToString();
            /*
            return @"
            ISA*00*          *00*          *30*AA0989922      *30*330989922      *030519*1608*U*00401*000012145*1*T*:~
            GS*HS*AA0989922*330989922*20030519*1608*12145*X*004010X092~
            ST*270*0001~
            BHT*0022*13*ASX012145WEB*20030519*1608~
            HL*1**20*1~
            NM1*PR*2*Metlife*****PI*65978~
            HL*2*1*21*1~
            NM1*1P*1*PROVLAST*PROVFIRST****XX*1234567893~
            REF*TJ*200384584~
            N3*JUNIT ROAD~
            N4*CHICAGO*IL*60602~
            PRV*PE*ZZ*1223G0001X~
            HL*3*2*22*0~
            TRN*1*12145*1AA0989922~
            NM1*IL*1*SUBLASTNAME*SUBFIRSTNAME****MI*123456789~
            DMG*D8*19750323~
            DTP*307*D8*20030519~
            EQ*30~
            SE*17*0001~
            GE*1*12145~
            IEA*1*000012145~";
            */

            //return "ISA*00*          *00*          *30*AA0989922      *30*330989922      *030519*1608*U*00401*000012145*1*T*:~GS*HS*AA0989922*330989922*20030519*1608*12145*X*004010X092~ST*270*0001~BHT*0022*13*ASX012145WEB*20030519*1608~HL*1**20*1~NM1*PR*2*Metlife*****PI*65978~HL*2*1*21*1~NM1*1P*1*PROVLAST*PROVFIRST****XX*1234567893~REF*TJ*200384584~N3*JUNIT ROAD~N4*CHICAGO*IL*60602~PRV*PE*ZZ*1223G0001X~HL*3*2*22*0~TRN*1*12145*1AA0989922~NM1*IL*1*SUBLASTNAME*SUBFIRSTNAME****MI*123456789~DMG*D8*19750323~DTP*307*D8*20030519~EQ*30~SE*17*0001~GE*1*12145~IEA*1*000012145~";
        }
Esempio n. 26
0
		private void fillContext() {
			//Fill Patient-------------------------------------------------------------------------------------------------------------------
			if(PatCur!=null) {
				textPatName.Text=PatCur.GetNameFL();
				if(PatCur.Birthdate!=DateTime.MinValue) {
					textPatBirth.Text=PatCur.Birthdate.ToShortDateString();
				}
				comboPatLang.SelectedIndex=comboPatLang.Items.IndexOf(System.Globalization.CultureInfo.CurrentCulture.DisplayName);
				switch(PatCur.Gender) {
					case PatientGender.Female:
						radioPatGenFem.Checked=true;
						break;
					case PatientGender.Male:
						radioPatGenMale.Checked=true;
						break;
					case PatientGender.Unknown:
					default:
						radioPatGenUn.Checked=true;
						break;
				}
			}
			//Fill Provider------------------------------------------------------------------------------------------------------------------
			if(ProvCur==null && PatCur!=null) {
				ProvCur=Providers.GetProv(PatCur.PriProv);
			}
			if(ProvCur==null) {
				ProvCur=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
			}
			if(ProvCur!=null) {
				textProvName.Text=ProvCur.GetFormalName();
				textProvID.Text=ProvCur.NationalProvID;
				comboProvLang.SelectedIndex=comboPatLang.Items.IndexOf(System.Globalization.CultureInfo.CurrentCulture.DisplayName);
			}
			//Fill Organization--------------------------------------------------------------------------------------------------------------
			textOrgName.Text=PrefC.GetString(PrefName.PracticeTitle);
			//Fill Encounter-----------------------------------------------------------------------------------------------------------------
			ActEC=ActEncounterCode.AMB;
			comboEncType.SelectedIndex=(int)ActEC;//ambulatory
			if(PatCur!=null) {
				textEncLocID.Text=PatCur.ClinicNum.ToString();//do not use to generate message if this value is zero.
			}
			//Fill Requestor/Recievor--------------------------------------------------------------------------------------------------------
			radioReqProv.Checked=PerformerIsProvider;
			radioReqPat.Checked=!PerformerIsProvider;
			radioRecProv.Checked=RecipientIsProvider;
			radioRecPat.Checked=!RecipientIsProvider;
			//Fill Task Type-----------------------------------------------------------------------------------------------------------------
			ActTC=ActTaskCode.PATINFO;//may need to change this later.
			comboTask.SelectedIndex=(int)ActTC;
		}
		private static string Run(int scriptNum,Carrier carrier,CanadianNetwork network,Provider prov,out Etrans etrans,DateTime reconciliationDate) {
			string retVal="";
			etrans=CanadianOutput.GetSummaryReconciliation(carrier,network,prov,reconciliationDate);
			retVal+="Summary Reconciliation#"+scriptNum.ToString()+" successful.\r\n";
			return retVal;
		}
Esempio n. 28
0
File: FormEHR.cs Progetto: mnisl/OD
		private void FormEHR_Shown(object sender,EventArgs e) {
			ResultOnClosing=EhrFormResult.None;
			PatCur=Patients.GetPat(PatNum);
			ProvPat=Providers.GetProv(PatCur.PriProv);
			labelProvPat.Text=ProvPat.GetLongDesc();
			if(EhrProvKeys.GetKeysByFLName(ProvPat.LName,ProvPat.FName).Count==0) {
				labelProvPat.Text+=" (no ehr provider key entered)";
			}
			if(Security.CurUser.ProvNum==0) {
				labelProvUser.Text="none";
			}
			else {
				Provider provUser=Providers.GetProv(Security.CurUser.ProvNum);
				labelProvUser.Text=Providers.GetLongDesc(provUser.ProvNum);
				if(EhrProvKeys.GetKeysByFLName(provUser.LName,provUser.FName).Count==0) {
					labelProvUser.Text+=" (no ehr provider key entered)";
				}
			}
			FillGridMu();
			if(OnShowLaunchOrders) {
				//LaunchOrdersWindow();
				OnShowLaunchOrders=false;
			}
			//We already indicate that the patient's provider does not have an ehr key entered in labelProvPat.  No need for a popup.
			//This is so that non-ehr providers can still use many of our ehr features.  E.g. vital signs.
			//if(ProvPat.EhrKey=="") {
			//	MessageBox.Show("No ehr provider key entered for this patient's primary provider.");
			//}
		}
Esempio n. 29
0
		/// <summary></summary>
		public static string RunAll() {
			string retVal="";
			//GetString
			string strResult=WebServiceTests.GetString("Input");
			if(strResult!="Input-Processed"){
				throw new Exception("Should be Input-Processed");
			}
			retVal+="GetString: Passed.\r\n";
			strResult=WebServiceTests.GetStringNull("Input");
			if(strResult!=null){
				throw new Exception("Should be null");
			}
			retVal+="GetStringNull: Passed.\r\n";
			strResult=WebServiceTests.GetStringCarriageReturn("Carriage\r\nReturn");
			if(strResult!="Carriage\r\nReturn-Processed") {
				throw new Exception("Should be Carriage\r\nReturn-Processed");
			}
			retVal+="GetStringCarriageReturn: Passed.\r\n";
			//GetInt
			int intResult=WebServiceTests.GetInt(1);
			if(intResult!=2){
				throw new Exception("Should be 2");
			}
			retVal+="GetInt: Passed.\r\n";
			//GetLong
			long longResult=WebServiceTests.GetLong(1);
			if(longResult!=2){
				throw new Exception("Should be 2");
			}
			retVal+="GetLong: Passed.\r\n";
			//GetVoid
			WebServiceTests.GetVoid();
			retVal+="GetVoid: Passed.\r\n";
			//GetBool
			bool boolResult=WebServiceTests.GetBool();
			if(boolResult!=true){
				throw new Exception("Should be true");
			}
			retVal+="GetBool: Passed.\r\n";
			//GetObject
			Patient pat=WebServiceTests.GetObjectPat();
			if(pat.LName!="Smith"){
				throw new Exception("Should be Smith");
			}
			if(pat.FName!=null){
				throw new Exception("Should be null");
			}
			retVal+="GetObjectPat: Passed.\r\n";
			//GetTable
			DataTable table=WebServiceTests.GetTable();
			if(table.Rows[0][0].ToString()!="cell00"){
				throw new Exception("Should be cell00");
			}
			retVal+="GetTable: Passed.\r\n";
			//GetTable with carriage return
			table=WebServiceTests.GetTableCarriageReturn();
			if(table.Rows[0][0].ToString()!="cell\r\n00"){
				throw new Exception("Should be cell\r\n00");
			}
			retVal+="GetTableCarriageReturn: Passed.\r\n";
			//Get2by3
			table=WebServiceTests.GetTable2by3();
			for(int i=0;i<table.Rows.Count;i++) {
				for(int j=0;j<table.Columns.Count;j++) {
					if(table.Rows[i][j].ToString()!="cell"+i.ToString()+j.ToString()) {
						throw new Exception("Should be cell"+i.ToString()+j.ToString());
					}
				}
			}
			retVal+="GetTable2by3: Passed.\r\n";
			//GetSpecialChars
			table=WebServiceTests.GetTableSpecialChars();
			char[] chars={'|','<','>','&','\'','"','\\','/'};
			for(int i=0;i<table.Rows.Count;i++) {
				for(int j=0;j<table.Columns.Count;j++) {
					if(table.Rows[i][j].ToString()!="cell"+i.ToString()+j.ToString()+chars[i*2+j].ToString()) {
						throw new Exception("Should be cell"+i.ToString()+j.ToString()+chars[i*2+j].ToString());
					}
				}
			}
			retVal+="GetTableSpecialChars: Passed.\r\n";
			//GetDataTypes
			table=WebServiceTests.GetTableDataTypes();
			if(table.Rows[0][0].GetType()!=typeof(string)) {
				throw new Exception("Should be "+typeof(string).ToString());
			}
			if(table.Rows[0][1].GetType()!=typeof(decimal)) {
				throw new Exception("Should be "+typeof(decimal).ToString());
			}
			if(table.Rows[0][2].GetType()!=typeof(DateTime)) {
				throw new Exception("Should be "+typeof(DateTime).ToString());
			}
			retVal+="GetTableDataTypes: Passed.\r\n";
			//GetDataSet
			DataSet ds=WebServiceTests.GetDataSet();
			if(ds.Tables[0].TableName!="table0"){
				throw new Exception("Should be table0");
			}
			retVal+="GetDataSet: Passed.\r\n";
			//GetList
			List<int> listInt=WebServiceTests.GetListInt();
			if(listInt[0]!=2){
				throw new Exception("Should be 2");
			}
			retVal+="GetListInt: Passed.\r\n";
			//GetArrayPatient
			Patient[] arrayPat=WebServiceTests.GetArrayPatient();
			if(arrayPat[0].LName!="Jones"){
				throw new Exception("Should be Jones");
			}
			if(arrayPat[1]!=null){
				throw new Exception("Should be null");
			}
			retVal+="GetArrayPatient: Passed.\r\n";
			//SendNullParam
			strResult=WebServiceTests.SendNullParam(null);
			if(strResult!="nullOK"){
				throw new Exception("Should be nullOK");
			}
			retVal+="SendNullParam: Passed.\r\n";
			//GetObjectNull
			Patient pat2=WebServiceTests.GetObjectNull();
			if(pat2!=null){
				throw new Exception("Should be null");
			}
			retVal+="GetObjectNull: Passed.\r\n";
			//SendColorParam
			Color colorResult=WebServiceTests.SendColorParam(Color.Fuchsia);
			if(colorResult.ToArgb()!=Color.Green.ToArgb()) {
				throw new Exception("Should be green.");
			}
			retVal+="SendColorParam: Passed.\r\n";
			//SendProviderColor
			Provider prov=new Provider();
			prov.ProvColor=Color.Fuchsia;
			strResult=WebServiceTests.SendProviderColor(prov);
			if(strResult!="fuchsiaOK") {
				throw new Exception("Should be fuchsiaOK.");
			}
			retVal+="SendProviderColor: Passed.\r\n";
			//SendSheetParameter
			SheetParameter sheetParam=new SheetParameter(false,"ParamNameOK");
			strResult=WebServiceTests.SendSheetParameter(sheetParam);
			if(strResult!="paramNameOK") {
				throw new Exception("Should be paramNameOK.");
			}
			retVal+="SendSheetParameter: Passed.\r\n";
			//SendSheetWithFields
			Sheet sheet=new Sheet();
			sheet.SheetFields=new List<SheetField>();
			sheet.Parameters=new List<SheetParameter>();
			SheetField field=new SheetField();
			field.FieldName="FieldNameGreen";
			sheet.SheetFields.Add(field);
			strResult=WebServiceTests.SendSheetWithFields(sheet);
			if(strResult!="fieldOK") {
				throw new Exception("Should be fieldOK.");
			}
			retVal+="SendSheetWithFields: Passed.\r\n";
			//SendSheetDefWithFields
			SheetDef sheetdef=new SheetDef();
			sheetdef.SheetFieldDefs=new List<SheetFieldDef>();
			sheetdef.Parameters=new List<SheetParameter>();
			SheetFieldDef fielddef=new SheetFieldDef();
			fielddef.FieldName="FieldNameTeal";
			sheetdef.SheetFieldDefs.Add(fielddef);
			strResult=WebServiceTests.SendSheetDefWithFieldDefs(sheetdef);
			if(strResult!="fielddefOK") {
				throw new Exception("Should be fielddefOK.");
			}
			retVal+="SendSheetDefWithFieldDefs: Passed.\r\n";
			//TimeSpanNeg
			TimeSpan tspan=WebServiceTests.GetTimeSpan();
			if(tspan!=new TimeSpan(1,0,0)) {
				throw new Exception("Should be 1 hour.");
			}
			retVal+="GetTimeSpan: Passed.\r\n";
			//GetStringContainingCR
			strResult=WebServiceTests.GetStringContainingCR();
			//strResult=strResult.Replace("\\r","\r");
			if(strResult!="Line1\r\nLine2") {
				throw new Exception("Should be Line1\r\nLine2");
			}
			retVal+="GetStringContainingCR: Passed.\r\n";
			/*
			//GetListTasksContainingCR
			Task task=WebServiceTests.GetListTasksContainingCR()[0];
			if(task.Descript!="Line1\r\nLine2") {
				throw new Exception("Should be Line1\r\nLine2");
			}
			retVal+="GetListTasksContainingCR: Passed.\r\n";*/


			
			return retVal;
		}
Esempio n. 30
0
		///<summary>Generates SiteID REF G5 for Emdeon only.</summary>
		private static void Write2010AASiteIDforEmdeon(StreamWriter sw,Provider prov,string payorID) {
			ProviderIdent[] provIdents=ProviderIdents.GetForPayor(prov.ProvNum,payorID);
			for(int i=0;i<provIdents.Length;i++) {
				if(provIdents[i].SuppIDType==ProviderSupplementalID.SiteNumber) {
					sw.Write("REF"+s
						+"G5"+s//REF01 2/3 Reference Identification Qualifier: 
						+Sout(provIdents[i].IDNumber,50));//REF02 1/50 Reference Identification:
					EndSegment(sw);//REF03 and REF04 are not used.
				}
			}
		}