Avatar of kwh3856
kwh3856
Flag for United States of America

asked on 

Object reference not set to an instance of an object.

I am trying to assign a field in a table a value.  I keep getting this error message even when I have assigned the object a variable.  What am I missing?


MyGlobalVars.ssn = myUser.ssn;
                    MyGlobalVars.sex = myUser.sex;-----------Object is assigned Data Here ---
                }
                //-------------   Got dob, ssn, and sex   --------------------
 
 
                //--------- Lookup Information from PatientInfo Table  ---------
                var filteredpatinfolist = from patinfo in dceClinicalWorks.patientinfos
                                       where patinfo.pid == patient.p.pid
                                       select new { patinfo };
 
                foreach (var patinforec in filteredpatinfolist)
                {
                    patientinfo myPatinfo = new patientinfo();
                    // Put variables here
 
                }
                //---
 
 
 
                Console.WriteLine(String.Format("{0},{1},{2}", patient.p.pid, patient.p.ControlNo, patient.p.employername));
                Console.ReadLine();
 
 
 
                // ------- Instantiate Chart Relay Tables to Write To
                MPI myMPI = new MPI();
                PATIENT myCRpatient = new PATIENT();
                PATIENT_PHONE_NUMBER myPatPhones = new PATIENT_PHONE_NUMBER();
                Patient_Address myPatAddresses = new Patient_Address();
                PATIENTS_ATTENDED_BY_DOCTOR myPatAttByDoc = new PATIENTS_ATTENDED_BY_DOCTOR();
                PATIENT_IN myPatIns = new PATIENT_IN();
                EMPLOYER myPatEmployers = new EMPLOYER();
                BillingAlert myPatBillAlerts = new BillingAlert();
                EligibilityStatus myPatElgStatus = new EligibilityStatus();
 
                
 
 
 
                // ===================     Collect MPI Table Information ===================
                //
                //
                MyGlobalVars.initGuid = Guid.NewGuid();
                myMPI.MPI1 = MyGlobalVars.initGuid;
                myMPI.NPI = MyGlobalVars.docnpi;
                myMPI.ModifiedDate = DateTime.Today;
                
                int myPatAcctNum;
                if (Int32.TryParse(patient.p.pid.ToString(), out myPatAcctNum))
                {
                    // Success! myInt now contains the numeric value of myString
                    myMPI.EntitySystemAcctNum = myPatAcctNum.ToString();
                    MyGlobalVars.patacctnum = myPatAcctNum.ToString();
                }
                else
                {
                    // Failed! MyInt is not defined.
                }
 
                myMPI.EntitySystemModifiedDate = DateTime.Today;
                myMPI.SYSTEM_TYPE = "eClinicalWorks";
                myMPI.DOB = MyGlobalVars.dob;
                myMPI.SSN = MyGlobalVars.ssn;
                myMPI.Sex = MyGlobalVars.sex.ToUpper();   ----------   Error Occurs Here  ------

Open in new window

.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon