Missing ) after For-loop. Not idea what's wrong.

Execeismazica

New Member
I'm attempting to run this script to parse an XML document. When I validate the js I get a missing ) after for-loop. I'm new to programming and not sure where I've gone wrong. I've posted the entire js file at the end. Thanks! \[code\]var meds = [];for (var i = docMedActivities.size(); i--; i >= 0) { var activity = docMedActivities.get(i); var material = activity.getConsumable().getManufacturedProduct().getManufacturedMaterial();meds.push({ name: String(material.getName().getText()), displayName: String(material.getCode().getDisplayName()), ndc: String(material.getCode().getTranslations().get(0).getCode()), doseQty: String(activity.getDoseQuantity().getValue()), effectiveDateTime: String(activity.getEffectiveTimes().get(0).getLow().getValue()), // 20120502000000+0000 code: String(material.getCode().getCode())});}\[/code\]Entire js file below :\[code\]// Load the CCD Documentvar doc = org.openhealthtools.mdht.uml.cda.util.CDAUtil.load(new java.io.ByteArrayInputStream(messageObject.getRawData().getBytes("UTF-8")));// Get CCD Document Sections to be parsedvar docPatientRole = doc.getRecordTargets().get(0).getPatientRole();var docPatient = docPatientRole.getPatient();var docPatientName = docPatient.getNames().get(0);var docPatientAddress = docPatientRole.getAddrs().get(0);var docMedSection = doc.getMedicationsSection();var docMedActivities = docMedSection.getMedicationActivities();// Patient Identityvar patient = {firstName: String(docPatientName.getGivens().get(0).getText()),lastName: String(docPatientName.getFamilies().get(0).getText()),genderCode: String(docPatient.getAdministrativeGenderCode().getCode()),dateOfBirth: String(docPatient.getBirthTime().getValue()) // YYYYMMDD};// Patient Addressvar address = {addressCity: String(docPatientAddress.getCities().get(0).getText()),addressState: String(docPatientAddress.getStates().get(0).getText()),addressPostalCode: String(docPatientAddress.getPostalCodes().get(0).getText())};// Patient Medication Activitiesvar meds = [];for (var i = docMedActivities.size(); i--; i >= 0) {var activity = docMedActivities.get(i);var material = activity.getConsumable().getManufacturedProduct().getManufacturedMaterial();meds.push({ name: String(material.getName().getText()), displayName: String(material.getCode().getDisplayName()), ndc: String(material.getCode().getTranslations().get(0).getCode()), doseQty: String(activity.getDoseQuantity().getValue()), effectiveDateTime: String(activity.getEffectiveTimes().get(0).getLow().getValue()), // 20120502000000+0000 code: String(material.getCode().getCode())});}// Populate Channel Map, use JSON so logs are readablechannelMap.put(&apos;patient&apos;, JSON.stringify(patient, null, 2));channelMap.put(&apos;address&apos;, JSON.stringify(address, null, 2));channelMap.put(&apos;meds&apos;, JSON.stringify(meds, null, 2));</script> <type>JavaScript</type> <data class="map"> <entry> <string>Script</string> <string>// Load the CCD Documentvar doc = org.openhealthtools.mdht.uml.cda.util.CDAUtil.load(new java.io.ByteArrayInputStream(messageObject.getRawData().getBytes("UTF-8")));// Get CCD Document Sections to be parsedvar docPatientRole = doc.getRecordTargets().get(0).getPatientRole();var docPatient = docPatientRole.getPatient();var docPatientName = docPatient.getNames().get(0);var docPatientAddress = docPatientRole.getAddrs().get(0);var docMedSection = doc.getMedicationsSection();var docMedActivities = docMedSection.getMedicationActivities();// Patient Identityvar patient = {firstName: String(docPatientName.getGivens().get(0).getText()),lastName: String(docPatientName.getFamilies().get(0).getText()),genderCode: String(docPatient.getAdministrativeGenderCode().getCode()),dateOfBirth: String(docPatient.getBirthTime().getValue()) // YYYYMMDD};// Patient Addressvar address = {addressCity: String(docPatientAddress.getCities().get(0).getText()),addressState: String(docPatientAddress.getStates().get(0).getText()),addressPostalCode: String(docPatientAddress.getPostalCodes().get(0).getText())};// Patient Medication Activitiesvar meds = [];for (var i = docMedActivities.size(); i--; i >= 0) {var activity = docMedActivities.get(i);var material = activity.getConsumable().getManufacturedProduct().getManufacturedMaterial();meds.push({ name: String(material.getName().getText()), displayName: String(material.getCode().getDisplayName()), ndc: String(material.getCode().getTranslations().get(0).getCode()), doseQty: String(activity.getDoseQuantity().getValue()), effectiveDateTime: String(activity.getEffectiveTimes().get(0).getLow().getValue()), // 20120502000000+0000 code: String(material.getCode().getCode())});}// Populate Channel Map, use JSON so logs are readablechannelMap.put(&apos;patient&apos;, JSON.stringify(patient, null, 2));channelMap.put(&apos;address&apos;, JSON.stringify(address, null, 2));channelMap.put(&apos;meds&apos;, JSON.stringify(meds, null, 2));\[/code\]
 
Back
Top