Skip to content

Commit

Permalink
Issue #773 - Extract identifer field of reference elements
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Biesterfeld <tbieste@us.ibm.com>
  • Loading branch information
tbieste committed Mar 17, 2021
1 parent 7ccfdf5 commit dd44abe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017,2020
* (C) Copyright IBM Corp. 2017, 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -614,6 +614,16 @@ public boolean visit(java.lang.String elementName, int elementIndex, Reference r
p.setName(searchParamCode);
result.add(p);
}
Identifier identifier = reference.getIdentifier();
if (identifier != null && identifier.getValue() != null) {
TokenParmVal p = new TokenParmVal();
p.setName(searchParamCode);
if (identifier.getSystem() != null) {
p.setValueSystem(identifier.getSystem().getValue());
}
p.setValueCode(identifier.getValue().getValue());
result.add(p);
}
} catch (FHIRSearchException x) {
// Log the error, but skip it because we're not supposed to throw exceptions here
log.log(Level.WARNING, "Error processing reference", x);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020
* (C) Copyright IBM Corp. 2019, 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -649,12 +649,18 @@ public void testReference() throws FHIRPersistenceProcessorException {
JDBCParameterBuildingVisitor parameterBuilder = new JDBCParameterBuildingVisitor(referenceSearchParam);
Reference.builder()
.reference(string(SAMPLE_REF))
.identifier(Identifier.builder()
.system(Uri.of(SAMPLE_URI))
.value(string(SAMPLE_STRING))
.build())
.build()
.accept(parameterBuilder);
List<ExtractedParameterValue> params = parameterBuilder.getResult();
assertEquals(params.size(), 1, "Number of extracted parameters");
assertEquals(params.size(), 2, "Number of extracted parameters");
assertEquals(((ReferenceParmVal) params.get(0)).getRefValue().getValue(), SAMPLE_REF_ID);
assertEquals(((ReferenceParmVal) params.get(0)).getRefValue().getTargetResourceType(), SAMPLE_REF_RESOURCE_TYPE);
assertEquals(((TokenParmVal) params.get(1)).getValueSystem(), SAMPLE_URI);
assertEquals(((TokenParmVal) params.get(1)).getValueCode(), SAMPLE_STRING);
}

@Test
Expand Down

0 comments on commit dd44abe

Please sign in to comment.