Changeset 4159 for openmrs-modules/sockethl7listener/src/org/openmrs/module/sockethl7listener/HL7SocketHandler.java
- Timestamp:
- 05/09/08 18:54:25 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/sockethl7listener/src/org/openmrs/module/sockethl7listener/HL7SocketHandler.java
r4133 r4159 38 38 import org.openmrs.api.context.Context; 39 39 import org.openmrs.api.context.ContextAuthenticationException; 40 import org.openmrs.api.context.UserContext;41 40 import org.openmrs.hl7.HL7Constants; 42 41 import org.openmrs.hl7.HL7InQueue; … … 56 55 import ca.uhn.hl7v2.model.v25.datatype.CWE; 57 56 import ca.uhn.hl7v2.model.v25.datatype.CX; 57 import ca.uhn.hl7v2.model.v25.datatype.DTM; 58 58 import ca.uhn.hl7v2.model.v25.datatype.ID; 59 59 import ca.uhn.hl7v2.model.v25.datatype.NM; … … 152 152 * @throws ContextAuthenticationException 153 153 */ 154 public Message processMessage(Message message) throws ApplicationException {154 public synchronized Message processMessage(Message message) throws ApplicationException { 155 155 156 156 Context.openSession(); … … 234 234 235 235 // validate message 236 236 Date starttime = new Date(); 237 237 validate(message); 238 238 boolean error = false; … … 269 269 + message.getName()); 270 270 } 271 271 DTM dtm = (DTM) timeStamp.getComponent(0); 272 if (dtm == null || dtm.getValue() == null){ 273 timeStamp = msh.getDateTimeOfMessage(); 274 } 272 275 273 276 … … 284 287 285 288 // Get the location 286 Date starttime = new Date();289 //Date starttime = new Date(); 287 290 String institutionId = zlr.getOrderingFacilityIDNum(); 288 291 Location encounterLocation = setLocation(institutionId); 289 292 Date encounterDate = TranslateDate(timeStamp); 290 293 Patient hl7Patient = patientHandler.setPatientFromHL7(pid,nk1,encounterDate,encounterLocation); 291 Provider provider = patientHandler.setProviderFromPV1(pv1,hl7Patient );294 Provider provider = patientHandler.setProviderFromPV1(pv1,hl7Patient,encounterDate); 292 295 293 296 Patient resultPatient = findPatient(hl7Patient,encounterDate); … … 300 303 resultPatient,encounterDate, provider); 301 304 } 302 305 createObsForProvider(encounter,provider); 303 306 if (message instanceof ORU_R01) 304 307 { … … 403 406 enc.setProvider(providerUser); 404 407 es.createEncounter(enc); 405 createObsForProvider(enc,provider);408 //createObsForProvider(enc,provider); 406 409 407 410 … … 1232 1235 1233 1236 1234 String id, mrn ,fn,ln,gender,city,state,zip, db, mb, yb, tel , hl7Tel, matchTel, addr1; 1237 String id, mrn ="" ,fn = "", ln = "", gender = "", 1238 city = "", state = "", zip = "", db = "", mb = "", 1239 yb = "", tel= "" , hl7Tel = "", matchTel = "", addr1 = ""; 1235 1240 1236 1241 Calendar hl7cal = Calendar.getInstance(); … … 1259 1264 PersonAddress hl7PA = hl7Patient.getPersonAddress(); 1260 1265 1261 String hl7City , hl7State, hl7Zip, hl7Addr1;1266 String hl7City = "", hl7State = "", hl7Zip = "", hl7Addr1 = ""; 1262 1267 if (hl7PA != null) { 1263 1268 hl7Addr1 = hl7PA.getAddress1(); 1269 if (hl7Addr1 == null || hl7Addr1.equals("")){ 1270 hl7Addr1 = ""; 1271 } 1264 1272 hl7City = hl7PA.getCityVillage(); 1273 if (hl7City == null || hl7City.equals("")){ 1274 hl7City = ""; 1275 } 1276 1265 1277 hl7State = hl7PA.getStateProvince(); 1278 if (hl7State == null || hl7State.equals("")){ 1279 hl7State = ""; 1280 } 1266 1281 hl7Zip = hl7PA.getPostalCode(); 1267 }else{ 1268 hl7Addr1 = ""; 1269 hl7City = ""; 1270 hl7State = ""; 1271 hl7Zip = ""; 1282 1283 if (hl7Zip == null || hl7Zip.equals("")){ 1284 hl7Zip = ""; 1285 } 1272 1286 } 1273 1287 … … 1611 1625 String firstname = ""; 1612 1626 String lastname = ""; 1613 int index1 =NKnameValue.indexOf(" .");1627 int index1 =NKnameValue.indexOf("|"); 1614 1628 if (index1 != -1){ 1615 1629 firstname = NKnameValue.substring(0,index1);