Inexact matches are tried first before exact matches (in fact, a name-based exact match query is never attempted). It seems to me that exact match should be tried first, then inexact matches, then try the code based search.
Example
An example of this giving incorrect results was when the input of the method is "Bladder Adenocarcinoma". Using inexact matching first, the return was:
```
[{"code":"GBAD","color":"Green","name":"Gallbladder Adenocarcinoma, NOS","mainType":"Hepatobiliary Cancer","externalReferences":{},"tissue":"Biliary Tract","children":{},"parent":"GBC","history":[],"level":4,"revocations":[],"precursors":[]},{"code":"BLAD","color":"Yellow","name":"Bladder Adenocarcinoma","mainType":"Bladder Cancer","externalReferences":{"UMLS":["C0279682"],"NCI":["C4032"]},"tissue":"Bladder/Urinary Tract","children":{},"parent":"BLADDER","history":[],"level":2,"revocations":[],"precursors":[]}]
```
As per the logic of the method, the first item in the list was selected, returning "Hepatobiliary Cancer", which is incorrect. If exact match was used first we would have:
```
[{"code":"BLAD","color":"Yellow","name":"Bladder Adenocarcinoma","mainType":"Bladder Cancer","externalReferences":{"UMLS":["C0279682"],"NCI":["C4032"]},"tissue":"Bladder/Urinary Tract","children":{},"parent":"BLADDER","history":[],"level":2,"revocations":[],"precursors":[]}]
```
This list has one element, which is correct.
I noticed that the order of operations here may result in choosing the incorrect parent tumor: https://github.com/mskcc/LimsRest/blob/04ce972e29044fb8b268ee502464285b3a89493b/src/main/java/org/mskcc/limsrest/util/Utils.java#L524-L541
Inexact matches are tried first before exact matches (in fact, a name-based exact match query is never attempted). It seems to me that exact match should be tried first, then inexact matches, then try the code based search.
Example
An example of this giving incorrect results was when the input of the method is "Bladder Adenocarcinoma". Using inexact matching first, the return was: ``` [{"code":"GBAD","color":"Green","name":"Gallbladder Adenocarcinoma, NOS","mainType":"Hepatobiliary Cancer","externalReferences":{},"tissue":"Biliary Tract","children":{},"parent":"GBC","history":[],"level":4,"revocations":[],"precursors":[]},{"code":"BLAD","color":"Yellow","name":"Bladder Adenocarcinoma","mainType":"Bladder Cancer","externalReferences":{"UMLS":["C0279682"],"NCI":["C4032"]},"tissue":"Bladder/Urinary Tract","children":{},"parent":"BLADDER","history":[],"level":2,"revocations":[],"precursors":[]}] ``` As per the logic of the method, the first item in the list was selected, returning "Hepatobiliary Cancer", which is incorrect. If exact match was used first we would have: ``` [{"code":"BLAD","color":"Yellow","name":"Bladder Adenocarcinoma","mainType":"Bladder Cancer","externalReferences":{"UMLS":["C0279682"],"NCI":["C4032"]},"tissue":"Bladder/Urinary Tract","children":{},"parent":"BLADDER","history":[],"level":2,"revocations":[],"precursors":[]}] ``` This list has one element, which is correct.