public static string GetDepartCodeByRegistryID(string registryID) { using (gjtEmrPatients.emrPatients pi = new gjtEmrPatients.emrPatients()) { string DepartCode = null; XmlNode patients = pi.QueryPatientList(gjtEmrPatients.QueryMode.RegistryID, registryID, Globals.inStyle); if (patients == null) { return(null); } if (patients.SelectNodes(ElementNames.Patient).Count == 0) { return(null); } foreach (XmlNode patient in patients.SelectNodes(ElementNames.Patient)[0]) { if (patient.Attributes[AttributeNames.RegistryID].Value == registryID) { return(patient.Attributes[AttributeNames.DepartmentCode].Value); } } return(DepartCode); } }