public string FillInformantInfo(ClinicalDocument clinicalDoc, Factory hl7factory, III hl7III, PatientClinicalInformation patientinfo)
        {
            string informantdetais = string.Empty;
            var    informant       = clinicalDoc.Informant.Append();

            //assignedEntity.Time.AsDateTime = DateTime.Now;
            //var assignedAuthor = assignedEntity.AssignedAuthor;
            hl7III = informant.AsAssignedEntity.Id.Append();
            hl7III.Init("2.16.840.1.113883.4.6", "KP00017");
            IPN AsName = hl7factory.CreatePN();

            addressphno         = new GenerateAddressPhNo();
            addressinfo         = new AddressModel();///Fill Clinic Address
            addressinfo.street  = patientinfo.ptClinicInformation.ClinicStreeet;
            addressinfo.city    = patientinfo.ptClinicInformation.ClinicCity;
            addressinfo.state   = patientinfo.ptClinicInformation.ClinicState;
            addressinfo.country = patientinfo.ptClinicInformation.ClinicCountry;
            addressinfo.pinCode = patientinfo.ptClinicInformation.ClinicZip.ToString();
            informant.AsAssignedEntity.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory)); ///END

            contactinfo             = new PhNoModel();                                                 ///FIll Clinic Contact Number
            contactinfo.telcomUse   = "WP";
            contactinfo.telcomValue = patientinfo.ptClinicInformation.ClinicPhoneNumber;
            contactinfo.nullFlavor  = "UNK";
            informant.AsAssignedEntity.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory)); ///END

            AsName   = informant.AsAssignedEntity.AssignedPerson.Name.Append();                        ///Manage Clinic Name
            nameinfo = new NameModel();
            nameinfo.Createengiven = patientinfo.ptClinicInformation.ClinicName;
            addressphno.FillName(nameinfo, AsName, hl7factory);///FIll Clinic Name

            informantdetais = clinicalDoc.Xml;
            return(informantdetais);
        }
        public void GenerateProcedureEntry(ProcedureList patientProcedure, int refid, PatientClinicalInformation patientinfo, III hl7III, Factory hl7factory)
        {
            IEntry Entry = functionalStatus.Section.Entry.Append();

            Entry.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            Entry.AsObservation.ClassCode = "OBS";
            hl7III = Entry.AsObservation.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.13");
            hl7III = Entry.AsObservation.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            Entry.AsObservation.Code.Code           = patientProcedure.CPTCodes;
            Entry.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.6.96";
            Entry.AsObservation.Code.CodeSystemName = "CPT";
            Entry.AsObservation.Code.DisplayName    = patientProcedure.Description;
            Entry.AsObservation.Code.OriginalText.Reference.Value = ("#Proc" + (refid + 1).ToString());
            Entry.AsObservation.StatusCode.Code          = "completed";
            Entry.AsObservation.EffectiveTime.NullFlavor = "UNK";
            Entry.AsObservation.PriorityCode.NullFlavor  = "UNK";
            CD obsValueAsCD = new CD();

            obsValueAsCD.OriginalText.Reference.Value = ("#Proc" + (refid + 1).ToString());
            Entry.AsObservation.Value.Add(obsValueAsCD);
            if (patientinfo.ptClinicInformation.ClinicName != null)
            {
                addressphno             = new GenerateAddressPhNo();
                addressinfo             = new AddressModel();///Fill Clinic Address
                addressinfo.street      = patientinfo.ptClinicInformation.ClinicStreeet;
                addressinfo.city        = patientinfo.ptClinicInformation.ClinicCity;
                addressinfo.state       = patientinfo.ptClinicInformation.ClinicState;
                addressinfo.country     = patientinfo.ptClinicInformation.ClinicCountry;
                addressinfo.pinCode     = patientinfo.ptClinicInformation.ClinicZip.ToString();
                contactinfo             = new PhNoModel();///FIll Clinic Contact Number
                contactinfo.telcomUse   = "WP";
                contactinfo.telcomValue = patientinfo.ptClinicInformation.ClinicPhoneNumber;
                contactinfo.nullFlavor  = "UNK";
            }
            var Performer = Entry.AsObservation.Performer.Append();

            hl7III = Performer.AssignedEntity.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            Performer.AssignedEntity.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory));
            Performer.AssignedEntity.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory));
            hl7III = Performer.AssignedEntity.RepresentedOrganization.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            IAD hl7IADInterface = hl7factory.CreateAD();

            hl7IADInterface.NullFlavor = "UNK";
            Performer.AssignedEntity.RepresentedOrganization.Addr.Add(hl7IADInterface);
            ITEL telcom = hl7factory.CreateTEL();

            telcom            = hl7factory.CreateTEL();
            telcom.NullFlavor = "UNK";
            Performer.AssignedEntity.RepresentedOrganization.Telecom.Add(telcom);
        }
        public string FillAuthorInfo(ClinicalDocument clinicalDoc, Factory hl7factory, III hl7III, PatientClinicalInformation patientinfo)
        {
            string authordetais = string.Empty;
            //var targetrole = clinicalDoc.RecordTarget.Append();
            var authors = clinicalDoc.Author.Append();

            authors.Time.AsDateTime = DateTime.Now;
            var assignedAuthor = authors.AssignedAuthor;

            hl7III = assignedAuthor.Id.Append();
            hl7III.Init("2.16.840.1.113883.4.6", "999999");
            assignedAuthor.Code.Code           = "200000000X";
            assignedAuthor.Code.CodeSystem     = "2.16.840.1.113883.6.101";
            assignedAuthor.Code.CodeSystemName = "NUCC";
            assignedAuthor.Code.DisplayName    = "Allopathic & Osteopathic Physicians";
            IPN   AsName = hl7factory.CreatePN();
            IENXP Ienxn  = hl7factory.CreateENXP();

            addressphno         = new GenerateAddressPhNo();
            addressinfo         = new AddressModel();///Fill Clinic Address
            addressinfo.street  = patientinfo.ptClinicInformation.ClinicStreeet;
            addressinfo.city    = patientinfo.ptClinicInformation.ClinicCity;
            addressinfo.state   = patientinfo.ptClinicInformation.ClinicState;
            addressinfo.country = patientinfo.ptClinicInformation.ClinicCountry;
            addressinfo.pinCode = patientinfo.ptClinicInformation.ClinicZip.ToString();
            assignedAuthor.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory)); ///END

            contactinfo             = new PhNoModel();                                     ///FIll Clinic Contact Number
            contactinfo.telcomUse   = "WP";
            contactinfo.telcomValue = patientinfo.ptClinicInformation.ClinicPhoneNumber;
            contactinfo.nullFlavor  = "UNK";
            assignedAuthor.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory)); ///END

            AsName   = assignedAuthor.AsPerson.Name.Append();                              ///Manage Clinic Name
            nameinfo = new NameModel();
            nameinfo.Createengiven = patientinfo.ptClinicInformation.ClinicName;
            //nameinfo.Createenfamily = patientinfo.LastName;
            addressphno.FillName(nameinfo, AsName, hl7factory);///FIll Clinic Name

            authordetais = clinicalDoc.Xml;
            return(authordetais);
        }
Ejemplo n.º 4
0
        public string FillLegalAuthenticatorInfo(ClinicalDocument clinicalDoc, Factory hl7factory, III hl7III, PatientClinicalInformation patientinfo)
        {
            string legalAuthenticatordetais = string.Empty;
            var    assignedEntity           = clinicalDoc.LegalAuthenticator.AssignedEntity;

            clinicalDoc.LegalAuthenticator.Time.Init(DateTime.Now);
            clinicalDoc.LegalAuthenticator.SignatureCode.Init("S");
            hl7III = assignedEntity.Id.Append();
            hl7III.Init("2.16.840.1.113883.4.6", "KP00017");
            assignedEntity.Code.Code           = "207QA0505X";
            assignedEntity.Code.CodeSystem     = "2.16.840.1.113883.6.101";
            assignedEntity.Code.CodeSystemName = "NUCC";
            assignedEntity.Code.DisplayName    = "Adult Medicine";
            IPN AsName = hl7factory.CreatePN();

            addressphno         = new GenerateAddressPhNo();
            addressinfo         = new AddressModel();///Fill Clinic Address
            addressinfo.street  = patientinfo.ptClinicInformation.ClinicStreeet;
            addressinfo.city    = patientinfo.ptClinicInformation.ClinicCity;
            addressinfo.state   = patientinfo.ptClinicInformation.ClinicState;
            addressinfo.country = patientinfo.ptClinicInformation.ClinicCountry;
            addressinfo.pinCode = patientinfo.ptClinicInformation.ClinicZip.ToString();
            assignedEntity.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory)); ///END

            contactinfo             = new PhNoModel();                                     ///FIll Clinic Contact Number
            contactinfo.telcomUse   = "WP";
            contactinfo.telcomValue = patientinfo.ptClinicInformation.ClinicPhoneNumber;
            contactinfo.nullFlavor  = "UNK";
            assignedEntity.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory)); ///END

            AsName   = assignedEntity.AssignedPerson.Name.Append();                        ///Manage Clinic Name
            nameinfo = new NameModel();
            nameinfo.Createengiven = patientinfo.ptClinicInformation.ClinicName;
            addressphno.FillName(nameinfo, AsName, hl7factory);///FIll Clinic Name

            legalAuthenticatordetais = clinicalDoc.Xml;
            return(legalAuthenticatordetais);
        }
        public string FillParticipantInfo(ClinicalDocument clinicalDoc, Factory hl7factory, III hl7III, PatientClinicalInformation patientinfo)
        {
            string participantdetais = string.Empty;
            var    participant       = clinicalDoc.Participant.Append();
            var    times             = hl7factory.CreateIVXB_TS();

            times.Init(DateTime.Now);
            IPN AsName = hl7factory.CreatePN();

            participant.TypeCode = "IND";
            participant.Time.Init(null, times, times);
            participant.AssociatedEntity.ClassCode       = "CAREGIVER";
            participant.AssociatedEntity.Code.Code       = "MTH";
            participant.AssociatedEntity.Code.CodeSystem = "2.16.840.1.113883.5.111";
            addressphno         = new GenerateAddressPhNo();
            addressinfo         = new AddressModel();///Fill Clinic Address
            addressinfo.street  = patientinfo.ptClinicInformation.ClinicStreeet;
            addressinfo.city    = patientinfo.ptClinicInformation.ClinicCity;
            addressinfo.state   = patientinfo.ptClinicInformation.ClinicState;
            addressinfo.country = patientinfo.ptClinicInformation.ClinicCountry;
            addressinfo.pinCode = patientinfo.ptClinicInformation.ClinicZip.ToString();
            participant.AssociatedEntity.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory)); ///END

            contactinfo             = new PhNoModel();                                                   ///FIll Clinic Contact Number
            contactinfo.telcomUse   = "WP";
            contactinfo.telcomValue = patientinfo.ptClinicInformation.ClinicPhoneNumber;
            contactinfo.nullFlavor  = "UNK";
            participant.AssociatedEntity.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory)); ///END

            AsName   = participant.AssociatedEntity.AssociatedPerson.Name.Append();                      ///Manage Clinic Name
            nameinfo = new NameModel();
            nameinfo.Createengiven = patientinfo.ptClinicInformation.ClinicName;
            addressphno.FillName(nameinfo, AsName, hl7factory);///FIll Clinic Name

            participantdetais = clinicalDoc.Xml;
            return(participantdetais);
        }
Ejemplo n.º 6
0
        public string FillDocumentationOf(ClinicalDocument clinicalDoc, Factory hl7factory, III hl7III, PatientClinicalInformation patientinfo)
        {
            string documentationOfdetais = string.Empty;

            addressphno         = new GenerateAddressPhNo();
            addressinfo         = new AddressModel();///Fill Clinic Address
            addressinfo.street  = patientinfo.ptClinicInformation.ClinicStreeet;
            addressinfo.city    = patientinfo.ptClinicInformation.ClinicCity;
            addressinfo.state   = patientinfo.ptClinicInformation.ClinicState;
            addressinfo.country = patientinfo.ptClinicInformation.ClinicCountry;
            addressinfo.pinCode = patientinfo.ptClinicInformation.ClinicZip.ToString();

            contactinfo           = new PhNoModel();///FIll Clinic Contact Number
            contactinfo.telcomUse = "WP";
            //contactinfo.telcomValue = patientinfo.ClinicPhoneNumber;
            contactinfo.nullFlavor = "UNK";



            var docof = clinicalDoc.DocumentationOf.Append();
            int count = 0;

            foreach (DocumentationOfList item in patientinfo.documentationOfInfo)
            {
                IVXB_TS low = new IVXB_TS();
                docof.ServiceEvent.ClassCode           = "PCPR";
                docof.ServiceEvent.Code.Code           = "99214";
                docof.ServiceEvent.Code.CodeSystem     = "2.16.840.1.113883.6.12";
                docof.ServiceEvent.Code.CodeSystemName = "CPT4";
                docof.ServiceEvent.Code.DisplayName    = "Office Visit";
                var performer = docof.ServiceEvent.Performer.Append();

                performer.TypeCode = x_ServiceEventPerformer.PRF;
                if (count == 0)
                {
                    low.Init(Convert.ToDateTime(item.date));
                    docof.ServiceEvent.EffectiveTime = new IVL_TS().Init(low: low);
                    performer.FunctionCode.Code      = "PP";
                }
                else
                {
                    if (Convert.ToDateTime(item.date).Date < Convert.ToDateTime(patientinfo.documentationOfInfo[count - 1].date).Date)
                    {
                        low.Init(Convert.ToDateTime(item.date));
                        docof.ServiceEvent.EffectiveTime = new IVL_TS().Init(low: low);
                    }
                    performer.FunctionCode.Code = "SP";
                }
                performer.FunctionCode.DisplayName    = "Care Provider";
                performer.FunctionCode.CodeSystem     = "2.16.840.1.113883.12.443";
                performer.FunctionCode.CodeSystemName = "Provider Role";
                low.Init(Convert.ToDateTime(item.date));
                performer.Time = new IVL_TS().Init(low: low);
                var id = performer.AssignedEntity.Id.Append();
                id.Init("2.16.840.1.113883.4.6", "111111111", "NPI");
                performer.AssignedEntity.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory));
                contactinfo.telcomValue = "mailto: info @drummondgroup.com";
                performer.AssignedEntity.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory));
                IPN AsName = hl7factory.CreatePN();
                AsName   = performer.AssignedEntity.AssignedPerson.Name.Append();///Manage Clinic Name
                nameinfo = new NameModel();
                //nameinfo.Createengiven = patientinfo.ClinicName;
                nameinfo.Createenfamily = item.staffName;
                addressphno.FillName(nameinfo, AsName, hl7factory);///FIll Clinic Name
                count++;
            }
            documentationOfdetais = clinicalDoc.Xml;
            return(documentationOfdetais);
        }
        public void GenerateEncounterEntry(Encounters ptEncounters, PatientClinicalInformation patientinfo, int refid, III hl7III, Factory hl7factory)
        {
            var Entry = functionalStatus.Section.Entry.Append();

            Entry.AsEncounter.ClassCode = "ENC";
            Entry.AsEncounter.MoodCode  = x_DocumentEncounterMood.EVN;
            hl7III = Entry.AsEncounter.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.49");
            hl7III = Entry.AsEncounter.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            Entry.AsEncounter.Code.Code           = "99212";
            Entry.AsEncounter.Code.DisplayName    = "Outpatient Visit";
            Entry.AsEncounter.Code.CodeSystem     = "2.16.840.1.113883.6.12";
            Entry.AsEncounter.Code.CodeSystemName = "CPT";
            IVXB_TS low = new IVXB_TS();

            low.Init(Convert.ToDateTime(ptEncounters.EncounterDate));
            Entry.AsEncounter.EffectiveTime = new IVL_TS().Init(low: low);
            var performer = Entry.AsEncounter.Performer.Append();

            hl7III = performer.AssignedEntity.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            performer.AssignedEntity.Code.Code           = "59058001";
            performer.AssignedEntity.Code.CodeSystem     = "2.16.840.1.113883.6.96";
            performer.AssignedEntity.Code.CodeSystemName = "SNOMED CT";
            performer.AssignedEntity.Code.DisplayName    = "General Physician";
            var Participant = Entry.AsEncounter.Participant.Append();

            Participant.TypeCode = "LOC";
            Participant.ParticipantRole.ClassCode = "SDLOC";
            hl7III = Participant.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.32");
            Participant.ParticipantRole.Code.Code           = "1117-1";
            Participant.ParticipantRole.Code.CodeSystem     = "2.16.840.1.113883.6.259";
            Participant.ParticipantRole.Code.CodeSystemName = "HealthcareServiceLocation";
            Participant.ParticipantRole.Code.DisplayName    = "Family Medicine Clinic";

            addressphno         = new GenerateAddressPhNo();
            addressinfo         = new AddressModel();///Fill Clinic Address
            addressinfo.street  = patientinfo.ptClinicInformation.ClinicStreeet;
            addressinfo.city    = patientinfo.ptClinicInformation.ClinicCity;
            addressinfo.state   = patientinfo.ptClinicInformation.ClinicState;
            addressinfo.country = patientinfo.ptClinicInformation.ClinicCountry;
            addressinfo.pinCode = patientinfo.ptClinicInformation.ClinicZip.ToString();
            Participant.ParticipantRole.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory)); ///END

            contactinfo             = new PhNoModel();                                                  ///FIll Clinic Contact Number
            contactinfo.telcomUse   = "WP";
            contactinfo.telcomValue = patientinfo.ptClinicInformation.ClinicPhoneNumber;
            contactinfo.nullFlavor  = "UNK";
            Participant.ParticipantRole.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory)); ///END

            var Rel = Entry.AsEncounter.EntryRelationship.Append();

            Rel.TypeCode = x_ActRelationshipEntryRelationship.RSON;
            Rel.AsObservation.ClassCode = "OBS";
            Rel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            hl7III = Rel.AsObservation.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.19");
            hl7III = Rel.AsObservation.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            Rel.AsObservation.Code.Code           = "404684003";
            Rel.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.6.96";
            Rel.AsObservation.Code.CodeSystemName = "SNOMED CT";
            Rel.AsObservation.Code.DisplayName    = "Finding";
            Rel.AsObservation.StatusCode.Code     = "completed";
            Rel.AsObservation.EffectiveTime       = new IVL_TS().Init(low: low);
            CD obsValueAsCD = new CD();

            obsValueAsCD.Code        = ptEncounters.Code;
            obsValueAsCD.DisplayName = Convert.ToString(ptEncounters.EncounterDescription);
            obsValueAsCD.CodeSystem  = "2.16.840.1.113883.6.96";
            Rel.AsObservation.Value.Add(obsValueAsCD);
            Rel                 = Entry.AsEncounter.EntryRelationship.Append();
            Rel.TypeCode        = x_ActRelationshipEntryRelationship.SUBJ;
            Rel.AsAct.ClassCode = 0;
            Rel.AsAct.MoodCode  = x_DocumentActMood.EVN;
            hl7III              = Rel.AsAct.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.80");
            hl7III = Rel.AsAct.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            Rel.AsAct.Code.Code           = "29308-4";
            Rel.AsAct.Code.CodeSystem     = "2.16.840.1.113883.6.1";
            Rel.AsAct.Code.CodeSystemName = "LOINC";
            Rel.AsAct.Code.DisplayName    = "ENCOUNTER DIAGNOSIS";
            Rel.AsAct.StatusCode.Code     = "active";
            Rel.AsAct.EffectiveTime       = new IVL_TS().Init(low: low);
            var SubRel = Rel.AsAct.EntryRelationship.Append();

            SubRel.TypeCode = x_ActRelationshipEntryRelationship.SUBJ;
            SubRel.AsObservation.ClassCode = "OBS";
            SubRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            hl7III = SubRel.AsObservation.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.4");
            hl7III = SubRel.AsObservation.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            SubRel.AsObservation.Code.Code        = "409586006";
            SubRel.AsObservation.Code.CodeSystem  = "2.16.840.1.113883.6.96";
            SubRel.AsObservation.Code.DisplayName = "Complaint";
            SubRel.AsObservation.StatusCode.Code  = "completed";
            SubRel.AsObservation.EffectiveTime    = new IVL_TS().Init(low: low);
            CD obsValueAsCDSub = new CD();

            obsValueAsCDSub.Code        = ptEncounters.Code;
            obsValueAsCDSub.DisplayName = Convert.ToString(ptEncounters.EncounterDescription);
            obsValueAsCDSub.CodeSystem  = "2.16.840.1.113883.6.96";
            SubRel.AsObservation.Value.Add(obsValueAsCDSub);
        }
Ejemplo n.º 8
0
        public string BindRecordTarget(string title, ClinicalDocument clinicalDoc, Factory hl7factory, III hl7III, PatientClinicalInformation patientinfo)
        {
            string recordtarget = string.Empty;
            var    targetrole   = clinicalDoc.RecordTarget.Append();
            var    PRole        = targetrole.PatientRole;

            hl7III = PRole.Id.Append();
            string SSN = string.Empty;

            if (patientinfo.ptDemographicDetail.SSN != "")
            { /// MANAGE Patient SSN
                SSN = patientinfo.ptDemographicDetail.SSN;
            }
            hl7III.Init("2.16.840.1.113883.19.5", SSN); /// Manage ID Tag UNDER Record Target
                                                        ///Patient Address Information
            addressinfo         = new AddressModel();
            addressinfo.street  = patientinfo.ptDemographicDetail.Street;
            addressinfo.city    = patientinfo.ptDemographicDetail.City;
            addressinfo.state   = patientinfo.ptDemographicDetail.State;
            addressinfo.country = patientinfo.ptDemographicDetail.Country;
            addressinfo.pinCode = Convert.ToString(patientinfo.ptDemographicDetail.Zip);
            ///END
            ///Fill Address
            addressphno = new GenerateAddressPhNo();
            PRole.Addr.Add(addressphno.GenerateAddress(addressinfo, hl7factory)); ///FIll Patient Address
                                                                                  ///END
                                                                                  ///Patient Contact Information
            contactinfo             = new PhNoModel();
            contactinfo.telcomUse   = "WP";
            contactinfo.telcomValue = patientinfo.ptDemographicDetail.ContactNo;
            contactinfo.nullFlavor  = "UNK";
            PRole.Telecom.Add(addressphno.GeneratePhNo(contactinfo, hl7factory)); ///FIll Patient Contact Number
                                                                                  ///END
            var PatientName = targetrole.PatientRole.Patient.Name.Append();       ///Manage Patient Name

            //Fill Patient Name
            nameinfo = new NameModel();
            nameinfo.Createengiven  = patientinfo.ptDemographicDetail.FirstName;
            nameinfo.Createenfamily = patientinfo.ptDemographicDetail.LastName;
            addressphno.FillName(nameinfo, PatientName, hl7factory);                                                       ///FIll Patient Name
            //End
            var Patientbesic = targetrole.PatientRole.Patient;                                                             ///Manage Patient Gender

            Patientbesic.AdministrativeGenderCode.CodeSystem = "2.16.840.1.113883.5.1";                                    ///FIll Patient Gender Value Constraint
            Patientbesic.AdministrativeGenderCode.Code       = patientinfo.ptDemographicDetail.gender;                     //////FIll Patient Gender
            if (patientinfo.ptDemographicDetail.DateofBirth != "")                                                         ///Manage Patient DOB
            {
                Patientbesic.BirthTime.Value = addressphno.GetDateWithFormat(patientinfo.ptDemographicDetail.DateofBirth); ///Fill Patient DOB
            }
            if (patientinfo.ptDemographicDetail.Race != null && patientinfo.ptDemographicDetail.Race != "")                ///Manage Patient Race
            {
                string[] race = patientinfo.ptDemographicDetail.Race.Split(',');
                for (int i = 0; i < race.Length; i++)
                {
                    ICD icdObjects = hl7factory.CreateCD();
                    switch (race[i].ToString())
                    {
                    case "American Indian or Alaska Native":
                        Patientbesic.RaceCode.Code           = "1002-5";
                        Patientbesic.RaceCode.DisplayName    = "American Indian or Alaska Native";
                        Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    case "Asian":
                        Patientbesic.RaceCode.Code           = "2028-9";
                        Patientbesic.RaceCode.DisplayName    = "Asian";
                        Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    case "Black or African American":
                        Patientbesic.RaceCode.Code           = "2054-5";
                        Patientbesic.RaceCode.DisplayName    = "Black or African American";
                        Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    case "Hispanic or Latino":
                        Patientbesic.RaceCode.Code           = "2135-2";
                        Patientbesic.RaceCode.DisplayName    = "Hispanic or Latino";
                        Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    case "Native Hawaiian or Pacific Islander":
                        Patientbesic.RaceCode.Code           = "2076-8";
                        Patientbesic.RaceCode.DisplayName    = "Native Hawaiian or Pacific Islander";
                        Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    case "White":
                        Patientbesic.RaceCode.Code           = "2106-3";
                        Patientbesic.RaceCode.DisplayName    = "White";
                        Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    case "Some Other Race":
                        Patientbesic.RaceCode.Code           = "2131-1";
                        Patientbesic.RaceCode.DisplayName    = "White";
                        Patientbesic.RaceCode.CodeSystem     = "Some Other Race";
                        Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                        break;

                    default:
                        Patientbesic.RaceCode.NullFlavor = "UNK";
                        break;
                    }
                }
            }
            if (patientinfo.ptDemographicDetail.Ethnicity != null && patientinfo.ptDemographicDetail.Ethnicity != "")///Manage Patient Ethnicity
            {
                switch (patientinfo.ptDemographicDetail.Ethnicity)
                {
                case "Hispanic or Latino":
                    Patientbesic.EthnicGroupCode.Code    = "2135-2";
                    Patientbesic.RaceCode.DisplayName    = "Hispanic or Latino";
                    Patientbesic.RaceCode.CodeSystem     = "2.16.840.1.113883.6.238";
                    Patientbesic.RaceCode.CodeSystemName = "Race & Ethnicity - CDC";
                    break;

                case "Not Hispanic or Latino":
                    Patientbesic.EthnicGroupCode.Code           = "2186-5";
                    Patientbesic.EthnicGroupCode.DisplayName    = "Not Hispanic or Latino";
                    Patientbesic.EthnicGroupCode.CodeSystem     = "2.16.840.1.113883.6.238";
                    Patientbesic.EthnicGroupCode.CodeSystemName = "Race & Ethnicity - CDC";
                    break;

                default:
                    Patientbesic.EthnicGroupCode.NullFlavor = "UNK";
                    break;
                }
            }
            if (patientinfo.ptDemographicDetail.LanguageCode != null && patientinfo.ptDemographicDetail.LanguageCode != "")///Manage Patient LanguageCode
            {
                ILanguageCommunication langComm = hl7factory.CreateLanguageCommunication();
                langComm.LanguageCode.Code            = patientinfo.ptDemographicDetail.LanguageCode;
                langComm.PreferenceInd.ValueSpecified = true;
                langComm.PreferenceInd.Value          = true;
                Patientbesic.LanguageCommunication.Add(langComm);
            }
            return(clinicalDoc.Xml);
        }