/// <summary>
        /// Generation interactions based on a #
        /// </summary>
        /// <param name="profiles">the number of profiles to create</param>
        /// <returns>Give back a list of the speicfic type of interactions generated</returns>
        public static new List <Profile> GenerateProfilesByCount(int profiles, object configuration)
        {
            try
            {
                SampleDataCache.InitializeDataCache();

                List <Profile> listAccounts = new List <Profile>();

                for (int i = 0; i < profiles; i++)
                {
                    Organization a = new Organization();

                    SampleDataCache.AddressInfo addressInfo = SampleDataCache.AddressInfos[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.AddressInfos.Count - 1)];

                    a.Name = SampleDataCache.Accounts[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Accounts.Count - 1)];

                    a.Address1City            = addressInfo.City;
                    a.Address1Country         = addressInfo.Country;
                    a.Address1Line1           = addressInfo.Address;
                    a.Telephone1              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(business)
                    a.Address1PostalCode      = addressInfo.Zipcode;
                    a.Address1StateOrProvince = addressInfo.State;

                    listAccounts.Add(a);
                }

                return(listAccounts);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Example #2
0
        /// <summary>
        /// Generation interactions based on a #
        /// </summary>
        /// <param name="profiles">the number of profiles to create</param>
        /// <returns>Give back a list of the speicfic type of interactions generated</returns>
        public static new List <Profile> GenerateProfilesByCount(int profiles, object configuration)
        {
            try
            {
                SampleDataCache.InitializeDataCache();

                //SampleDataCache.RandomDateTime birthDayrdt = new SampleDataCache.RandomDateTime(1955, 1, 1, new DateTime(2000, 1, 1));

                List <Profile> listContacts = new List <Profile>();

                for (int i = 0; i < profiles; i++)
                {
                    ////generate our fake data
                    Contact a = new Contact();

                    int maleorfemale = SampleDataCache.SelectRandomItem.Next(1, 100);

                    a.FirstName = maleorfemale < 50 ? SampleDataCache.Malenames[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Malenames.Count - 1)] : SampleDataCache.Femalenames[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Femalenames.Count - 1)];

                    a.LastName = SampleDataCache.Lastnames[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Lastnames.Count - 1)];


                    //a.PrimaryLanguageCode = SampleDataCache.Languages[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Languages.Count - 1)];

                    a.PrimaryLanguageCode = SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.Language.ToString()]
                                            .Values.ElementAt(SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.Language.ToString()]
                                                                                                    .Values.Count - 1)).Key;

                    SampleDataCache.AddressInfo addressInfo = SampleDataCache.AddressInfos[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.AddressInfos.Count - 1)];

                    a.Address1City            = addressInfo.City;
                    a.Address1Country         = addressInfo.Country;
                    a.Address1Line1           = addressInfo.Address;
                    a.Telephone1              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(business)
                    a.MobilePhone             = addressInfo.Areacode + "-" + addressInfo.Telephone;
                    a.Telephone2              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(home)
                    a.Address1PostalCode      = addressInfo.Zipcode;
                    a.Address1StateOrProvince = addressInfo.State;
                    a.Age            = SampleDataCache.SelectRandomItem.Next(18, 100);
                    a.EmailAddress1  = a.FirstName + "_" + a.LastName + "@testlive.com";
                    a.FullName       = a.FirstName + " " + a.LastName;
                    a.GenderCode     = maleorfemale < 50 ? (int)ContactGenderCode.Male : (int)ContactGenderCode.Female;
                    a.Salutation     = maleorfemale < 50 ? "Mr." : "Mrs.";
                    a.CDMContactType = ProfileType.Standard;
                    a.BirthDate      = birthDayRandomGenerator.Next();

                    listContacts.Add(a);
                }

                return(listContacts);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// Generation interactions based on a #
        /// </summary>
        /// <param name="profiles">the number of profiles to create</param>
        /// <returns>Give back a list of the speicfic type of interactions generated</returns>
        public static new List <Profile> GenerateProfilesByCount(int profiles, object configuration)
        {
            try
            {
                SampleDataCache.InitializeDataCache();

                List <Profile>       listPatients = new List <Profile>();
                List <RelatedPerson> listRelatedPersons;
                List <Practitioner>  listPractitioners;
                List <Organization>  listOrganizations = null;

                //SampleDataCache.RandomDateTime birthDayrdt = new SampleDataCache.RandomDateTime(1955, 1, 1, new DateTime(2000, 1, 1));

                for (int i = 0; i < profiles; i++)
                {
                    ////generate our fake data
                    Patient a = new Patient();

                    a.PatientConfiguration = ((PatientConfiguration)(configuration));

                    int maleorfemale = SampleDataCache.SelectRandomItem.Next(1, 100);

                    a.FirstName = maleorfemale < 50 ? SampleDataCache.Malenames[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Malenames.Count - 1)] : SampleDataCache.Femalenames[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Femalenames.Count - 1)];
                    a.LastName  = SampleDataCache.Lastnames[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Lastnames.Count - 1)];

                    SampleDataCache.AddressInfo addressInfo = SampleDataCache.AddressInfos[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.AddressInfos.Count - 1)];

                    // Now set the Emergency and Primary Contact etc
                    string practitionersfile  = a.PatientConfiguration.PractionerFileName;
                    string relatedpersonsfile = a.PatientConfiguration.RelatedPersonsFileName;
                    string locationsfile      = a.patientConfiguration.LocationsFileName;
                    string organizationsfile  = a.patientConfiguration.AccountsFileName;

                    if (!string.IsNullOrEmpty(locationsfile))
                    {
                        // this will get used in multiple places lower on
                        a.Locations = Location.ImportProfiles(locationsfile);
                    }

                    if (!string.IsNullOrEmpty(organizationsfile))
                    {
                        // this will get used in multiple places lower on
                        listOrganizations = Organization.ImportProfiles(organizationsfile);
                    }

                    if (!string.IsNullOrEmpty(relatedpersonsfile))
                    {
                        listRelatedPersons = RelatedPerson.ImportProfiles(relatedpersonsfile);

                        if (listRelatedPersons != null)
                        {
                            Profile emergencyContact = listRelatedPersons[SampleDataCache.SelectRandomItem.Next(0, listRelatedPersons.Count - 1)];
                            Profile primaryContact   = listRelatedPersons[SampleDataCache.SelectRandomItem.Next(0, listRelatedPersons.Count - 1)];

                            a.EmergencyContactId = emergencyContact.ContactId;
                            a.PrimaryContactId   = primaryContact.ContactId;

                            a.EmergencyContactRelationshipTypeId = SampleDataCache.RelatedPersonTypes[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.RelatedPersonTypes.Count - 1)];
                            a.PrimaryContactRelationshipTypeId   = SampleDataCache.RelatedPersonTypes[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.RelatedPersonTypes.Count - 1)];
                        }
                    }

                    if (!string.IsNullOrEmpty(practitionersfile))
                    {
                        listPractitioners = Practitioner.ImportProfiles(practitionersfile);

                        if (listPractitioners != null)
                        {
                            Profile primaryPractitioner = listPractitioners[SampleDataCache.SelectRandomItem.Next(0, listPractitioners.Count - 1)];

                            a.PrimaryPractitionerId = primaryPractitioner.ContactId;
                        }
                    }

                    if (a.PatientConfiguration.AllergyIntoleranceCount > 0)
                    {
                        for (int iAllergies = 0; iAllergies < a.PatientConfiguration.AllergyIntoleranceCount; iAllergies++)
                        {
                            AllergyIntolerance ai = new AllergyIntolerance();
                            a.AllergyIntolerances.Add(ai);
                        }
                    }

                    if (a.PatientConfiguration.NutritionOrderCount > 0)
                    {
                        for (int iNutritionOrders = 0; iNutritionOrders < a.PatientConfiguration.NutritionOrderCount; iNutritionOrders++)
                        {
                            NutritionOrder no = new NutritionOrder();
                            a.NutritionOrders.Add(no);
                        }
                    }


                    if (a.PatientConfiguration.ConditionCount > 0)
                    {
                        for (int iConditions = 0; iConditions < a.PatientConfiguration.ConditionCount; iConditions++)
                        {
                            Condition condition = new Condition();

                            condition.VerificationStatus = HealthCDMEnums.RandomEnumInt <HealthCDMEnums.Condition_Verificationstatus>();
                            a.Conditions.Add(condition);
                        }
                    }

                    if (a.PatientConfiguration.DeviceCount > 0)
                    {
                        for (int iDevice = 0; iDevice < a.PatientConfiguration.DeviceCount; iDevice++)
                        {
                            Device device = new Device();

                            if (a.Locations != null)
                            {
                                Location location = a.Locations[SampleDataCache.SelectRandomItem.Next(0, a.Locations.Count - 1)];

                                device.LocationId = location.LocationId;
                            }

                            a.Devices.Add(device);
                        }
                    }

                    if (a.PatientConfiguration.ProcedureCount > 0)
                    {
                        for (int iProcedure = 0; iProcedure < a.PatientConfiguration.ProcedureCount; iProcedure++)
                        {
                            Procedure procedure = new Procedure();

                            if (a.Locations != null)
                            {
                                Location location = a.Locations[SampleDataCache.SelectRandomItem.Next(0, a.Locations.Count - 1)];

                                procedure.LocationId = location.LocationId;
                            }

                            a.Procedures.Add(procedure);
                        }
                    }

                    if (a.PatientConfiguration.ReferralCount > 0)
                    {
                        for (int iReferral = 0; iReferral < a.PatientConfiguration.ReferralCount; iReferral++)
                        {
                            ReferralRequest request = new ReferralRequest();
                            a.ReferralRequests.Add(request);
                        }
                    }

                    // COMPLETE THIS ONE THE ENCOUNTERS ARE DONE
                    if (a.PatientConfiguration.MedicationCount > 0)
                    {
                        for (int iMedication = 0; iMedication < a.PatientConfiguration.MedicationCount; iMedication++)
                        {
                            MedicationRequest medication = new MedicationRequest();
                            a.MedicationRequests.Add(medication);
                        }
                    }

                    if (a.PatientConfiguration.EpisodesOfCareCount > 0)
                    {
                        for (int iEpisode = 0; iEpisode < a.PatientConfiguration.EpisodesOfCareCount; iEpisode++)
                        {
                            EpisodeOfCare episode = new EpisodeOfCare();

                            episode.PractitionerId = a.PrimaryPractitionerId;
                            episode.Description    = a.FullName + " - Episode of Care";
                            episode.AccountId      = listOrganizations[SampleDataCache.SelectRandomItem.Next(0, listOrganizations.Count - 1)].OrganizationId;

                            a.EpisodesOfCare.Add(episode);
                        }
                    }

                    if (a.PatientConfiguration.EncountersCount > 0)
                    {
                        for (int iEncounter = 0; iEncounter < a.PatientConfiguration.EncountersCount; iEncounter++)
                        {
                            Encounter encounter = new Encounter();

                            if (a.Locations != null)
                            {
                                Location location = a.Locations[SampleDataCache.SelectRandomItem.Next(0, a.Locations.Count - 1)];

                                encounter.HospitalizationOriginId      = location.LocationId;
                                encounter.HospitalizationDestinationId = location.LocationId;
                            }

                            a.Encounters.Add(encounter);
                        }
                    }

                    if (a.PatientConfiguration.AppointmentCount > 0)
                    {
                        for (int iAppointment = 0; iAppointment < a.PatientConfiguration.AppointmentCount; iAppointment++)
                        {
                            Appointment appointment = new Appointment();


                            if (a.Locations != null)
                            {
                                Location location = a.Locations[SampleDataCache.SelectRandomItem.Next(0, a.Locations.Count - 1)];

                                appointment.LocationId = location.LocationId;
                            }

                            appointment.PractitionerId = a.PrimaryPractitionerId;

                            a.Appointments.Add(appointment);
                        }
                    }

                    if (a.PatientConfiguration.CarePlanCount > 0)
                    {
                        CarePlan careplan = new CarePlan();

                        a.Careplans.Add(careplan);
                    }


                    if (a.PatientConfiguration.CareTeamCount > 0)
                    {
                        CareTeam team = new CareTeam();

                        a.Careteams.Add(team);
                    }

                    if (a.PatientConfiguration.RiskAssessmentCount > 0)
                    {
                        for (int iAssessment = 0; iAssessment < a.PatientConfiguration.RiskAssessmentCount; iAssessment++)
                        {
                            RiskAssessment assessment = new RiskAssessment();

                            a.RiskAssessments.Add(assessment);
                        }
                    }

                    if (a.PatientConfiguration.SpecimenCount > 0)
                    {
                        for (int iSpecimen = 0; iSpecimen < a.PatientConfiguration.SpecimenCount; iSpecimen++)
                        {
                            Specimen specimen = new DataModel.Specimen();
                            a.Specimens.Add(specimen);
                        }
                    }

                    if (a.PatientConfiguration.TaskCount > 0)
                    {
                        for (int iTask = 0; iTask < a.PatientConfiguration.TaskCount; iTask++)
                        {
                            PatientTask task = new PatientTask();
                            a.Tasks.Add(task);
                        }
                    }

                    if (a.PatientConfiguration.ProductCount > 0)
                    {
                        for (int iProduct = 0; iProduct < a.PatientConfiguration.ProductCount; iProduct++)
                        {
                            Medication product = new Medication();
                            a.Products.Add(product);
                        }
                    }

                    a.PrimaryLanguageCode = SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.Language.ToString()]
                                            .Values.ElementAt(SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.Language.ToString()]
                                                                                                    .Values.Count - 1)).Key;


                    a.Address1City            = addressInfo.City;
                    a.Address1Country         = addressInfo.Country;
                    a.Address1Line1           = addressInfo.Address;
                    a.Telephone1              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(business)
                    a.MobilePhone             = addressInfo.Areacode + "-" + addressInfo.Telephone;
                    a.Telephone2              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(home)
                    a.Address1PostalCode      = addressInfo.Zipcode;
                    a.Address1StateOrProvince = addressInfo.State;
                    a.Age                  = SampleDataCache.SelectRandomItem.Next(18, 100);
                    a.EmailAddress1        = a.FirstName + "_" + a.LastName + "@testlive.com";
                    a.FullName             = a.FirstName + " " + a.LastName;
                    a.GenderCode           = maleorfemale < 50 ? (int)ContactGenderCode.Male : (int)ContactGenderCode.Female;
                    a.Salutation           = maleorfemale < 50 ? "Mr." : "Mrs.";
                    a.CDMContactType       = ProfileType.Patient;
                    a.PatientMedicalNumber = GenerateMedicalNumber();
                    a.BirthDate            = birthDayRandomGenerator.Next();

                    listPatients.Add(a);
                }

                return(listPatients);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Example #4
0
        public static new List <Profile> GenerateProfilesByCount(int profiles, object configuration)
        {
            try
            {
                string accountsFile = (string)configuration;

                SampleDataCache.InitializeDataCache();
                SampleDataCache.GenerateRandomDateTime rdt = new SampleDataCache.GenerateRandomDateTime(2010, 1, 1, DateTime.Today);

                List <Profile>      listAccounts = new List <Profile>();
                List <Organization> listOrganizations;

                for (int i = 0; i < profiles; i++)
                {
                    Location a = new Location();

                    SampleDataCache.AddressInfo addressInfo = SampleDataCache.AddressInfos[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.AddressInfos.Count - 1)];

                    a.Name = SampleDataCache.Accounts[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Accounts.Count - 1)];

                    a.Address1City            = addressInfo.City;
                    a.Address1Country         = addressInfo.Country;
                    a.Address1Line1           = addressInfo.Address;
                    a.Address1PostalCode      = addressInfo.Zipcode;
                    a.Address1StateOrProvince = addressInfo.State;

                    a.PeriodStart = rdt.Next();
                    a.PeriodEnd   = rdt.AddYears(a.PeriodStart, 5, 10);

                    a.AddressType = HealthCDMEnums.RandomEnumInt <HealthCDMEnums.Location_Addresstype>();
                    a.AddressUse  = HealthCDMEnums.RandomEnumInt <HealthCDMEnums.Location_Addressuse>();

                    a.LocationNumber = GenerateRandomNumber(10);

                    a.Mode = (int)HealthCDMEnums.Location_Mode.instance;
                    //a.OrganizationId = (string)configuration;

                    a.OperationalStatus = HealthCDMEnums.RandomEnumInt <HealthCDMEnums.Location_Operationalstatus>();

                    //a.LocationType = SampleDataCache.Accounts[SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.Accounts.Count - 1)];
                    a.LocationType = SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.LocationType.ToString()]
                                     .Values.ElementAt(SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.LocationType.ToString()]
                                                                                             .Values.Count - 1)).Key;

                    if (!string.IsNullOrEmpty(accountsFile))
                    {
                        listOrganizations = Organization.ImportProfiles(accountsFile);

                        if (listOrganizations != null)
                        {
                            Organization account = listOrganizations[SampleDataCache.SelectRandomItem.Next(0, listOrganizations.Count - 1)];

                            a.OrganizationId = account.OrganizationId;
                        }
                    }

                    listAccounts.Add(a);
                }

                return(listAccounts);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
        /// <summary>
        /// Generation interactions based on a #
        /// </summary>
        /// <param name="profiles">the number of profiles to create</param>
        /// <returns>Give back a list of the speicfic type of interactions generated</returns>
        public static new List <Profile> GenerateProfilesByCount(int profiles, object configuration)
        {
            try
            {
                //SampleDataCache.RandomDateTime birthDayrdt = new SampleDataCache.RandomDateTime(1955, 1, 1, new DateTime(2000, 1, 1));

                SampleDataCache.InitializeFakeDataHelpers();

                List <Profile> listContacts   = new List <Profile>();
                int            roles          = ((PractitionerConfiguration)(configuration)).Roles;
                int            qualifications = ((PractitionerConfiguration)(configuration)).Qualifications;

                for (int i = 0; i < profiles; i++)
                {
                    ////generate our fake data
                    Practitioner a = new Practitioner();

                    a.PractitionerConfiguration = ((PractitionerConfiguration)(configuration));

                    int maleorfemale = SampleDataCache.RandomContactGenerator.Next(1, 100);

                    a.FirstName = maleorfemale < 50 ? SampleDataCache.Malenames[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Malenames.Count - 1)] : SampleDataCache.Femalenames[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Femalenames.Count - 1)];
                    a.LastName  = SampleDataCache.Lastnames[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Lastnames.Count - 1)];

                    SampleDataCache.AddressInfo addressInfo = SampleDataCache.AddressInfos[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.AddressInfos.Count - 1)];

                    a.PrimaryLanguageCode = SampleDataCache.Languages[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Languages.Count - 1)];

                    a.Address1City            = addressInfo.City;
                    a.Address1Country         = addressInfo.Country;
                    a.Address1Line1           = addressInfo.Address;
                    a.Telephone1              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(business)
                    a.MobilePhone             = addressInfo.Areacode + "-" + addressInfo.Telephone;
                    a.Telephone2              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(home)
                    a.Address1PostalCode      = addressInfo.Zipcode;
                    a.Address1StateOrProvince = addressInfo.State;
                    a.Age            = SampleDataCache.RandomContactGenerator.Next(18, 100);
                    a.EmailAddress1  = a.FirstName + "_" + a.LastName + "@testlive.com";
                    a.FullName       = a.FirstName + " " + a.LastName;
                    a.GenderCode     = maleorfemale < 50 ? (int)ContactGenderCode.Male : (int)ContactGenderCode.Female;
                    a.Salutation     = SampleDataCache.PractitionerSalutations[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.PractitionerSalutations.Count - 1)];
                    a.CDMContactType = ContactType.Practitioner;
                    a.BirthDate      = birthDayRandomGenerator.Next();

                    if (roles >= 1)
                    {
                        for (int r = 0; r < roles; r++)
                        {
                            PractitionerRole pr = new PractitionerRole();
                            a.Roles.Add(pr);
                        }
                    }

                    if (qualifications >= 1)
                    {
                        for (int q = 0; q < roles; q++)
                        {
                            PractitionerQualification pq = new PractitionerQualification();
                            a.Qualifications.Add(pq);
                        }
                    }

                    listContacts.Add(a);
                }

                return(listContacts);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Example #6
0
        /// <summary>
        /// Generation interactions based on a #
        /// </summary>
        /// <param name="profiles">the number of profiles to create</param>
        /// <returns>Give back a list of the speicfic type of interactions generated</returns>
        public static new List <Profile> GenerateProfilesByCount(int profiles, object configuration)
        {
            try
            {
                SampleDataCache.InitializeFakeDataHelpers();

                List <Profile>       listPatients = new List <Profile>();
                List <RelatedPerson> listRelatedPersons;
                List <Practitioner>  listPractitioners;

                //SampleDataCache.RandomDateTime birthDayrdt = new SampleDataCache.RandomDateTime(1955, 1, 1, new DateTime(2000, 1, 1));

                for (int i = 0; i < profiles; i++)
                {
                    ////generate our fake data
                    Patient a = new Patient();

                    a.PatientConfiguration = ((PatientConfiguration)(configuration));

                    int maleorfemale = SampleDataCache.RandomContactGenerator.Next(1, 100);

                    a.FirstName = maleorfemale < 50 ? SampleDataCache.Malenames[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Malenames.Count - 1)] : SampleDataCache.Femalenames[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Femalenames.Count - 1)];
                    a.LastName  = SampleDataCache.Lastnames[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Lastnames.Count - 1)];

                    SampleDataCache.AddressInfo addressInfo = SampleDataCache.AddressInfos[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.AddressInfos.Count - 1)];

                    // Now set the Emergency and Primary Contact etc
                    string practitionersfile  = a.PatientConfiguration.PractionerFileName;
                    string relatedpersonsfile = a.PatientConfiguration.RelatedPersonsFileName;

                    if (!string.IsNullOrEmpty(relatedpersonsfile))
                    {
                        listRelatedPersons = RelatedPerson.ImportProfiles(relatedpersonsfile);

                        if (listRelatedPersons != null)
                        {
                            Profile emergencyContact = listRelatedPersons[SampleDataCache.RandomContactGenerator.Next(0, listRelatedPersons.Count - 1)];
                            Profile primaryContact   = listRelatedPersons[SampleDataCache.RandomContactGenerator.Next(0, listRelatedPersons.Count - 1)];

                            a.EmergencyContactId = emergencyContact.ContactId;
                            a.PrimaryContactId   = primaryContact.ContactId;

                            a.EmergencyContactRelationshipTypeId = SampleDataCache.RelatedPersonTypes[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.RelatedPersonTypes.Count - 1)];
                            a.PrimaryContactRelationshipTypeId   = SampleDataCache.RelatedPersonTypes[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.RelatedPersonTypes.Count - 1)];
                        }
                    }

                    if (!string.IsNullOrEmpty(practitionersfile))
                    {
                        listPractitioners = Practitioner.ImportProfiles(practitionersfile);

                        if (listPractitioners != null)
                        {
                            Profile primaryPractitioner = listPractitioners[SampleDataCache.RandomContactGenerator.Next(0, listPractitioners.Count - 1)];

                            a.PrimaryPractitionerId = primaryPractitioner.ContactId;
                        }
                    }

                    if (a.PatientConfiguration.AllergyIntoleranceCount > 0)
                    {
                        for (int iAllergies = 0; iAllergies < a.PatientConfiguration.AllergyIntoleranceCount; iAllergies++)
                        {
                            AllergyIntolerance ai = new AllergyIntolerance();
                            a.AllergyIntolerances.Add(ai);
                        }
                    }

                    if (a.PatientConfiguration.NutritionOrderCount > 0)
                    {
                        for (int iNutritionOrders = 0; iNutritionOrders < a.PatientConfiguration.NutritionOrderCount; iNutritionOrders++)
                        {
                            NutritionOrder no = new NutritionOrder();
                            a.NutritionOrders.Add(no);
                        }
                    }


                    if (a.PatientConfiguration.ConditionCount > 0)
                    {
                        for (int iConditions = 0; iConditions < a.PatientConfiguration.ConditionCount; iConditions++)
                        {
                            Condition condition = new Condition();

                            condition.VerificationStatus = HealthCDMEnums.RandomEnumInt <HealthCDMEnums.Condition_Verificationstatus>();
                            a.Conditions.Add(condition);
                        }
                    }

                    if (a.PatientConfiguration.DeviceCount > 0)
                    {
                        for (int iDevice = 0; iDevice < a.PatientConfiguration.DeviceCount; iDevice++)
                        {
                            Device device = new Device();
                            a.Devices.Add(device);
                        }
                    }

                    if (a.PatientConfiguration.ProcedureCount > 0)
                    {
                        for (int iProcedure = 0; iProcedure < a.PatientConfiguration.ProcedureCount; iProcedure++)
                        {
                            Procedure procedure = new Procedure();
                            a.Procedures.Add(procedure);
                        }
                    }

                    if (a.PatientConfiguration.ReferralCount > 0)
                    {
                        for (int iReferral = 0; iReferral < a.PatientConfiguration.ReferralCount; iReferral++)
                        {
                            ReferralRequest request = new ReferralRequest();
                            a.ReferralRequests.Add(request);
                        }
                    }

                    if (a.PatientConfiguration.MedicationCount > 0)
                    {
                        for (int iMedication = 0; iMedication < a.PatientConfiguration.MedicationCount; iMedication++)
                        {
                            MedicationRequest medication = new MedicationRequest();
                            a.MedicationRequests.Add(medication);
                        }
                    }

                    a.PrimaryLanguageCode = SampleDataCache.Languages[SampleDataCache.RandomContactGenerator.Next(0, SampleDataCache.Languages.Count - 1)];


                    a.Address1City            = addressInfo.City;
                    a.Address1Country         = addressInfo.Country;
                    a.Address1Line1           = addressInfo.Address;
                    a.Telephone1              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(business)
                    a.MobilePhone             = addressInfo.Areacode + "-" + addressInfo.Telephone;
                    a.Telephone2              = addressInfo.Areacode + "-" + addressInfo.Telephone; //(home)
                    a.Address1PostalCode      = addressInfo.Zipcode;
                    a.Address1StateOrProvince = addressInfo.State;
                    a.Age                  = SampleDataCache.RandomContactGenerator.Next(18, 100);
                    a.EmailAddress1        = a.FirstName + "_" + a.LastName + "@testlive.com";
                    a.FullName             = a.FirstName + " " + a.LastName;
                    a.GenderCode           = maleorfemale < 50 ? (int)ContactGenderCode.Male : (int)ContactGenderCode.Female;
                    a.Salutation           = maleorfemale < 50 ? "Mr." : "Mrs.";
                    a.CDMContactType       = ContactType.Patient;
                    a.PatientMedicalNumber = GenerateMedicalNumber();
                    a.BirthDate            = birthDayRandomGenerator.Next();

                    listPatients.Add(a);
                }

                return(listPatients);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }