public query ( MdoQuery request, AbstractPermission permission = null ) : object | ||
request | MdoQuery | |
permission | AbstractPermission | |
return | object |
public Dictionary <string, string> getTreatingFacilityIds(string pid) { SqlDataAdapter request = buildGetTreatingFacilityRequest(pid); IDataReader response = (SqlDataReader)_myCxn.query(request); return(toTreatingFacilityIdsFromReader(response)); }
/// <summary> /// Match a patient on Name, SSN and DOB /// </summary> /// <param name="p">The patient to match</param> /// <returns>An array of patients matching the passed patient</returns> public Patient[] getPatient(Patient p) { if (p == null || p.SSN == null || !p.SSN.IsValid || p.Name == null || String.IsNullOrEmpty(p.DOB)) { throw new MdoException(MdoExceptionCode.ARGUMENT_NULL, "Must supply valid SSN, Name and DOB to match"); } try { utils.DateUtils.IsoDateStringToDateTime(p.DOB); } catch (Exception) { throw new MdoException(MdoExceptionCode.ARGUMENT_DATE_FORMAT, "Patient DOB should be in ISO format: YYYYMMDD"); } //SqlTransaction tx = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand("SELECT * FROM " + PATIENT_TABLE + " WHERE ssn=@SSN AND name=@NAME AND vistaDOB=@DOB;"); SqlParameter ssnParam = new SqlParameter("@SSN", System.Data.SqlDbType.Char, 9); ssnParam.Value = p.SSN.toString(); cmd.Parameters.Add(ssnParam); SqlParameter nameParam = new SqlParameter("@NAME", SqlDbType.VarChar, 255); nameParam.Value = p.Name.LastNameFirst; cmd.Parameters.Add(nameParam); SqlParameter dobParam = new SqlParameter("@DOB", SqlDbType.VarChar, 7); dobParam.Value = vista.VistaTimestamp.fromDateTimeShortString(utils.DateUtils.IsoDateStringToDateTime(p.DOB)); cmd.Parameters.Add(dobParam); _myCxn.SqlParameters = cmd.Parameters; // kind of a hack to use SQL parameters _myCxn.connect(); SqlDataReader reader = (SqlDataReader)_myCxn.query(cmd.CommandText); try { IList <Patient> list = getPatientsFromDataReader(reader); Patient[] patients = new Patient[list.Count]; list.CopyTo(patients, 0); return(patients); } catch (Exception) { throw; } finally { if (reader != null) { reader.Close(); } _myCxn.disconnect(); } }