diff --git a/README.md b/README.md index 035d0bf..8ebf6cd 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ The server may be configured with subscription support by enabling properties in ## Enabling EMPI -Set `empi.enabled=true` in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file to enable EMPI on this server. The EMPI matching rules are configured in [empi-rules.json](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/empi-rules.json). The rules in this example file should be replaced with actual matching rules appropriate to your data. +Set `empi.enabled=true` in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file to enable EMPI on this server. The EMPI matching rules are configured in [empi-rules.json](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/empi-rules.json). The rules in this example file should be replaced with actual matching rules appropriate to your data. Note that EMPI relies on subscriptions, so for EMPI to work, subscriptions must be enabled. ## Using Elasticsearch diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java index 462aba8..107aa97 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/EmpiConfig.java @@ -1,9 +1,15 @@ package ca.uhn.fhir.jpa.starter; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.empi.api.IEmpiSettings; +import ca.uhn.fhir.empi.rules.config.EmpiRuleValidator; import ca.uhn.fhir.empi.rules.config.EmpiSettings; +import ca.uhn.fhir.jpa.empi.svc.EmpiSearchParamSvc; +import ca.uhn.fhir.jpa.subscription.channel.subscription.IChannelNamer; +import ca.uhn.fhir.rest.server.util.ISearchParamRetriever; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.DefaultResourceLoader; @@ -15,11 +21,11 @@ import java.io.IOException; public class EmpiConfig { @Bean - IEmpiSettings empiSettings() throws IOException { + IEmpiSettings empiSettings(EmpiRuleValidator theEmpiRuleValidator) throws IOException { DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource = resourceLoader.getResource("empi-rules.json"); String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8); - return null; // new EmpiSettings().setEnabled(HapiProperties.getEmpiEnabled()).setScriptText(json); + return new EmpiSettings(theEmpiRuleValidator).setEnabled(HapiProperties.getEmpiEnabled()).setScriptText(json); } } diff --git a/src/main/resources/empi-rules.json b/src/main/resources/empi-rules.json index 78e77b6..ad549d8 100644 --- a/src/main/resources/empi-rules.json +++ b/src/main/resources/empi-rules.json @@ -1,35 +1,46 @@ { - "candidateSearchParams" : [ { - "resourceType" : "Patient", - "searchParam" : "birthdate" - }, { - "resourceType" : "*", - "searchParam" : "identifier" - },{ - "resourceType" : "Patient", - "searchParam" : "general-practitioner" - } ], - "candidateFilterSearchParams" : [ { - "resourceType" : "*", - "searchParam" : "active", - "fixedValue" : "true" - } ], - "matchFields" : [ { - "name" : "given-name", - "resourceType" : "*", - "resourcePath" : "name.given", - "metric" : "COSINE", - "matchThreshold" : 0.8 - }, { - "name" : "last-name", - "resourceType" : "*", - "resourcePath" : "name.family", - "metric" : "JARO_WINKLER", - "matchThreshold" : 0.8 - }], - "matchResultMap" : { - "given-name" : "POSSIBLE_MATCH", - "given-name,last-name" : "MATCH" - }, - "eidSystem": "http://company.io/fhir/NamingSystem/custom-eid-system" + "candidateSearchParams": [ + { + "resourceType": "Patient", + "searchParams": ["birthdate"] + }, + { + "resourceType": "*", + "searchParams": ["identifier"] + }, + { + "resourceType": "Patient", + "searchParams": ["general-practitioner"] + } + ], + "candidateFilterSearchParams": [ + { + "resourceType": "*", + "searchParam": "active", + "fixedValue": "true" + } + ], + "matchFields": [ + { + "name": "cosine-given-name", + "resourceType": "*", + "resourcePath": "name.given", + "metric": "COSINE", + "matchThreshold": 0.8, + "exact": true + }, + { + "name": "jaro-last-name", + "resourceType": "*", + "resourcePath": "name.family", + "metric": "JARO_WINKLER", + "matchThreshold": 0.8, + "exact": true + } + ], + "matchResultMap": { + "cosine-given-name" : "POSSIBLE_MATCH", + "cosine-given-name,jaro-last-name" : "MATCH" + }, + "eidSystem": "http://company.io/fhir/NamingSystem/custom-eid-system" }