From 11b33e3ab8d2f5c38a2104d385241dea7f2c1a91 Mon Sep 17 00:00:00 2001 From: Justin Fyfe Date: Thu, 30 Jan 2020 12:31:27 -0500 Subject: [PATCH] Started refactor of the code to work on OpenMRS 2.x --- api/pom.xml | 4 ++++ .../santedb/mpiclient/aop/PatientSyncWorker.java | 8 ++++++-- .../santedb/mpiclient/aop/PatientUpdateWorker.java | 8 +++++++- .../module/santedb/mpiclient/util/FhirUtil.java | 13 +++---------- pom.xml | 10 ++++++++-- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 8573abd..f5686ee 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -36,6 +36,10 @@ openmrs-web test-jar + + ca.uhn.hapi + hapi-structures-v231 + org.apache.commons commons-lang3 diff --git a/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientSyncWorker.java b/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientSyncWorker.java index 20c456a..f9091d8 100644 --- a/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientSyncWorker.java +++ b/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientSyncWorker.java @@ -1,7 +1,9 @@ package org.openmrs.module.santedb.mpiclient.aop; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -82,9 +84,11 @@ public void run() { if(pit != null && patient.getPatientIdentifier(pit) == null) { PatientIdentifier pid = hieService.resolvePatientIdentifier(patient, xrefDomain); - + List pitList = new ArrayList(); + pitList.add(pit); + // Already exists - if(pid != null && Context.getPatientService().getPatientIdentifiers(pid.getIdentifier(), pit).size() != 0) + if(pid != null && Context.getPatientService().getPatientIdentifiers(pid.getIdentifier(), pitList, null, null, null).size() != 0) log.warn(String.format("Identifier %s already exists", pid.getIdentifier())); else if(pid != null) { pid.setPatient(patient); diff --git a/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientUpdateWorker.java b/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientUpdateWorker.java index 638a627..fb77852 100644 --- a/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientUpdateWorker.java +++ b/api/src/main/java/org/openmrs/module/santedb/mpiclient/aop/PatientUpdateWorker.java @@ -1,9 +1,12 @@ package org.openmrs.module.santedb.mpiclient.aop; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.marc.everest.datatypes.generic.LIST; import org.openmrs.Patient; import org.openmrs.PatientIdentifier; import org.openmrs.PatientIdentifierType; @@ -73,10 +76,13 @@ public void run() { break; } + List pitList = new ArrayList(); + pitList.add(pit); + if (pit != null && this.m_patient.getPatientIdentifier(pit) == null) { PatientIdentifier pid = hieService.resolvePatientIdentifier(this.m_patient, xrefDomain); // Already exists - if(pid != null && Context.getPatientService().getPatientIdentifiers(pid.getIdentifier(), pit).size() != 0) + if(pid != null && Context.getPatientService().getPatientIdentifiers(pid.getIdentifier(), pitList, null, null, null).size() != 0) log.warn(String.format("Identifier %s already exists", pid.getIdentifier())); else if (pid != null) { pid.setPatient(this.m_patient); diff --git a/api/src/main/java/org/openmrs/module/santedb/mpiclient/util/FhirUtil.java b/api/src/main/java/org/openmrs/module/santedb/mpiclient/util/FhirUtil.java index c4e5411..bd26558 100644 --- a/api/src/main/java/org/openmrs/module/santedb/mpiclient/util/FhirUtil.java +++ b/api/src/main/java/org/openmrs/module/santedb/mpiclient/util/FhirUtil.java @@ -36,14 +36,7 @@ import ca.uhn.hl7v2.HL7Exception; import ca.uhn.hl7v2.model.DataTypeException; -import ca.uhn.hl7v2.model.Segment; -import ca.uhn.hl7v2.model.Structure; -import ca.uhn.hl7v2.model.v25.datatype.CX; -import ca.uhn.hl7v2.model.v25.datatype.XAD; -import ca.uhn.hl7v2.model.v25.datatype.XPN; -import ca.uhn.hl7v2.model.v25.segment.NK1; -import ca.uhn.hl7v2.util.Terser; -import net.sf.saxon.regex.RegexSyntaxException; + public class FhirUtil { @@ -176,7 +169,7 @@ private PatientIdentifier interpretFhirId(Identifier id) { * @param pn The person name to convert * @throws RegexSyntaxException */ - private void updateFhirName(HumanName name, PersonName pn) throws RegexSyntaxException { + private void updateFhirName(HumanName name, PersonName pn) { String nameRewrite = this.m_configuration.getNameRewriteRule(); @@ -266,7 +259,7 @@ else if (this.m_configuration.getDefaultCountry() != null * @throws RegexSyntaxException */ public org.hl7.fhir.r4.model.Patient createFhirPatient(Patient patient, boolean localIdOnly) - throws HL7Exception, RegexSyntaxException { + throws HL7Exception { // Update the PID information HashMap exportIdentifiers = this.m_configuration.getLocalPatientIdentifierTypeMap(); diff --git a/pom.xml b/pom.xml index 6252c49..74d2af0 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,13 @@ scope: Find matching dependencies in maven central repository. org.other.library library-name library.version compile --> - + + ca.uhn.hapi + hapi-structures-v231 + 2.0 + jar + provided + org.openmrs.api openmrs-api @@ -124,7 +130,7 @@ - 1.9.8 + 2.2.0