907. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/9/2017 12:04:21 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

907.1 Files compared

# Location File Last Modified
1 OSCIF_HEC_v1.4_Sprint23_build4_Apr_2017.zip\Web_Resources\VIA vhacrm_via_library.js Fri Apr 28 20:45:14 2017 UTC
2 OSCIF_HEC_v1.4_Sprint23_build4_Apr_2017.zip\Web_Resources\VIA vhacrm_via_library.js Thu May 4 22:57:30 2017 UTC

907.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 1562
Changed 2 4
Inserted 0 0
Removed 0 0

907.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

907.4 Active regular expressions

No regular expressions were active.

907.5 Comparison detail

  1   if (typeof  (VIAServi ces) === " undefined" ) {
  2       VIASer vices = {  __namespac e: true };
  3   }
  4  
  5   //Static V ariables
  6   var consum ingApp;
  7   //Get VIA  URL and ot her items  needed 
  8   consumingA pp = new A ppInfo();
  9   consumingA pp.name =  "HRC_CRM";
  10   consumingA pp.token =  "HRC_CRM_ ID_5496";
  11   consumingA pp.passwor d = "Bf5d2 w!rQj";
  12   consumingA pp.url = " https:// URL      ";
  13   consumingA pp.notetit leid = 194 9;
  14  
  15   var callBa ckFunction ;
  16  
  17   var xml_en code_map =  {
  18       '&': ' &',
  19       '"': ' "',
  20       '<': ' &lt;',
  21       '>': ' &gt;',
  22       '/': ' &#92;'
  23   };
  24  
  25   var xml_de code_map =  {
  26       '&amp; ': '&',
  27       '&quot ;': '"',
  28       '&lt;' : '<',
  29       '&gt;' : '>',
  30       '&#92; ': '/'
  31   };
  32  
  33   function e ncodeXml(s tring) {
  34       return  string.re place(/([\ &"<>])/g,  function ( str, item)  {
  35           re turn xml_e ncode_map[ item];
  36       });
  37   };
  38  
  39   function d ecodeXml(s tring) {
  40       return  string.re place(/(&q uot;|&lt;| &gt;|&amp; )/g,
  41                    func tion (str,  item) {
  42                         return xml _decode_ma p[item];
  43                    });
  44   }
  45  
  46   function v iaLineBrea ks(string)  {
  47       return  string.re place(/[\n \r]/g, '|' );
  48   }
  49  
  50   function c reateNode( tag, value ) {
  51       return  "<" + tag  + ">" + v alue + "</ " + tag +  ">"
  52   }
  53  
  54   function v ia_getCook ie(cname)  {
  55       try {
  56           va r name = c name + "=" ;
  57           va r result =  document. cookie.mat ch(new Reg Exp(cname  + '=([^;]+ )'));
  58           re sult && (r esult = JS ON.parse(r esult[1])) ;
  59           re turn resul t;
  60       }
  61       catch  (err) {
  62           al ert('via_g etCookie:  ' + err.me ssage);
  63       }
  64   }
  65  
  66   function v ia_setCook ie(cname,  cvalue, ex minutes) {
  67       var vi a_context  = GetGloba lContext() ;
  68       var vi a_orgName  = via_cont ext.getOrg UniqueName ();
  69  
  70       try {
  71           va r d = new  Date();
  72           d. setMinutes (d.getMinu tes() + (e xminutes)) ;
  73           va r expires  = "expires =" + d.toU TCString() ;
  74           do cument.coo kie = [cna me, "=", J SON.string ify(cvalue ), "; ", e xpires, ";  path=/",  via_orgNam e, "/;"].j oin("");
  75       }
  76       catch  (err) {
  77           al ert('via_s etCookie:  ' + err.me ssage);
  78       }
  79   }
  80  
  81   function v ia_checkUs erLogIn()  {
  82       //Chec k if VIA L ogin cooki e exist (n ot expired )
  83       var lo ginCookie  = via_getC ookie("via sessionlin k");
  84  
  85       //Hide  Vista Log in section  and exit  if cookie  exist
  86       if (lo ginCookie  != null) {
  87           re turn true;
  88       }
  89       else {
  90           re turn false ;
  91       }
  92   }
  93  
  94   function v ia_getLoca tions(call back) {
  95       var ap iName = "g etLocation s";
  96       var ta rget = "*" ;  // Get  all locati ons
  97       var us erTO = via _getCookie ("viasessi onlink");
  98       try {
  99           if  (target ! == null &&  userTO != = null) {
  100                VIAServi ces.getLoc ations(use rTO, targe t, callbac k);
  101           }  else {
  102                alert("A ll fields  must be fi lled out,  please try  again.");
  103           }
  104       } catc h (err) {
  105           al ert(apiNam e.value +  ': ' + err .message);
  106       }
  107   }
  108  
  109   function v ia_getVete ran(vetera nId, callb ack) {
  110       // Get  selected  Veteran's  SSN
  111       SDK.RE ST.retriev eMultipleR ecords("Co ntact",
  112           "$ select=bah _ssn_text& $filter=Co ntactId eq  guid'" +  veteranId[ 0].id.toSt ring() + " '",
  113           fu nction (da ta) {
  114                if (data .length >  0) {
  115                    var  target = d ata[0].bah _ssn_text;
  116                    var  userTO = v ia_getCook ie("viases sionlink") ;
  117                    if ( target &&  userTO) {
  118                         VIAService s.match(us erTO, targ et, callba ck);
  119                    }
  120                }
  121           },
  122           fu nction (er ror) {
  123                alert("E rror loadi ng Veteran  identifie rs" + ":\n " + error) ;
  124           },
  125           fu nction ()  {
  126                //do not hing on co mpletion
  127           }
  128       );
  129   }
  130  
  131   //Key Valu e Pairs
  132   function g etKeyValue Pair(kvpna me, callba ck) {
  133       SDK.RE ST.retriev eMultipleR ecords("ba h_keyvalue pair",
  134           "$ select=*&$ filter=bah _name_text  eq '" + k vpname + " '",
  135           fu nction (da ta) {
  136                if (data .length >  0) {
  137                    swit ch (data[0 ].bah_valu etype_code .Value) {
  138                         case 81005 0003:
  139                             callba ck(data[0] .bah_datev alue_date) ;
  140                             break;
  141                         case 81005 0001:
  142                             callba ck(data[0] .bah_decim alvalue_nu m);
  143                             break;
  144                         case 81005 0002:
  145                             callba ck(data[0] .bah_integ ervalue_nu m);
  146                             break;
  147                         case 81005 0000:
  148                             callba ck(data[0] .bah_strin gvalue_tex t);
  149                             break;
  150                    }
  151                } else {
  152                    aler t("Could n ot find va lue for "  + kvpname) ;
  153                }
  154           },
  155           fu nction (er ror) {
  156                alert("E rror loadi ng value f or " + kvp name + ":\ n" + error );
  157           },
  158           fu nction ()  {
  159                //do not hing on co mpletion
  160           }
  161       );
  162   }
  163  
  164   function g et2Digits( startValue ) {
  165       var en dValue = " 0";
  166  
  167       if (st artValue <  10) {
  168           en dValue +=  startValue ;
  169       } else  {
  170           en dValue = s tartValue;
  171       }
  172  
  173       return  endValue;
  174   }
  175  
  176   function g etVistaDat e(myDate)  {
  177  
  178       var da y = get2Di gits(myDat e.getDate( ));
  179       var mo nth = get2 Digits(myD ate.getMon th() + 1);  //January  is 0!
  180       var ye ar = myDat e.getFullY ear() - 17 00;
  181       var ho ur = get2D igits(myDa te.getHour s());
  182       var mi nute = get 2Digits(my Date.getMi nutes());
  183       var se cond = get 2Digits(my Date.getSe conds());
  184  
  185       return  (year + m onth + day  + "." + h our + minu te + secon d);
  186   }
  187  
  188   Date.proto type.vista _date = fu nction ()  {
  189       var da y = get2Di gits(this. getDate()) ;
  190       var mo nth = get2 Digits(thi s.getMonth () + 1); / /January i s 0!
  191       var ye ar = this. getFullYea r() - 1700 ;
  192       var ho ur = get2D igits(this .getHours( ));
  193       var mi nute = get 2Digits(th is.getMinu tes());
  194       var se cond = get 2Digits(th is.getSeco nds());
  195  
  196       return  (year + m onth + day  + "." + h our + minu te + secon d);
  197   };
  198  
  199   Date.proto type.yyyym mdd = func tion () {
  200       var da y = get2Di gits(this. getDate()) ;
  201       var mo nth = get2 Digits(thi s.getMonth () + 1); / / getMonth () is zero -based
  202       var ye ar = this. getFullYea r();
  203  
  204       return  (year + m onth + day );
  205   };
  206  
  207  
  208  
  209   //AppInfo
  210   function A ppInfo() {
  211       this.n ame = "";
  212       this.t oken = "";
  213       this.p assword =  "";
  214       this.n otetitleid  = "";
  215       this.u rl = "";
  216   }
  217  
  218   AppInfo.pr ototype.ge tXMLNodes  = function  () {
  219       return  "<request ingApp>" +  this.name  + "</requ estingApp> " +
  220                             "<cons umingAppTo ken>" + th is.token +  "</consum ingAppToke n>" +
  221                             "<cons umingAppPa ssword>" +  this.pass word + "</ consumingA ppPassword >";
  222   };
  223  
  224   //Soap Wra pper
  225   function S oapWrapper (servicena me) {
  226       this.s ervicename  = service name;
  227   }
  228  
  229   SoapWrappe r.prototyp e.getSoapH eader = fu nction ()  {
  230       return  "<soapenv :Envelope  xmlns:soap env='http: //schemas. xmlsoap.or g/soap/env elope/' "  +
  231                  "xmlns:ser ='http:// DNS          . URL         /'>" +
  232                             "<soap env:Header />" +
  233                             "<soap env:Body>"  +
  234                             "<ser: " + this.s ervicename  + ">";
  235   };
  236  
  237   SoapWrappe r.prototyp e.getSoapF ooter = fu nction ()  {
  238       return  "</ser:"  + this.ser vicename +  ">" +
  239                             "</soa penv:Body> " +
  240                             "</soa penv:Envel ope>";
  241   };
  242  
  243   //UserTO
  244   function U serTO() {
  245       this.n ame = "";
  246       this.s sn = "";
  247       this.d uz = "";
  248       this.v istaduz =  "";
  249       this.s iteid = "" ;
  250       this.g reeting =  "";
  251       this.f ault = "";
  252       this.e rror = "";
  253       this.v alue = "";
  254   }
  255  
  256   UserTO.pro totype.get XMLNodes =  function  () {
  257       return  "<name>"  + this.nam e + "</nam e>" +
  258                             "<logi nSiteCode> " + this.g etSubDivis ion() + "< /loginSite Code>" +
  259                             "<user Id>" + thi s.duz + "< /userId>";
  260   };
  261   UserTO.pro totype.get SiteId = f unction ()  {
  262       return  this.site id.substr( 0, 3);
  263   };
  264   UserTO.pro totype.get SubDivisio n = functi on () {
  265       return  ((this.si teid.lengt h > 3) ? t his.siteid .substr(3)  : this.si teid.subst r(0, 3));
  266   };
  267  
  268   //Patient
  269   function P atientTO()  {
  270       this.n ame = "";
  271       this.s sn = "";
  272       this.d ob = "";
  273       this.p atientname  = "";
  274       this.l ocalpid =  "";
  275       this.p atientflag s = "";
  276       this.f ault = "";
  277       this.e rror = "";
  278       this.v alue = "";
  279  
  280       //addi tional fie lds from s elect
  281       this.g ender = "" ;
  282       this.m pipid = "" ;
  283       this.m pichecksum  = "";
  284       this.l ocation =  "";
  285       this.r estricted  = "";
  286       this.c onfidentia lity = "";
  287  
  288   }
  289  
  290   PatientTO. prototype. getXMLNode s = functi on () {
  291       return  "<name>"  + this.pat ientname +  "</name>"  +
  292                             "<loca lPid>" + t his.localp id + "</lo calPid>";
  293  
  294   };
  295  
  296   //Note Tit les
  297   function N oteTitle()  {
  298       this.i d = "";
  299       this.n ame = "";
  300       this.f ault = "";
  301       this.e rror = "";
  302       this.v alue = "";
  303   }
  304  
  305   //Location
  306   function L ocation()  {
  307       this.i d = "";
  308       this.n ame = "";
  309       this.f ault = "";
  310       this.e rror = "";
  311       this.v alue = "";
  312   }
  313  
  314   //isConsul t isSurger y
  315   function V isitTO() {
  316       this.t ype = "";
  317       this.l ocation =  new Locati on();
  318       this.t imestamp =  "";
  319       this.s tatus = "" ;
  320       this.f ault = "";
  321       this.e rror = "";
  322       this.v alue = "";
  323   }
  324  
  325  
  326   //Write No te 
  327   function N oteResultT O() {
  328       this.i d = "";
  329       this.t otalpages  = "";
  330       this.l astpagerec d = "";
  331       this.f ault = "";
  332       this.e rror = "";
  333       this.v alue = "";
  334   }
  335  
  336   //isConsul t isSurger y Confiden tiality
  337   function T extTo() {
  338       this.t ext = "";
  339       this.f ault = "";
  340       this.e rror = "";
  341       this.v alue = "";
  342   }
  343  
  344   function B uildEncoun terString( isHistoric al, locati onId) {
  345       //LOCA TIONIEN;YY YYMMDD;ENC OUNTERTYPE
  346       // --- ---------- ---------- ---------- ---------- ------
  347       //  hi storical
  348       //  -l ocation    locationid ; currentd ate; E  
  349       // --- ---------- ---------- ---------- ---------- ------
  350       //  no n-historic
  351       //  -l ocation    locationid ; currentd ate; A
  352       //  -v isit       visitlocat ionid; vis itdate; vi sittype
  353       // --- ---------- ---------- ---------- ---------- ------
  354       // Enc ounter Typ e â€“ Can  be one of  three poss ible value s: 
  355       //           A (A MBULATORY)
  356       //           H (H OSPITALIZA TION)
  357       //           E (E VENT- HIST ORICAL)
  358  
  359       //var  visitTime  = window.p arent.Xrm. Page.getAt tribute("v cl_via_vis it_time_te xt").getVa lue();
  360       //var  visitType  = window.p arent.Xrm. Page.getAt tribute("v cl_via_vis it_type_te xt").getVa lue();
  361  
  362       var en counterTyp e = (isHis torical =  'Y' ? 'E'  : 'A');
  363  
  364       var en counterDat e = getVis taDate(new  Date());
  365  
  366       return  (location Id + ";" +  encounter Date + ";"  + encount erType)
  367   }
  368  
  369   //Start of  Namespace
  370  
  371   VIAService s = {
  372  
  373       callSe rvice: fun ction (soa pMessage,  on_success , on_error ) {
  374           va r resultDa ta = null;
  375           $. ajax({
  376                url: con sumingApp. url,
  377                type: "P OST",
  378                datatype : "xml",
  379                data: so apMessage,
  380                contentT ype: "text /xml; char set=\'utf- 8'",
  381                success:  on_succes s,
  382                error: o n_error
  383           }) ;
  384       },
  385  
  386       //VIA  SERVICE: l oginVIA      
  387       loginV IA: functi on (siteId , accessCo de, verify Code, call back) {
  388           va r viaLogin Wrapper =  new SoapWr apper("log inVIA");
  389  
  390           va r soapMess age = viaL oginWrappe r.getSoapH eader() +
  391                                                       "< queryBean> " +
  392                                 cr eateNode(" requesting App", cons umingApp.n ame) +
  393                                 cr eateNode(" consumingA ppToken",  consumingA pp.token)  +
  394                                 cr eateNode(" consumingA ppPassword ", consumi ngApp.pass word) +
  395                                                       "< /queryBean >" +
  396                                                       cr eateNode(" siteCode",  siteId) +
  397                                                       cr eateNode(" accessCode ", encodeX ml(accessC ode)) +
  398                                                       cr eateNode(" verifyCode ", encodeX ml(verifyC ode)) +
  399                             viaLog inWrapper. getSoapFoo ter();
  400  
  401           if  (typeof c allback == = "functio n") { call BackFuncti on = callb ack; }
  402           el se { callB ackFunctio n = ""; }
  403           VI AServices. callServic e(soapMess age, VIASe rvices.log inVIA_OnSu ccess, VIA Services.l oginVIA_On Error);
  404       },
  405  
  406       loginV IA_OnSucce ss: functi on (data,  status) {
  407           // FIND TAG N AME:  valu eNodes.chi ldNodes[0] .childNode s[2].tagNa me                 
  408  
  409           // Check for  return nod e
  410           if  (data.get ElementsBy TagName('n s2:UserTO' ).length >  0) {
  411                var valu eNodes = d ata.getEle mentsByTag Name('ns2: UserTO')[0 ];
  412  
  413                //Parse  return nod e (includi ng fault)
  414                var retu rnUserTO =  new UserT O();
  415                returnUs erTO.name  = $(valueN odes.getEl ementsByTa gName('nam e')).text( );
  416                returnUs erTO.ssn =  $(valueNo des.getEle mentsByTag Name('SSN' )).text();
  417                returnUs erTO.duz =  $(valueNo des.getEle mentsByTag Name('DUZ' )).text();
  418                returnUs erTO.sitei d = $(valu eNodes.get ElementsBy TagName('s iteId')).t ext();
  419                returnUs erTO.greet ing = $(va lueNodes.g etElements ByTagName( 'greeting' )).text();
  420                returnUs erTO.vista duz = $(va lueNodes.g etElements ByTagName( 'vistaDUZ' )).text();
  421                returnUs erTO.fault  = $(value Nodes.getE lementsByT agName('fa ult')).tex t();
  422                returnUs erTO.value  = $(value Nodes).tex t();
  423  
  424                //check  if error
  425                if (retu rnUserTO.f ault !== " " && retur nUserTO.fa ult !== nu ll) {
  426                    retu rnUserTO.e rror = "Lo gin failed ";
  427                }
  428           }
  429  
  430           if  (callBack Function ! == "") { c allBackFun ction(retu rnUserTO);  }
  431       },
  432  
  433       loginV IA_OnError : function  (request,  status, e rror) {
  434           // Parse Faul t
  435           va r returnUs erTO = new  UserTO();
  436           re turnUserTO .error = e rror;
  437           re turnUserTO .fault = $ (request.r esponseXML .getElemen tsByTagNam e('faultst ring')).te xt();
  438           re turnUserTO .value = $ (request.r esponseTex t).text();
  439  
  440           if  (callBack Function ! == "") { c allBackFun ction(retu rnUserTO);  }
  441       },
  442  
  443       //VIA  SERVICE: m atch         
  444       match:  function  (userTO, t arget, cal lback) {
  445           //  target an d directio n are opti onal per d ocumentati on
  446           va r getMatch Wrapper =  new SoapWr apper("mat ch");
  447  
  448           va r soapMess age = getM atchWrappe r.getSoapH eader() +
  449                                 "< queryBean> " +
  450                                                                crea teNode("ta rget", enc odeXml(tar get)) +
  451                                                                crea teNode("di rection",  1) +
  452                                 "< provider>"  +
  453                                 cr eateNode(" name", use rTO.name)  +
  454                                 cr eateNode(" loginSiteC ode", ((us erTO.sitei d.length >  3) ? user TO.siteid. substr(3)  : userTO.s iteid.subs tr(0, 3)))  +
  455                                 cr eateNode(" userId", u serTO.duz)  +
  456                                 "< /provider> " +
  457                                 cr eateNode(" requesting App", cons umingApp.n ame) +
  458                                 cr eateNode(" consumingA ppToken",  consumingA pp.token)  +
  459                                 cr eateNode(" consumingA ppPassword ", consumi ngApp.pass word) +
  460                                                                "</q ueryBean>"  +
  461                                                       ge tMatchWrap per.getSoa pFooter();
  462  
  463           if  (typeof c allback == = "functio n") { call BackFuncti on = callb ack; }
  464           el se { callB ackFunctio n = ""; }
  465           VI AServices. callServic e(soapMess age, VIASe rvices.mat ch_OnSucce ss, VIASer vices.matc h_OnError) ;
  466       },
  467  
  468       match_ OnSuccess:  function  (data, sta tus) {
  469           va r returnRe sult = [];
  470  
  471           // Check for  return nod e
  472           if  (data.get ElementsBy TagName("n s2:TaggedP atientArra y").length  > 0) {
  473                var valu eNodes = d ata.getEle mentsByTag Name("ns2: TaggedPati entArray") [0].getEle mentsByTag Name("pati ents")[0];
  474  
  475                $(valueN odes).chil dren().eac h(function  (index) {
  476                    //Pa rse return  node (inc luding fau lt)
  477                    var  tempPatien tTO = new  PatientTO( );
  478                    temp PatientTO. name = $(v alueNodes. childNodes [index].ge tElementsB yTagName(' name')).te xt();
  479                    temp PatientTO. ssn = $(va lueNodes.c hildNodes[ index].get ElementsBy TagName('s sn')).text ()
  480                    temp PatientTO. dob = $(va lueNodes.c hildNodes[ index].get ElementsBy TagName('d ob')).text ();
  481                    temp PatientTO. patientnam e = $(valu eNodes.chi ldNodes[in dex].getEl ementsByTa gName('pat ientName') ).text();
  482                    temp PatientTO. localpid =  $(valueNo des.childN odes[index ].getEleme ntsByTagNa me('localP id')).text ();
  483                    temp PatientTO. patientfla gs = $(val ueNodes.ch ildNodes[i ndex].getE lementsByT agName('pa tientFlags ')).text() ;
  484                    temp PatientTO. fault = $( valueNodes .childNode s[index].g etElements ByTagName( 'fault')). text();
  485                    temp PatientTO. value = $( valueNodes .childNode s[index].g etElements ByTagName( 'patientTO ')).text() ;
  486  
  487                    //ch eck if err or
  488                    if ( tempPatien tTO.fault  !== "" &&  tempPatien tTO.fault  !== null)  {
  489                         tempPatien tTO.error  = "Get Pat ient Faile d";
  490                    }
  491  
  492                    retu rnResult.p ush(tempPa tientTO);
  493                });
  494  
  495           }  else {
  496                //Could  not find m ain node
  497                //Parse  Fault
  498                var temp PatientTO  = new Pati entTO();
  499                tempPati entTO.erro r = "Could  not find  return dat a in expec ted struct ure";
  500                tempPati entTO.faul t = $(data .getElemen tsByTagNam e('fault') ).text();
  501                tempPati entTO.valu e = $(data .documentE lement).te xt();
  502  
  503                returnRe sult.push( tempPatien tTO);
  504           }
  505  
  506           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  507       },
  508  
  509       match_ OnError: f unction (r equest, st atus, erro r) {
  510           va r returnRe sult = [];
  511  
  512           va r tempPati entTO = ne w PatientT O();
  513           te mpPatientT O.value =  request;
  514           te mpPatientT O.error =  error;
  515  
  516           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult.p ush(tempPa tientTO));  }
  517       },
  518  
  519       //VIA  SERVICE: s elect
  520       select : function  (userTO,  localPid,  target, ca llback) {
  521           //  target an d directio n are opti onal per d ocumentati on
  522           va r selectWr apper = ne w SoapWrap per("selec t");
  523  
  524           va r soapMess age = sele ctWrapper. getSoapHea der() +
  525                                                                "<qu eryBean>"  +
  526                                                                         "<pati ent>" +
  527                                                                                  createNo de("localP id", local Pid) +
  528                                                                                  createNo de("localS iteId", us erTO.getSi teId()) +
  529                                                                         "</pat ient>" +
  530                                 "< provider>"  +
  531                                 cr eateNode(" name", use rTO.name)  +
  532                                 cr eateNode(" loginSiteC ode", ((us erTO.sitei d.length >  3) ? user TO.siteid. substr(3)  : userTO.s iteid.subs tr(0, 3)))  +
  533                                 cr eateNode(" userId", u serTO.duz)  +
  534                                 "< /provider> " +
  535                                 cr eateNode(" requesting App", cons umingApp.n ame) +
  536                                 cr eateNode(" consumingA ppToken",  consumingA pp.token)  +
  537                                 cr eateNode(" consumingA ppPassword ", consumi ngApp.pass word) +
  538                                 "< /queryBean >" +
  539                                                       se lectWrappe r.getSoapF ooter();
  540  
  541           if  (typeof c allback == = "functio n") { call BackFuncti on = callb ack; }
  542           el se { callB ackFunctio n = ""; }
  543           VI AServices. callServic e(soapMess age, VIASe rvices.sel ect_OnSucc ess, VIASe rvices.sel ect_OnErro r);
  544  
  545       },
  546  
  547       select _OnSuccess : function  (data, st atus) {
  548           va r returnRe sult = [];
  549  
  550           if  (data.get ElementsBy TagName("n s2:selectR esponse"). length > 0 ) {
  551                var valu eNodes = d ata.getEle mentsByTag Name("ns2: selectResp onse")[0];
  552  
  553                $(valueN odes).chil dren().eac h(function  (index) {
  554                    var  tempPatien tTo = new  PatientTO( );
  555  
  556                    temp PatientTo. name = $(v alueNodes. childNodes [index].ge tElementsB yTagName(' name')).te xt();
  557                    temp PatientTo. ssn = $(va lueNodes.c hildNodes[ index].get ElementsBy TagName('s sn')).text ();
  558                    temp PatientTo. dob = $(va lueNodes.c hildNodes[ index].get ElementsBy TagName('d ob')).text ();
  559                    temp PatientTo. patientnam e = $(valu eNodes.chi ldNodes[in dex].getEl ementsByTa gName('pat ientName') ).text();
  560                    temp PatientTo. localpid =  $(valueNo des.childN odes[index ].getEleme ntsByTagNa me('localP id')).text ();
  561                    temp PatientTo. patientfla gs = $(val ueNodes.ch ildNodes[i ndex].getE lementsByT agName('pa tientFlags ')).text() ;
  562  
  563                    temp PatientTo. gender = $ (valueNode s.childNod es[index]. getElement sByTagName ('gender') ).text();
  564                    temp PatientTo. mpipid = $ (valueNode s.childNod es[index]. getElement sByTagName ('mpiPid') ).text();
  565                    temp PatientTo. mpichecksu m = $(valu eNodes.chi ldNodes[in dex].getEl ementsByTa gName('mpi Checksum') ).text();
  566                    temp PatientTo. location =  $(valueNo des.childN odes[index ].getEleme ntsByTagNa me('locati on')).text ();
  567                    temp PatientTo. restricted  = $(value Nodes.chil dNodes[ind ex].getEle mentsByTag Name('rest ricted')). text();
  568                    temp PatientTo. confidenti ality = $( valueNodes .childNode s[index].g etElements ByTagName( 'confident iality')). text();
  569  
  570                    temp PatientTo. fault = $( valueNodes .childNode s[index].g etElements ByTagName( 'fault')). text();
  571                    temp PatientTo. value = $( valueNodes .childNode s[index]). text();
  572  
  573                    //ch eck if err or
  574                    if ( tempPatien tTo.fault  !== "" &&  tempPatien tTo.fault  !== null)  {
  575                         tempPatien tTo.error  = "Select  Patient Fa iled";
  576                    }
  577  
  578                    retu rnResult.p ush(tempPa tientTo);
  579                });
  580  
  581           }  else {
  582                //Could  not find m ain node
  583                //Parse  Fault
  584                var temp PatientTo  = new Pati entTO();
  585                tempPati entTo.erro r = "Could  not find  return dat a in expec ted struct ure";
  586                tempPati entTo.faul t = $(data .getElemen tsByTagNam e('fault') ).text();
  587                tempPati entTo.valu e = $(data .documentE lement).te xt();
  588  
  589                returnRe sult.push( tempPatien tTo);
  590           }
  591  
  592           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  593  
  594       },
  595  
  596       select _OnError:  function ( request, s tatus, err or) {
  597           va r returnRe sult = [];
  598  
  599           va r tempPati entTo = ne w PatientT O();
  600           te mpPatientT o.error =  error;
  601           te mpPatientT o.fault =  $(request. responseXM L.getEleme ntsByTagNa me('faults tring')).t ext();
  602           te mpPatientT o.value =  $(request. responseTe xt).text() ;
  603  
  604           re turnResult .push(temp PatientTo) ;
  605  
  606           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  607       },
  608  
  609  
  610       //VIA  SERVICE: g etLocation
  611       getLoc ations: fu nction (us erTO, targ et, callba ck) {
  612           //  target an d directio n are opti onal per d ocumentati on
  613           va r getLocat ionsWrappe r = new So apWrapper( "getLocati ons");
  614  
  615           va r soapMess age = getL ocationsWr apper.getS oapHeader( ) +
  616                                 "< queryBean> " +
  617                                                                crea teNode("ta rget", enc odeXml(tar get)) +
  618                                                                crea teNode("di rection",  1) +
  619                                 "< provider>"  +
  620                                 cr eateNode(" name", use rTO.name)  +
  621                                 cr eateNode(" loginSiteC ode", ((us erTO.sitei d.length >  3) ? user TO.siteid. substr(3)  : userTO.s iteid.subs tr(0, 3)))  +
  622                                 cr eateNode(" userId", u serTO.duz)  +
  623                                 "< /provider> " +
  624                                 cr eateNode(" requesting App", cons umingApp.n ame) +
  625                                 cr eateNode(" consumingA ppToken",  consumingA pp.token)  +
  626                                 cr eateNode(" consumingA ppPassword ", consumi ngApp.pass word) +
  627                                                                "</q ueryBean>"  +
  628                                                       ge tLocations Wrapper.ge tSoapFoote r();
  629  
  630           if  (typeof c allback == = "functio n") { call BackFuncti on = callb ack; }
  631           el se { callB ackFunctio n = ""; }
  632           VI AServices. callServic e(soapMess age, VIASe rvices.get Locations_ OnSuccess,  VIAServic es.getLoca tions_OnEr ror);
  633       },
  634  
  635       getLoc ations_OnS uccess: fu nction (da ta, status ) {
  636           va r returnRe sult = [];
  637  
  638           if  (data.get ElementsBy TagName("n s2:TaggedH ospitalLoc ationArray ").length  > 0) {
  639                var valu eNodes = d ata.getEle mentsByTag Name("loca tions")[0] ;
  640  
  641                $(valueN odes).chil dren().eac h(function  (index) {
  642                    var  tempLocati on = new L ocation();
  643                    temp Location.i d = $(valu eNodes.chi ldNodes[in dex].getEl ementsByTa gName('id' )).text();
  644                    temp Location.n ame = $(va lueNodes.c hildNodes[ index].get ElementsBy TagName('n ame')).tex t();
  645                    temp Location.f ault = $(v alueNodes. childNodes [index].ge tElementsB yTagName(' fault')).t ext();
  646                    temp Location.v alue = $(v alueNodes. childNodes [index]).t ext();
  647  
  648                    //ch eck if err or
  649                    if ( tempLocati on.fault ! == "" && t empLocatio n.fault != = null) {
  650                         tempLocati on.error =  "Get Loca tion Faile d";
  651                    }
  652  
  653                    retu rnResult.p ush(tempLo cation);
  654                });
  655           }  else {
  656                //Could  not find m ain node
  657                //Parse  Fault
  658                var temp Location =  new Locat ion();
  659                tempLoca tion.error  = "Could  not find r eturn data  in expect ed structu re";
  660                tempLoca tion.fault  = $(data. getElement sByTagName ('fault')) .text();
  661                tempLoca tion.value  = $(data. documentEl ement).tex t();
  662  
  663                returnRe sult.push( tempLocati on);
  664           }
  665  
  666           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  667       },
  668  
  669       getLoc ations_OnE rror: func tion (requ est, statu s, error)  {
  670           va r returnRe sult = [];
  671  
  672           va r tempLoca tion = new  Location( );
  673           te mpLocation .error = e rror;
  674           te mpLocation .fault = $ (request.r esponseXML .getElemen tsByTagNam e('faultst ring')).te xt();
  675           te mpLocation .value = $ (request.r esponseTex t).text();
  676  
  677           re turnResult .push(temp Location);
  678  
  679           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  680       },
  681  
  682  
  683       
  684       //VIA  SERVICE: w riteNotes    
  685       writeN ote: funct ion (userT O, localPi d, titleId , encounte rString, c ontent, ca llback) {
  686           // encounter  date
  687           va r myDate =  new Date( );
  688           va r encounte rDate = ge tVistaDate (new Date( ));
  689           // Change lin ebreaks
  690           co ntent = vi aLineBreak s(content) ;
  691  
  692           //  target an d directio n are opti onal per d ocumentati on
  693           va r writeNot eWrapper =  new SoapW rapper("wr iteNote");
  694  
  695           va r soapMess age = writ eNoteWrapp er.getSoap Header() +
  696                                                                crea teNode("ti tleIEN", t itleId);
  697  
  698           so apMessage  += createN ode("encou nterString ", encount erString);   //LOCATI ONIEN;YYYY MMDD;ENCOU NTERTYPE
  699  
  700           so apMessage  += createN ode("text" , content)  +
  701                             "<quer yBean>" +
  702                                 "< patient>"  +
  703                                      createNo de("localP id", local Pid) +
  704                                 "< /patient>"  +
  705                                 "< provider>"  +
  706                                 cr eateNode(" name", use rTO.name)  +
  707                                 cr eateNode(" loginSiteC ode", ((us erTO.sitei d.length >  3) ? user TO.siteid. substr(3)  : userTO.s iteid.subs tr(0, 3)))  +
  708                                 cr eateNode(" userId", u serTO.duz)  +
  709                                 "< /provider> " +
  710                                 cr eateNode(" recordSite Code", ((u serTO.site id.length  > 3) ? use rTO.siteid .substr(3)  : userTO. siteid.sub str(0, 3)) ) +
  711                                 cr eateNode(" requesting App", cons umingApp.n ame) +
  712                                 cr eateNode(" consumingA ppToken",  consumingA pp.token)  +
  713                                 cr eateNode(" consumingA ppPassword ", consumi ngApp.pass word) +
  714                             "</que ryBean>" +
  715                         writeNoteW rapper.get SoapFooter ();
  716  
  717           // <encounter String>887 ;3140121.1 63242;E</e ncounterSt ring>
  718           //  Location  ID â€“ Mig ht need to  use the V IA service  â€œgetHos pitalLocat ions” to  retrieve  the valid  location I Ds by name
  719           //  VistA Dat e/Time - G enerate th e second p iece of in formation  by sending  a date an d time in  Vista form at. 
  720           //                         i.e. 313 0715.16324 2 represen ts July 15 , 2013 4:3 2:42. 
  721           //                         The Vist A date for mat is Vis taYear + m mdd.hhmmss
  722           //                         The only  weird thi ng is the  VistA year . It is ca lculated u sing the c urrent yea r minus 17 00.
  723           // So Februar y 7, 2017  08:00 woul d be 31702 07.080000.  Where 317  is 2017 â €“ 1700.
  724  
  725           if  (typeof c allback == = "functio n") { call BackFuncti on = callb ack; }
  726           el se { callB ackFunctio n = ""; }
  727           VI AServices. callServic e(soapMess age, VIASe rvices.wri teNote_OnS uccess, VI AServices. writeNote_ OnError);
  728       },
  729  
  730       writeN ote_OnSucc ess: funct ion (data,  status) {
  731           va r returnRe sult = [];
  732  
  733           // Check for  return nod e
  734           if  (data.get ElementsBy TagName('s oap:Envelo pe').lengt h > 0) {
  735                var valu eNodes = d ata.getEle mentsByTag Name('soap :Envelope' )[0].child Nodes[0].c hildNodes[ 0];
  736  
  737                $(valueN odes).chil dren().eac h(function  (index) {
  738                    //Pa rse return  node (inc luding fau lt)
  739                    var  noteResult To = new N oteResultT O();
  740                    note ResultTo.i d = $(valu eNodes.chi ldNodes[in dex].getEl ementsByTa gName('id' )).text();
  741                    note ResultTo.t otalpages  = $(valueN odes.child Nodes[inde x].getElem entsByTagN ame('total Pages')).t ext()
  742                    note ResultTo.l astpagerec d = $(valu eNodes.chi ldNodes[in dex].getEl ementsByTa gName('las tPageRecd' )).text();
  743                    note ResultTo.f ault = $(v alueNodes. childNodes [index].ge tElementsB yTagName(' fault')).t ext();
  744                    note ResultTo.v alue = $(v alueNodes. childNodes [index]).t ext();
  745  
  746                    //ch eck if err or
  747                    if ( noteResult To.fault ! == "" && n oteResultT o.fault != = null) {
  748                         noteResult To.error =  "Note Wri te Failed" ;
  749                    }
  750  
  751                    retu rnResult.p ush(noteRe sultTo);
  752                });
  753  
  754           }  else {
  755                //Could  not find m ain node
  756                //Parse  Fault
  757                var note ResultTo =  new NoteR esultTO();
  758                noteResu ltTo.error  = "Could  not find r eturn data  in expect ed structu re";
  759                noteResu ltTo.fault  = $(data. getElement sByTagName ('fault')) .text();
  760                noteResu ltTo.value  = $(data. documentEl ement).tex t();
  761  
  762                returnRe sult.push( noteResult To);
  763           }
  764  
  765           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  766  
  767       },
  768  
  769       writeN ote_OnErro r: functio n (request , status,  error) {
  770           va r returnRe sult = [];
  771  
  772           va r noteResu ltTo = new  NoteResul tTO();
  773           no teResultTo .error = e rror;
  774           no teResultTo .fault = $ (request.r esponseXML .getElemen tsByTagNam e('faultst ring')).te xt();
  775           no teResultTo .value = $ (request.r esponseTex t).text();
  776  
  777           re turnResult .push(note ResultTo);
  778  
  779           if  (callBack Function ! == "") { c allBackFun ction(retu rnResult);  }
  780  
  781       },
  782  
  783   }