private PatientInformation Reconcile(PatientInformation patient, XmlDocument rulesDocument, string rulesElementName)
        {
            PatientInformation returnPatient = patient.Clone();

            if (String.IsNullOrEmpty(patient.PatientId))
            {
                return(returnPatient);
            }

            returnPatient.PatientId = returnPatient.PatientId.Trim();

            XmlElement rulesNode = rulesDocument.SelectSingleNode("//" + rulesElementName) as XmlElement;

            if (rulesNode != null)
            {
                foreach (XmlNode ruleNode in rulesNode.SelectNodes("rule"))
                {
                    XmlElement ruleElement = ruleNode as XmlElement;

                    if (ruleElement != null)
                    {
                        if (_applicator.Apply(ruleElement, returnPatient))
                        {
                            break;
                        }
                    }
                }
            }

            return(returnPatient);
        }
        public IPatientData ReconcilePatientInformation(IPatientData patientInfo)
        {
            Platform.CheckMemberIsSet(StudyTree, "StudyTree");

            var testPatientInformation = new PatientInformation {
                PatientId = patientInfo.PatientId
            };

            testPatientInformation = Reconcile(testPatientInformation, DefaultPatientReconciliationSettings.Default.PatientReconciliationRulesXml, "patient-reconciliation-rules");

            foreach (var patient in StudyTree.Patients)
            {
                var reconciledPatientInfo = new PatientInformation {
                    PatientId = patient.PatientId
                };
                reconciledPatientInfo = Reconcile(reconciledPatientInfo, DefaultPatientReconciliationSettings.Default.PatientReconciliationRulesXml, "patient-reconciliation-rules");

                if (reconciledPatientInfo.PatientId == testPatientInformation.PatientId)
                {
                    return new PatientInformation(patient)
                           {
                               PatientId = reconciledPatientInfo.PatientId
                           }
                }
                ;
            }

            return(null);
        }
        public IPatientData ReconcileSearchCriteria(IPatientData patientInfo)
        {
            var patientInformation = new PatientInformation {
                PatientId = patientInfo.PatientId
            };

            return(Reconcile(patientInformation, DefaultPatientReconciliationSettings.Default.SearchReconciliationRulesXml, "search-reconciliation-rules"));
        }
		private PatientInformation Reconcile(PatientInformation patient, XmlDocument rulesDocument, string rulesElementName)
		{
			PatientInformation returnPatient = patient.Clone();
			if (String.IsNullOrEmpty(patient.PatientId))
				return returnPatient;

			returnPatient.PatientId = returnPatient.PatientId.Trim();

			XmlElement rulesNode = rulesDocument.SelectSingleNode("//" + rulesElementName) as XmlElement;
			if (rulesNode != null)
			{
				foreach (XmlNode ruleNode in rulesNode.SelectNodes("rule"))
				{
					XmlElement ruleElement = ruleNode as XmlElement;
					if (ruleElement != null)
					{
						if (_applicator.Apply(ruleElement, returnPatient))
							break;
					}
				}
			}

			return returnPatient;
		}
		public IPatientData ReconcilePatientInformation(IPatientData patientInfo)
		{
			Platform.CheckMemberIsSet(StudyTree, "StudyTree");

			var testPatientInformation = new PatientInformation{ PatientId = patientInfo.PatientId };
			testPatientInformation = Reconcile(testPatientInformation, DefaultPatientReconciliationSettings.Default.PatientReconciliationRulesXml, "patient-reconciliation-rules");

			foreach (var patient in StudyTree.Patients)
			{
				var reconciledPatientInfo = new PatientInformation { PatientId = patient.PatientId };
				reconciledPatientInfo = Reconcile(reconciledPatientInfo, DefaultPatientReconciliationSettings.Default.PatientReconciliationRulesXml, "patient-reconciliation-rules");

				if (reconciledPatientInfo.PatientId == testPatientInformation.PatientId)
					return new PatientInformation(patient) { PatientId = reconciledPatientInfo.PatientId };
			}

			return null;
		}
		public IPatientData ReconcileSearchCriteria(IPatientData patientInfo)
		{
			var patientInformation = new PatientInformation{ PatientId = patientInfo.PatientId };
			return Reconcile(patientInformation, DefaultPatientReconciliationSettings.Default.SearchReconciliationRulesXml, "search-reconciliation-rules");
		}