Skip to content

Commit

Permalink
Merge 747505d into 906355d
Browse files Browse the repository at this point in the history
  • Loading branch information
Capt-Mac authored Jul 13, 2023
2 parents 906355d + 747505d commit 44507b7
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.param.UriParam;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
Expand Down Expand Up @@ -74,9 +75,22 @@ public Iterable<IBaseResource> search(String theResourceType) {

@Override
public Iterable<IBaseResource> searchByUrl(String theResourceType, String theUrl) {
var b = this.myDaoRegistry
.getResourceDao(theResourceType)
.search(new SearchParameterMap().add("url", new UriParam(theUrl)), myRequestDetails);
return new BundleIterable(myRequestDetails, b);
if (theUrl.contains("|")) {
var urlSplit = theUrl.split("\\|");
var urlBase = urlSplit[0];
var urlVersion = urlSplit[1];

var a = this.myDaoRegistry
.getResourceDao(theResourceType)
.search(SearchParameterMap.newSynchronous()
.add("url", new UriParam(urlBase))
.add("version", new TokenParam(urlVersion)));
return new BundleIterable(myRequestDetails, a);
} else {
var b = this.myDaoRegistry
.getResourceDao(theResourceType)
.search(SearchParameterMap.newSynchronous().add("url", new UriParam(theUrl)));
return new BundleIterable(myRequestDetails, b);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import ca.uhn.fhir.cr.BaseCrR4Test;
import ca.uhn.fhir.cr.common.HapiFhirDal;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* This class tests the functionality of HapiFhirDal operations inside the cr module
*/
Expand Down Expand Up @@ -37,4 +41,19 @@ void canSearchMoreThan50Patients(){
assertEquals(63, counter, "Patient search results don't match available resources");
}

@Test
void canSearchVersionURL(){
loadBundle("ca/uhn/fhir/cr/r4/Bundle-HapiFhirDalTestLibrary.json");

HapiFhirDal hapiFhirDal = new HapiFhirDal(this.getDaoRegistry(), null);
var url = "http://content.smilecdr.com/fhir/dqm/Library/ImmunizationStatusRoutine|2.0.1";
var result = hapiFhirDal.searchByUrl("Library", url);

var resultIter = result.iterator();
assertTrue(resultIter.hasNext());
var finalResult = resultIter.next();
assertNotNull(finalResult);
}


}
Loading

0 comments on commit 44507b7

Please sign in to comment.