Parse FHIR Ответ пациента на json - PullRequest
0 голосов
/ 01 мая 2020

Я новичок в. Net и FHIR. Я ознакомился с несколькими уроками, чтобы понять, как работает FHIR API. Мне нужно создать приложение, которое использует только запрос GET для получения данных с сервера. Ниже я пытаюсь сделать запрос на получение пациента по идентификатору в классе PatientRepository. Тем не менее, когда я тестирую его с почтальоном, он не возвращает никакого ответа. Как я должен изменить свой код? Большое спасибо

Модель:

public class Patient : Hl7.Fhir.Model.Patient
    {
        public string name { get; set; }
        public string birthday { get; set; }
    }

public class PatientList
    {
        public List<Patient> Patients { get; set; }
    }

Контроллер:

public class PatientController : Controller
    {
        private readonly IPatientRepository _patientRepository;
        public PatientController(IPatientRepository patientRepository)
        {
            _patientRepository = patientRepository;
        }
        [HttpGet]
        [Route("api/GetPatientById/{id}")]
        public IActionResult getPatientById(long id)
        {
            var model = _patientRepository.GetPatientById(id);
            if (model == null)
                return NotFound();
            return Ok(model);
        }
    }
}

PatientRepository:

public class PatientRepository : IPatientRepository
    {
        public async Task<Patient> GetPatientById(long id)
        {
            var client = new FhirClient("https://fhir.****.***/hapi-fhir-jpaserver/fhir/");
            client.Timeout = (60 * 100);
            client.PreferredFormat = ResourceFormat.Json;
            var pat = client.Read<Patient>("Patient/1");

            var parser = new FhirJsonParser();
            return new Patient
            {
                birthday = pat.birthday,
            }
        }
    }
...