How to search birthData in fhir using _content?

旧时模样 提交于 2020-03-25 13:47:40

问题


When I search with only birthData in fhir I am getting results.

For example: http://localhost:8080/hapi-fhir-jpaserver/fhir/Patient?_pretty=true&birthdate=2020-03-16 will return patient who has birthdate as 2020-03-16.

When I am searching with _content I am not getting any results. Something like this:

http://localhost:8080/hapi-fhir-jpaserver/fhir/Patient?_content=2019-09-05

回答1:


_content is for searching text content.

If you want to search for dates you need to use a date search parameter. E.g.:

http://localhost:8080/hapi-fhir-jpaserver/fhir/Patient?birthDate=2019-09-05




回答2:


This can be achieved using Search Parameters.

Search parameters are essentially named paths within resources that are indexed by the system so that they can be used to find resources that match a given criteria.

Using Search parameter

  • we can add additional search parameters that will index fields that do not have a standard search parameter defined.

  • we can add additional search parameters that will index extensions used by your clients.

  • we can disable search parameters

Example:

Lets say I have a PractitionerRole

    "resourceType": "PractitionerRole",
    "id": "6639",
    "meta": {
      "versionId": "1",
      "lastUpdated": "2020-03-19T13:26:34.748+05:30",
      "source": "#aYyeIlv9Yutudiwy"
    },
    "text": {
      "status": "generated",
      "div": "<div xmlns=\"<http://www.w3.org/1999/xhtml\">foo</div>">
    },
    "active": true,
    "practitioner": {
      "reference": "Practitioner/6607"
    },
    "organization": {
      "reference": "Organization/6528"
    },
    "specialty": [
      {
        "coding": [
          {
            "system": "<http://snomed.info/sct",>
            "code": "42343242",
            "display": "Clinical immunology"
          }
        ]
      }
    ]
}

PractitionerRole has thier own search parameters. Apart from those search parameters we wanted to have a search parameter which will filter all practitioner roles based on practitioner.reference. We can achieve this using Search parameters. All we need to do is creating a new search parameter just like below.

{
"resourceType": "SearchParameter",
"title": "Practitioner Referecene",
"base": [ "PractitionerRole" ],
"status": "active",
"code": "practitioner_reference",
"type": "token",
"expression": "PractitionerRole.practitioner.reference",
"xpathUsage": "normal"
}

Here what fhir tells is when user wanted to filter with practitioner_reference then look for PractitionerRole.practitioner.reference.

This looks something like this: http://localhost:8080/hapi-fhir-jpaserver/fhir/PractitionerRole?practitioner_reference=Practitioner/6607

We can also extend this to search with multiple parameters. We can create a search parameter with or condition so that it can search with multi parameters.

  "resourceType": "SearchParameter",
  "title": "Patient Multi Search",
  "base": [ "Patient" ],
  "status": "active",
  "code": "pcontent",
  "type": "token",
  "expression": "Patient.managingOrganization.reference|Patient.birthDate|Patient.address[0].city",
  "xpathUsage": "normal"
}

Above SearchParameter will search withPatient.managingOrganization.reference or Patient.birthDate or Patient.address[0].city.

The query looks like this:

Search With City → http://localhost:8080/hapi-fhir-jpaserver/fhir/Patient?pcontent=Bruenmouth

Search With Birth Date → http://localhost:8080/hapi-fhir-jpaserver/fhir/Patient?pcontent=2019-04-06



来源:https://stackoverflow.com/questions/60733954/how-to-search-birthdata-in-fhir-using-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!