Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            // Client used to communicate with Patient GRPC Server

            var channel = GrpcChannel.ForAddress("https://localhost:5001");

            // Fetch patient ID #1
            var input = new PatientLookupModel {
                PatientId = 1
            };
            var client = new Patient.PatientClient(channel);

            var patient = await client.GetPatientInfoAsync(input);

            Console.WriteLine($"Patient { patient.FirstName } { patient.LastName }. Chart ID { patient.ChartId }");

            // Fetch all patients on database
            Console.WriteLine("All patients: ");

            using (var patients = client.GetAllPatientsInfo(new AllPatientsRequest()))
            {
                while (await patients.ResponseStream.MoveNext())
                {
                    var pt = patients.ResponseStream.Current;
                    Console.WriteLine($"Patient { pt.FirstName } { pt.LastName }. Chart ID { pt.ChartId }");
                }
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public override async Task <PatientModel> GetPatientInfo(
            PatientLookupModel request,
            ServerCallContext context)
        {
            // Function is called when the GRPC server is requested a patient's information
            // with the request containing a patient ID to search for.

            // Query for the patient by ID
            Models.Patient patient = await _context.Patient.FirstOrDefaultAsync(x => x.PatientId == request.PatientId);

            return(await Task.FromResult(
                       new PatientModel
            {
                FirstName = patient.FirstName,
                LastName = patient.LastName,
                ChartId = patient.ChartId,
                FacilityId = patient.FacilityId,
                EpisodeId = patient.EpisodeId
            }
                       ));
        }