このスクリプトを実行してXMLドキュメントを解析しようとしています。jsを検証すると、forループの後に)が欠落します。私はプログラミングに不慣れで、どこが間違っているのかわかりません。最後にjsファイル全体を投稿しました。ありがとう!
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())
});
}
以下のjsファイル全体:
// Load the CCD Document
var doc = org.openhealthtools.mdht.uml.cda.util.CDAUtil.load(new java.io.ByteArrayInputStream(messageObject.getRawData().getBytes("UTF-8")));
// Get CCD Document Sections to be parsed
var 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 Identity
var 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 Address
var address = {
addressCity: String(docPatientAddress.getCities().get(0).getText()),
addressState: String(docPatientAddress.getStates().get(0).getText()),
addressPostalCode: String(docPatientAddress.getPostalCodes().get(0).getText())
};
// Patient Medication Activities
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())
});
}
// Populate Channel Map, use JSON so logs are readable
channelMap.put('patient', JSON.stringify(patient, null, 2));
channelMap.put('address', JSON.stringify(address, null, 2));
channelMap.put('meds', JSON.stringify(meds, null, 2));</script>
<type>JavaScript</type>
<data class="map">
<entry>
<string>Script</string>
<string>// Load the CCD Document
var doc = org.openhealthtools.mdht.uml.cda.util.CDAUtil.load(new java.io.ByteArrayInputStream(messageObject.getRawData().getBytes("UTF-8")));
// Get CCD Document Sections to be parsed
var 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 Identity
var 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 Address
var address = {
addressCity: String(docPatientAddress.getCities().get(0).getText()),
addressState: String(docPatientAddress.getStates().get(0).getText()),
addressPostalCode: String(docPatientAddress.getPostalCodes().get(0).getText())
};
// Patient Medication Activities
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())
});
}
// Populate Channel Map, use JSON so logs are readable
channelMap.put('patient', JSON.stringify(patient, null, 2));
channelMap.put('address', JSON.stringify(address, null, 2));
channelMap.put('meds', JSON.stringify(meds, null, 2));