View Javadoc
1   package ca.uhn.fhir.jpa.dao.data;
2   
3   import ca.uhn.fhir.jpa.entity.TermCodeSystem;
4   import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
5   import org.springframework.data.jpa.repository.JpaRepository;
6   import org.springframework.data.jpa.repository.Modifying;
7   import org.springframework.data.jpa.repository.Query;
8   import org.springframework.data.repository.query.Param;
9   
10  import java.util.List;
11  
12  /*
13   * #%L
14   * HAPI FHIR JPA Server
15   * %%
16   * Copyright (C) 2014 - 2018 University Health Network
17   * %%
18   * Licensed under the Apache License, Version 2.0 (the "License");
19   * you may not use this file except in compliance with the License.
20   * You may obtain a copy of the License at
21   * 
22   *      http://www.apache.org/licenses/LICENSE-2.0
23   * 
24   * Unless required by applicable law or agreed to in writing, software
25   * distributed under the License is distributed on an "AS IS" BASIS,
26   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27   * See the License for the specific language governing permissions and
28   * limitations under the License.
29   * #L%
30   */
31  
32  public interface ITermCodeSystemVersionDao extends JpaRepository<TermCodeSystemVersion, Long> {
33  
34  	@Modifying
35  	@Query("DELETE FROM TermCodeSystemVersion csv WHERE csv.myCodeSystem = :cs")
36  	void deleteForCodeSystem(@Param("cs") TermCodeSystem theCodeSystem);
37  
38  	@Query("SELECT cs FROM TermCodeSystemVersion cs WHERE cs.myResource.myId = :resource_id")
39  	List<TermCodeSystemVersion> findByCodeSystemResource(@Param("resource_id") Long theCodeSystemResourcePid);
40  
41  	@Query("SELECT cs FROM TermCodeSystemVersion cs WHERE cs.myCodeSystemHavingThisVersionAsCurrentVersionIfAny.myResource.myId = :resource_id")
42  	TermCodeSystemVersion findCurrentVersionForCodeSystemResourcePid(@Param("resource_id") Long theCodeSystemResourcePid);
43  
44  }