晚上好,我试图找到一种方法来扫描多个变量以获取特定值...与1相比为null。 这是一个示例:
this.importDataObject("MEDDIAGNOSISICD-10.txt", "C:/Users/dell/Documents/tab
excel/MEDDIAGNOSISICD-10.txt");
var oFile = this.getDataObjectContents("MEDDIAGNOSISICD-10.txt");
var cFile = util.stringFromStream(oFile, "utf-8");
var fileArray = cFile.split('\n');
var Medical1 = this.getField("Medications 1");
var Medical3 = this.getField("Medications 3");
var Medical5 = this.getField("Medications 5");
var Medical7 = this.getField("Medications 7");
var Medical9 = this.getField("Medications 9");
var Medical11 = this.getField("Medications 11");
var Medical13 = this.getField("Medications 13");
var Medical15 = this.getField("Medications 15");
var Medical17 = this.getField("Medications 17");
var Medical19 = this.getField("Medications 19");
var Medical21 = this.getField("Medications 21");
var Medical23 = this.getField("Medications 23");
var Medical25 = this.getField("Medications 25");
var Medical27 = this.getField("Medications 27");
var Medical29 = this.getField("Medications 29");
var Medical31 = this.getField("Medications 31");
var Medical33 = this.getField("Medications 33");
var Medical35 = this.getField("Medications 35");
var Medical37 = this.getField("Medications 37");
var Medical39 = this.getField("Medications 39");
var MedicalIndex1 = null
var MedicalIndex3 = null
var MedicalIndex5 = null
var MedicalIndex7 = null
var MedicalIndex9 = null
var MedicalIndex11 = null
var MedicalIndex13 = null
var MedicalIndex15 = null
var MedicalIndex17 = null
var MedicalIndex19 = null
var MedicalIndex21 = null
var MedicalIndex23 = null
var MedicalIndex25 = null
var MedicalIndex27 = null
var MedicalIndex29 = null
var MedicalIndex31 = null
var MedicalIndex33 = null
var MedicalIndex35 = null
var MedicalIndex37 = null
var MedicalIndex39 = null
var MedicalArray = ["DEPRESSION", "ANGINA", "BIPOLAR DEPRESSION",
"ATHEROSCLEROSIS", "HEART ATTACK"];
var temp = 0
var Medical1 = this.getField("Medications 1");
var Medical3 = this.getField("Medications 3");
var Medical5 = this.getField("Medications 5");
var MedicalIndex1 = null
var MedicalIndex3 = null
var MedicalIndex5 = null
var i, Index;
for (i = 0; i < fileArray.length; i++) {
Index = fileArray[i].indexOf(Medical5.value);
if(Index > -1) Cartographer = fileArray[i].split('\t');
if(Index > -1) MedAnalysis = Cartographer[0];
if(Index > -1) BrandAnalysis = Cartographer[1];
if(Index > -1) DiagAnalysis = Cartographer[2];
if(Index > -1) CodeAnalysis = Cartographer[3];
if(Index > -1) DiagSearch = DiagAnalysis.indexOf(MedicalArray[0]);
if(Index > -1 && DiagSearch != -1) MedicalIndex5 = 1;
if(Index > -1) DiagSearch = DiagAnalysis.indexOf(MedicalArray[1]);
if(Index > -1 && DiagSearch != -1) MedicalIndex5 = 1;
if(Index > -1) DiagSearch = DiagAnalysis.indexOf(MedicalArray[2]);
if(Index > -1 && DiagSearch != -1) MedicalIndex5 = 1;
if(Index > -1) DiagSearch = DiagAnalysis.indexOf(MedicalArray[3]);
if(Index > -1 && DiagSearch != -1) MedicalIndex5 = 1;
if(Index > -1) DiagSearch = DiagAnalysis.indexOf(MedicalArray[4]);
if(Index > -1 && DiagSearch != -1) MedicalIndex5 = 1;
}
编辑:我留下了一个代码块,该代码块用于扫描Medical变量是否在MedicalArray中具有任何值。这些块大约有15个,因此我只放一个以节省空间和时间。
我希望能够找到值为1的MedicalIndex并将其切换为第一个Medical变量...因此,如果MedicalIndex 27的值为1,则Medical27将使用其中一个来切换位置空的第一个医学变量。