Beispiel #1
0
 private ClassLoaderStrategy getClassLoaderStrategy(String fullyQualifiedClassName)
     throws Exception {
   try {
     // Get just the package name
     StringBuffer sb = new StringBuffer(fullyQualifiedClassName);
     sb.delete(sb.lastIndexOf("."), sb.length());
     currentPackage = sb.toString();
     // Retrieve the Java classpath from the system properties
     String cp = System.getProperty("java.class.path");
     String sepChar = System.getProperty("path.separator");
     String[] paths = StringUtils.pieceList(cp, sepChar.charAt(0));
     ClassLoaderStrategy cl =
         ClassLoaderUtil.getClassLoader(ClassLoaderUtil.FILE_SYSTEM_CLASS_LOADER, new String[] {});
     // Iterate through paths until class with the specified name is found
     String classpath = StringUtils.replaceChar(currentPackage, '.', File.separatorChar);
     for (int i = 0; i < paths.length; i++) {
       Class[] classes = cl.getClasses(paths[i] + File.separatorChar + classpath, currentPackage);
       for (int j = 0; j < classes.length; j++) {
         if (classes[j].getName().equals(fullyQualifiedClassName)) {
           return ClassLoaderUtil.getClassLoader(
               ClassLoaderUtil.FILE_SYSTEM_CLASS_LOADER, new String[] {paths[i]});
         }
       }
     }
     throw new Exception("Class could not be found.");
   } catch (Exception e) {
     System.err.println("Exception creating class loader strategy.");
     System.err.println(e.getMessage());
     throw e;
   }
 }
 // RPC API
 public AllergiesReactants getAllergiesReactants(String dfn) throws Exception {
   // setDefaultContext("OR CPRS GUI CHART");
   setDefaultContext("VPS AVS INTERFACE");
   // setDefaultRpcName("ORQQAL LIST");
   setDefaultRpcName("VPS AL LIST");
   List<String> list = lCall(dfn);
   /*
    Returns array of patient allergies.  Returned data is delimited by "^" and
    includes: allergen/reactant, reactions/symptoms (multiple symptoms/
    reactions are possible - delimited by ";"), severity, allergy id (record
    number from the Patient Allergies file (#120.8).
   */
   AllergiesReactants allergiesReactants = new AllergiesReactants();
   if (list.size() == 1) {
     String a = StringUtils.piece((String) list.get(0), 2);
     if (a.equalsIgnoreCase("no known allergies")) {
       allergiesReactants.setNoKnownAllergies(true);
       list.clear();
     } else if (a.equalsIgnoreCase("no allergy assessment")) {
       allergiesReactants.setNoAllergyAssessment(true);
       list.clear();
     }
   }
   List<AllergyReactant> allergiesReactantsList = new ArrayList<AllergyReactant>();
   for (String s : list) {
     AllergyReactant allergyReactant = new AllergyReactant();
     allergyReactant.setDfn(dfn);
     allergyReactant.setIen(StringUtils.piece(s, 1));
     allergyReactant.setAllergenReactant(StringUtils.piece(s, 2));
     allergyReactant.setSeverity(StringUtils.piece(s, 3));
     String[] x = StringUtils.pieceList(StringUtils.piece(s, 4), ';');
     allergyReactant.setReactionsSymptoms(x);
     allergiesReactantsList.add(allergyReactant);
   }
   allergiesReactants.setAllergiesReactants(allergiesReactantsList);
   return allergiesReactants;
 }