/// <summary> /// Method that will fetch all dummy data. /// </summary> public void FetchInitialPatients() { try { var client = new FhirClient("https://apps.hdap.gatech.edu/gt-fhir/fhir"); var query = new SearchParams(); var backPainCode = "279039007"; query.Add("code", backPainCode); query.LimitTo(20); var bundle = client.Search <Condition>(query); foreach (Bundle.EntryComponent entry in bundle.Entry) { if (entry.Resource is Condition c) { var patientString = c.Subject.Reference; var id = Regex.Match(patientString, @"\d+"); var patientQuery = new string[] { $"_id={id.Value}" }; var patientBundle = client.Search <FhirPatient>(patientQuery); var patient = patientBundle.Entry.First().Resource as FhirPatient; var patientToAdd = new Patient { Name = patient.Name.First().ToString(), BirthDate = patient.BirthDate, Id = patient.Id, Gender = patient.Gender?.ToString(), MaritalStatus = patient.MaritalStatus?.Text ?? "Unknown" }; this.patientRepo.TryAdd(patient.Id, patientToAdd); } } } catch { Console.Write("Unable to fetch patients"); } }
/// <summary> /// Updates the patient with the given id. /// </summary> /// <param name="id">Id of the patient.</param> /// <param name="patient">The patient model.</param> public void Update(string id, Patient patient) { this.patientRepo[id] = patient; }