001package ca.uhn.fhir.mdm.rules.json;
002
003/*-
004 * #%L
005 * HAPI FHIR - Master Data Management
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.context.FhirContext;
024import ca.uhn.fhir.mdm.rules.matcher.MdmMatcherEnum;
025import ca.uhn.fhir.model.api.IModelJson;
026import com.fasterxml.jackson.annotation.JsonProperty;
027import org.hl7.fhir.instance.model.api.IBase;
028
029public class MdmMatcherJson implements IModelJson {
030        @JsonProperty(value = "algorithm", required = true)
031        MdmMatcherEnum myAlgorithm;
032
033        @JsonProperty(value = "identifierSystem", required = false)
034        String myIdentifierSystem;
035
036        /**
037         * For String value types, should the values be normalized (case, accents) before they are compared
038         */
039        @JsonProperty(value = "exact")
040        boolean myExact;
041
042        public MdmMatcherEnum getAlgorithm() {
043                return myAlgorithm;
044        }
045
046        public MdmMatcherJson setAlgorithm(MdmMatcherEnum theAlgorithm) {
047                myAlgorithm = theAlgorithm;
048                return this;
049        }
050
051        public String getIdentifierSystem() {
052                return myIdentifierSystem;
053        }
054
055        public MdmMatcherJson setIdentifierSystem(String theIdentifierSystem) {
056                myIdentifierSystem = theIdentifierSystem;
057                return this;
058        }
059
060        public boolean getExact() {
061                return myExact;
062        }
063
064        public MdmMatcherJson setExact(boolean theExact) {
065                myExact = theExact;
066                return this;
067        }
068
069        public boolean isMatchingEmptyFields() {
070                return myAlgorithm.isMatchingEmptyFields();
071        }
072
073        public boolean match(FhirContext theFhirContext, IBase theLeftValue, IBase theRightValue) {
074                return myAlgorithm.match(theFhirContext, theLeftValue, theRightValue, myExact, myIdentifierSystem);
075        }
076}