Commit 2fdefb5f authored by Rob Tomsick's avatar Rob Tomsick

Disable NDC inferrence by default for barcode endpoint, allow inferrence to be...

Disable NDC inferrence by default for barcode endpoint, allow inferrence to be disabled for /all endpoint
parent 5e83414e
......@@ -66,6 +66,25 @@ will not be able to load the spec from the filesystem. Instead, to view the
documentation locally you will have to launch a web server which will serve
the `api-docs` directory. Yes, really.
## Barcode Search
Currently CRxREST supports UPC-A barcodes. In an attempt to make this support
more useful, CRxREST is able to use these barcodes to attempt a search against
dictionaries which do not have support for barcodes, but do support NDCs.
UPCs beginning with a `3` (aka UPN) will have their payload extracted, and
three possible (partial) NDCs created from the resulting data. These will
then be used to search the dictionary by NDC for possible matches.
Unfortunately, as it is impossible to determine the grouping form (5-4-2,
4-4-2, etc.) from a 10-digit without dashes, the exact NDC cannot be
determined. The ambiguity therefore means that this approach may produce
unrelated results. Due to this possibility, this approach is disabled by
default for the barcode search endpoint (it may be enabled via a request
parameter, and even then will only be used if an exact UPC match was not
found.) It is, however, enabled by default for the "all-in" search (but may
be disabled by request parameter).
## Errata
### SPI
......
......@@ -309,6 +309,10 @@ public class SearchController
defaultValue = "")
@NotNull
String barcodeStr,
@RequestParam(value = "infer-ndc", required = false,
defaultValue = "false")
boolean inferNDC,
@PathVariable("dictionary")
@NotNull @Size(min = 1)
......@@ -348,7 +352,8 @@ public class SearchController
*/
if (service.dictionary().supports(DictionaryCapabilities.NDC)
&& barcode instanceof UPCA
&& results.size() < limit)
&& results.isEmpty()
&& inferNDC)
{
/* handle UPN if available */
if (barcode instanceof UPCA)
......@@ -440,7 +445,17 @@ public class SearchController
@ApiParam(value = "whether to search for drugs matching "
+ "the search term",
defaultValue = "false")
boolean searchDrugs)
boolean searchDrugs,
@RequestParam(value = "infer-ndc", required = false,
defaultValue = "true")
@ApiParam(value = "Whether to attempt to infer NDCs usable "
+ "for search from UPC-A barcodes. Due "
+ "to the inherent ambiguity of UPC's "
+ "representation of NDCs, this may "
+ "produce inexact or inaccurate results.",
defaultValue = "true", required = false)
boolean inferNDC)
{
final DictionaryService service = this.dpSource.get(dictionaryName);
......@@ -513,7 +528,7 @@ public class SearchController
}
/* handle UPN if available */
if (barcode instanceof UPCA)
if (inferNDC && (barcode instanceof UPCA))
{
NDC[] ndcs = NDC.possibleNDCs((UPCA) barcode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment