use of org.monarchinitiative.loinc2hpo.loinc.LoincEntry in project loinc2hpo by monarch-initiative.
the class ObservationDownloader method iteratorHapiFHIRServer.
public static void iteratorHapiFHIRServer() {
// printObservationInfo();
// printPatientInfo();
// BufferedReader bufferedReader = new BufferedReader(new FileReader(""));
// find20CompleteRecordOfEachType();
String path = null;
HashMap<String, StringBuilder> completeObservations = new HashMap<>();
completeObservations.put("Qn", new StringBuilder());
completeObservations.put("Ord", new StringBuilder());
completeObservations.put("Nom", new StringBuilder());
completeObservations.put("Nar", new StringBuilder());
completeObservations.put("OrdQn", new StringBuilder());
completeObservations.put("unkown", new StringBuilder());
HashMap<String, Integer> countComplete = new HashMap<>();
countComplete.put("Qn", 0);
countComplete.put("Ord", 0);
countComplete.put("Nom", 0);
countComplete.put("Nar", 0);
countComplete.put("OrdQn", 0);
countComplete.put("unknown", 0);
HashMap<String, StringBuilder> accetableObservations = new HashMap<>();
accetableObservations.put("Qn", new StringBuilder());
accetableObservations.put("Ord", new StringBuilder());
accetableObservations.put("Nom", new StringBuilder());
accetableObservations.put("Nar", new StringBuilder());
accetableObservations.put("OrdQn", new StringBuilder());
accetableObservations.put("unknown", new StringBuilder());
HashMap<String, Integer> countAccetable = new HashMap<>();
countAccetable.put("Qn", 0);
countAccetable.put("Ord", 0);
countAccetable.put("Nom", 0);
countAccetable.put("Nar", 0);
countAccetable.put("OrdQn", 0);
countAccetable.put("unknown", 0);
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
path = chooser.getSelectedFile().getAbsolutePath();
System.out.println(path);
Map<LoincId, LoincEntry> loincEntryMap = LoincEntry.getLoincEntryList(path);
System.out.println("size of loinc table: " + loincEntryMap.size());
for (LoincEntry loincEntry : loincEntryMap.values()) {
if (countComplete.containsKey(loincEntry.getScale()) && countComplete.get(loincEntry.getScale()) < 50) {
try {
List<Observation> results = ObservationDownloader.retrieveObservation(loincEntry.getLOINC_Number().toString());
if (results != null && !results.isEmpty()) {
for (Observation observation : results) {
if (isComplte(observation)) {
String aCompleteRecord = jsonParser.setPrettyPrint(true).encodeResourceToString(observation);
if (completeObservations.containsKey(loincEntry.getScale())) {
completeObservations.get(loincEntry.getScale()).append(aCompleteRecord);
completeObservations.get(loincEntry.getScale()).append("\n\n");
completeObservations.get(loincEntry.getScale()).append(Character.toString((char) 12));
countComplete.put(loincEntry.getScale(), countComplete.get(loincEntry.getScale()) + 1);
} else {
completeObservations.get("unknown").append(aCompleteRecord);
completeObservations.get("unknown").append("\n\n");
completeObservations.get("unknown").append(Character.toString((char) 12));
countComplete.put("unknown", countAccetable.get("unknown") + 1);
}
continue;
}
if (isAcceptable(observation)) {
String aAcceptableRecord = jsonParser.setPrettyPrint(true).encodeResourceToString(observation);
if (accetableObservations.containsKey(loincEntry.getScale()) && countAccetable.get(loincEntry.getScale()) < 50) {
accetableObservations.get(loincEntry.getScale()).append(aAcceptableRecord);
accetableObservations.get(loincEntry.getScale()).append("\n\n");
accetableObservations.get(loincEntry.getScale()).append(Character.toString((char) 12));
countAccetable.put(loincEntry.getScale(), countAccetable.get(loincEntry.getScale()) + 1);
} else if (countAccetable.get("unknown") < 50) {
accetableObservations.get("unknown").append(aAcceptableRecord);
accetableObservations.get("unknown").append("\n\n");
accetableObservations.get("unknown").append(Character.toString((char) 12));
countAccetable.put("unknown", countAccetable.get("unknown") + 1);
}
}
}
}
} catch (Exception e) {
continue;
}
}
}
}
for (String scale : completeObservations.keySet()) {
if (!completeObservations.get(scale).toString().isEmpty()) {
WriteToFile.writeToFile(completeObservations.get(scale).toString(), scale + "_complteObservations.txt");
} else {
System.out.println("No complete observations were found for loinc scale type: " + scale);
}
}
for (String scale : accetableObservations.keySet()) {
if (!accetableObservations.get(scale).toString().isEmpty()) {
WriteToFile.writeToFile(accetableObservations.get(scale).toString(), scale + "_acceptableObservations.txt");
} else {
System.out.println("No acceptable observations were found for loinc scale type: " + scale);
}
}
}
use of org.monarchinitiative.loinc2hpo.loinc.LoincEntry in project loinc2hpo by monarch-initiative.
the class CurrentAnnotationController method populateTables.
private void populateTables() {
if (model == null) {
logger.error("model is null.");
return;
}
this.currentAnnotation = model.getCurrentAnnotation();
LoincEntry currentLoincEntry = model.getLoincEntryMap().get(currentAnnotation.getLoincId());
annotationTitle.setText(String.format("Annotations for Loinc: %s[%s]", currentLoincEntry.getLOINC_Number(), currentLoincEntry.getLongName()));
internalCodeAnnotations.clear();
currentAnnotation.getCandidateHpoTerms().entrySet().stream().filter(p -> p.getKey().getSystem().equals(Loinc2HPOCodedValue.CODESYSTEM)).map(p -> new Annotation(p.getKey(), p.getValue())).forEach(internalCodeAnnotations::add);
externalCodeAnnotations.clear();
currentAnnotation.getCandidateHpoTerms().entrySet().stream().filter(p -> !p.getKey().getSystem().equals(Loinc2HPOCodedValue.CODESYSTEM)).map(p -> new Annotation(p.getKey(), p.getValue())).forEach(externalCodeAnnotations::add);
interpretationCodeAnnotations.clear();
for (Map.Entry<Code, Code> entry : CodeSystemConvertor.getCodeConversionMap().entrySet()) {
logger.debug("key: " + entry.getKey() + "\nvalue: " + entry.getValue());
HpoTermId4LoincTest result = currentAnnotation.loincInterpretationToHPO(entry.getValue());
logger.debug("result is null? " + (result == null));
if (result != null) {
Annotation annotation = new Annotation(entry.getKey(), result);
interpretationCodeAnnotations.add(annotation);
logger.debug("interpretationCodeAnnotations size: " + interpretationCodeAnnotations.size());
}
}
logger.debug("internalTableview is null: " + (internalTableview == null));
logger.debug("internalCodeAnnotations is null: " + (internalTableview == null));
logger.debug("internal annotation size: " + internalCodeAnnotations.size());
internalCodeAnnotations.forEach(logger::info);
logger.trace("exit initInternalTableview()");
}
Aggregations