-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to apply an old mapping to a new set of codes. This can be
helpful when the vocabulary and/or the source data has updated.
- Loading branch information
Showing
8 changed files
with
182 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/org/ohdsi/usagi/ui/actions/ApplyPreviousMappingAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/******************************************************************************* | ||
* Copyright 2016 Observational Health Data Sciences and Informatics | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
******************************************************************************/ | ||
package org.ohdsi.usagi.ui.actions; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.swing.AbstractAction; | ||
import javax.swing.Action; | ||
import javax.swing.JFileChooser; | ||
import javax.swing.JOptionPane; | ||
import javax.swing.filechooser.FileFilter; | ||
import javax.swing.filechooser.FileNameExtensionFilter; | ||
|
||
import org.ohdsi.usagi.CodeMapping; | ||
import org.ohdsi.usagi.TargetConcept; | ||
import org.ohdsi.usagi.ui.Global; | ||
import org.ohdsi.usagi.ui.Mapping; | ||
|
||
public class ApplyPreviousMappingAction extends AbstractAction { | ||
|
||
private static final long serialVersionUID = 3420357922150237898L; | ||
|
||
public ApplyPreviousMappingAction() { | ||
putValue(Action.NAME, "Apply previous mapping"); | ||
putValue(Action.SHORT_DESCRIPTION, "Apply previous mapping to current code set"); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent arg0) { | ||
JFileChooser fileChooser = new JFileChooser(Global.folder); | ||
FileFilter csvFilter = new FileNameExtensionFilter("CSV files", "csv"); | ||
fileChooser.setFileFilter(csvFilter); | ||
if (fileChooser.showOpenDialog(Global.frame) == JFileChooser.APPROVE_OPTION) { | ||
int mappingsUsed = 0; | ||
int mappingsFailed = 0; | ||
File file = fileChooser.getSelectedFile(); | ||
Mapping mapping = new Mapping(); | ||
mapping.loadFromFile(file.getAbsolutePath()); | ||
Map<String, List<TargetConcept>> codeToTargetConcept = new HashMap<String, List<TargetConcept>>(); | ||
for (CodeMapping codeMapping : mapping) | ||
if (codeMapping.mappingStatus.equals(CodeMapping.MappingStatus.APPROVED)) | ||
codeToTargetConcept.put(codeMapping.sourceCode.sourceCode, codeMapping.targetConcepts); | ||
|
||
for (CodeMapping codeMapping : Global.mapping) { | ||
List<TargetConcept> targetConcepts = codeToTargetConcept.get(codeMapping.sourceCode.sourceCode); | ||
if (targetConcepts != null) { | ||
List<TargetConcept> newTargetConcepts = new ArrayList<TargetConcept>(targetConcepts.size()); | ||
for (TargetConcept targetConcept : targetConcepts) { | ||
TargetConcept newTargetConcept = Global.usagiSearchEngine.getTargetConcept(targetConcept.conceptId); | ||
if (newTargetConcept == null) | ||
mappingsFailed++; | ||
else | ||
newTargetConcepts.add(newTargetConcept); | ||
|
||
} | ||
if (newTargetConcepts.size() > 0) { | ||
codeMapping.targetConcepts = newTargetConcepts; | ||
mappingsUsed++; | ||
} | ||
if (newTargetConcepts.size() == targetConcepts.size()) | ||
codeMapping.mappingStatus = CodeMapping.MappingStatus.APPROVED; | ||
} | ||
} | ||
String message = "The old mapping contained " + codeToTargetConcept.size() + " approved mappings of which " + mappingsUsed | ||
+ " were applied to the current mapping. " + mappingsFailed + " old target concepts could not be found in the new vocabulary."; | ||
Global.mappingTablePanel.updateUI(); | ||
Global.mappingDetailPanel.updateUI(); | ||
JOptionPane.showMessageDialog(Global.frame, message); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Copyright 2016 Observational Health Data Sciences and Informatics | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
******************************************************************************/ | ||
package org.ohdsi.usagi.ui.actions; | ||
|
||
import java.awt.event.ActionEvent; | ||
|
||
import javax.swing.AbstractAction; | ||
import javax.swing.Action; | ||
|
||
public class ExitAction extends AbstractAction { | ||
|
||
private static final long serialVersionUID = 3420357922150237898L; | ||
|
||
public ExitAction() { | ||
putValue(Action.NAME, "Exit"); | ||
putValue(Action.SHORT_DESCRIPTION, "Exit Usagi"); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent arg0) { | ||
System.exit(0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters