001package ca.uhn.fhir.jpa.dao.data;
002
003import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink;
004import org.springframework.data.domain.Pageable;
005import org.springframework.data.domain.Slice;
006import org.springframework.data.jpa.repository.JpaRepository;
007import org.springframework.data.jpa.repository.Query;
008import org.springframework.data.repository.query.Param;
009
010import java.util.Collection;
011
012/*
013 * #%L
014 * HAPI FHIR JPA Server
015 * %%
016 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
017 * %%
018 * Licensed under the Apache License, Version 2.0 (the "License");
019 * you may not use this file except in compliance with the License.
020 * You may obtain a copy of the License at
021 *
022 *      http://www.apache.org/licenses/LICENSE-2.0
023 *
024 * Unless required by applicable law or agreed to in writing, software
025 * distributed under the License is distributed on an "AS IS" BASIS,
026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
027 * See the License for the specific language governing permissions and
028 * limitations under the License.
029 * #L%
030 */
031
032public interface ITermConceptParentChildLinkDao extends JpaRepository<TermConceptParentChildLink, Long>, IHapiFhirJpaRepository {
033
034        @Query("SELECT COUNT(t) FROM TermConceptParentChildLink t WHERE t.myCodeSystem.myId = :cs_pid")
035        Integer countByCodeSystemVersion(@Param("cs_pid") Long thePid);
036
037        @Query("SELECT t.myParentPid FROM TermConceptParentChildLink t WHERE t.myChildPid = :child_pid")
038        Collection<Long> findAllWithChild(@Param("child_pid") Long theConceptPid);
039
040        @Query("SELECT t.myPid FROM TermConceptParentChildLink t WHERE t.myCodeSystem.myId = :cs_pid")
041        Slice<Long> findIdsByCodeSystemVersion(Pageable thePage, @Param("cs_pid") Long thePid);
042
043}