Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/07/08 18:28:28 (7 months ago)
Author:
msheley
Message:

sockethl7listener --
* Removal of provider name and id from person attribute. This was primarily for use related to patient matching. They are no longer required
* Removed some member variables in MatchHandler.
* Adjusted comparison methods for identifier, name, address, provider.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/sockethl7listener/src/org/openmrs/module/sockethl7listener/HL7PatientHandler.java

    r4059 r4133  
    4848        protected static final String ATTRIBUTE_RACE = "Race"; 
    4949        protected static final String ATTRIBUTE_BIRTHPLACE = "Birthplace"; 
    50         protected static final String PROVIDER_ID = "Provider ID"; 
    51         protected static final String PROVIDER_NAME = "Provider Name"; 
    5250        protected static final String CITIZENSHIP = "Citizenship"; 
    5351        protected static final String MATCH_INFO = "Other Matching Information"; 
    54         protected static final String PATIENT_IDENT_TYPE = "MRN"; 
    5552         
    5653        protected PatientService patientService; 
     
    8885        public Patient setPatientFromHL7(PID pid, NK1 nk1, 
    8986                        Date encounterDate, Location encounterLocation){ 
    90                 personAttrList = ""; 
     87                //personAttrList = ""; 
    9188                Patient hl7Patient = new Patient(); 
    9289                CX[] identList = null; 
     
    438435 
    439436                //Save matchin information attribute; Check if attribute type exists 
    440               PersonAttributeType otherMatchingAttrType = personService.getPersonAttributeType(MATCH_INFO); 
     437        /*    PersonAttributeType otherMatchingAttrType = personService.getPersonAttributeType(MATCH_INFO); 
    441438 
    442439                if (otherMatchingAttrType == null){ 
     
    444441                } 
    445442 
    446                 //personAttrList += ";openmrs_id:"; 
    447443                PersonAttribute matchingInfoAttribute = new PersonAttribute(otherMatchingAttrType,personAttrList); 
    448                 //matchingInfoAttribute.setDateCreated(encounterDate); 
    449                 //matchingInfoAttribute.setCreator(userContext.getAuthenticatedUser()); 
    450                 hl7Patient. addAttribute(matchingInfoAttribute); 
     444                hl7Patient. addAttribute(matchingInfoAttribute);*/ 
    451445                return hl7Patient; 
    452446        } 
     
    467461                        String stIdent = ""; 
    468462                        String assignAuth = ""; 
    469                         personAttrList ="mrn:"; 
     463                        //personAttrList ="mrn:"; 
    470464                         
    471465                        if (identList.length != 0) 
     
    498492                                } 
    499493                                 
    500                                 if (identifiers.iterator().hasNext())personAttrList += identifiers.iterator().next().getIdentifier(); 
     494                                //if (identifiers.iterator().hasNext())personAttrList += identifiers.iterator().next().getIdentifier(); 
    501495                                hl7Patient.setIdentifiers(identifiers); 
    502496 
     
    574568                        fn = checkFirstName(fn,this.distinct_only); 
    575569                } 
    576                 personAttrList += ";fn:" + fn + ";ln:" + ln; 
     570                //personAttrList += ";fn:" + fn + ";ln:" + ln; 
    577571 
    578572                hl7Patient.setNames(personNamesSet); 
     
    580574                hl7Patient.getPersonName().setCreator(Context.getAuthenticatedUser()); 
    581575 
    582                 //hl7Patient.setNames(personNamesSet); 
    583                 //hl7Patient.setDateChanged(encounterDate); 
    584                 //hl7Patient.getPersonName().setDateCreated(new Date()); 
    585                 //hl7Patient.getPersonName().setDateChanged(encounterDate); 
    586                 //hl7Patient.getPersonName().setCreator(Context.getAuthenticatedUser()); 
    587576 
    588577        } 
     
    619608                } 
    620609 
    621                 personAttrList += ";race:" + race ; 
     610                //personAttrList += ";race:" + race ; 
    622611 
    623612 
     
    670659                hl7Patient.setGender(gender); 
    671660                 
    672                 concatMatchingAttribute("sex", gender); 
     661                //concatMatchingAttribute("sex", gender); 
    673662                //personAttrList += ";sex:" + gender; 
    674663 
     
    712701                        int year = ts.getTime().getYear(); 
    713702                        if (year != 0) stYear = String.valueOf(year); 
    714                         concatMatchingAttribute("db", stDay); 
    715                         concatMatchingAttribute("mb", stMonth); 
    716                         concatMatchingAttribute("yb", stYear); 
     703                        //concatMatchingAttribute("db", stDay); 
     704                        //concatMatchingAttribute("mb", stMonth); 
     705                        //concatMatchingAttribute("yb", stYear); 
    717706 
    718707                } catch (DataTypeException e) { 
     
    768757                        hl7Patient.getPersonAddress().setCreator(Context.getAuthenticatedUser()); 
    769758 
    770                         concatMatchingAttribute("city", city); 
    771                         concatMatchingAttribute("st", stateProvince); 
    772                         concatMatchingAttribute("zip", postalCode); 
     759                        //concatMatchingAttribute("city", city); 
     760                        //concatMatchingAttribute("st", stateProvince); 
     761                        //concatMatchingAttribute("zip", postalCode); 
    773762 
    774763                } catch (RuntimeException e) { 
     
    800789                } 
    801790                 
    802                 personAttrList += ";tel:" + tNumber; // no value available for matching string 
     791                //personAttrList += ";tel:" + tNumber; // no value available for matching string 
    803792                PersonAttribute telNumAttr = new PersonAttribute(telPhoneAttrType,tNumber); 
    804793                 
     
    852841                        if (nkln == null) nkln = ""; 
    853842                        if (nkfn == null) nkfn = ""; 
    854                         personAttrList += ";nkfn:" + nkfn + ";nkln:" + nkln; 
    855                         motherNameString = nkfn + "." + nkln; 
     843                        //personAttrList += ";nkfn:" + nkfn + ";nkln:" + nkln; 
     844                        motherNameString = nkfn + "|" + nkln; 
    856845                        motherNameAttr.setAttributeType(motherAttributeType); 
    857846                        motherNameAttr.setValue(motherNameString);       
     
    891880        } 
    892881 
    893         protected void formatDoctorName(XCN doctor, Provider provider) 
    894         { 
    895                 String firstName = ""; 
    896                 String lastName = ""; 
    897                 if (doctor.getGivenName()!= null){ 
    898                         firstName = doctor.getGivenName().toString(); 
    899                         if (firstName == null) firstName = ""; 
    900                 } 
    901                 if (doctor.getGivenName()!= null){ 
    902                         lastName = doctor.getFamilyName().getSurname().toString(); 
    903                         if (lastName == null) lastName = ""; 
    904                 } 
    905                 provider.setFirstName(firstName); 
    906                 provider.setLastName(lastName); 
    907         } 
    908  
    909         public Provider setProviderFromPV1(PV1 pv1,Patient hl7Patient, 
    910                         Date encounterDate) { 
     882        public Provider setProviderFromPV1(PV1 pv1,Patient hl7Patient) { 
    911883 
    912884                //      Extract provider information for provider observations. 
     
    917889                try { 
    918890                        doctor= pv1.getAttendingDoctor(0);       
     891 
     892 
     893                        //Load provider object with PV1 information 
     894 
     895                        if (doctor != null){ 
     896 
     897                                String id = ""; 
     898                                String firstName = ""; 
     899                                String lastName = ""; 
     900 
     901                                if (doctor.getIDNumber()!= null){ 
     902                                        id = doctor.getIDNumber().toString(); 
     903                                } 
     904                                if (doctor.getGivenName()!= null){ 
     905                                        firstName = doctor.getGivenName().toString(); 
     906                                } 
     907                                if (doctor.getGivenName()!= null){ 
     908                                        lastName = doctor.getFamilyName().getSurname().toString(); 
     909                                } 
     910 
     911                                provider.setFirstName(firstName); 
     912                                provider.setLastName(lastName); 
     913                                provider.setId(id); 
     914                                //using npi for provider id 
     915                                SocketHL7ListenerService hl7ListService = (SocketHL7ListenerService) Context.getService(SocketHL7ListenerService.class); 
     916                                if (id == null ||id.equals("")){ 
     917                                        String npi = hl7ListService.getNPI(provider.getFirstName(),provider.getLastName()); 
     918                                        provider.setId(npi); 
     919                                } 
     920 
     921                                provider.createUserForProvider(provider); 
     922                                setPatientMatchingAttribute(provider, hl7Patient); 
     923 
     924 
     925                        } 
     926 
    919927                } catch (HL7Exception e2) { 
    920928                        hl7Logger.error("Unable to collect provider id from PV1 segment",e2); 
    921929                }        
    922  
    923                 //Load provider object with PV1 information 
    924  
    925                 if (doctor != null){ 
    926  
    927                         String id = ""; 
    928                          
    929                         if (doctor.getIDNumber()!= null){ 
    930                                 id = doctor.getIDNumber().toString(); 
    931                                 if (id == null) id = ""; 
    932                         } 
    933                          
    934                         provider.setId(id); 
    935                         formatDoctorName(doctor,provider); 
    936                         provider.createUserForProvider(provider); 
    937                         //using npi for provider id 
    938                         SocketHL7ListenerService hl7ListService = (SocketHL7ListenerService) Context.getService(SocketHL7ListenerService.class); 
    939                         String npi = hl7ListService.getNPI(provider.getFirstName(),provider.getLastName()); 
    940                         provider.setId(npi); 
    941                          
    942                         try { 
    943                                         //May not need this attribute after storing provider as a user. 
    944                                         PersonAttributeType providerIDAttrType = personService.getPersonAttributeType(PROVIDER_ID); 
    945                                         if (providerIDAttrType == null){ 
    946                                                 createAttributeType(PROVIDER_ID); 
    947                                         } 
    948                                         PersonAttribute providerID = new PersonAttribute(providerIDAttrType,provider.getId()); 
    949                                         providerID.setDateCreated(encounterDate); 
    950                                         //providerID.setDateChanged(encounterDate); 
    951                                         providerID.setCreator(Context.getAuthenticatedUser()); 
    952                                         hl7Patient.addAttribute(providerID); 
    953          
    954                                         PersonAttributeType providerNameAttrType = personService.getPersonAttributeType(PROVIDER_NAME); 
    955                                         if (providerNameAttrType == null){ 
    956                                                 createAttributeType(PROVIDER_NAME); 
    957                                         } 
    958          
    959                                         PersonAttribute providerNameAttr = new PersonAttribute(providerNameAttrType,provider.getFirstName()  
    960                                                         + "." +  provider.getLastName()); 
    961                                         providerNameAttr.setDateCreated(encounterDate); 
    962                                         providerNameAttr.setCreator(Context.getAuthenticatedUser()); 
    963                                         hl7Patient.addAttribute(providerNameAttr); 
    964  
    965                                 //Add to the attribute string used for matching 
    966                             //TODO If id is empty in the hl7 message, do we want to add 
    967                                         //add that empty string for drid, or do we want to use 
    968                                         //the referenced npi value? 
    969                                 //concatMatchingAttribute("drid", id); 
    970                                 concatMatchingAttribute("drid", provider.getId()); 
    971                                 concatMatchingAttribute("drfn", provider.getFirstName()); 
    972                                 concatMatchingAttribute("drln", provider.getLastName()); 
    973                                  
    974                                 //Create the attribute type  
    975                                 PersonAttributeType otherMatchingAttrType = personService.getPersonAttributeType(MATCH_INFO); 
    976                                 if (otherMatchingAttrType == null){ 
    977                                         createAttributeType(MATCH_INFO); 
    978                                 } 
    979                                 //Add the attribute type 
    980                                 PersonAttribute matchingInfoAttribute = new PersonAttribute(otherMatchingAttrType,personAttrList); 
    981                                 //matchingInfoAttribute.setDateChanged(encounterDate); 
    982                                 matchingInfoAttribute.setDateCreated(encounterDate); 
    983                                 matchingInfoAttribute.setCreator(Context.getAuthenticatedUser()); 
    984                                 hl7Patient.addAttribute(matchingInfoAttribute); 
    985  
    986                         } catch (RuntimeException e) { 
    987                                 logger.error("Unable to create attribute for provider id or provider name " + e.getMessage()); 
    988                         } 
    989                 } 
    990930                return provider; 
    991931        } 
     
    1004944        } 
    1005945 
    1006         protected void concatMatchingAttribute(String segment, String value 
    1007                         ){ 
    1008                 if (value == null) value = ""; 
    1009                 personAttrList += ";" + segment + ":" + value; 
    1010         } 
    1011946         
    1012947        public static String checkFirstName(String fname,boolean distinct_only){ 
     
    1052987                 
    1053988        } 
     989         
     990        public String setPatientMatchingAttribute(Provider provider, Patient p){ 
     991                String mrn = "", attribute = "", drid = "" , 
     992                       drfn = "", drln = "", nkfn = "", nkln = "", 
     993                       db = "", yb = "", mb = "", fn = "", ln = "", 
     994                       city = "", zip = "", st = "", race = "", tel = "", 
     995                       sex = "" , nkname = ""; 
     996                 
     997         
     998                if (provider != null){ 
     999                        drid = provider.getId(); 
     1000                        drfn = provider.getFirstName(); 
     1001                        drln = provider.getLastName(); 
     1002                } 
     1003                 
     1004                fn = p.getGivenName(); 
     1005                ln = p.getFamilyName(); 
     1006                sex = p.getGender(); 
     1007                if (p.getAttribute(ATTRIBUTE_RACE) != null){ 
     1008                        race = p.getAttribute(ATTRIBUTE_RACE).getValue().toLowerCase(); 
     1009                } 
     1010                if (p.getAttribute(ATTRIBUTE_TELEPHONE) != null) { 
     1011                        tel = p.getAttribute(ATTRIBUTE_TELEPHONE).getValue().toLowerCase(); 
     1012                } 
     1013                if (p.getPatientIdentifier()!= null) { 
     1014                        mrn = p.getPatientIdentifier().getIdentifier(); 
     1015                } 
     1016                if (p.getAttribute(ATTRIBUTE_NEXT_OF_KIN) != null){ 
     1017                        nkname = p.getAttribute(ATTRIBUTE_NEXT_OF_KIN).getValue().toLowerCase(); 
     1018                } 
     1019                int index = nkname.indexOf("|"); 
     1020                if (index > 0){ 
     1021                  nkfn = nkname.substring(0,index); 
     1022                  nkln = nkname.substring(index + 1); 
     1023                }else { 
     1024                        nkln = nkname; 
     1025                } 
     1026                 
     1027                if (p.getPersonAddress()!= null){ 
     1028                        city = p.getPersonAddress().getCityVillage().toLowerCase(); 
     1029                        zip = p.getPersonAddress().getPostalCode().toLowerCase(); 
     1030                        st = p.getPersonAddress().getStateProvince().toLowerCase(); 
     1031                } 
     1032                 
     1033             
     1034                Calendar cal = Calendar.getInstance(); 
     1035                cal.setTime(p.getBirthdate()); 
     1036                yb = Integer.toString(cal.get(Calendar.YEAR)); 
     1037                mb = Integer.toString(cal.get(Calendar.MONTH ) + 1); 
     1038                db = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)); 
     1039                attribute = "mrn:" + mrn + ";fn:" + fn + ";ln:" + ln + ";race:"  
     1040                        + race + ";nkfn:" + nkfn + ";nkln:" + nkln + ";db:" + db  
     1041                        + ";mb:" + mb + ";yb:" + yb + ";sex:" + sex + ";city:" 
     1042                        + city + ";st:" + st + ";zip:" + zip + ";tel:" + tel 
     1043                        + ";drid:" + drid + ";drfn:" + drfn + ";drln:" + drln; 
     1044                 
     1045                 
     1046                PersonAttributeType otherMatchingAttrType = personService.getPersonAttributeType(MATCH_INFO); 
     1047 
     1048                if (otherMatchingAttrType == null){ 
     1049                        createAttributeType(MATCH_INFO); 
     1050                } 
     1051 
     1052                PersonAttribute matchingInfoAttribute = new PersonAttribute(otherMatchingAttrType,attribute); 
     1053                p.addAttribute(matchingInfoAttribute); 
     1054                return attribute; 
     1055        } 
     1056         
    10541057 
    10551058}