public override async Task <IGetFhirMedications.Model> Handle(IGetFhirMedications.Query request, CancellationToken cancellationToken) { var taskList = new List <Task <Bundle> >();//launch multiple http request from here //implementation will vary based on FHIR version var medRequestQuery = new SearchParams() .Where($"patient={request.PatientId}") .Include("MedicationRequest:medication") // .Include("MedicationRequest:requester") .LimitTo(100); //These are only added to the bundle if there is a Medication Resource referenced, not if there is a CodeableConcept describing the Medication var medStatementQuery = new SearchParams() .Where($"patient={request.PatientId}") .Include("MedicationStatement:medication") // .Include("MedicationStatement:requester") .LimitTo(100); taskList.Add(client.SearchAsync <MedicationRequest>(medRequestQuery)); taskList.Add(client.SearchAsync <MedicationStatement>(medStatementQuery)); var res = new IGetFhirMedications.Model(); var meds = await ParseMedicationsAsync(taskList).ConfigureAwait(false); //if this is not awaited, the channel will start to TryRead before anything is in the channel and an empty res in returned meds.ToList().ForEach(dto => res.Requests.Add(dto)); return(res); }
public override async Task <IGetFhirMedications.Model> Handle(IGetFhirMedications.Query request, CancellationToken cancellationToken) { //implementation will vary based on FHIR version var q = new SearchParams() .Where($"patient={request.PatientId}") .Include("MedicationRequest:medication").LimitTo(1000); //These are only added to the bundle if there is a Medication Resource referenced, not if there is a CodeableConcept describing the Medication var t = new SearchParams() .Where($"patient={request.PatientId}") .Include("MedicationStatement:medication").LimitTo(1000); var trans = new TransactionBuilder(_client.Endpoint); trans = trans.Search(q, "MedicationRequest").Search(t, "MedicationStatement"); //var result = await _client.SearchAsync<MedicationRequest>(q); var tResult = _client.TransactionAsync(trans.ToBundle()); var res = new IGetFhirMedications.Model(); await ParseMedicationsAsync(tResult).ConfigureAwait(false); //if this is not awaited, the channel will start to TryRead before anything is in the channel and an empty res in returned while (channel.Reader.TryRead(out var dto)) //what if this was switched to not closed and the ParseMedicationAsync isnt awaited?...Closes before it gets here { res.Requests.Add(dto); //Channels might be out of the practical scope of this project but it was a good way to learn how to use them...How would they be applicable? } //while (!channel.Reader.Completion.IsCompleted)//what if this was switched to not closed and the ParseMedicationAsync isnt awaited? //{ // res.Requests.Add(await channel.Reader.ReadAsync());//Channels might be out of the practical scope of this project but it was a good way to learn how to use them...How would they be applicable? //} return(res); }
public override async Task <IGetFhirMedications.Model> Handle(IGetFhirMedications.Query request, CancellationToken cancellationToken) { //var meds = await ParseMedicationsAsync(MedicationJSONString.ParseMedsAsync()); var res = new IGetFhirMedications.Model(); //meds.ToList().ForEach(dto=> res.Requests.Add(dto)); return(res); }
public override async Task <IGetFhirMedications.Model> Handle(IGetFhirMedications.Query request, CancellationToken cancellationToken) { await ParseMedicationsAsync(MedicationJSONString.ParseMedsAsync()); var res = new IGetFhirMedications.Model(); while (channel.Reader.TryRead(out var dto)) //behavior is odd under the debugger { res.Requests.Add(dto); //Channels are out of the practical scope of this project but it was a good way to learn how to use them...How would they be applicable? } return(res); }
public abstract Task <IGetFhirMedications.Model> Handle(IGetFhirMedications.Query request, CancellationToken cancellationToken);