001/*- 002 * #%L 003 * HAPI FHIR - Server Framework 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.rest.server.interceptor.consent; 021 022import org.apache.commons.lang3.Validate; 023import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; 024import org.hl7.fhir.instance.model.api.IBaseResource; 025 026public class ConsentOutcome { 027 028 /** 029 * Convenience constant containing <code>new ConsentOutcome(ConsentOperationStatusEnum.PROCEED)</code> 030 */ 031 public static final ConsentOutcome PROCEED = new ConsentOutcome(ConsentOperationStatusEnum.PROCEED); 032 /** 033 * Convenience constant containing <code>new ConsentOutcome(ConsentOperationStatusEnum.REJECT)</code> 034 */ 035 public static final ConsentOutcome REJECT = new ConsentOutcome(ConsentOperationStatusEnum.REJECT); 036 /** 037 * Convenience constant containing <code>new ConsentOutcome(ConsentOperationStatusEnum.AUTHORIZED)</code> 038 */ 039 public static final ConsentOutcome AUTHORIZED = new ConsentOutcome(ConsentOperationStatusEnum.AUTHORIZED); 040 041 private final ConsentOperationStatusEnum myStatus; 042 private final IBaseOperationOutcome myOperationOutcome; 043 private final IBaseResource myResource; 044 045 public ConsentOutcome(ConsentOperationStatusEnum theStatus) { 046 this(theStatus, null, null); 047 } 048 049 public ConsentOutcome(ConsentOperationStatusEnum theStatus, IBaseOperationOutcome theOperationOutcome) { 050 this(theStatus, theOperationOutcome, null); 051 } 052 053 public ConsentOutcome(ConsentOperationStatusEnum theStatus, IBaseResource theResource) { 054 this(theStatus, null, theResource); 055 } 056 057 private ConsentOutcome( 058 ConsentOperationStatusEnum theStatus, 059 IBaseOperationOutcome theOperationOutcome, 060 IBaseResource theResource) { 061 Validate.notNull(theStatus, "theStatus must not be null"); 062 Validate.isTrue( 063 !(theOperationOutcome != null && theResource != null), 064 "theOperationOutcome and theResource must not both be null"); 065 myStatus = theStatus; 066 myOperationOutcome = theOperationOutcome; 067 myResource = theResource; 068 } 069 070 public ConsentOperationStatusEnum getStatus() { 071 return myStatus; 072 } 073 074 public IBaseOperationOutcome getOperationOutcome() { 075 return myOperationOutcome; 076 } 077 078 public IBaseResource getResource() { 079 return myResource; 080 } 081}