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.api.MdmMatchEvaluation;
025import ca.uhn.fhir.mdm.rules.similarity.MdmSimilarityEnum;
026import ca.uhn.fhir.model.api.IModelJson;
027import com.fasterxml.jackson.annotation.JsonProperty;
028import org.hl7.fhir.instance.model.api.IBase;
029
030import javax.annotation.Nullable;
031
032public class MdmSimilarityJson implements IModelJson {
033        @JsonProperty(value = "algorithm", required = true)
034        MdmSimilarityEnum myAlgorithm;
035
036        @JsonProperty(value = "matchThreshold", required = true)
037        Double myMatchThreshold;
038
039        /**
040         * For String value types, should the values be normalized (case, accents) before they are compared
041         */
042        @JsonProperty(value = "exact")
043        boolean myExact;
044
045        public MdmSimilarityEnum getAlgorithm() {
046                return myAlgorithm;
047        }
048
049        public MdmSimilarityJson setAlgorithm(MdmSimilarityEnum theAlgorithm) {
050                myAlgorithm = theAlgorithm;
051                return this;
052        }
053
054        @Nullable
055        public Double getMatchThreshold() {
056                return myMatchThreshold;
057        }
058
059        public MdmSimilarityJson setMatchThreshold(double theMatchThreshold) {
060                myMatchThreshold = theMatchThreshold;
061                return this;
062        }
063
064        public boolean getExact() {
065                return myExact;
066        }
067
068        public MdmSimilarityJson setExact(boolean theExact) {
069                myExact = theExact;
070                return this;
071        }
072
073        public MdmMatchEvaluation match(FhirContext theFhirContext, IBase theLeftValue, IBase theRightValue) {
074                return myAlgorithm.match(theFhirContext, theLeftValue, theRightValue, myExact, myMatchThreshold);
075        }
076}