All pastes #101646 Raw Edit

Miscellany

public text v1 · immutable
#101646 ·published 2006-07-27 01:29 UTC
rendered paste body
		/* Read the file used for converting brand/generic names */

		try {

			BufferedReader conversion = new BufferedReader(new FileReader(conversion_txt));

			while ((conversion_line = conversion.readLine()) != null) {
				conversion_line = conversion_line.toUpperCase();
				conversion_data.add(conversion_line);
			}

			/* Convert brand names to generic and add them to formulary list */

			pharma_to_check.add(drugname);

			for (String it : conversion_data) {
				String[] temparray = it.split("," + " ");
				for (String it_two : pharma_to_check) {
					Pattern pattern = null;
					Matcher matcher = null;
					pattern = Pattern.compile("\\b" + Pattern.quote(it_two) + "\\b");
					if (temparray.length == 2) {
						matcher = pattern.matcher(temparray[1]);
						if (matcher.find() && !temparray[0].equals(temparray[1])) {
							pharma_to_check_generic.add(temparray[0]);
						}
					}
				}
			}

			for (String it : pharma_to_check_generic) {
				pharma_to_check.add(it);
			}

			/* Match the list of pharmaceuticals to formularies */

			for (String it : input.keySet()) {
				input_reader = new BufferedReader(new FileReader(it));
				while ((input_line = input_reader.readLine()) != null) {
					input_line = input_line.toUpperCase();
					for (String it_two : pharma_to_check) {
						Pattern pattern = null;
						Matcher matcher = null;
						pattern = Pattern.compile("\\b" + Pattern.quote(input_line) + "\\b");
						matcher = pattern.matcher(it_two);
						if (matcher.find()) {
							result_names.add(input.get(it));
							if (placements.isEmpty() == true) {
								placements.put(drugname, result_names);
							}
							break;
						}
					}
				}
			}
		} catch (IOException e) {

		}

		/* Print results */

		for (Map.Entry it : placements.entrySet()) {
			System.out.println(it.getKey() + ":" + " " + it.getValue().toString().replaceAll("\\[", "").replaceAll("\\]", "") + "\n");
		}
	}