Search in sources :

Example 1 with FhirResourceCriteria

use of org.hl7.davinci.endpoint.database.FhirResourceCriteria in project CRD by HL7-DaVinci.

the class ValueSetCache method fetchValueSet.

/**
 * Fetch a ValueSet from VSAC or cache and add it to the FhirResourceRepository.
 * @param oid The VSAC OID of the ValueSet to fetch.
 * @return true if sucessful, false if failed to fetch ValueSet.
 */
public boolean fetchValueSet(String oid) {
    // check if the valueset has already been loaded
    FhirResourceCriteria criteria = new FhirResourceCriteria();
    criteria.setFhirVersion("R4").setResourceType("valueset").setId("valueset/" + oid);
    List<FhirResource> fhirResourceList = fhirResources.findById(criteria);
    // Skip fetching if it already has been loaded
    if (!fhirResourceList.isEmpty()) {
        logger.info("ValueSet (" + oid + ") already loaded.");
        return true;
    }
    // If the VSACLoader is initialized, attempt to fetch from VSAC. Otherwise fall back to cache dir.
    if (this.vsacLoader == null) {
        return this.fetchValueSetFromCache(oid);
    } else {
        return this.fetchValueSetFromVSAC(oid);
    }
}
Also used : FhirResource(org.hl7.davinci.endpoint.database.FhirResource) FhirResourceCriteria(org.hl7.davinci.endpoint.database.FhirResourceCriteria)

Aggregations

FhirResource (org.hl7.davinci.endpoint.database.FhirResource)1 FhirResourceCriteria (org.hl7.davinci.endpoint.database.FhirResourceCriteria)1