Skip to content

Commit

Permalink
Started refactor of the code to work on OpenMRS 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-fyfe committed Jan 30, 2020
1 parent 147ba6c commit 11b33e3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
4 changes: 4 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<artifactId>openmrs-web</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v231</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -82,9 +84,11 @@ public void run() {

if(pit != null && patient.getPatientIdentifier(pit) == null) {
PatientIdentifier pid = hieService.resolvePatientIdentifier(patient, xrefDomain);

List<PatientIdentifierType> pitList = new ArrayList<PatientIdentifierType>();
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -73,10 +76,13 @@ public void run() {
break;
}

List<PatientIdentifierType> pitList = new ArrayList<PatientIdentifierType>();
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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<String, String> exportIdentifiers = this.m_configuration.getLocalPatientIdentifierTypeMap();
Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
scope: Find matching dependencies in maven central repository. <dependency>
<groupId>org.other.library</groupId> <artifactId>library-name</artifactId>
<version>library.version</version> <scope>compile</scope> </dependency> -->

<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v231</artifactId>
<version>2.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
Expand Down Expand Up @@ -124,7 +130,7 @@
</dependencyManagement>

<properties>
<openMRSVersion>1.9.8</openMRSVersion>
<openMRSVersion>2.2.0</openMRSVersion>
</properties>

<build>
Expand Down

0 comments on commit 11b33e3

Please sign in to comment.