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