001/*- 002 * #%L 003 * HAPI FHIR - Master Data Management 004 * %% 005 * Copyright (C) 2014 - 2025 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.mdm.provider; 021 022import ca.uhn.fhir.i18n.Msg; 023import ca.uhn.fhir.rest.annotation.Operation; 024import ca.uhn.fhir.rest.annotation.OperationParam; 025import ca.uhn.fhir.rest.api.server.RequestDetails; 026import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; 027import ca.uhn.fhir.rest.server.provider.ProviderConstants; 028import org.hl7.fhir.instance.model.api.IAnyResource; 029import org.hl7.fhir.instance.model.api.IBaseBundle; 030 031public class PatientMatchProvider { 032 private final MdmControllerHelper myMdmControllerHelper; 033 034 public PatientMatchProvider(MdmControllerHelper theMdmControllerHelper) { 035 myMdmControllerHelper = theMdmControllerHelper; 036 } 037 038 /** 039 * Searches for matches for the provided patient resource 040 * @param thePatient - the patient resource 041 * @param theRequestDetails - the request details 042 * @return - any matches to the provided patient resource 043 */ 044 @Operation(name = ProviderConstants.PATIENT_MATCH, typeName = "Patient") 045 public IBaseBundle match( 046 @OperationParam(name = ProviderConstants.MDM_MATCH_RESOURCE, min = 1, max = 1, typeName = "Patient") 047 IAnyResource thePatient, 048 RequestDetails theRequestDetails) { 049 if (thePatient == null) { 050 throw new InvalidRequestException(Msg.code(1498) + "resource may not be null"); 051 } 052 return myMdmControllerHelper.getMatchesAndPossibleMatchesForResource(thePatient, "Patient", theRequestDetails); 053 } 054}