Fix matcher. Add another medication test
This commit is contained in:
parent
46235226cf
commit
71ab400006
|
@ -39,12 +39,14 @@ import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||||
import org.hl7.fhir.r4.model.ContactPoint;
|
import org.hl7.fhir.r4.model.ContactPoint;
|
||||||
import org.hl7.fhir.r4.model.DateType;
|
import org.hl7.fhir.r4.model.DateType;
|
||||||
import org.hl7.fhir.r4.model.Medication;
|
import org.hl7.fhir.r4.model.Medication;
|
||||||
import org.hl7.fhir.r4.model.Organization;
|
import org.hl7.fhir.r4.model.Organization;
|
||||||
import org.hl7.fhir.r4.model.Patient;
|
import org.hl7.fhir.r4.model.Patient;
|
||||||
import org.hl7.fhir.r4.model.Practitioner;
|
import org.hl7.fhir.r4.model.Practitioner;
|
||||||
|
import org.hl7.fhir.r4.model.Reference;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
@ -321,6 +323,20 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
|
||||||
return thePatient;
|
return thePatient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Medication buildMedication(String theManufacturerReference) {
|
||||||
|
Medication medication = new Medication();
|
||||||
|
medication.setManufacturer(new Reference(theManufacturerReference));
|
||||||
|
CodeableConcept codeableConcept = new CodeableConcept();
|
||||||
|
codeableConcept.addCoding().setSystem("zoop").setCode("boop");
|
||||||
|
medication.setCode(codeableConcept);
|
||||||
|
return medication;
|
||||||
|
}
|
||||||
|
protected Medication createMedicationAndUpdateLinks(Medication theMedication) {
|
||||||
|
theMedication = createMedication(theMedication);
|
||||||
|
myEmpiMatchLinkSvc.updateEmpiLinksForEmpiTarget(theMedication, createContextForCreate("Medication"));
|
||||||
|
return theMedication;
|
||||||
|
}
|
||||||
|
|
||||||
protected EmpiTransactionContext createContextForCreate(String theResourceType) {
|
protected EmpiTransactionContext createContextForCreate(String theResourceType) {
|
||||||
EmpiTransactionContext ctx = new EmpiTransactionContext();
|
EmpiTransactionContext ctx = new EmpiTransactionContext();
|
||||||
ctx.setRestOperation(EmpiTransactionContext.OperationType.CREATE_RESOURCE);
|
ctx.setRestOperation(EmpiTransactionContext.OperationType.CREATE_RESOURCE);
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
|
||||||
org.setId("Organization/mfr");
|
org.setId("Organization/mfr");
|
||||||
myOrganizationDao.update(org);
|
myOrganizationDao.update(org);
|
||||||
|
|
||||||
|
|
||||||
Medication medication = buildMedication();
|
Medication medication = buildMedication();
|
||||||
Medication createdMedication = createMedication(medication);
|
Medication createdMedication = createMedication(medication);
|
||||||
Medication newMedication = buildMedication();
|
Medication newMedication = buildMedication();
|
||||||
|
@ -77,6 +78,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
|
||||||
Bundle.BundleEntrySearchComponent searchComponent = entry0.getSearch();
|
Bundle.BundleEntrySearchComponent searchComponent = entry0.getSearch();
|
||||||
assertEquals(Bundle.SearchEntryMode.MATCH, searchComponent.getMode());
|
assertEquals(Bundle.SearchEntryMode.MATCH, searchComponent.getMode());
|
||||||
|
|
||||||
|
//Since there is only
|
||||||
assertEquals(1.0 / 1.0, searchComponent.getScore().doubleValue(), 0.01);
|
assertEquals(1.0 / 1.0, searchComponent.getScore().doubleValue(), 0.01);
|
||||||
Extension matchGradeExtension = searchComponent.getExtensionByUrl(EmpiConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
|
Extension matchGradeExtension = searchComponent.getExtensionByUrl(EmpiConstants.FIHR_STRUCTURE_DEF_MATCH_GRADE_URL_NAMESPACE);
|
||||||
assertNotNull(matchGradeExtension);
|
assertNotNull(matchGradeExtension);
|
||||||
|
@ -84,14 +86,6 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Medication buildMedication() {
|
|
||||||
Medication medication = new Medication();
|
|
||||||
medication.setManufacturer(new Reference("Organization/mfr"));
|
|
||||||
CodeableConcept codeableConcept = new CodeableConcept();
|
|
||||||
codeableConcept.addCoding().setSystem("zoop").setCode("boop");
|
|
||||||
medication.setCode(codeableConcept);
|
|
||||||
return medication;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServerLevelMatch() throws Exception {
|
public void testServerLevelMatch() throws Exception {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import ca.uhn.fhir.empi.util.EIDHelper;
|
||||||
import ca.uhn.fhir.empi.util.EmpiUtil;
|
import ca.uhn.fhir.empi.util.EmpiUtil;
|
||||||
import ca.uhn.fhir.empi.util.PersonHelper;
|
import ca.uhn.fhir.empi.util.PersonHelper;
|
||||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||||
import ca.uhn.fhir.jpa.api.dao.IDao;
|
|
||||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||||
import ca.uhn.fhir.jpa.dao.data.IEmpiLinkDao;
|
import ca.uhn.fhir.jpa.dao.data.IEmpiLinkDao;
|
||||||
import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
|
import ca.uhn.fhir.jpa.empi.BaseEmpiR4Test;
|
||||||
|
@ -22,6 +21,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.r4.model.Enumerations;
|
import org.hl7.fhir.r4.model.Enumerations;
|
||||||
import org.hl7.fhir.r4.model.HumanName;
|
import org.hl7.fhir.r4.model.HumanName;
|
||||||
import org.hl7.fhir.r4.model.Identifier;
|
import org.hl7.fhir.r4.model.Identifier;
|
||||||
|
import org.hl7.fhir.r4.model.Organization;
|
||||||
import org.hl7.fhir.r4.model.Patient;
|
import org.hl7.fhir.r4.model.Patient;
|
||||||
import org.hl7.fhir.r4.model.Practitioner;
|
import org.hl7.fhir.r4.model.Practitioner;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -46,7 +46,9 @@ import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.hamcrest.Matchers.in;
|
import static org.hamcrest.Matchers.in;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
public class EmpiMatchLinkSvcTest extends BaseEmpiR4Test {
|
public class EmpiMatchLinkSvcTest extends BaseEmpiR4Test {
|
||||||
|
@ -78,6 +80,19 @@ public class EmpiMatchLinkSvcTest extends BaseEmpiR4Test {
|
||||||
assertLinksMatchedByEid(false);
|
assertLinksMatchedByEid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddMedicationLinksToNewGoldenRecordMedicationIfNoneFound() {
|
||||||
|
Organization org = new Organization();
|
||||||
|
org.setId("Organization/mfr");
|
||||||
|
myOrganizationDao.update(org);
|
||||||
|
|
||||||
|
createMedicationAndUpdateLinks(buildMedication("Organization/mfr"));
|
||||||
|
assertLinkCount(1);
|
||||||
|
assertLinksMatchResult(MATCH);
|
||||||
|
assertLinksCreatedNewResource(true);
|
||||||
|
assertLinksMatchedByEid(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddPatientLinksToNewlyCreatedResourceIfNoMatch() {
|
public void testAddPatientLinksToNewlyCreatedResourceIfNoMatch() {
|
||||||
Patient patient1 = createPatientAndUpdateLinks(buildJanePatient());
|
Patient patient1 = createPatientAndUpdateLinks(buildJanePatient());
|
||||||
|
|
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.empi.rules.svc;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.empi.api.EmpiConstants;
|
||||||
import ca.uhn.fhir.empi.api.EmpiMatchEvaluation;
|
import ca.uhn.fhir.empi.api.EmpiMatchEvaluation;
|
||||||
import ca.uhn.fhir.empi.api.EmpiMatchOutcome;
|
import ca.uhn.fhir.empi.api.EmpiMatchOutcome;
|
||||||
import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
|
import ca.uhn.fhir.empi.api.EmpiMatchResultEnum;
|
||||||
|
@ -120,7 +121,7 @@ public class EmpiResourceMatcherSvc {
|
||||||
//TODO GGG MDM: This grabs ALL comparators, not just the ones we care about (e.g. the ones for Medication)
|
//TODO GGG MDM: This grabs ALL comparators, not just the ones we care about (e.g. the ones for Medication)
|
||||||
String resourceType = myFhirContext.getResourceType(theLeftResource);
|
String resourceType = myFhirContext.getResourceType(theLeftResource);
|
||||||
List<EmpiResourceFieldMatcher> resourceRelevantFieldMatchers = myFieldMatchers.stream()
|
List<EmpiResourceFieldMatcher> resourceRelevantFieldMatchers = myFieldMatchers.stream()
|
||||||
.filter(comp -> comp.getResourceType().equalsIgnoreCase("*") || comp.getResourceType().equalsIgnoreCase(resourceType))
|
.filter(comp -> comp.getResourceType().equalsIgnoreCase(EmpiConstants.ALL_RESOURCE_SEARCH_PARAM_TYPE) || comp.getResourceType().equalsIgnoreCase(resourceType))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
for (int i = 0; i < resourceRelevantFieldMatchers.size(); ++i) {
|
for (int i = 0; i < resourceRelevantFieldMatchers.size(); ++i) {
|
||||||
|
|
Loading…
Reference in New Issue