Skip to content

Instantly share code, notes, and snippets.

@TGOlson
Last active April 5, 2017 18:47
Show Gist options
  • Save TGOlson/d519d862cd5dc401d426fb517a55cf84 to your computer and use it in GitHub Desktop.
Save TGOlson/d519d862cd5dc401d426fb517a55cf84 to your computer and use it in GitHub Desktop.
var DCData = { /* ... */ }
var TestData = { /* ... */ }
var PanelCodes = {
"LABS, Inc": {
"CT Panel": "3328",
"WU Panel": "3223"
},
"ViroMed Laboratories": {
"CT Panel": "139467",
"WU Panel": "139468"
}
}
function handleFormChange() {
var dcName = this.getField("DC").value;
var panelName = this.getField("Panel").value;
var dcData = DCData[dcName];
var labName = dcData.lab
var testData = TestData[labName];
// TODO: what should we do if there is no panel selected?
// aka. `panelName == null`?
var panelCode = PanelCodes[labName][panelName];
setDcDataFormValues(dcData);
setTestDataFormValues(testData, panelCode);
}
function setDcDataFormValues(dcData) {
// Populate fields with values from the Department Data Object
this.getField("Account").value = dcData.account;
this.getField("DCName").value = dcData.dcname;
this.getField("Contact").value = dcData.contact;
this.getField("Phone").value = dcData.phone;
this.getField("Fax").value = dcData.fax;
this.getField("Email").value = dcData.email;
this.getField("Lab").value = dcData.lab;
this.getField("Address1").value = dcData.address1;
this.getField("Address2").value = dcData.address2;
this.getField("Address3").value = dcData.address3;
this.getField("HgBS").value = dcData.hgbcode;
}
function setTestDataFormValues(testData, panelCode) {
// Populate fields with values from the Object
this.getField("test1").value = testData.test1;
this.getField("test2").value = testData.test2;
this.getField("test3").value = testData.test3;
this.getField("test4").value = testData.test4;
this.getField("test5").value = testData.test5;
this.getField("test6").value = testData.test6;
this.getField("test7").value = testData.test7;
this.getField("test8").value = testData.test8;
this.getField("test9").value = testData.test9;
this.getField("test10").value = testData.test10;
this.getField("test11").value = testData.test11;
this.getField("PanelCode").value = panelcode;
}
//</ACRO_script>
//</Document-Level>
//<AcroForm>
//<ACRO_source>DC:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:DC:Keystroke ***********/
if( event.willCommit ) {
if(event.value == " ") {
this.resetForm(["DCName","Account","DC","Contact","Phone","Fax","Email", "DrawDate", "DrawTime", "Lab","Address1","Address2","Address3" ]);
} else {
handleFormChange();
}
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>Panel:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Panel:Keystroke ***********/
if( event.willCommit ) {
if(event.value == " ") {
this.resetForm(["Panel","test1","test2","test3","test4","test5","test6","test7","test8","test9","test10","test11","PanelCode" ]);
} else {
handleFormChange();
}
}
//</ACRO_script>
//</AcroForm>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment