HAPI FHIR 检索患者

huangapple go评论123阅读模式
英文:

HAPI FHIR Retrieve Patients

问题

我对HAPI FHIR客户端非常陌生,并且一直在浏览教程和文档,试图帮助我开发的程序,但是当我要查询服务器以搜索由同一医生治疗的患者列表时,我现在陷入了困境。换句话说,我希望用户输入医生的ID号码,系统返回一个包含患者详细信息的列表。当我输入医生的ID号码时,我能够查询服务器以获取所有的就诊记录(Encounters),这些记录都放在一个Bundle中,但我不知道接下来该怎么做。我已经放置了我用来获取Bundle的代码行,并且可以验证它的有效性,因为当我统计Bundle中资源的数量时,我得到了正确的数字。pracID是用户输入的整数。

Bundle response = client.search().forResource(Encounter.class).where(Encounter.PRACTITIONER.hasId(Integer.toString(pracID))).returnBundle(Bundle.class).execute();

我也在IntelliJ中使用Java进行编码,使用的是R4版本的Context客户端。非常感谢您的帮助。提前致谢。

英文:

I am very new to the HAPI FHIR client, and have been endlessly browsing tutorials and documentation to try and assist me with my program that I am trying to develop, but I am now stuck when it comes to querying a server to search for a list of Patients that are all being treated by the same practitioner. In other words, I want a user to enter a Practitioner ID number and for the system to return a list of patients with their details. I was able to query the server to get all the Encounters when entering the ID number of the Practitioner, which were all placed into a Bundle, but I have no idea where to go from there. I have placed the line of code I used to get the Bundle and can verify that it works, because when couting the number of resources in the bundle, I get the correct number. pracID is the user-entered integer.

Bundle response = client.search().forResource(Encounter.class).where(Encounter.PRACTITIONER.hasId(Integer.toString(pracID))).returnBundle(Bundle.class).execute();

I am also coding this in Java on IntelliJ, using the R4 version of the Context client. I will highly appreciate any help. Thanks in advance

答案1

得分: 2

我认为通往罗马的道路有很多条,但我的第一个天真的方法将是以下内容:您可以尝试使用搜索参数_include递归地查找患者数据。此搜索参数会针对所有与相应主题相关的就诊对象进行搜索:

Bundle response = 
   client.search()
   .forResource(Encounter.class)
   .where(Encounter.PRACTITIONER.hasId(Integer.toString(pracID)))
   .include(Patient.INCLUDE_ALL.asRecursive())
   .returnBundle(Bundle.class).execute(); 

如果链接可用,则束缚现在不仅应包含就诊对象,还应包含患者对象,可以按以下方式检索以进行进一步处理:

List<Patient> listPatients = new ArrayList<Patient>();
response.getEntry().forEach(entry -> { 
      if (entry.getResource() instanceof Patient) {
        listPatients.add((Patient) entry.getResource());
      }
});
英文:

I think there are many roads leading to Rome, but my first naive approach would be the following: You could try to find the patient data recursively using the search parameter _include. This search parameter searches all encounter objects for the corresponding Subject:

Bundle response = 
   client.search()
   .forResource(Encounter.class)
   .where(Encounter.PRACTITIONER.hasId(Integer.toString(pracID)))
   .include(Patient.INCLUDE_ALL.asRecursive())
   .returnBundle(Bundle.class).execute(); 

If links are available, the bundle should now contain not only Encounter objects but also Patient objects, which could be retrieved for further processing as follows:

List&lt;Patient&gt; listPatients = new ArrayList&lt;Patient&gt;();
response.getEntry().forEach(entry -&gt; { 
      if (entry.getResource() instanceof Patient) {
        listPatients.add((Patient) entry.getResource());
      }
});

huangapple
  • 本文由 发表于 2020年5月3日 19:39:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/61573824.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定