public Bundle Search(IEnumerable <KeyValuePair <string, string> > parameters, int?Count, SummaryType summary) { var uri = GetUrl(RequestDetails.RequestUri.AbsoluteUri); // Get XML from CDR XmlDocument xml = dataAccess.GetXmlForFihr_Patient(parameters, (int)Count); // Map the fields from the CDR xml to Fhir model Bundle patientBundle = PatientMapping.MapFromCDRToFHirModelBundle(xml, uri); return(patientBundle); }
public Resource Get(string resourceId, string VersionId, SummaryType summary) { // Creating params to GetXmlForFihr_Patient var parameters = new[] { new KeyValuePair <string, string>("_id", resourceId) }; // Get XML from CDR XmlDocument xml = dataAccess.GetXmlForFihr_Patient(parameters, 1); // Mapping one patient resource Patient patient = PatientMapping.MapFromCDRToFHirModel(xml); if (patient == null) { throw new Exception(string.Format("Patient {0}, v{1} not found", resourceId, VersionId)); } //throw new Exception($"Patient {resourceId}, v{VersionId} not found"); return(patient); }
public CSVGeneReader(string fileName) { _data = File.ReadAllLines(fileName); string[] header = _data.First().Split(','); _data = _data.Skip(1); for (int column = 1; column < header.Length; ++column) { var columnParts = header[column].Split('_'); Debug.Assert(columnParts.Length == 2); int patient = int.Parse(columnParts[0]); PatientMapping mapping; if (!m_patientMappings.TryGetValue(patient, out mapping)) { mapping = new PatientMapping(); m_patientMappings.Add(patient, mapping); } switch (columnParts[1]) { case "Before": mapping.BeforeColumn = column; break; case "After": mapping.AfterColumn = column; break; default: throw new InvalidDataException("Unexpected column in the genes file"); } } }
public XmlDocument GetXmlForFihr_Patient(IEnumerable <KeyValuePair <string, string> > parameters, int Count) { var id = parameters.Where(p => p.Key.Equals("_id")).FirstOrDefault().Value; var family = parameters.Where(p => p.Key.Equals("family")).FirstOrDefault().Value; var given = parameters.Where(p => p.Key.Equals("given")).FirstOrDefault().Value; var birthdate = parameters.Where(p => p.Key.Equals("birthday")).FirstOrDefault().Value; var gender = parameters.Where(p => p.Key.Equals("gender")).FirstOrDefault().Value; var identifier = parameters.Where(p => p.Key.Equals("identifier")).FirstOrDefault().Value; // Create a xmldocument to map the fields XmlDocument xml = new XmlDocument(); // Open connection with CDR and query Resource using (var con = new SqlConnection(GetConnectionString())) { // Call the procedure to the specific resource var cmd = new SqlCommand("sp_GetXmlForFihr_Patient", con) { CommandType = CommandType.StoredProcedure }; // add procedure parameters if (!string.IsNullOrEmpty(id)) { cmd.Parameters.AddWithValue("@id", Convert.ToInt64(id)); } if (!string.IsNullOrEmpty(family)) { cmd.Parameters.AddWithValue("@family", family); } if (!string.IsNullOrEmpty(given)) { cmd.Parameters.AddWithValue("@given", given); } if (!string.IsNullOrEmpty(birthdate)) { cmd.Parameters.AddWithValue("@birthdate", birthdate); } if (!string.IsNullOrEmpty(gender)) { cmd.Parameters.AddWithValue("@gender", PatientMapping.GetHl7GenderFromAdministrativeGender(gender)); } if (!string.IsNullOrEmpty(identifier)) { cmd.Parameters.AddWithValue("@identifier", identifier); } cmd.Parameters.AddWithValue("@count", Convert.ToInt64(Count)); // open the connection with DB Server con.Open(); // read the XML returned from the procedure XmlReader reader = cmd.ExecuteXmlReader(); reader.Read(); xml.Load(reader); // close connection with DB Server con.Close(); } return(xml); }