Hi Robert,
Yes, API allows a result set to be filtered. Keep in mind this is the same API we use to power our SearchLOINC tool. Within the web app, say you search for influenza. You can click the Filter icon to see the available filters and available rows. See example screenshot.
This FilterCounts data is returned in every API response—so long as you set the optional ‘includefiltercounts’ parameter to true.
Here is the request/response to that same ‘influenza’ search via the API. (Note I have removed the ‘Results’ node and truncated ‘FilterCounts’ from the snippet below so this post would fit within the forum’s character limit.)
https://loinc.regenstrief.org/searchapi/loincs?query=influenza&includefiltercounts=true
"ResponseSummary": {
"RecordsFound": 585,
"StartingOffset": 0,
"RowsReturned": 50,
"LoincVersion": "2.78",
"Copyright": "Copyright © 2024 Regenstrief Institute, Inc. All Rights Reserved.",
"QueryUrl": "https://loinc.regenstrief.org/searchapi/loincs?query=influenza&includefiltercounts=true",
"Next": "https://loinc.regenstrief.org/searchapi/loincs?query=influenza&includefiltercounts=true&offset=50",
"QueryExecutionTime": "2024-09-24T16:17:27.4800469-04:00",
"QueryDuration": 0.073304
},
"Results": [
],
"FilterCounts": {
"System": [],
"Method": [],
"Property": [],
"Timing": [],
"Scale": [],
"Class": [],
"VersionFirstReleased": [],
"VersionLastChanged": [],
"Tags": [],
"ClassType": [],
"OrderObs": [
{
"Label": "Both",
"Search": "=orderobs:Both",
"Count": 506
},
{
"Label": "Observation",
"Search": "=orderobs:Observation",
"Count": 53
},
{
"Label": "Order",
"Search": "=orderobs:Order",
"Count": 18
},
{
"Label": "Subset",
"Search": "=orderobs:Subset",
"Count": 1
}
],
"PanelType": [
{
"Label": "Organizer",
"Search": "=paneltype:Organizer",
"Count": 2
},
{
"Label": "Panel",
"Search": "=paneltype:Panel",
"Count": 20
}
],
"CodeSystems": [
{
"Label": "CMS IRF-PAI 1.4",
"Search": "=codesystems:\"CMS IRF\\-PAI 1.4\"",
"Count": 4
},
{
"Label": "CMS IRF-PAI 1.5",
"Search": "=codesystems:\"CMS IRF\\-PAI 1.5\"",
"Count": 4
},
{
"Label": "CMS IRF-PAI 2.0",
"Search": "=codesystems:\"CMS IRF\\-PAI 2.0\"",
"Count": 4
},
{
"Label": "CMS LCDS 3.00",
"Search": "=codesystems:\"CMS LCDS 3.00\"",
"Count": 4
},
{
"Label": "CMS LCDS 4.00",
"Search": "=codesystems:\"CMS LCDS 4.00\"",
"Count": 4
},
{
"Label": "CMS MDS 1.14.1",
"Search": "=codesystems:\"CMS MDS 1.14.1\"",
"Count": 4
},
{
"Label": "CMS MDS 1.15.1",
"Search": "=codesystems:\"CMS MDS 1.15.1\"",
"Count": 4
},
{
"Label": "CMS MDS 1.16.1",
"Search": "=codesystems:\"CMS MDS 1.16.1\"",
"Count": 4
},
{
"Label": "CMS MDS 1.17.1",
"Search": "=codesystems:\"CMS MDS 1.17.1\"",
"Count": 4
},
{
"Label": "CMS MDS 1.17.2",
"Search": "=codesystems:\"CMS MDS 1.17.2\"",
"Count": 4
},
{
"Label": "CMS MDS v1.18.11",
"Search": "=codesystems:\"CMS MDS v1.18.11\"",
"Count": 4
},
{
"Label": "CMS OASIS C2",
"Search": "=codesystems:\"CMS OASIS C2\"",
"Count": 2
},
{
"Label": "CMS OASIS D",
"Search": "=codesystems:\"CMS OASIS D\"",
"Count": 2
},
{
"Label": "CMS OASIS D1",
"Search": "=codesystems:\"CMS OASIS D1\"",
"Count": 2
},
{
"Label": "CMS OASIS E",
"Search": "=codesystems:\"CMS OASIS E\"",
"Count": 2
},
{
"Label": "https://www.phenxtoolkit.org",
"Search": "=codesystems:https\\://www.phenxtoolkit.org",
"Count": 1
}
],
"Status": [
{
"Label": "ACTIVE",
"Search": "=status:ACTIVE",
"Count": 565
},
{
"Label": "DEPRECATED",
"Search": "=status:DEPRECATED",
"Count": 10
},
{
"Label": "DISCOURAGED",
"Search": "=status:DISCOURAGED",
"Count": 10
}
]
}
}
To “apply” a filter, simply add the ‘Search’ to the query parameter. For instance, to get the 18 results indicated by ‘OrderObs’ equal to ‘Order’, the encoded request would be:
https://loinc.regenstrief.org/searchapi/loincs?query=influenza%20%3Dorderobs:Order&includefiltercounts=true
I hope this makes sense. Let us know if you need more information.