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