001package ca.uhn.fhir.jpa.dao.data; 002 003import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; 004import ca.uhn.fhir.jpa.entity.TermConcept; 005import org.springframework.data.domain.Page; 006import org.springframework.data.domain.Pageable; 007import org.springframework.data.jpa.repository.JpaRepository; 008import org.springframework.data.jpa.repository.Modifying; 009import org.springframework.data.jpa.repository.Query; 010import org.springframework.data.repository.query.Param; 011 012import java.util.List; 013import java.util.Optional; 014 015/* 016 * #%L 017 * HAPI FHIR JPA Server 018 * %% 019 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 020 * %% 021 * Licensed under the Apache License, Version 2.0 (the "License"); 022 * you may not use this file except in compliance with the License. 023 * You may obtain a copy of the License at 024 * 025 * http://www.apache.org/licenses/LICENSE-2.0 026 * 027 * Unless required by applicable law or agreed to in writing, software 028 * distributed under the License is distributed on an "AS IS" BASIS, 029 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 030 * See the License for the specific language governing permissions and 031 * limitations under the License. 032 * #L% 033 */ 034 035public interface ITermConceptDao extends JpaRepository<TermConcept, Long>, IHapiFhirJpaRepository { 036 037 @Query("SELECT COUNT(t) FROM TermConcept t WHERE t.myCodeSystem.myId = :cs_pid") 038 Integer countByCodeSystemVersion(@Param("cs_pid") Long thePid); 039 040 @Query("SELECT c FROM TermConcept c WHERE c.myCodeSystem = :code_system AND c.myCode = :code") 041 Optional<TermConcept> findByCodeSystemAndCode(@Param("code_system") TermCodeSystemVersion theCodeSystem, @Param("code") String theCode); 042 043 @Modifying 044 @Query("DELETE FROM TermConcept WHERE myCodeSystem.myId = :cs_pid") 045 int deleteByCodeSystemVersion(@Param("cs_pid") Long thePid); 046 047 @Query("SELECT c FROM TermConcept c WHERE c.myCodeSystem = :code_system") 048 List<TermConcept> findByCodeSystemVersion(@Param("code_system") TermCodeSystemVersion theCodeSystem); 049 050 @Query("SELECT t FROM TermConcept t WHERE t.myIndexStatus = null") 051 Page<TermConcept> findResourcesRequiringReindexing(Pageable thePageRequest); 052 053}