Changeset 4159 for openmrs-modules/sockethl7listener/src/org/openmrs/module/sockethl7listener/HL7PatientHandler.java
- Timestamp:
- 05/09/08 13:54:25 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/sockethl7listener/src/org/openmrs/module/sockethl7listener/HL7PatientHandler.java
r4133 r4159 541 541 ST STmn = xpn.getSecondAndFurtherGivenNamesOrInitialsThereof(); 542 542 543 if ( FNln != null){ 544 ln = FNln.getSurname().getValue(); 545 } 543 if ( FNln != null && FNln.getSurname() != null){ 544 String lnvalue = FNln.getSurname().getValue(); 545 if (lnvalue != null ) ln = lnvalue; 546 } 547 546 548 if (STfn != null){ 547 fn = STfn.getValue(); 549 String fnvalue = STfn.getValue(); 550 if (fnvalue != null) fn = fnvalue; 548 551 } 549 552 550 553 if (STmn != null){ 551 mn = STmn.getValue(); 554 String mnvalue = STmn.getValue(); 555 if (mnvalue != null) mn = mnvalue; 552 556 } 553 557 … … 561 565 personNamesSet.add(name); 562 566 563 ln = ((ln == null) || ln.toLowerCase().equalsIgnoreCase("null"))? "" : ln;564 fn = ((fn == null) || fn.toLowerCase().equalsIgnoreCase("null"))? "" : fn;565 567 //for matching attribute only, check first name for invalid names 566 568 //and nullify if needed … … 568 570 fn = checkFirstName(fn,this.distinct_only); 569 571 } 570 //personAttrList += ";fn:" + fn + ";ln:" + ln; 571 572 572 573 hl7Patient.setNames(personNamesSet); 573 574 hl7Patient.getPersonName().setDateCreated(encounterDate); … … 880 881 } 881 882 882 public Provider setProviderFromPV1(PV1 pv1,Patient hl7Patient ) {883 public Provider setProviderFromPV1(PV1 pv1,Patient hl7Patient, Date encounterDate) { 883 884 884 885 // Extract provider information for provider observations. … … 920 921 921 922 provider.createUserForProvider(provider); 922 setPatientMatchingAttribute(provider, hl7Patient );923 setPatientMatchingAttribute(provider, hl7Patient, encounterDate); 923 924 924 925 … … 988 989 } 989 990 990 public String setPatientMatchingAttribute(Provider provider, Patient p ){991 public String setPatientMatchingAttribute(Provider provider, Patient p, Date encounterDate){ 991 992 String mrn = "", attribute = "", drid = "" , 992 993 drfn = "", drln = "", nkfn = "", nkln = "", … … 998 999 if (provider != null){ 999 1000 drid = provider.getId(); 1001 if (drid == null){ 1002 drid = ""; 1003 } 1000 1004 drfn = provider.getFirstName(); 1005 if (drfn == null){ 1006 drfn = ""; 1007 } 1001 1008 drln = provider.getLastName(); 1009 if (drln == null){ 1010 drln = ""; 1011 } 1002 1012 } 1003 1013 1004 1014 fn = p.getGivenName(); 1015 if (fn == null) fn = ""; 1005 1016 ln = p.getFamilyName(); 1017 if (ln == null) ln = ""; 1006 1018 sex = p.getGender(); 1019 if (sex == null) sex = ""; 1020 1007 1021 if (p.getAttribute(ATTRIBUTE_RACE) != null){ 1008 race = p.getAttribute(ATTRIBUTE_RACE).getValue() .toLowerCase();1022 race = p.getAttribute(ATTRIBUTE_RACE).getValue(); 1009 1023 } 1010 1024 if (p.getAttribute(ATTRIBUTE_TELEPHONE) != null) { 1011 tel = p.getAttribute(ATTRIBUTE_TELEPHONE).getValue() .toLowerCase();1025 tel = p.getAttribute(ATTRIBUTE_TELEPHONE).getValue(); 1012 1026 } 1013 1027 if (p.getPatientIdentifier()!= null) { … … 1015 1029 } 1016 1030 if (p.getAttribute(ATTRIBUTE_NEXT_OF_KIN) != null){ 1017 nkname = p.getAttribute(ATTRIBUTE_NEXT_OF_KIN).getValue() .toLowerCase();1031 nkname = p.getAttribute(ATTRIBUTE_NEXT_OF_KIN).getValue(); 1018 1032 } 1019 1033 int index = nkname.indexOf("|"); … … 1026 1040 1027 1041 if (p.getPersonAddress()!= null){ 1028 city = p.getPersonAddress().getCityVillage().toLowerCase(); 1029 zip = p.getPersonAddress().getPostalCode().toLowerCase(); 1030 st = p.getPersonAddress().getStateProvince().toLowerCase(); 1042 city = p.getPersonAddress().getCityVillage(); 1043 if (city == null) city = ""; 1044 zip = p.getPersonAddress().getPostalCode(); 1045 if (zip == null) zip = ""; 1046 st = p.getPersonAddress().getStateProvince(); 1047 if (st == null) st = ""; 1031 1048 } 1032 1049 … … 1050 1067 } 1051 1068 1052 PersonAttribute matchingInfoAttribute = new PersonAttribute(otherMatchingAttrType,attribute); 1069 PersonAttribute matchingInfoAttribute = new PersonAttribute(); 1070 matchingInfoAttribute.setAttributeType(otherMatchingAttrType); 1071 matchingInfoAttribute.setDateCreated(encounterDate); 1072 matchingInfoAttribute.setCreator(Context.getAuthenticatedUser()); 1073 matchingInfoAttribute.setValue(attribute); 1053 1074 p.addAttribute(matchingInfoAttribute); 1054 1075 return attribute;