Skip to content

Commit

Permalink
Update order id to include obs id (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Dec 9, 2024
1 parent 6da3ae2 commit 001a1b7
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.config.LabIntegrationProperties;
import org.openmrs.module.labintegration.api.hl7.config.OrderIdentifier;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.ObrGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.OrcGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.PidGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.ObrGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.OrcGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.PidGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.util.VersionSwitcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.config.LabIntegrationProperties;
import org.openmrs.module.labintegration.api.hl7.config.OrderIdentifier;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.ObrGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.OrcGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.PidGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.Pv1Generator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.ObrGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.OrcGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.PidGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.Pv1Generator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators;
package org.openmrs.module.labintegration.api.hl7.messages.generators;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.segment.MSH;
import org.openmrs.module.labintegration.api.date.DateSource;
import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.messages.generators.msh.MessageControlIdSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators;
package org.openmrs.module.labintegration.api.hl7.messages.generators;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.v25.segment.OBR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators;
package org.openmrs.module.labintegration.api.hl7.messages.generators;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.v25.segment.ORC;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators;
package org.openmrs.module.labintegration.api.hl7.messages.generators;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.segment.PID;
import org.openmrs.Encounter;
import org.openmrs.Patient;
import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.messages.MessageCreationException;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid.PidAddressHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid.PidBillingNumberHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid.PidIdHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid.PidMotherNameHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid.PidNameHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid.RegistrationDataHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pid.PidAddressHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pid.PidBillingNumberHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pid.PidIdHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pid.PidMotherNameHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pid.PidNameHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pid.RegistrationDataHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators;
package org.openmrs.module.labintegration.api.hl7.messages.generators;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.v25.datatype.XCN;
Expand All @@ -7,8 +7,8 @@
import org.openmrs.Provider;
import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.messages.MessageCreationException;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers.ProviderInformationHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.pv1.Pv1AssignedPatientLocationHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.helpers.ProviderInformationHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.pv1.Pv1AssignedPatientLocationHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers;
package org.openmrs.module.labintegration.api.hl7.messages.generators.helpers;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.segment.OBR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers;
package org.openmrs.module.labintegration.api.hl7.messages.generators.helpers;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.v25.datatype.XCN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers;
package org.openmrs.module.labintegration.api.hl7.messages.generators.helpers;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.datatype.FN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers;
package org.openmrs.module.labintegration.api.hl7.messages.generators.helpers;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.datatype.XCN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers;
package org.openmrs.module.labintegration.api.hl7.messages.generators.helpers;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.v25.datatype.TQ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.msh;
package org.openmrs.module.labintegration.api.hl7.messages.generators.msh;

import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.scc.SCCHL7Config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pid;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.datatype.XAD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pid;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.segment.PID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pid;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.segment.PID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pid;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.datatype.XPN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pid;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.datatype.XPN;
import ca.uhn.hl7v2.model.v25.segment.PID;
import org.openmrs.Patient;
import org.openmrs.PersonName;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers.PersonNameHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.helpers.PersonNameHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pid;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pid;

import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.segment.PID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openmrs.module.labintegration.api.hl7.messages.gnerators.pv1;
package org.openmrs.module.labintegration.api.hl7.messages.generators.pv1;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.DataTypeException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v25.datatype.EI;
import ca.uhn.hl7v2.model.v25.segment.OBR;
import ca.uhn.hl7v2.model.v25.segment.ORC;
import org.openmrs.Encounter;
import org.openmrs.LocationAttribute;
import org.openmrs.Obs;
import org.openmrs.module.labintegration.api.hl7.config.HL7Config;
import org.openmrs.module.labintegration.api.hl7.config.OrderIdentifier;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers.LnspCodeHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers.OrderingProviderHelper;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.helpers.QuantityTimingHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.helpers.LnspCodeHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.helpers.OrderingProviderHelper;
import org.openmrs.module.labintegration.api.hl7.messages.generators.helpers.QuantityTimingHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -48,27 +49,7 @@ public void updateORC(ORC orc, Obs obs) throws HL7Exception {

@Override
public void updatePlacerOrderNumber(ORC orc, Obs obs) throws DataTypeException {

//added site code to Placer Order number: site code + encounter id

Encounter encounter = obs.getEncounter();

String siteCode = "";
String uuid = "0e52924e-4ebb-40ba-9b83-b198b532653b";

for (LocationAttribute locationAttribute : encounter.getLocation().getAttributes()) {

if (locationAttribute.getAttributeType().getUuid().equals(uuid)) {
siteCode = locationAttribute.getValueReference();
}
}

Integer encounterId = obs.getEncounter().getEncounterId();
orc.getPlacerOrderNumber().getEntityIdentifier().setValue(siteCode + encounterId);

/* Integer encounterLocationUuid = obs.getEncounter().getLocation().getId();
orc.getPlacerOrderNumber().getEntityIdentifier().setValue(encounterLocationUuid.toString()); */

generatePlacerOrderNumber(obs, orc.getPlacerOrderNumber());
}

@Override
Expand All @@ -81,29 +62,32 @@ public void updateOBR(OBR obr, Obs obs) throws HL7Exception {
String encounterLocationUuid = obs.getEncounter().getLocation().getUuid();
obr.getPlacerOrderNumber().getEntityIdentifier().setValue(encounterLocationUuid);

generatePlacerOrderNumber(obs, obr.getPlacerOrderNumber());

obr.getSpecimenActionCode().setValue(DEFAULT_ACTION_CODE);
}

@Override
public void updateUniversalServiceID(OBR obr, Obs obs) throws DataTypeException {
lnspCodeHelper.updateUniversalServiceID(obr, obs);
}

private void generatePlacerOrderNumber(Obs obs, EI placerOrderNumber) throws DataTypeException {
//added site code to Placer Order number: site code + obs id

Encounter encounter = obs.getEncounter();

String siteCode = "";
String uuid = "0e52924e-4ebb-40ba-9b83-b198b532653b";

for (LocationAttribute locationAttribute : encounter.getLocation().getAttributes()) {

for (LocationAttribute locationAttribute : encounter.getLocation().getActiveAttributes()) {

if (locationAttribute.getAttributeType().getUuid().equals(uuid)) {
siteCode = locationAttribute.getValueReference();
}
}

Integer encounterId = obs.getEncounter().getEncounterId();
obr.getPlacerOrderNumber().getEntityIdentifier().setValue(siteCode + encounterId);

/*Integer encounterLocationUuid = obs.getEncounter().getLocation().getId();
obr.getPlacerOrderNumber().getEntityIdentifier().setValue(encounterLocationUuid.toString());*/

obr.getSpecimenActionCode().setValue(DEFAULT_ACTION_CODE);
}

@Override
public void updateUniversalServiceID(OBR obr, Obs obs) throws DataTypeException {
lnspCodeHelper.updateUniversalServiceID(obr, obs);
placerOrderNumber.getEntityIdentifier().setValue(siteCode + '-' + encounter.getEncounterId() + '-' + obs.getObsId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.openmrs.module.labintegration.api.communication.hl7.messages.utils.OrderConverterTestUtils;
import org.openmrs.module.labintegration.api.hl7.messages.OMLO21OrderConverter;
import org.openmrs.module.labintegration.api.hl7.messages.OrderControl;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.messages.generators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.openelis.OpenElisHL7Config;
import org.openmrs.module.labintegration.api.hl7.util.HL7TestMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.openmrs.module.labintegration.api.communication.hl7.messages.utils.OrderConverterTestUtils;
import org.openmrs.module.labintegration.api.hl7.messages.ORMO01OrderConverter;
import org.openmrs.module.labintegration.api.hl7.messages.OrderControl;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.messages.generators.MshGenerator;
import org.openmrs.module.labintegration.api.hl7.messages.generators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.scc.SCCHL7Config;
import org.openmrs.module.labintegration.api.hl7.util.HL7TestMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;
import org.openmrs.module.labintegration.api.hl7.messages.gnerators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.messages.generators.msh.MessageControlIdSource;

import java.util.Calendar;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.openmrs.module.labintegration.api.communication.hl7.messages.utils;

import org.openmrs.module.labintegration.api.hl7.messages.gnerators.msh.MessageControlIdSource;
import org.openmrs.module.labintegration.api.hl7.messages.generators.msh.MessageControlIdSource;

import static org.mockito.Mockito.when;

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</pluginRepositories>

<properties>
<revision>2.2.1-SNAPSHOT</revision>
<revision>2.3.0-SNAPSHOT</revision>
<openmrsPlatformVersion>2.0.5</openmrsPlatformVersion>
<javaCompilerVersion>1.8</javaCompilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 001a1b7

Please sign in to comment.