
001package ca.uhn.fhir.jpa.dao.r4; 002 003/* 004 * #%L 005 * HAPI FHIR JPA Server 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import ca.uhn.fhir.interceptor.model.RequestPartitionId; 024import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDaoObservation; 025import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; 026import ca.uhn.fhir.jpa.model.entity.ResourceTable; 027import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc; 028import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; 029import ca.uhn.fhir.rest.api.CacheControlDirective; 030import ca.uhn.fhir.rest.api.Constants; 031import ca.uhn.fhir.rest.api.server.IBundleProvider; 032import ca.uhn.fhir.rest.api.server.RequestDetails; 033import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; 034import org.hl7.fhir.instance.model.api.IBaseResource; 035import org.hl7.fhir.r4.model.Observation; 036import org.springframework.beans.factory.annotation.Autowired; 037 038import javax.persistence.EntityManager; 039import javax.persistence.PersistenceContext; 040import javax.persistence.PersistenceContextType; 041import javax.servlet.http.HttpServletResponse; 042import java.util.Date; 043 044public class FhirResourceDaoObservationR4 extends BaseHapiFhirResourceDaoObservation<Observation> { 045 046 047 @PersistenceContext(type = PersistenceContextType.TRANSACTION) 048 protected EntityManager myEntityManager; 049 @Autowired 050 private IRequestPartitionHelperSvc myRequestPartitionHelperService; 051 052 @Override 053 public IBundleProvider observationsLastN(SearchParameterMap theSearchParameterMap, RequestDetails theRequestDetails, HttpServletResponse theServletResponse) { 054 updateSearchParamsForLastn(theSearchParameterMap, theRequestDetails); 055 056 RequestPartitionId requestPartitionId = myRequestPartitionHelperService.determineReadPartitionForRequestForSearchType(theRequestDetails, getResourceName(), theSearchParameterMap, null); 057 return mySearchCoordinatorSvc.registerSearch(this, theSearchParameterMap, getResourceName(), new CacheControlDirective().parse(theRequestDetails.getHeaders(Constants.HEADER_CACHE_CONTROL)), theRequestDetails, requestPartitionId); 058 } 059 060 @Override 061 protected String getEffectiveParamName() { 062 return Observation.SP_DATE; 063 } 064 065 @Override 066 protected String getCodeParamName() { 067 return Observation.SP_CODE; 068 } 069 070 @Override 071 protected String getSubjectParamName() { 072 return Observation.SP_SUBJECT; 073 } 074 075 @Override 076 protected String getPatientParamName() { 077 return Observation.SP_PATIENT; 078 } 079 080 @Override 081 public ResourceTable updateEntity(RequestDetails theRequest, IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing, 082 boolean theUpdateVersion, TransactionDetails theTransactionDetails, boolean theForceUpdate, boolean theCreateNewHistoryEntry) { 083 return updateObservationEntity(theRequest, theResource, theEntity, theDeletedTimestampOrNull, 084 thePerformIndexing, theUpdateVersion, theTransactionDetails, theForceUpdate, 085 theCreateNewHistoryEntry); 086 } 087 088}