Skip to content

Commit

Permalink
#1 Fix FindDocumentsByReferenceId
Browse files Browse the repository at this point in the history
  • Loading branch information
Thopap committed Dec 30, 2023
1 parent fa40dbf commit ce6e19f
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import static org.openehealth.app.xdstofhir.registry.query.StoredQueryMapper.urnIdentifierList;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -288,14 +287,14 @@ public void visit(FindSubmissionSetsQuery query) {
@Override
public void visit(FindDocumentsByReferenceIdQuery query) {
var documentFhirQuery = prepareQuery(query);
// TODO: Not yet working as expected
if (query.getReferenceIds() != null){
var searchToken = query.getTypedReferenceIds().getOuterList().stream()
.flatMap(List::stream)
.map(StoredQueryMapper::asSearchToken)
.toList();

if (!searchToken.isEmpty()) {
documentFhirQuery.where(DocumentReference.RELATED.hasAnyOfIds(searchToken));
documentFhirQuery.where(new TokenClientParam("related:identifier").exactly().codes(searchToken));
}
}
mapDocuments(buildResultForDocuments(documentFhirQuery));
Expand Down Expand Up @@ -472,7 +471,7 @@ private List<T> getResourcesFromBundle(){
}
}

private Collection<Association> createAssociationsBetween(List<DocumentReference> fhirDocuments) {
private List<Association> createAssociationsBetween(List<DocumentReference> fhirDocuments) {
var xdsAssocations = new ArrayList<Association>();
for (var doc : fhirDocuments) {
for (var related : doc.getRelatesTo()) {
Expand All @@ -491,8 +490,8 @@ private Collection<Association> createAssociationsBetween(List<DocumentReference
return xdsAssocations;
}

private Collection<Association> createAssociationsBetween(List<MhdSubmissionSet> fhirSubmissions,
Collection<Association> fdDocAssoc) {
private List<Association> createAssociationsBetween(List<MhdSubmissionSet> fhirSubmissions,
List<Association> fdDocAssoc) {
var xdsAssocations = new ArrayList<Association>();
for (var list : fhirSubmissions) {
for (var entry : list.getEntry()) {
Expand All @@ -515,7 +514,7 @@ private Collection<Association> createAssociationsBetween(List<MhdSubmissionSet>
return xdsAssocations;
}

private Collection<Association> createAssociationsFrom(List<? extends ListResource> lists,
private List<Association> createAssociationsFrom(List<? extends ListResource> lists,
List<? extends DomainResource> fhirResource) {
var xdsAssocations = new ArrayList<Association>();
for (var list : lists) {
Expand Down Expand Up @@ -559,7 +558,7 @@ private List<MhdFolder> mapFolders(Iterable<MhdFolder> fhirFolder) {
return processedFhirFolders;
}

private void mapAssociations(Collection<Association> associations) {
private void mapAssociations(List<Association> associations) {
if (isObjectRefResult)
response.getReferences().addAll(associations.stream()
.map(assoc -> new ObjectReference(assoc.getEntryUuid())).toList());
Expand Down

0 comments on commit ce6e19f

Please sign in to comment.