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