Commit 601501c1 by Owen Ryan Ang

Return element and other changes.

parent 968b8d92
import { ENCODING_PASS } from "../config.js";
import { createInfoModal, createModal } from "../genericPopup/genericPopup.js";
import { getUrlGetReturnedElement, getUrlGetWaitingElement, getUrlGetWorkload, getUrlReturnElement } from "./bpoService.js";
import { urlGetFields, urlGetIfExisting } from "./gfsService.js";
import { urlGetFields, urlGetIfExisting, urlGetMobileFields } from "./gfsService.js";
export class BPO {
......@@ -164,6 +164,28 @@ export class BPO {
}
}
async getMobileFieldData() {
let elementId = sessionStorage.getItem("element_id");
let xmlData = {
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB")
}
let response = await fetch(urlGetMobileFields, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(xmlData)
});
if (response.status == 200) {
let json = await response.json();
return json;
} else {
return null;
}
}
getXmlLastImage(xmlString) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, "text/xml");
......
......@@ -6,4 +6,5 @@ export let urlWriteXml = GDE_URL + "/" + "write-xml";
export let urlUpdateEob = GDE_URL + "/" + "update-eob";
export let urlUpdateException = GDE_URL + "/" + "update-exception";
export let urlWriteMetrics = GDE_URL + "/" + "write-metrics";
export let urlGetFields = GDE_URL + "/" + "get-fields";
\ No newline at end of file
export let urlGetFields = GDE_URL + "/" + "get-fields";
export let urlGetMobileFields = GDE_URL + "/" + "get-mobile-fields";
\ No newline at end of file
......@@ -335,14 +335,14 @@ function saveExceptionToXml(){
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec": 0,
"totalRec": 1,
"maxRec": "1",
"totalKeystroke": 0,
"procTime": "",
"procDuration": 0,
"eob": "",
"exceptionRemark": selected,
"recordNo": "0",
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
......
......@@ -62,14 +62,14 @@ function returnSaveXML(){
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec":"0",
"totalRec":"1",
"maxRec": "1",
"totalKeystroke": "",
"procTime": "",
"procDuration": "",
"eob": "",
"exceptionRemark": "",
"recordNo": "0",
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
......
......@@ -2148,11 +2148,12 @@ export function populateForm(index) {
}
}
export async function populateFields(imagePath) {
export async function populateFields() {
await fetchSchema();
var fields = {};
var resp = [];
resp.push(await BPO_OBJECT.getFieldData(imagePath));
console.log(await BPO_OBJECT.getMobileFieldData());
resp.push(await BPO_OBJECT.getMobileFieldData());
if (resp.length == 0 || resp == null) {
return;
}
......@@ -2175,8 +2176,8 @@ export async function populateFields(imagePath) {
document.querySelector('#DocType').value = doctype;
sessionStorage.setItem("doctype", doctype);
const docType = $("#DocType");
if (docType[0]) {
const docType = $("#DocType");
if(docType[0]){
for (let i = 0; i < docType[0].options.length; i++) {
if (docType[0].options[i].value == doctype) {
docType[0].options[i].selected = "selected"
......@@ -2187,11 +2188,11 @@ export async function populateFields(imagePath) {
sessionStorage.setItem("section", section);
document.querySelector('#Section').value = section;
const sectionElem = $("Section");
const sectionElem =$("Section");
for (let i = 0; i < document.getElementById("Section").options.length; i++) {
if (document.getElementById("Section").options[i].value == section) {
document.getElementById("Section").options[i].selected = "selected"
if (sectionElem[0]) {
document.getElementById("Section").options[i].selected = "selected";
if(sectionElem[0]){
sectionElem.trigger('change');
}
}
......@@ -2204,7 +2205,7 @@ export async function populateFields(imagePath) {
sessionStorage.setItem("doctype", doctype);
for (let i = 0; i < document.getElementById("DocType").options.length; i++) {
if (document.getElementById("DocType").options[i].value == doctype) {
document.getElementById("DocType").options[i].selected = "selected"
document.getElementById("DocType").options[i].selected = "selected";
}
}
......@@ -2224,10 +2225,77 @@ export async function populateFields(imagePath) {
for (let [k, v] of Object.entries(fieldsobj)) {
for (let key of Object.keys(schema[doctype][section])) {
if (schema[doctype][section][key].aka == "field" + k) {
//console.log("key = " + key);
//console.log("validation: " + schema[doctype][section][key].validation.collection);
fields["field" + k] = v;
var fieldId = schema[doctype][section][key].fieldLabel;
var currId = fieldId.replace(" ", "_")
document.getElementById(currId).value = v;
if(schema[doctype][section][key].validation.collection === 'radiolist'){
//retrieve the radio button value from the XML
const radioButton = document.querySelector(`#dropdownContainer_${key} input[value="${v}"]`);
if(radioButton){
radioButton.checked = true;
} else {
const radOther1 = document.querySelector(`#dropdownContainer_${key} input[value="other"]`);
if(radOther1){
radOther1.checked = true;
}
const radOther2 = document.querySelector(`#dropdownContainer_${key} input[value="others"]`);
if(radOther2){
radOther2.checked = true;
}
document.getElementById(`dependentTB_${key}`).value = v;
document.getElementById(`dependentTB_${key}`).style.display = 'inline-block';
}
} else if(schema[doctype][section][key].validation.collection === 'checklist') {
const checklistArrayValues = v.split(",");
let otherValues = "";
let isFirstCheckboxOtherValue = true;
let checkboxOtherValue = "";
for(let checklistValue of checklistArrayValues){
console.log("Array Values: " + checklistValue);
const checklistbox = document.querySelector(`#checklistContainer_${key} input[value="${checklistValue}"]`);
if(checklistbox){
checklistbox.checked = true;
if(checklistValue === "other" || checklistValue === "others"){
checkboxOtherValue = checklistValue;
document.getElementById(`dependentTB_${key}`).value = checkboxOtherValue;
document.getElementById(`dependentTB_${key}`).style.display = 'inline-block';
isFirstCheckboxOtherValue = false;
}
} else {
if(isFirstCheckboxOtherValue){
checkboxOtherValue = checklistValue;
isFirstCheckboxOtherValue = false;
} else{
checkboxOtherValue = checkboxOtherValue + "," + checklistValue;
}
const checkOther1 = document.querySelector(`#checklistContainer_${key} input[value="other"]`);
if(checkOther1){
console.log("checkOther1 checked");
checkOther1.checked = true;
}
const checkOther2 = document.querySelector(`#checklistContainer_${key} input[value="others"]`);
if(checkOther2){
console.log("checkOther2 checked");
checkOther2.checked = true;
}
document.getElementById(`dependentTB_${key}`).value = checkboxOtherValue;
document.getElementById(`dependentTB_${key}`).style.display = 'inline-block';
}
}
} else{
document.getElementById(key).value = v;
}
continue;
}
}
}
......
import { createWebGdeInterface, removeLoadingScreen } from '../../script.js';
import { populateFields } from '../DataInputWidget/generateFields.js';
import { ADD_NEW_OPTION, CURRENT_NODE, BPO_URL, DISPLAYED_DETAILS } from '../config.js';
import { DocumentControlWidget } from "../documentControlWidget/documentControlWidget.js";
import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "../globalVariable.js";
......@@ -254,6 +255,10 @@ export class ElementListWidget {
return;
}
}
// Populate fields if assignment is successful.
if(assignResponse.successful){
await populateFields();
}
}
}
......
......@@ -160,14 +160,14 @@ async function createBPOXML(fields, metrics, doctype, section){
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec":"0",
"totalRec":"1",
"maxRec": "1",
"totalKeystroke": metrics[0],
"procTime": "",
"procDuration": metrics[1],
"eob": "",
"exceptionRemark": "",
"recordNo": "0",
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
......
......@@ -6,8 +6,9 @@ import { DocumentControlWidget } from "./WebGde-Widgets/documentControlWidget/do
import { ElementListWidget } from "./WebGde-Widgets/ElementListWidget/ElementListWidget.js";
// import { DocumentControlWidget } from "./WebGde-Widgets/documentControlWidget/documentControlWidget.js";
import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "./WebGde-Widgets/globalVariable.js";
import { SHOW_ELEMENT_LIST_VIEWER, CURRENT_NODE } from "./WebGde-Widgets/config.js";
import { SHOW_ELEMENT_LIST_VIEWER, CURRENT_NODE, IS_RETRIEVE_FROM_BPO } from "./WebGde-Widgets/config.js";
import { fallbackLogin } from "./WebGde-Widgets/LogInWidget/LoginJavaInterface.js";
import { BPO } from "./WebGde-Widgets/BPO/getElement.js";
document.addEventListener("DOMContentLoaded", function() {
startApplication();
......@@ -48,6 +49,12 @@ async function initializeWebGDE() {
// UNCOMMENTED BY ADAM 9/25/2023
if(IS_RETRIEVE_FROM_BPO){
if (!BPO_OBJECT) {
setBPOObject(new BPO());
}
}
if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
setDocumentControlObject(new DocumentControlWidget());
......@@ -189,7 +196,7 @@ function testFunction() {
let fid = Nodes[i].id;
if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue
if (Nodes[i].type === 'button' || Nodes[i].type === 'submit') continue; // Skip elements of type "button" and "submit"
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value;
// fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value;
console.log(Nodes[i].id + ": " + Nodes[i].value);
}
......
......@@ -311,6 +311,19 @@ public class GDEWebServices {
}
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/get-mobile-fields")
public Response getMobileFields(XMLContents xml) {
try {
return Response.ok(XMLUtil.getFieldsFromSingleRecord(xml)).build();
} catch (Exception e) {
return Response.status(500).entity("Fail").build();
}
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
......
......@@ -326,4 +326,39 @@ public class XMLUtil {
return records;
}
public static Map<String, Object> getFieldsFromSingleRecord(XMLContents xml)
throws ParserConfigurationException, SAXException, IOException {
Map<String, Object> records = new HashMap<>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xml.getOutputDir());
Node imagename = document.getElementsByTagName("imagename").item(0);
Node xmlSubRecord = imagename.getParentNode().getLastChild().getPreviousSibling();
Map<String, String> fields = new HashMap<>();
records.put("DocType", imagename.getParentNode().getFirstChild().getNextSibling().getNextSibling()
.getNextSibling().getTextContent());
records.put("Section", imagename.getParentNode().getFirstChild().getNextSibling().getNextSibling()
.getNextSibling().getNextSibling().getNextSibling().getTextContent());
records.put("fields", fields);
for (int i = 0; i < xmlSubRecord.getChildNodes().getLength(); i++) {
if (xmlSubRecord.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE) {
for (int j = 0; j < xmlSubRecord.getChildNodes().item(i).getChildNodes().getLength(); j++) {
if (xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j)
.getNodeType() == Node.ELEMENT_NODE) {
fields.put(
xmlSubRecord.getChildNodes().item(i).getAttributes().getNamedItem("no").getNodeValue(),
xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j).getTextContent());
records.put("fields", fields);
}
}
}
}
return records;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment