001/* 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.dao.dstu3; 021 022import ca.uhn.fhir.jpa.dao.BaseHapiFhirSystemDao; 023import ca.uhn.fhir.jpa.dao.JpaResourceDao; 024import ca.uhn.fhir.jpa.model.entity.TagDefinition; 025import ca.uhn.fhir.rest.api.server.RequestDetails; 026import jakarta.persistence.TypedQuery; 027import org.hl7.fhir.dstu3.model.Bundle; 028import org.hl7.fhir.dstu3.model.Meta; 029import org.hl7.fhir.instance.model.api.IBaseBundle; 030 031import java.util.Collection; 032import java.util.List; 033 034public class FhirSystemDaoDstu3 extends BaseHapiFhirSystemDao<Bundle, Meta> { 035 036 @Override 037 public Meta metaGetOperation(RequestDetails theRequestDetails) { 038 String sql = "SELECT d FROM TagDefinition d WHERE d.myId IN (SELECT DISTINCT t.myTagId FROM ResourceTag t)"; 039 TypedQuery<TagDefinition> q = myEntityManager.createQuery(sql, TagDefinition.class); 040 List<TagDefinition> tagDefinitions = q.getResultList(); 041 042 return toMeta(tagDefinitions); 043 } 044 045 private Meta toMeta(Collection<TagDefinition> tagDefinitions) { 046 Meta retVal = new Meta(); 047 for (TagDefinition next : tagDefinitions) { 048 switch (next.getTagType()) { 049 case PROFILE: 050 retVal.addProfile(next.getCode()); 051 break; 052 case SECURITY_LABEL: 053 retVal.addSecurity() 054 .setSystem(next.getSystem()) 055 .setCode(next.getCode()) 056 .setDisplay(next.getDisplay()); 057 break; 058 case TAG: 059 retVal.addTag() 060 .setSystem(next.getSystem()) 061 .setCode(next.getCode()) 062 .setDisplay(next.getDisplay()); 063 break; 064 } 065 } 066 return retVal; 067 } 068 069 @Override 070 public IBaseBundle processMessage(RequestDetails theRequestDetails, IBaseBundle theMessage) { 071 return JpaResourceDao.throwProcessMessageNotImplemented(); 072 } 073}