View Javadoc
1   package ca.uhn.fhir.jpa.dao.data;
2   
3   import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
4   import ca.uhn.fhir.jpa.entity.TermConcept;
5   import org.springframework.data.domain.Page;
6   import org.springframework.data.domain.Pageable;
7   import org.springframework.data.domain.Slice;
8   import org.springframework.data.jpa.repository.JpaRepository;
9   import org.springframework.data.jpa.repository.Modifying;
10  import org.springframework.data.jpa.repository.Query;
11  import org.springframework.data.repository.query.Param;
12  
13  import java.util.List;
14  
15  /*
16   * #%L
17   * HAPI FHIR JPA Server
18   * %%
19   * Copyright (C) 2014 - 2018 University Health Network
20   * %%
21   * Licensed under the Apache License, Version 2.0 (the "License");
22   * you may not use this file except in compliance with the License.
23   * You may obtain a copy of the License at
24   * 
25   *      http://www.apache.org/licenses/LICENSE-2.0
26   * 
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS,
29   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30   * See the License for the specific language governing permissions and
31   * limitations under the License.
32   * #L%
33   */
34  
35  public interface ITermConceptDao extends JpaRepository<TermConcept, Long> {
36  
37  	@Query("SELECT COUNT(t) FROM TermConcept t WHERE t.myCodeSystem.myId = :cs_pid")
38  	Integer countByCodeSystemVersion(@Param("cs_pid") Long thePid);
39  
40  	@Query("SELECT c FROM TermConcept c WHERE c.myCodeSystem = :code_system AND c.myCode = :code")
41  	TermConcept findByCodeSystemAndCode(@Param("code_system") TermCodeSystemVersion theCodeSystem, @Param("code") String theCode);
42  
43  	@Query("SELECT t FROM TermConcept t WHERE t.myCodeSystem.myId = :cs_pid")
44  	Slice<TermConcept> findByCodeSystemVersion(Pageable thePage, @Param("cs_pid") Long thePid);
45  
46  	@Query("SELECT c FROM TermConcept c WHERE c.myCodeSystem = :code_system")
47  	List<TermConcept> findByCodeSystemVersion(@Param("code_system") TermCodeSystemVersion theCodeSystem);
48  
49  	@Query("SELECT t FROM TermConcept t WHERE t.myIndexStatus = null")
50  	Page<TermConcept> findResourcesRequiringReindexing(Pageable thePageRequest);
51  
52  	@Query("UPDATE TermConcept t SET t.myIndexStatus = null")
53  	@Modifying
54  	int markAllForReindexing();
55  
56  }