6. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/4/2019 2:57:42 PM Central 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.

6.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\VHIE_VDIF\RegistryHub\CustomClasses HS.Local.VA.HS.Registry.xml Tue Apr 2 18:50:42 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\eHealth Exchange Enhancements Phase 2-redacted\VHIE_VDIF\RegistryHub\CustomClasses HS.Local.VA.HS.Registry.xml Tue Apr 2 20:08:30 2019 UTC

6.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 10 11450
Changed 9 20
Inserted 0 0
Removed 0 0

6.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

6.4 Active regular expressions

No regular expressions were active.

6.5 Comparison detail

  1   <?xml 
  2     version="1 .0" 
  3     encoding=" UTF-8"
  4   ?>
  5   <Export 
  6     generator= "Cache" 
  7     version="2 5" 
  8     zv="Cache  for UNIX ( Red Hat En terprise L inux for x 86-64) 201 7.1.3 (Bui ld 317_0_1 8518U)" 
  9     ts="2019-0 2-08 10:22 :06"
  10   >
  11     <Class 
  12      name="HS.L ocal.VA.HS .Registry. ESR.Operat ions"
  13     >
  14      <Super>
  15       HS.Util.SO APClient.O perations
  16      </Super>
  17      <TimeChang ed>
  18       64954,4498 0.24874
  19      </TimeChan ged>
  20      <TimeCreat ed>
  21       64932,4099 2.083223
  22      </TimeCrea ted>
  23     
  24      <Parameter  
  25       name="INVO CATION"
  26      >
  27       <Default>
  28        Queue
  29       </Default>
  30      </Paramete r>
  31     
  32      <Parameter  
  33       name="ADAP TER"
  34      >
  35       <Default>
  36        EnsLib.SOA P.Outbound Adapter
  37       </Default>
  38      </Paramete r>
  39     
  40      <Parameter  
  41       name="MUST UNDERSTAND REPLYTO"
  42      >
  43       <Type>
  44        %Boolean
  45       </Type>
  46       <Default>
  47        0
  48       </Default>
  49      </Paramete r>
  50     
  51      <Parameter  
  52       name="MUST UNDERSTAND ACTION"
  53      >
  54       <Type>
  55        %Boolean
  56       </Type>
  57       <Default>
  58        0
  59       </Default>
  60      </Paramete r>
  61     
  62      <XData 
  63       name="Mess ageMap"
  64      >
  65       <Data>
  66        <![CDATA[
  67        <MapItems>
  68                <M apItem Mes sageType=" HS.Local.V A.HS.Regis try.Messag e.ESR.getE ESummaryRe quest">
  69                         <Met hod>getEES ummary</Me thod>
  70                </ MapItem>
  71        </MapItems >
  72        ]]>
  73       </Data>
  74      </XData>
  75     
  76      <Method 
  77       name="getE ESummary"
  78      >
  79       <FormalSpe c>
  80        pRequest:H S.Local.VA .HS.Regist ry.Message .ESR.getEE SummaryReq uest,*pRes ponse:HS.L ocal.VA.HS .Registry. Message.ES R.getEESum maryRespon se
  81       </FormalSp ec>
  82       <ReturnTyp e>
  83        %Library.S tatus
  84       </ReturnTy pe>
  85       <Implement ation>
  86        <![CDATA[
  87         ;Set ..Ad apter.WebS erviceClie ntClass =  "eeSummary PortServic e.VA.ESR.e eSummaryPo rtSoap11"
  88         ;Set tSC  = ..Adapte r.InvokeMe thod("getE ESummary", ,pRequest. key,pReque st.keyType ,pRequest. requestNam e,.summary ,.eesVersi on,.invoca tionDate,. noDataMess age)  Quit :$$$ISERR( tSC) tSC
  89         set tActi on=""
  90         Set tSC=  ..InvokeWe bService(, , tAction,  pRequest,  .tRespons e)
  91         If $$$ISE RR(tSC) {
  92                                  $$$HST RACE("Web  Service Re sponse","t SC",tSC)
  93                                  Set tS C=$$$ERROR ($$$Genera lError,"Un able to re trieve sec ondary dem ographics  from ESR")
  94                                  set tM sg = $Syst em.Status. GetErrorTe xt(tSC)      
  95                         }
  96                         Quit :$$$ISERR( tSC) 
  97         Set tSC =  pRequest. NewRespons e(.pRespon se)  Quit: $$$ISERR(t SC) tSC
  98         Set pResp onse.summa ry = $get( summary),p Response.e esVersion  = $get(ees Version),p Response.i nvocationD ate = $get (invocatio nDate),pRe sponse.noD ataMessage  = $get(no DataMessag e)
  99         Quit $$$O K
  100        ]]>
  101       </Implemen tation>
  102      </Method>
  103     </Class>
  104    
  105    
  106    
  107    
  108     <Class 
  109      name="HS.L ocal.VA.HS .Registry. HS.IHE.PDQ v3.Consume r.Operatio ns"
  110     >
  111      <IncludeCo de>
  112       HS.Common
  113      </IncludeC ode>
  114      <Procedure Block>
  115       1
  116      </Procedur eBlock>
  117      <Super>
  118       HS.IHE.PDQ v3.Consume r.Operatio ns,HS.Util .Trace.Hel per
  119      </Super>
  120      <TimeChang ed>
  121       65036,4946 9.02989
  122      </TimeChan ged>
  123      <TimeCreat ed>
  124       64838,6049 6.355057
  125      </TimeCrea ted>
  126      <Inheritan ce>
  127       right
  128      </Inherita nce>
  129     
  130      <Parameter  
  131       name="MUST UNDERSTAND ACTION"
  132      >
  133       <Type>
  134        %Boolean
  135       </Type>
  136       <Default>
  137        0
  138       </Default>
  139      </Paramete r>
  140     
  141      <Parameter  
  142       name="MUST UNDERSTAND REPLYTO"
  143      >
  144       <Type>
  145        %Boolean
  146       </Type>
  147       <Default>
  148        0
  149       </Default>
  150      </Paramete r>
  151     
  152      <UDLText 
  153       name="T"
  154      >
  155       <Content>
  156        <![CDATA[
  157        // Paramet er WSADDRE SSING = "O FF";
  158       
  159        ]]>
  160       </Content>
  161      </UDLText>
  162     
  163      <Property 
  164       name="Serv iceName"
  165      >
  166       <Descripti on>
  167        The config uration it em name fo und in HS. Registry.S ervice.*
  168       </Descript ion>
  169       <Type>
  170        %String
  171       </Type>
  172       <InitialEx pression>
  173        "MVI.PDQv3 .Consumer"
  174       </InitialE xpression>
  175       <Parameter  
  176        name="MAXL EN" 
  177        value="255 "
  178       />
  179      </Property >
  180     
  181      <UDLText 
  182       name="T"
  183      >
  184       <Content>
  185        <![CDATA[
  186        /*
  187        Parameter  FOUNDATION  = 1;
  188       
  189        Parameter  SETTINGS =  "Device:B asic:selec tor?Select =1&context ={HS.Util. ContextSea rch/Device OIDs}, Tra nsformPati entSearchT oPDQ, Tran sformPDQTo PatientSea rch, -XSLT Directory" ;
  190        */
  191        ]]>
  192       </Content>
  193      </UDLText>
  194     
  195      <Property 
  196       name="Devi ce"
  197      >
  198       <Descripti on>
  199        Used as th e sender d evice ID -  IdentityC ode from t he HS.Data .OIDMap ta ble
  200       </Descript ion>
  201       <Type>
  202        %String
  203       </Type>
  204       <InitialEx pression>
  205        "200HSEP"
  206       </InitialE xpression>
  207      </Property >
  208     
  209      <UDLText 
  210       name="T"
  211      >
  212       <Content>
  213        <![CDATA[
  214        /*
  215        /// conver ted device  entry to  OID
  216        Property D eviceOID A s %String( MAXLEN = 6 4);
  217       
  218        /// Captur e the Regi stryServic e $lb(Name ,ID) from  the servic e name
  219        Property R egistrySer vice As %S tring;
  220        */
  221        ]]>
  222       </Content>
  223      </UDLText>
  224     
  225      <UDLText 
  226       name="T"
  227      >
  228       <Content>
  229        <![CDATA[
  230        // sam, de fault tran sform to C ustom fold er
  231       
  232        ]]>
  233       </Content>
  234      </UDLText>
  235     
  236      <Property 
  237       name="Tran sformPatie ntSearchTo PDQ"
  238      >
  239       <Descripti on>
  240        PatientSea rchRequest  to PIX qu ery (20130 9)
  241       </Descript ion>
  242       <Type>
  243        %String
  244       </Type>
  245       <InitialEx pression>
  246        "IHE/PDQ/V ersion1/Cu stom/vaPat ientSearch ToPRPAIN20 1305UV.xsl "
  247       </InitialE xpression>
  248       <Parameter  
  249        name="MAXL EN"
  250       />
  251      </Property >
  252     
  253      <UDLText 
  254       name="T"
  255      >
  256       <Content>
  257        <![CDATA[
  258        // sam, de fault tran sform to C ustom fold er
  259       
  260        ]]>
  261       </Content>
  262      </UDLText>
  263     
  264      <Property 
  265       name="Tran sformPDQTo PatientSea rch"
  266      >
  267       <Descripti on>
  268        PIX respon se 201310  to Patient SearchResp onse
  269       </Descript ion>
  270       <Type>
  271        %String
  272       </Type>
  273       <InitialEx pression>
  274        "IHE/PDQ/V ersion1/Cu stom/vaPRP AIN201306U VToPatient SearchResp onse.xsl"
  275       </InitialE xpression>
  276       <Parameter  
  277        name="MAXL EN"
  278       />
  279      </Property >
  280     
  281      <XData 
  282       name="Mess ageMap"
  283      >
  284       <Data>
  285        <![CDATA[
  286        <MapItems>
  287                <M apItem Mes sageType=" HS.Message .PatientSe archReques t"> 
  288                         <Met hod>PDQReq uest</Meth od>
  289                </ MapItem>
  290        </MapItems >
  291        ]]>
  292       </Data>
  293      </XData>
  294     
  295      <Method 
  296       name="OnMe ssage"
  297      >
  298       <FormalSpe c>
  299        pRequest:H S.Message. XMLMessage ,*pRespons e:HS.Messa ge.XMLMess age
  300       </FormalSp ec>
  301       <ReturnTyp e>
  302        %Status
  303       </ReturnTy pe>
  304       <Implement ation>
  305        <![CDATA[
  306                #d im eOnMess age As %Ex ception.Ab stractExce ption
  307                
  308                Se t tSC = $$ $OK
  309                Tr y {
  310                         Set  pResponse  = ##class( HS.Message .XMLMessag e).%New()
  311                         If ( pRequest.N ame = $$$P DQv3QueryR equest) {
  312                                  Set tA ction                       = $$ $PDQv3Quer yAction(1)
  313                                  Set pR esponse.Na me      =  $$$PDQv3Qu eryRespons e
  314                         }
  315                         Else If (pReque st.Name =  $$$PDQv3Co ntinueRequ est) {
  316                                  Set tA ction                       = $$ $PDQv3Cont inueAction (1)
  317                                  Set pR esponse.Na me      =  $$$PDQv3Co ntinueResp onse
  318                         }
  319                         Else If (pReque st.Name =  $$$PDQv3Ca ncelReques t) {
  320                                  Set tA ction                       = $$ $PDQv3Canc elAction(1 )
  321                                  Set pR esponse.Na me      =  $$$PDQv3Ca ncelRespon se
  322                         }
  323                         Else  {
  324                                  Set tS C = $$$ERR OR($$$Gene ralError,  "Request t ype not ha ndled:  "  _ pRequest .Name) Qui t
  325                         }
  326       
  327                         Set  tSC= ..Inv okeWebServ ice(,, tAc tion, pReq uest, .tRe sponse)
  328                         
  329                         //Se t tSC=$$$E RROR($$$Ge neralError ,"Test Dow ntime")
  330                         If $ $$ISERR(tS C)  {
  331                                  $$$HST RACE("Web  Service Re sponse","t SC",tSC) 
  332                                  Set tS C=$$$ERROR ($$$Genera lError,"MV I web serv ice is dow n, please  check the  MVI regist ry connect ions")  
  333                         }
  334                         Quit :$$$ISERR( tSC)
  335                         $$$H STRACE("We b Service  Response", "tResponse ",tRespons e) 
  336                         Set  pResponse. ContentStr eam     =  tResponse. ContentStr eam                
  337                         Do $ $$ATNAEven t("PDQv3Co nsumer",pR equest,pRe sponse,tSC )
  338                }
  339                Ca tch eOnMes sage {
  340                         Set  tSC = eOnM essage.AsS tatus()
  341                }
  342                
  343                Qu it tSC
  344        ]]>
  345       </Implemen tation>
  346      </Method>
  347     
  348      <Method 
  349       name="PDQR equest"
  350      >
  351       <FormalSpe c>
  352        <![CDATA[p Request:HS .Message.P atientSear chRequest, &pResponse :HS.Messag e.PatientS earchRespo nse]]>
  353       </FormalSp ec>
  354       <ReturnTyp e>
  355        %Status
  356       </ReturnTy pe>
  357       <Implement ation>
  358        <![CDATA[
  359                #d im tSC As  %Status
  360                #d im eExcept ion As %Ex ception.Ab stractExce ption
  361       
  362                Se t tSC=$$$O K
  363                tr y {
  364                         If p Request.Ad ditionalIn fo.GetAt(" Continuati onPointer" )'="" {
  365                                  Set tS C = ..PDQC ontinuatio n(pRequest , .pRespon se)
  366                         } El seIf pRequ est.Additi onalInfo.G etAt("Canc elQuery")' ="" {
  367                                  Set tS C = ..PDQC ancel(pReq uest, .pRe sponse)
  368                         } El se {
  369                                  Set tS C = ..PDQL ookup(pReq uest, .pRe sponse)
  370                         }
  371       
  372                }  Catch eExc eption {
  373                         Set  tSC = eExc eption.AsS tatus()
  374                }
  375                Qu it tSC
  376        ]]>
  377       </Implemen tation>
  378      </Method>
  379     
  380      <Method 
  381       name="PDQL ookup"
  382      >
  383       <Descripti on>
  384        given the  additional  info sele cted in th e document  set list  issue fetc h
  385       </Descript ion>
  386       <FormalSpe c>
  387        <![CDATA[p Request:HS .Message.P atientSear chRequest, &pResponse :HS.Messag e.PatientS earchRespo nse]]>
  388       </FormalSp ec>
  389       <ReturnTyp e>
  390        %Status
  391       </ReturnTy pe>
  392       <Implement ation>
  393        <![CDATA[
  394                #d im tSC As  %Status
  395                #d im eExcept ion As %Ex ception.Ab stractExce ption
  396       
  397                Se t tSC=$$$O K
  398                tr y {
  399                         Set  tSC = pReq uest.NewRe sponse(.pR esponse)
  400                         Quit :$$$ISERR( tSC)
  401                         Set  tRequest =  pRequest. %Construct Clone(0)
  402                         Set  tServiceNa me=pReques t.Addition alInfo.Get At("Servic eName")
  403                         #; F or some re ason NIST  PIX PDQ pr e-Connecat hon wants  queryExten sion hard- coded to N IST_CONTIN UATION.
  404                         Set  tQueryExte nsion = $S elect(pReq uest.Addit ionalInfo. GetAt("Tes tNIST"):"N IST_CONTIN UATION",1: "1")
  405                         
  406                         #; b uild a PDQ v3 using P atientSear chRequest
  407                         Do . .UpdateReg istryServi ce(tServic eName)
  408                         Set  tXSLArgume nts("messa geExtensio n") = "'1' "
  409                         Set  tXSLArgume nts("messa geID") = " '"_$system .Util.Crea teGUID()_" '"
  410                         Set  tXSLArgume nts("query ID") = "'" _$system.U til.Create GUID()_"'"
  411                         Set  tXSLArgume nts("query Extension" ) = "'"_tQ ueryExtens ion_"'"
  412                         Set  tXSLArgume nts("recei verDeviceO ID")="'"_$ lg(..Regis tryService ,3)_"'"
  413                         Set  tXSLArgume nts("sende rDeviceOID ")="'"_..D eviceOID_" '"
  414                         Set  tXSLArgume nts("messa geID")="'" _$System.U til.Create GUID()_"'"
  415                         Set  tXSLArgume nts("creat ionTime")= "'"_##clas s(HS.Util. XSLTHelper ).timestam p()_"'"
  416       
  417                         #dim  tInput as  %Stream.G lobalChara cter
  418                         $$$H STRACE("aa  "_tReques t.Assignin gAuthority )
  419                Se t tSC = tR equest.XML ExportToSt ream(.tInp ut) Quit:$ $$ISERR(tS C)
  420                         #dim  tTarget a s %Stream. GlobalChar acter
  421                Se t tSC = .. Transform( tInput, .. TransformP atientSear chToPDQ /* "IHE/PDQ/V ersion1/Pa tientSearc hToPRPAIN2 01305UV.xs l"*/,.tOut put,.tXSLA rguments) 
  422                Qu it:$$$ISER R(tSC) 
  423                Do  tOutput.R ewind()
  424                $$ $HSTRACE(" PDQ Reques t","tOutpu t",tOutput )
  425                Do  tOutput.R ewind()
  426                         Set  tRetrieveR equest = # #class(HS. Message.XM LMessage). %New()
  427                         Set  tRetrieveR equest.Nam e = $$$PDQ v3QueryReq uest
  428                         Do t RetrieveRe quest.Cont entStream. CopyFrom(t Output)
  429                         Do t RetrieveRe quest.Cont entStream. Rewind()
  430                         Do:t ServiceNam e]"" tRetr ieveReques t.Addition alInfo.Set At(tServic eName,"Ser viceName")
  431                         Do # #class(HS. Types.Requ estInfo).R equestInfo ToXMLMessa ge(pReques t, tRetrie veRequest)  //SAML/Us er Auth
  432                         Set  tSC=..OnMe ssage(tRet rieveReque st,.tRespo nse) 
  433                         Quit :$$$ISERR( tSC)
  434                         Kill  tXSLArgum ents
  435                         
  436                         Set  tSC = ..Tr ansformInt oObject(tR esponse.Co ntentStrea m,..Transf ormPDQToPa tientSearc h /*"IHE/P DQ/Version 1/PRPAIN20 1306UVToPa tientSearc hResponse. xsl"*/,.pR esponse,.t XSLArgumen ts,"HS.Mes sage.Patie ntSearchRe sponse") 
  437                         $$$H STRACE("pR esponse"," pResponse" ,pResponse )
  438                         Set  tAffinityD omain=$S($ lg(..Regis tryService ,4)]"":$lg (..Registr yService,4 ),1:$$$Aff inityDomai n)
  439                         For  tIdx=1:1:p Response.R esults.Cou nt() {
  440                                  Set tR esponse=pR esponse.Re sults.GetA t(tIdx)
  441                                  #; loc ate MPI ID  and move  to propert y
  442                                  For tI dx2=1:1:tR esponse.Id entifiers. Count() {
  443                                           Set tIde ntifier =  tResponse. Identifier s.GetAt(tI dx2)
  444                                           //If $zc vt(tIdenti fier.Root, "1")=$zcvt (tAffinity Domain,"l" ) Set tRes ponse.MPII D=tIdentif ier.Extens ion Quit
  445                                           If tIden tifier.Ext ension["^N I^200M^USV HA" Set tR esponse.MP IID = $P(t Identifier .Extension , "^",1) Q uit
  446                                  }
  447                         }
  448                         Set  pResponse. ErrStatus= $S(pRespon se.Additio nalInfo.Ge tAt("ErrSt atusText") ="":$$$OK, 1:$$$ERROR ($$$Genera lError,pRe sponse.Add itionalInf o.GetAt("E rrStatusTe xt")))
  449                         Set  pResponse. ResultsCou nt=pRespon se.Results .Count()
  450                         
  451                         if p Response.A dditionalI nfo.GetAt( "ErrStatus Text")["En vironment  Database E rror" {
  452                                  $$$HST RACE("ErrS tatusText" ,"Error St atus Text" ,pResponse .Additiona lInfo.GetA t("ErrStat usText"))
  453                                  Set tS C=$$$ERROR ($$$Genera lError,"MV I is havin g a databa se issue.  Please try  again lat er.")
  454                         }
  455                         
  456                         
  457                }  Catch eExc eption {
  458                         Set  tSC = eExc eption.AsS tatus()
  459                }
  460                Qu it tSC
  461        ]]>
  462       </Implemen tation>
  463      </Method>
  464     
  465      <Method 
  466       name="PDQC ontinuatio n"
  467      >
  468       <Descripti on>
  469        given the  additional  info sele cted in th e document  set list  issue fetc h
  470       </Descript ion>
  471       <FormalSpe c>
  472        <![CDATA[p Request:HS .Message.P atientSear chRequest, &pResponse :HS.Messag e.PatientS earchRespo nse]]>
  473       </FormalSp ec>
  474       <ReturnTyp e>
  475        %Status
  476       </ReturnTy pe>
  477       <Implement ation>
  478        <![CDATA[
  479                #d im tSC As  %Status
  480                #d im eExcept ion As %Ex ception.Ab stractExce ption
  481       
  482                Se t tSC=$$$O K
  483                tr y {
  484                         Set  tSC = pReq uest.NewRe sponse(.pR esponse)
  485                         Quit :$$$ISERR( tSC)
  486                         Set  tRequest =  pRequest. %Construct Clone(0)
  487                         Set  tServiceNa me=pReques t.Addition alInfo.Get At("Servic eName")
  488                         #; F or some re ason NIST  PIX PDQ pr e-Connecat hon wants  queryExten sion hard- coded to N IST_CONTIN UATION.
  489                         Set  tQueryExte nsion = $S elect(pReq uest.Addit ionalInfo. GetAt("Tes tNIST"):"N IST_CONTIN UATION",1: "1")
  490                         
  491                         #; b uild a PDQ v3 using P atientSear chRequest
  492                         Do . .UpdateReg istryServi ce(tServic eName)
  493                         Set  tXSLArgume nts("messa geExtensio n") = "'1' "
  494                         Set  tXSLArgume nts("messa geID") = " '"_$system .Util.Crea teGUID()_" '"
  495                         Set  tXSLArgume nts("query ID") = "'" _pRequest. Additional Info.GetAt ("Original QueryID")_ "'"
  496                         Set  tXSLArgume nts("query Extension" ) = "'"_tQ ueryExtens ion_"'"
  497                         Set  tXSLArgume nts("recei verDeviceO ID")="'"_$ lg(..Regis tryService ,3)_"'"
  498                         Set  tXSLArgume nts("sende rDeviceOID ")="'"_..D eviceOID_" '"
  499                         Set  tXSLArgume nts("messa geID")="'" _$System.U til.Create GUID()_"'"
  500                         Set  tXSLArgume nts("creat ionTime")= "'"_##clas s(HS.Util. XSLTHelper ).timestam p()_"'"
  501       
  502                         #dim  tInput as  %Stream.G lobalChara cter
  503                         $$$H STRACE("aa  "_tReques t.Assignin gAuthority )
  504                         Set  tSC = tReq uest.XMLEx portToStre am(.tInput ) Quit:$$$ ISERR(tSC)
  505                         #dim  tTarget a s %Stream. GlobalChar acter
  506                Se t tSC = .. Transform( tInput, "I HE/PDQ/Ver sion1/Pati entSearchT oQUQIIN000 003UV01.xs l" /*"IHE/ PDQ/Versio n1/Patient SearchToQU QIIN000003 UV01"*/,.t Output,.tX SLArgument s) 
  507                Qu it:$$$ISER R(tSC) 
  508                Do  tOutput.R ewind()
  509                $$ $HSTRACE(" PDQ Contin uation","t Output",tO utput)
  510                Do  tOutput.R ewind()
  511                         Set  tRetrieveR equest = # #class(HS. Message.XM LMessage). %New()
  512                         Set  tRetrieveR equest.Nam e = $$$PDQ v3Continue Request
  513                         Do t RetrieveRe quest.Cont entStream. CopyFrom(t Output)
  514                         Do t RetrieveRe quest.Cont entStream. Rewind()
  515                         Do:t ServiceNam e]"" tRetr ieveReques t.Addition alInfo.Set At(tServic eName,"Ser viceName")
  516                         Do # #class(HS. Types.Requ estInfo).R equestInfo ToXMLMessa ge(pReques t, tRetrie veRequest)  //SAML/Us er Auth
  517                         Set  tSC=..OnMe ssage(tRet rieveReque st,.tRespo nse) 
  518                         Quit :$$$ISERR( tSC)
  519                         Kill  tXSLArgum ents
  520                         Set  tSC = ..Tr ansformInt oObject(tR esponse.Co ntentStrea m,..Transf ormPDQToPa tientSearc h /*"IHE/P DQ/Version 1/PRPAIN20 1306UVToPa tientSearc hResponse. xsl"*/,.pR esponse,.t XSLArgumen ts,"HS.Mes sage.Patie ntSearchRe sponse") 
  521                         Set  tAffinityD omain=$S($ lg(..Regis tryService ,4)]"":$lg (..Registr yService,4 ),1:$$$Aff inityDomai n)
  522                         For  tIdx=1:1:p Response.R esults.Cou nt() {
  523                                  Set tR esponse=pR esponse.Re sults.GetA t(tIdx)
  524                                  #; loc ate MPI ID  and move  to propert y
  525                                  For tI dx2=1:1:tR esponse.Id entifiers. Count() {
  526                                           Set tIde ntifier =  tResponse. Identifier s.GetAt(tI dx2)
  527                                           If $zcvt (tIdentifi er.Root,"l ")=$zcvt(t AffinityDo main,"l")  Set tRespo nse.MPIID= tIdentifie r.Extensio n Quit
  528                                  }
  529                         }
  530                         Set  pResponse. ErrStatus= $S(pRespon se.Additio nalInfo.Ge tAt("ErrSt atusText") ="":$$$OK, 1:$$$ERROR ($$$Genera lError,pRe sponse.Add itionalInf o.GetAt("E rrStatusTe xt")))
  531                         Do p Response.A dditionalI nfo.Remove At("ErrSta tusText")
  532                         Set  pResponse. ResultsCou nt=pRespon se.Results .Count()
  533                }  Catch eExc eption {
  534                         Set  tSC = eExc eption.AsS tatus()
  535                }
  536                Qu it tSC
  537        ]]>
  538       </Implemen tation>
  539      </Method>
  540     
  541      <Method 
  542       name="PDQC ancel"
  543      >
  544       <Descripti on>
  545        given the  additional  info sele cted in th e document  set list  issue fetc h
  546       </Descript ion>
  547       <FormalSpe c>
  548        <![CDATA[p Request:HS .Message.P atientSear chRequest, &pResponse :HS.Messag e.PatientS earchRespo nse]]>
  549       </FormalSp ec>
  550       <ReturnTyp e>
  551        %Status
  552       </ReturnTy pe>
  553       <Implement ation>
  554        <![CDATA[
  555                #d im tSC As  %Status
  556                #d im eExcept ion As %Ex ception.Ab stractExce ption
  557       
  558                Se t tSC=$$$O K
  559                tr y {
  560                         Set  tSC = pReq uest.NewRe sponse(.pR esponse)
  561                         Quit :$$$ISERR( tSC)
  562                         Set  tRequest =  pRequest. %Construct Clone(0)
  563                         Set  tServiceNa me=pReques t.Addition alInfo.Get At("Servic eName")
  564                         #; F or some re ason NIST  PIX PDQ pr e-Connecat hon wants  queryExten sion hard- coded to N IST_CONTIN UATION.
  565                         Set  tQueryExte nsion = $S elect(pReq uest.Addit ionalInfo. GetAt("Tes tNIST"):"N IST_CONTIN UATION",1: "1")
  566                         
  567                         #; b uild a PDQ v3 using P atientSear chRequest
  568                         Do . .UpdateReg istryServi ce(tServic eName)
  569                         Set  tXSLArgume nts("messa geExtensio n") = "'1' "
  570                         Set  tXSLArgume nts("messa geID") = " '"_$system .Util.Crea teGUID()_" '"
  571                         Set  tXSLArgume nts("query ID") = "'" _pRequest. Additional Info.GetAt ("Original QueryID")_ "'"
  572                         Set  tXSLArgume nts("query Extension" ) = "'"_tQ ueryExtens ion_"'"
  573                         Set  tXSLArgume nts("recei verDeviceO ID")="'"_$ lg(..Regis tryService ,3)_"'"
  574                         Set  tXSLArgume nts("sende rDeviceOID ")="'"_..D eviceOID_" '"
  575                         Set  tXSLArgume nts("messa geID")="'" _$System.U til.Create GUID()_"'"
  576                         Set  tXSLArgume nts("creat ionTime")= "'"_##clas s(HS.Util. XSLTHelper ).timestam p()_"'"
  577       
  578                         #dim  tInput as  %Stream.G lobalChara cter
  579                         $$$H STRACE("aa  "_tReques t.Assignin gAuthority )
  580                         Set  tSC = tReq uest.XMLEx portToStre am(.tInput ) Quit:$$$ ISERR(tSC)
  581                         #dim  tTarget a s %Stream. GlobalChar acter
  582                Se t tSC = .. Transform( tInput, "I HE/PDQ/Ver sion1/Pati entSearchT oQUQIIN000 003UV01.xs l" /*"IHE/ PDQ/Versio n1/Patient SearchToQU QIIN000003 UV01"*/,.t Output,.tX SLArgument s) 
  583                Qu it:$$$ISER R(tSC) 
  584                Do  tOutput.R ewind()
  585                $$ $HSTRACE(" PDQ Contin uation","t Output",tO utput)
  586                Do  tOutput.R ewind()
  587                         Set  tRetrieveR equest = # #class(HS. Message.XM LMessage). %New()
  588                         Set  tRetrieveR equest.Nam e = $$$PDQ v3CancelRe quest
  589                         Do t RetrieveRe quest.Cont entStream. CopyFrom(t Output)
  590                         Do t RetrieveRe quest.Cont entStream. Rewind()
  591                         Do:t ServiceNam e]"" tRetr ieveReques t.Addition alInfo.Set At(tServic eName,"Ser viceName")
  592                         Do # #class(HS. Types.Requ estInfo).R equestInfo ToXMLMessa ge(pReques t, tRetrie veRequest)  //SAML/Us er Auth
  593                         Set  tSC=..OnMe ssage(tRet rieveReque st,.tRespo nse) 
  594                         Quit :$$$ISERR( tSC)
  595                         Kill  tXSLArgum ents
  596                         Set  tSC = ..Tr ansformInt oObject(tR esponse.Co ntentStrea m,..Transf ormPDQToPa tientSearc h /*"IHE/P DQ/Version 1/PRPAIN20 1306UVToPa tientSearc hResponse. xsl"*/,.pR esponse,.t XSLArgumen ts,"HS.Mes sage.Patie ntSearchRe sponse") 
  597                         Set  tAffinityD omain=$S($ lg(..Regis tryService ,4)]"":$lg (..Registr yService,4 ),1:$$$Aff inityDomai n)
  598                         For  tIdx=1:1:p Response.R esults.Cou nt() {
  599                                  Set tR esponse=pR esponse.Re sults.GetA t(tIdx)
  600                                  #; loc ate MPI ID  and move  to propert y
  601                                  For tI dx2=1:1:tR esponse.Id entifiers. Count() {
  602                                           Set tIde ntifier =  tResponse. Identifier s.GetAt(tI dx2)
  603                                           If $zcvt (tIdentifi er.Root,"l ")=$zcvt(t AffinityDo main,"l")  Set tRespo nse.MPIID= tIdentifie r.Extensio n Quit
  604                                  }
  605                         }
  606                         Set  pResponse. ErrStatus= $S(pRespon se.Additio nalInfo.Ge tAt("ErrSt atusText") ="":$$$OK, 1:$$$ERROR ($$$Genera lError,pRe sponse.Add itionalInf o.GetAt("E rrStatusTe xt")))
  607                         Do p Response.A dditionalI nfo.Remove At("ErrSta tusText")
  608                         Set  pResponse. ResultsCou nt=pRespon se.Results .Count()
  609                }  Catch eExc eption {
  610                         Set  tSC = eExc eption.AsS tatus()
  611                }
  612                Qu it tSC
  613        ]]>
  614       </Implemen tation>
  615      </Method>
  616     
  617      <Method 
  618       name="OnPr oductionSt art"
  619      >
  620       <ClassMeth od>
  621        1
  622       </ClassMet hod>
  623       <FormalSpe c>
  624        pConfigNam e:%String= "Unknown A ctor"
  625       </FormalSp ec>
  626       <ReturnTyp e>
  627        %Status
  628       </ReturnTy pe>
  629       <Implement ation>
  630        <![CDATA[        Quit  $$$OK
  631        ]]>
  632       </Implemen tation>
  633      </Method>
  634     
  635      <Method 
  636       name="OnPr oductionSt op"
  637      >
  638       <Descripti on>
  639        This user  callback m ethod is c alled when  the syste m is being  stopped
  640       </Descript ion>
  641       <ClassMeth od>
  642        1
  643       </ClassMet hod>
  644       <FormalSpe c>
  645        pConfigNam e:%String= "Unknown A ctor"
  646       </FormalSp ec>
  647       <ReturnTyp e>
  648        %Status
  649       </ReturnTy pe>
  650       <Implement ation>
  651        <![CDATA[        Quit  $$$OK
  652        ]]>
  653       </Implemen tation>
  654      </Method>
  655     
  656      <Method 
  657       name="OnIn it"
  658      >
  659       <ReturnTyp e>
  660        %Status
  661       </ReturnTy pe>
  662       <Implement ation>
  663        <![CDATA[
  664                #d im tSC As  %Status
  665                #d im eExcept ion as %Ex ception.Ab stractExce ption
  666       
  667                Se t tSC=$$$O K
  668                tr y {
  669                         Set  ..DeviceOI D = ##clas s(HS.Data. OIDMap).OI DForType(. .Device,"D evice")
  670                }  Catch eExc eption {
  671                         Set  tSC=eExcep tion.AsSta tus()
  672                }
  673                Qu it tSC
  674        ]]>
  675       </Implemen tation>
  676      </Method>
  677     
  678      <Method 
  679       name="Upda teRegistry Service"
  680      >
  681       <Descripti on>
  682        Generally  the Servic eName will  be define d, but in  some cases  the servi ce may be  picked up  from 
  683        the reques t.Addition alInfo.Get At("Servic eName") wh ich will o verride th e default  service
  684       </Descript ion>
  685       <FormalSpe c>
  686        pService
  687       </FormalSp ec>
  688       <Implement ation>
  689        <![CDATA[
  690                Se t:pService ="" pServi ce=..Servi ceName
  691                Qu it:$lg(..R egistrySer vice)=pSer vice
  692                Se t tRegistr yService =  ##class(H S.Registry .Service.S OAP).EndPo intForName Type(pServ ice,"SOAP" )
  693                Qu it:'$IsObj ect(tRegis tryService )
  694                Se t tDeviceO ID=##class (HS.Data.O IDMap).OID ForType(tR egistrySer vice.OIDMa pCode.GetA t("Device" ),"Device" )
  695                Se t ..Regist ryService  = $lb(tReg istryServi ce.Name,tR egistrySer vice.%Id() ,tDeviceOI D,tRegistr yService.O IDMapCode. GetAt("Ass igningAuth ority"))
  696        ]]>
  697       </Implemen tation>
  698      </Method>
  699     </Class>
  700    
  701    
  702     <Class 
  703      name="HS.L ocal.VA.HS .Registry. HS.IHE.PIX .Consumer. Process"
  704     >
  705      <Descripti on>
  706      
  707       The PIX Co nsumer is  used in He althShare  to accept  updates fr om the MPI  matching  engine
  708       All other  transactio ns should  go through  the PIX m anager
  709      </Descript ion>
  710      <ClassType >
  711       persistent
  712      </ClassTyp e>
  713      <IncludeCo de>
  714       HS.Errors, HS.Common
  715      </IncludeC ode>
  716      <Super>
  717       Ens.Busine ssProcess, HS.Util.Tr ace.Helper ,HS.Util.T race.Perfo rmance
  718      </Super>
  719      <TimeChang ed>
  720       65042,4626 9.51378
  721      </TimeChan ged>
  722      <TimeCreat ed>
  723       61270,4207 1.494295
  724      </TimeCrea ted>
  725      <Inheritan ce>
  726       right
  727      </Inherita nce>
  728     
  729      <Parameter  
  730       name="DOMA IN"
  731      >
  732       <Default>
  733        HS
  734       </Default>
  735      </Paramete r>
  736     
  737      <Property 
  738       name="Erro rs"
  739      >
  740       <Type>
  741        HS.Types.I HE.Errors
  742       </Type>
  743      </Property >
  744     
  745      <Property 
  746       name="IHEV ersion"
  747      >
  748       <Type>
  749        %Integer
  750       </Type>
  751       <InitialEx pression>
  752        1
  753       </InitialE xpression>
  754      </Property >
  755     
  756      <Property 
  757       name="MPIO perations"
  758      >
  759       <Descripti on>
  760        If defined , sent the  request t o the MPI  Operation  (only call ed when th ere is a p rior MPIID )
  761       </Descript ion>
  762       <Type>
  763        Ens.DataTy pe.ConfigN ame
  764       </Type>
  765       <InitialEx pression>
  766        "HS.Hub.MP I.Manager"
  767       </InitialE xpression>
  768      </Property >
  769     
  770      <Property 
  771       name="Noti fyOthers"
  772      >
  773       <Descripti on>
  774        Other host s to notif y such as  the XDS re gistry (on ly called  when there  is a prio r MPIID)
  775       </Descript ion>
  776       <Type>
  777        %String
  778       </Type>
  779       <Parameter  
  780        name="MAXL EN" 
  781        value="102 4"
  782       />
  783      </Property >
  784     
  785      <Property 
  786       name="Affi nityDomain "
  787      >
  788       <Descripti on>
  789        Used in a  testing en vironment  allows set ting of th e Affinity Domain Cod e (which m ust be def ined in th e OID Regi stry) if n ot
  790        set the va lue from # #class(HS. IHE.Util). GetAffinit yDomain()  is used
  791       </Descript ion>
  792       <Type>
  793        %String
  794       </Type>
  795       <InitialEx pression>
  796        "USVHA"
  797       </InitialE xpression>
  798      </Property >
  799     
  800      <Property 
  801       name="Tran sformer"
  802      >
  803       <Type>
  804        HS.Util.XS LTTransfor mer
  805       </Type>
  806      </Property >
  807     
  808      <Parameter  
  809       name="SETT INGS"
  810      >
  811       <Default>
  812        <![CDATA[- IHEVersion ,MPIOperat ions:Basic :selector? size=40&co ntext={Ens .ContextSe arch/Produ ctionItems ?targets=1 &productio nName=@pro ductionId} ,-Affinity Domain,Not ifyOthers: Basic:sele ctor?multi Select=1&c ontext={En s.ContextS earch/Prod uctionItem s?targets= 1&producti onName=@pr oductionId },PartnerO peration,  VAStation,  HL7Proces singID, VA MVIOperati ons, Inact ivePatient Load]]>
  813       </Default>
  814      </Paramete r>
  815     
  816      <Property 
  817       name="Part nerOperati on"
  818      >
  819       <Type>
  820        Ens.DataTy pe.ConfigN ame
  821       </Type>
  822      </Property >
  823     
  824      <Property 
  825       name="VASt ation"
  826      >
  827       <Type>
  828        %String
  829       </Type>
  830      </Property >
  831     
  832      <Property 
  833       name="HL7P rocessingI D"
  834      >
  835       <Type>
  836        %String
  837       </Type>
  838      </Property >
  839     
  840      <Property 
  841       name="VAMV IOperation s"
  842      >
  843       <Type>
  844        Ens.DataTy pe.ConfigN ame
  845       </Type>
  846       <InitialEx pression>
  847        "VA.MVI.Op erations"
  848       </InitialE xpression>
  849      </Property >
  850     
  851      <Property 
  852       name="Inac tivePatien tLoad"
  853      >
  854       <Descripti on>
  855        Inactive P atient Loa d Process
  856       </Descript ion>
  857       <Type>
  858        Ens.DataTy pe.ConfigN ame
  859       </Type>
  860       <InitialEx pression>
  861        "VA.Inacti vePatientL oad.Proces s"
  862       </InitialE xpression>
  863      </Property >
  864     
  865      <Method 
  866       name="OnRe quest"
  867      >
  868       <FormalSpe c>
  869        pRequest:% Library.Pe rsistent,* pResponse: %Library.P ersistent
  870       </FormalSp ec>
  871       <ReturnTyp e>
  872        %Status
  873       </ReturnTy pe>
  874       <Implement ation>
  875        <![CDATA[
  876                Se t tSC = $$ $OK
  877                
  878                If  ..Affinit yDomain=""  Set ..Aff inityDomai n=$$$Affin ityDomain
  879                Se t ..Affini tyDomain =  "USVHA"
  880                Se t ..Errors  = ##class (HS.Types. IHE.Errors ).%New()
  881                
  882                Tr y {
  883                         If p Request.%I sA("HS.Mes sage.IDUpd ateNotific ationReque st") {
  884                                  Set tS C = ..Proc essNotific ation(pReq uest, .pRe sponse)
  885                         } El seIf pRequ est.%IsA(" EnsLib.HL7 .Message")  {
  886                                  Set tS C = ..Proc essHL7Mess age(pReque st, .pResp onse)
  887                         } El seIf pRequ est.%IsA(" HS.Message .XMLMessag e") {
  888                                  Set tS C = ..Proc essXMLMess age(pReque st, .pResp onse)
  889                         } El se {
  890                                  $$$LOG ERROR("Unk nown Reque st")
  891                                  Set tS C=$$$ERROR ($$$Genera lError,"Un known requ est")
  892                         }
  893                }  Catch eExc eption {
  894                         Set  tSC = eExc eption.AsS tatus()
  895                         Do . .Errors.lo gError("20 4","Error" ,$system.S tatus.GetE rrorText(t SC))    
  896                }
  897                
  898                // $$$HSTRACE ("Errors", "Errors",. .Errors)
  899                If  ..Errors. Errors.Cou nt() {
  900                         $$$H STRACE("Er rors","Err ors",..Err ors)
  901                         Set  tErrorText ="",tWarni ngText=""
  902                         For  tIdx=1:1:. .Errors.Er rors.Count () {
  903                                  Set tE rror = ..E rrors.Erro rs.GetAt(t Idx)
  904                                  If tEr ror.Severi ty="Error" !(tError.S everity="E ") {
  905                                           Set tErr orText = t ErrorText  _ "["_tErr or.Descrip tion_ "]"
  906                                  } Else  {
  907                                           Set tWar ningText =  tWarningT ext _ "["_ tError.Des cription_  "]"
  908                                  }
  909                         }
  910                         If t ErrorText] "" $$$LOGE RROR(tErro rText)
  911                         If t WarningTex t]"" $$$LO GWARNING(t WarningTex t)
  912                }
  913                
  914                Qu it tSC
  915        ]]>
  916       </Implemen tation>
  917      </Method>
  918     
  919      <Method 
  920       name="OnRe sponse"
  921      >
  922       <Descripti on>
  923        OnResponse  must be o verridden  here to av oid error  upon respo nse from a sync reque st.
  924       </Descript ion>
  925       <FormalSpe c>
  926        <![CDATA[p Request:En s.Request, &pResponse :Ens.Respo nse,pCallr equest:Ens .Request,p Callrespon se:Ens.Res ponse,pCom pletionKey :%String]] >
  927       </FormalSp ec>
  928       <ReturnTyp e>
  929        %Status
  930       </ReturnTy pe>
  931       <Implement ation>
  932        <![CDATA[        Quit  $$$OK
  933        ]]>
  934       </Implemen tation>
  935      </Method>
  936     
  937      <Method 
  938       name="Proc essHL7Mess age"
  939      >
  940       <Descripti on>
  941        Convert pR equest(HL7 v2) into I DUpdateNot ification
  942       </Descript ion>
  943       <FormalSpe c>
  944        pRequest:E nsLib.HL7. Message,*p Response:E nsLib.HL7. Message
  945       </FormalSp ec>
  946       <ReturnTyp e>
  947        %Status
  948       </ReturnTy pe>
  949       <Implement ation>
  950        <![CDATA[
  951                Se t tSC = $$ $OK
  952                
  953                Tr y {
  954                         $$$H STRACE("HL 7 Request  from servi ce", "pReq uest", pRe quest.Outp utToString ())
  955                                           
  956                         // C lone pRequ est to tHL 7Request s o that cha nges are o nly applie d to tHL7R equest.
  957                         Set  tHL7Reques t = pReque st.%Constr uctClone(1 )
  958                         
  959                         Set  tMessageTy pe = $ZCon vert(pRequ est.GetVal ueAt("MSH: 9.1")_"^"_ pRequest.G etValueAt( "MSH:9.2") ,"U")
  960                         Set  tFacility  = pRequest .GetValueA t("MSH:6.1 ")
  961                         
  962                         If t MessageTyp e="ADT^A43 " {
  963                                  
  964                                  Set tA ffinityDom ainOID=$$$ AffinityDo mainOIDGet (..Affinit yDomain)
  965                                  Set tS ourceOID =  pRequest. GetValueAt ("MSH:3")
  966                                  If '## class(HS.D ata.OIDMap ).GetCodeF orOID(tSou rceOID)=""  Do ..Erro rs.logErro r("200","E ","Unknown  OID : "_t SourceOID)  
  967                                  Set tR equest = # #class(HS. Message.ID UpdateNoti ficationRe quest).%Ne w()
  968                                  
  969                                  Set tN ewPID = ""    
  970                                  For i  = 1:1:pReq uest.GetVa lueAt("PID grp(1).PID :3(*)") {
  971                          If  pRequest.G etValueAt( "PIDgrp(1) .PID:3("_i _").6.2")= "200M" &&  (pRequest. GetValueAt ("PIDgrp(1 ).PID:3("_ i_").4.1") ="USVHA")  && (pReque st.GetValu eAt("PIDgr p(1).PID:3 ("_i_").5" )="NI") {     /// USS SA &USDOD  also has P ID.3(1).6. 2 as 200M
  972                          Set  tNewPID =  pRequest. GetValueAt ("PIDgrp(1 ).PID:3("_ i_").1")
  973                          $$$ HSTRACE("N ew Master  Patient ID : ","tNewP ID", tNewP ID)
  974                          $$$ LOGINFO("N ew Master  Patient ID : "_tNewPI D_" ") Qui t
  975                          }
  976                      }  
  977                                  //Set  tAD = $p($ p(tNewPID, "^^^",2)," &",2)
  978                                  //If t AD'=tAffin ityDomainO ID Do ..Er rors.logEr ror("200", "E","Incor rect affin ity domain  : "_tAD)
  979                                  Set tR equest.MPI ID = tNewP ID
  980                                  Set tO ldPID = pR equest.Get ValueAt("P IDgrp(1).M RG:1(1).1" )   
  981                                  $$$LOG INFO("Prio r Master P atient ID: "_tOldPID_ " ")
  982                                  
  983                                  //Set  tAD = $p($ p(tOldPID, "^^^",2)," &",2)
  984                                  //If t AD'=tAffin ityDomainO ID Do ..Er rors.logEr ror("200", "E","Incor rect affin ity domain  : "_tAD)  Quit
  985                                  
  986                                  Set tR esponse=## class(HS.M essage.Add UpdateHubR esponse).% New(),tRes ponse.ErrS tatus=$$$O K
  987                                  
  988                                  // Che ck if the  EF facilit y record n eeds to be  updated.
  989                                  // Che ck for exs istence of  TO ICN in  the regis try 
  990                                  Set tS tatement =  "", tCoun t = 0 , tS QL = ""
  991                                  Set tS QL = "SELE CT COUNT(* ) COUNTNo  FROM HS_Re gistry.Pat ient Where  MPIID = ?  AND Facil ity = 'EF' "
  992                                  Set tS tatement   = ##class( %SQL.State ment).%New (),tStatem ent.%Selec tMode = 1
  993                                  Set tS C = tState ment.%Prep are(tSQL)
  994                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  995                                  Set tR S = tState ment.%Exec ute(tNewPI D)
  996                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  997                                  
  998                                  Do tRS .%Next()
  999                                  Set tC ount = tRS .%Get("COU NTNo")
  1000                                  
  1001                                           
  1002                                           If tCoun t = 0  {                   /// T he TO ICN  is not kno wn in HS
  1003                                                    // Add EF  Facility t o the Regi stry
  1004                                                    $$$HSTRACE ("Adding E F Facility  Record"," tHL7Reques t",tHL7Req uest.Outpu tToString( ))
  1005                                                    Set tSC =  ..UpdateEF Patient(tH L7Request, .tResponse , 0)           
  1006                                           } Else {
  1007                                                    /// Do Not hing if To  ICN is kn own in HS  - Do not a dd EF Faci lity
  1008                                           }                
  1009                                  
  1010                                  Set tR equest.Pri orMPIID =  tOldPID        
  1011                                  Set tI dentifier  = ##class( HS.Types.I dentifier) .%New()
  1012                                  Do tRe quest.Iden tifiers.In sert(tIden tifier)
  1013                                  //Set  tLocalID =  pRequest. GetValueAt ("PIDgrp(1 ).PID:3(2) .1")
  1014                                  
  1015                                  Set tL ocalID = " " , tLocal Facility =  ""  
  1016                                  For i  = 1:1:pReq uest.GetVa lueAt("PID grp(1).PID :3(*)") {
  1017                          If  pRequest.G etValueAt( "PIDgrp(1) .PID:3("_i _").5") =  "PI" && (p Request.Ge tValueAt(" PIDgrp(1). PID:3("_i_ ").4.1") =  "USVHA"){     
  1018                                  Set tL ocalID = p Request.Ge tValueAt(" PIDgrp(1). PID:3("_i_ ").1")
  1019                                  Set tL ocalFacili ty = pRequ est.GetVal ueAt("PIDg rp(1).PID: 3("_i_").6 .2")
  1020                                  $$$LOG INFO("Loca l Facility  : "_tLoca lFacility_ " ")
  1021                                  $$$LOG INFO("Loca l ID or DF N : "_tLoc alID_" ") 
  1022                                  Quit
  1023                          }
  1024                      }
  1025                         
  1026                                  Set tI dentifier. Root=tLoca lFacility
  1027                                  Set tI dentifier. Extension= tLocalID
  1028                                  Do tRe quest.Addi tionalInfo .SetAt(tSo urceOID,"S ourceOID")
  1029                                  Do tRe quest.Addi tionalInfo .SetAt(1," XPID")
  1030                                  Set tS C = ..Proc essNotific ation(tReq uest,.tRes ponse)
  1031                                  
  1032                                  Do ..T riggerInac tivePatien tLoad(tNew PID)
  1033                                  
  1034                                  // Che ck for exs istence of  FROM ICN   in the re gistry 
  1035                                  Set tS tatement =  "", tCoun t = 0 , tS QL = ""
  1036                                  Set tS QL = "SELE CT COUNT(* ) COUNTNo   FROM HS_R egistry.Pa tient Wher e MPIID =  ? AND Faci lity != 'E F'"
  1037                                  Set tS tatement   = ##class( %SQL.State ment).%New (),tStatem ent.%Selec tMode = 1
  1038                                  Set tS C = tState ment.%Prep are(tSQL)
  1039                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1040                                  Set tR S = tState ment.%Exec ute(tOldPI D)
  1041                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1042                                  
  1043                                  Do tRS .%Next()
  1044                                  Set tC ount = tRS .%Get("COU NTNo")
  1045                                  
  1046                                  If tCo unt = 0  {                   ///  From ICN  is known i n HS
  1047                                           // Delet e EF Facil ity Record  from the  Registry
  1048                                           $$$HSTRA CE("Deleti ng EF Faci lity Recor d","tHL7Re quest",tHL 7Request)
  1049                                           Set tSC  = ..Update EFPatient( tHL7Reques t,.tRespon se, 1)
  1050                                           
  1051                                  } Else  {
  1052                                           // Do No thing here
  1053                                  }
  1054       
  1055                                  If tRe sponse.Err Status]"", $$$ISERR(t Response.E rrStatus)  Do ..Error s.logError ("200","E" ,$system.S tatus.GetE rrorText(t Response.E rrStatus))
  1056                                  Set tS C = ..Crea teXPIDATNA (pRequest, tRequest,t Response,t SC) If $$$ ISERR(tSC)  $$$LOGSTA TUS(tSC)
  1057                                  Set tS C = ..Gene ralHL7Resp onse( pReq uest, .pRe sponse) If  $$$ISERR( tSC) $$$LO GSTATUS(tS C)
  1058                                  Set tS C = ..Send RequestAsy nc(..Partn erOperatio n,pRespons e)
  1059                                  
  1060                         } El seIf tMess ageType="A DT^A31" {
  1061                                  
  1062                                  Set tI CNNbr = ""
  1063                                  For i  = 1:1:tHL7 Request.Ge tValueAt(" PID:3(*)")  {
  1064                          If  tHL7Reques t.GetValue At("PID:3( "_i_").6.2 ")="200M"  && (tHL7Re quest.GetV alueAt("PI D:3("_i_") .4.1")="US VHA") && ( tHL7Reques t.GetValue At("PID:3( "_i_").5") ="NI") {     
  1065                          Set  tICNNbr =  tHL7Reque st.GetValu eAt("PID:3 ("_i_").1" )
  1066                          $$$ LOGINFO("M aster Pati ent ID: "_ tICNNbr_"  ") 
  1067                          } 
  1068                      }   
  1069                                  
  1070                                  Set tS tatement =  "", tCoun t = 0 , tS QL = ""
  1071                                  Set tS QL = "SELE CT COUNT(* ) COUNTNo  FROM HS_Re gistry.Pat ient Where  MPIID = ?  AND Facil ity = 'EF' "
  1072                                  Set tS tatement   = ##class( %SQL.State ment).%New (),tStatem ent.%Selec tMode = 1
  1073                                  Set tS C = tState ment.%Prep are(tSQL)
  1074                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1075                                  Set tR S = tState ment.%Exec ute(tICNNb r)
  1076                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1077                                  
  1078                                  Do tRS .%Next()
  1079                                  Set tC ount = tRS .%Get("COU NTNo")
  1080                                  
  1081                                           If tCoun t = 0  {     /// The  ICN is not  known in  HS
  1082                                                    Do ..Error s.logError ("200","E" ,"Unable t o locate M PIID : "_t ICNNbr)
  1083                                                   
  1084                                           } Else {                   
  1085                                                    Set tSC=.. ProcessA31 Subscripti onMessage( tHL7Reques t, .pRespo nse)
  1086                                                    Set tEnvel opeFromSer vice = tHL 7Request.E nvelope
  1087                                                    Set tHL7Re quest.Enve lope = ""
  1088                                                    Set tFromH ost = $Pie ce($Piece( tEnvelopeF romService ,"<-",2)," :",1)
  1089                                                    Set tEnvel opeToAudit  = ""
  1090                                                    Set tEnvel opeToAudit  = tEnvelo peToAudit_ "|ToHost=" _$system.I NetInfo.Ho stNameToAd dr($system .INetInfo. LocalHostN ame())_"|"
  1091                                                    Set tEnvel opeToAudit  = tEnvelo peToAudit_ "|FromHost ="_tFromHo st_"|"
  1092                                                    Set tHL7Re quest.Enve lope = tEn velopeToAu dit
  1093                                                    //Set tSC= $$$ATNAEve nt("PIXv2C onsumer",  tHL7Reques t, pRespon se, tSC) I f $$$ISERR (tSC) $$$L OGSTATUS(t SC)
  1094                                           }
  1095                                  Set tS C = ..Gene ralHL7Resp onse( pReq uest, .pRe sponse) If  $$$ISERR( tSC) $$$LO GSTATUS(tS C)
  1096                                  Set tS C = ..Send RequestAsy nc(..Partn erOperatio n,pRespons e)
  1097                                           
  1098                                  
  1099                         } El seIf tMess ageType="A DT^A24" {
  1100                                  // Han dling ICN  and DFN Le vel Merges  using the  logic bel ow.
  1101                                  
  1102                                  Set tA ffinityDom ainOID=$$$ AffinityDo mainOIDGet (..Affinit yDomain)
  1103                                  Set tS ourceOID =  pRequest. GetValueAt ("MSH:3")
  1104                                  If '## class(HS.D ata.OIDMap ).GetCodeF orOID(tSou rceOID)=""  Do ..Erro rs.logErro r("200","E ","Unknown  OID : "_t SourceOID)  
  1105                                  Set tR equest = # #class(HS. Message.ID UpdateNoti ficationRe quest).%Ne w()
  1106                                  Set tN ewPID = ""  
  1107                                  For i  = 1:1:pReq uest.GetVa lueAt("PID :3(*)") {
  1108                          If  pRequest.G etValueAt( "PID:3("_i _").6.2")= "200M" &&  (pRequest. GetValueAt ("PID:3("_ i_").4.1") ="USVHA")  && (pReque st.GetValu eAt("PID:3 ("_i_").5" )="NI") {     /// USS SA &USDOD  also has P ID.3(1).6. 2 as 200M
  1109                          Set  tNewPID =  pRequest. GetValueAt ("PID:3("_ i_").1")
  1110                          $$$ LOGINFO("N ew Master  Patient ID :"_tNewPID _" ") Quit
  1111                          }
  1112                      }  
  1113                                  //Set  tAD = $p($ p(tNewPID, "^^^",2)," &",2)
  1114                                  //If t AD'=tAffin ityDomainO ID Do ..Er rors.logEr ror("200", "E","Incor rect affin ity domain  : "_tAD)
  1115                                  Set tR equest.MPI ID = $p(tN ewPID,"^^^ ")
  1116                                  
  1117                                  Set tO ldPID = ""
  1118                                  For i  = 1:1:pReq uest.GetVa lueAt("PID :3(*)") {
  1119                          If  pRequest.G etValueAt( "PIDi2:3(" _i_").6.2" )="200M" & & (pReques t.GetValue At("PIDi2: 3("_i_").4 .1")="USVH A") && (pR equest.Get ValueAt("P IDi2:3("_i _").5")="N I") {    / // USSSA & USDOD also  has PIDi2 .3(1).6.2  as 200M
  1120                          Set  tOldPID =  pRequest. GetValueAt ("PIDi2:3( "_i_").1")
  1121                          $$$ LOGINFO("P rior Maste r Patient  ID:"_tOldP ID_" ") Qu it
  1122                          }
  1123                      }
  1124                                  
  1125                         Set  tResponse= ##class(HS .Message.A ddUpdateHu bResponse) .%New(),tR esponse.Er rStatus=$$ $OK
  1126                                  
  1127                                  // Che ck if the  EF facilit y record n eeds to be  updated.
  1128                                  // Che ck for exs istence of  TO ICN in  the regis try 
  1129                                  Set tS tatement =  "", tCoun t = 0 , tS QL = ""
  1130                                  Set tS QL = "SELE CT COUNT(* ) COUNTNo  FROM HS_Re gistry.Pat ient Where  MPIID = ?  AND Facil ity = 'EF' "
  1131                                  Set tS tatement   = ##class( %SQL.State ment).%New (),tStatem ent.%Selec tMode = 1
  1132                                  Set tS C = tState ment.%Prep are(tSQL)
  1133                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1134                                  Set tR S = tState ment.%Exec ute(tNewPI D)
  1135                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1136                                  
  1137                                  Do tRS .%Next()
  1138                                  Set tC ount = tRS .%Get("COU NTNo")
  1139                                                   
  1140                                           If tCoun t = 0  {                   /// T he TO ICN  is not kno wn in HS
  1141                                                    // Add EF  Facility t o the Regi stry
  1142                                                    $$$HSTRACE ("Adding E F Facility  Record"," tHL7Reques t",tHL7Req uest.Outpu tToString( ))
  1143                                                    Set tSC =  ..UpdateEF Patient(tH L7Request, .tResponse , 0)           
  1144                                           } Else {
  1145                                                    /// Do Not hing if To  ICN is kn own in HS  - Do not a dd EF Faci lity
  1146                                           }                
  1147                                           
  1148                                  Set tR equest.Pri orMPIID =  $p(tOldPID ,"^^^")
  1149                                  Set tI dentifier  = ##class( HS.Types.I dentifier) .%New()
  1150                                  Do tRe quest.Iden tifiers.In sert(tIden tifier)
  1151                                  //Set  tLocalID =  pRequest. GetValueAt ("PID:3(2) .1")
  1152                                  //Set  tLocalID=p Request.Ge tValueAt(" PIDi2:3(2) .1")
  1153                                  
  1154                                  Set tL ocalID = " " , tLocal Facility =  ""    
  1155                                  For i  = 1:1:pReq uest.GetVa lueAt("PID i2:3(*)")  {
  1156                          If  pRequest.G etValueAt( "PIDi2:3(" _i_").5")  = "PI" &&  (pRequest. GetValueAt ("PIDi2:3( "_i_").4.1 ") = "USVH A"){
  1157                                  Set tL ocalID = p Request.Ge tValueAt(" PIDi2:3("_ i_").1")
  1158                                  Set tL ocalFacili ty = pRequ est.GetVal ueAt("PIDi 2:3("_i_") .6.2")
  1159                                  $$$LOG INFO("Loca l Facility  : "_tLoca lFacility_ " ")
  1160                                  $$$LOG INFO("Loca l ID or DF N : "_tLoc alID_" ")   
  1161                                  Quit
  1162                          }
  1163                      }  
  1164                                  
  1165                                  Set tI dentifier. Root = tLo calFacilit y
  1166                                  Set tI dentifier. Extension  = tLocalID     
  1167                                  Do tRe quest.Addi tionalInfo .SetAt(tSo urceOID,"S ourceOID")
  1168                                  Do tRe quest.Addi tionalInfo .SetAt(1," XPID")
  1169                                  Set tS C = ..Proc essNotific ation(tReq uest,.tRes ponse)
  1170                                  
  1171                                  Do ..T riggerInac tivePatien tLoad(tNew PID)
  1172                                  
  1173                                  // Che ck for exs istence of  FROM ICN   in the re gistry 
  1174                                  Set tS tatement =  "", tCoun t = 0 , tS QL = ""
  1175                                  Set tS QL = "SELE CT COUNT(* ) COUNTNo   FROM HS_R egistry.Pa tient Wher e MPIID =  ? AND Faci lity != 'E F'"
  1176                                  Set tS tatement   = ##class( %SQL.State ment).%New (),tStatem ent.%Selec tMode = 1
  1177                                  Set tS C = tState ment.%Prep are(tSQL)
  1178                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1179                                  Set tR S = tState ment.%Exec ute(tOldPI D)
  1180                                  If $$$ ISERR(tSC)  $$$ThrowO nError(tSC )
  1181                                  
  1182                                  Do tRS .%Next()
  1183                                  Set tC ount = tRS .%Get("COU NTNo")
  1184                                  
  1185                                  If tCo unt = 0  {                   ///  From ICN  is known i n HS
  1186                                           // Delet e EF Facil ity Record  
  1187                                           $$$HSTRA CE("Deleti ng EF Faci lity Recor d","tHL7Re quest",tHL 7Request)
  1188                                           Set tSC  = ..Update EFPatient( tHL7Reques t,.tRespon se, 1)
  1189                                           
  1190                                           
  1191                                  } Else  {
  1192                                           // Do No thing here
  1193                                  }
  1194                                  
  1195                                  If tRe sponse.Err Status]"", $$$ISERR(t Response.E rrStatus)  Do ..Error s.logError ("200","E" ,$system.S tatus.GetE rrorText(t Response.E rrStatus))
  1196                                  Set tS C = ..Crea teXPIDATNA (pRequest, tRequest,t Response,t SC) If $$$ ISERR(tSC)  $$$LOGSTA TUS(tSC)
  1197                                  
  1198                                  Set tS C = ..Gene ralHL7Resp onse( pReq uest, .pRe sponse) If  $$$ISERR( tSC) $$$LO GSTATUS(tS C)
  1199                                  Set tS C = ..Send RequestAsy nc(..Partn erOperatio n,pRespons e)
  1200                                  
  1201                                  }
  1202                                  
  1203                         Else  {
  1204                                  Do ..E rrors.logE rror("200" ,"E","Unsu pported HL 7 Message  Type : "_t MessageTyp e)
  1205                         }
  1206                }
  1207                Ca tch eExcep tion {
  1208                         Set  tSC = eExc eption.AsS tatus()
  1209                         Do . .Errors.lo gError("20 4","Error" ,$system.S tatus.GetE rrorText(t SC))    
  1210                }
  1211                If  ..Errors. Errors.Cou nt() Set t SC = ..HL7 ErrorRespo nse(tHL7Re quest, .pR esponse)
  1212                
  1213                If  $Data(pRe sponse),$I sObject(pR esponse) $ $$HSTRACE( "HL7 Respo nse to ser vice", "pR esponse",  pResponse. OutputToSt ring())
  1214                
  1215                Qu it tSC
  1216        ]]>
  1217       </Implemen tation>
  1218      </Method>
  1219     
  1220      <Method 
  1221       name="Crea teXPIDATNA "
  1222      >
  1223       <Descripti on>
  1224        Create the  ATNA audi t message  for XPID t ransaction
  1225       </Descript ion>
  1226       <FormalSpe c>
  1227        pRequest:E nsLib.HL7. Message,pU pdateReque st:HS.Mess age.IDUpda teNotifica tionReques t,pRespons e:HS.Messa ge.AddUpda teHubRespo nse="",pSC :%Status
  1228       </FormalSp ec>
  1229       <ReturnTyp e>
  1230        %Status
  1231       </ReturnTy pe>
  1232       <Implement ation>
  1233        <![CDATA[
  1234                Se t tATNAMes sage = ##c lass(HS.Me ssage.XMLM essage).%N ew()
  1235                Se t tATNAMes sage.Name= $$$XPIDNot ificationR equest
  1236                #;  take the  status fro m the Upda te, overwr ite if oka y and the  general st atus is an  error
  1237                Se t tStatus  = $S($IsOb ject(pResp onse):pRes ponse.ErrS tatus,1:$$ $OK)
  1238                Se t:$$$ISOK( tStatus) t Status=pSC
  1239                Do  tATNAMess age.Additi onalInfo.S etAt(tStat us,"Status ")
  1240                Do  tATNAMess age.Additi onalInfo.S etAt(pRequ est.GetVal ueAt("MSH: 3"),"Sendi ngApplicat ion")
  1241                Do  tATNAMess age.Additi onalInfo.S etAt(pRequ est.GetVal ueAt("MSH: 4"),"Sendi ngFacility ")
  1242                Do  tATNAMess age.Additi onalInfo.S etAt(pRequ est.GetVal ueAt("MSH: 5"),"Recei vingApplic ation")
  1243                Do  tATNAMess age.Additi onalInfo.S etAt(pRequ est.GetVal ueAt("MSH: 6"),"Recei vingFacili ty")
  1244                Se t tUserRol es = $Piec e($Piece(p Request.En velope,"|U serRoles=" ,2),"|",1)
  1245                Se t:tUserRol es="" tUse rRoles= $R oles
  1246                Do  tATNAMess age.Additi onalInfo.S etAt(tUser Roles,"Use rRoles")
  1247                Do  tATNAMess age.Additi onalInfo.S etAt($User Name,"USER :UserID")
  1248                Do  tATNAMess age.Additi onalInfo.S etAt($Piec e($Piece(p Request.En velope,"<- ",2),":",1 ),"FromHos t")
  1249                Do  tATNAMess age.Additi onalInfo.S etAt($syst em.INetInf o.HostName ToAddr($sy stem.INetI nfo.LocalH ostName()) ,"ToHost")
  1250                Do  tATNAMess age.Additi onalInfo.S etAt(pRequ est.GetVal ueAt("MSH: 10"),"Mess ageID")
  1251                Do  tATNAMess age.Additi onalInfo.S etAt(pUpda teRequest. PriorMPIID _"^^^&"_$$ $AffinityD omainOID_" &ISO","Pri orMPIID")
  1252                Do  tATNAMess age.Additi onalInfo.S etAt(pUpda teRequest. MPIID_"^^^ &"_$$$Affi nityDomain OID_"&ISO" ,"MPIID")
  1253                Se t tIdentif ier = pUpd ateRequest .Identifie rs.GetAt(1 )
  1254                Se t tIdentif ier = tIde ntifier.Ex tension_"^ ^^&"_tIden tifier.Roo t_"&ISO"
  1255                Do  tATNAMess age.Additi onalInfo.S etAt(tIden tifier,"MR N")
  1256                $$ $HSTRACE(" audit mess age","tATN AMessage", tATNAMessa ge)
  1257                Se t tSC= $$$ ATNAEvent( "XDSbRegis try",tATNA Message,pR esponse,pS C)
  1258                $$ $HSTRACE(" audit","tS C",tSC)
  1259                Qu it $$$OK
  1260        ]]>
  1261       </Implemen tation>
  1262      </Method>
  1263     
  1264      <Method 
  1265       name="Proc essXMLMess age"
  1266      >
  1267       <FormalSpe c>
  1268        pRequest:H S.Message. XMLMessage ,*pRespons e:HS.Messa ge.XMLMess age
  1269       </FormalSp ec>
  1270       <ReturnTyp e>
  1271        %Status
  1272       </ReturnTy pe>
  1273       <Implement ation>
  1274        <![CDATA[
  1275                Se t tSC=$$$O K
  1276                $$ $GetTransf ormer(..Tr ansformer)         
  1277                If  pRequest. Name=$$$PI Xv3ReviseR equest {
  1278                         Set  tSC=..Revi sedPatient v3(pReques t,.pRespon se)
  1279                         Do $ $$ATNAEven t("PIXv3Co nsumer",pR equest,pRe sponse,tSC )
  1280                }  Else {
  1281                         $$$L OGERROR("U nknown Req uest")
  1282                         Set  tSC=$$$ERR OR($$$Gene ralError," Unknown re quest")
  1283                }
  1284                         
  1285                Qu it tSC
  1286        ]]>
  1287       </Implemen tation>
  1288      </Method>
  1289     
  1290      <Method 
  1291       name="Revi sedPatient v3"
  1292      >
  1293       <FormalSpe c>
  1294        pRequest:H S.Message. XMLMessage ,*pRespons e:HS.Messa ge.XMLMess age
  1295       </FormalSp ec>
  1296       <ReturnTyp e>
  1297        %Status
  1298       </ReturnTy pe>
  1299       <Implement ation>
  1300        <![CDATA[
  1301                #d im eExcept ion As %Ex ception.Ab stractExce ption
  1302                tr y {
  1303                         Set  tSC = $$$O K
  1304       
  1305                         #dim  tRequest  as HS.Mess age.IDUpda teNotifica tionReques t
  1306                         $$$H STRACESTAR TCALL
  1307                         Set  tSC = ..Tr ansformer. TransformI ntoObject( pRequest.C ontentStre am,"IHE/PI X/Version1 /PRPAIN201 302UVToIDU pdateNotif icationReq uest.xsl", .tRequest, .tXSLArgum ents,"HS.M essage.IDU pdateNotif icationReq uest","IDU pdateNotif icationReq uest")
  1308                         $$$H STRACEENDC ALL
  1309                         
  1310                         Do # #class(HS. Types.Requ estInfo).X MLMessageT oRequestIn fo(pReques t, tReques t) //copy  SAML/User  Auth
  1311                         IF $ $$ISERR(tS C) || '$is Object(tRe quest) {
  1312                                  $$$LOG INFO("unkn own reques t:"_pReque st.Content Stream.Rea d(320000))
  1313                                  Do ..E rrors.logE rror("PIXE rror","Err or","Unkno wn request ")
  1314                                  Quit
  1315                         }
  1316                         $$$H STRACE("Re quest","St ream,tRequ est,tSC",p Request.Co ntentStrea m,tRequest ,tSC)
  1317                
  1318                         #; E xtract the  MPI ID fr om the Ide ntifiers c ollection  and put
  1319                         #; i t in the M PIID prope rty.  Also  set the U se propert y on
  1320                         #; I dentifiers  by lookin g up Root  value in t he Assigni ng
  1321                         #; A uthority R egistry.   If unable  to discern  the Assig ning
  1322                         #; A uthority I dentifierT ype then d iscard the  Identifie r.
  1323                         For  tIdx = tRe quest.Iden tifiers.Co unt():-1:1  {
  1324                                  Set tI dentifierO bj = tRequ est.Identi fiers.GetA t(tIdx)
  1325                                  Set tR oot = tIde ntifierObj .Root
  1326                                  Set tS C = ##clas s(HS.IHE.U til).AAIde ntifierTyp eForCode(t Root, .tAA Identifier Type)
  1327                                  If tRo ot = ..Aff inityDomai n {
  1328                                           #; found  the MPI I D in the i dentifiers  collectio n
  1329                                           Set tReq uest.MPIID  = tIdenti fierObj.Ex tension
  1330                                           Do tRequ est.Identi fiers.Remo veAt(tIdx)
  1331                                  } Else If $$$ISER R(tSC)!(tA AIdentifie rType="")  {
  1332                                           $$$LOGIN FO("Unable  to determ ine Use fo r Identifi er.Root="_ tRoot_" -  removed Id entifier")
  1333                                           Do tRequ est.Identi fiers.Remo veAt(tIdx)
  1334                                  } Else  {
  1335                                           Set tIde ntifierObj .Use = tAA Identifier Type
  1336                                  }
  1337                         }
  1338       
  1339                         $$$H STRACE("Re quest with  Identifie r updates" ,"tRequest ",tRequest )
  1340                         
  1341                         Set  tAffinityD omainOID =  $$$Affini tyDomainOI DGet(..Aff inityDomai n)
  1342                         #; c heck to ma ke sure th e Affinity Domain on  the Prior  MPI ID mat ches the s ystem affi nity domai n
  1343                         Set  tPriorMPII D=pRequest .Additiona lInfo.GetA t("priorID ")
  1344                         Set  tPriorMPIA A = $p(tPr iorMPIID," _")
  1345                         If t PriorMPIAA ]""  && (t PriorMPIAA '= tAffini tyDomainOI D) Do ..Er rors.logEr ror("PIXEr ror","Erro r",$$$Form atText($$$ Text("Assi gning Auth ority %1 d oes not ma tch the af finity dom ain"),tPri orMPIAA)) 
  1346                         Do . .ProcessNo tification (tRequest, .tResponse )
  1347                }  Catch eExc eption {
  1348                         Set  tSC = eExc eption.AsS tatus()
  1349                         Do . .Errors.lo gError("PI XError","E rror",$sys tem.Status .GetErrorT ext(tSC)) 
  1350                }
  1351                Tr y {
  1352                         Set  tOutput =  ##class(%S tream.Glob alCharacte r).%New()
  1353                         Do t Output.Wri te("<root> ")
  1354                         Do t Output.Wri te("<origi nalRequest >")
  1355                         Do t Output.Cop yFrom(pReq uest.Conte ntStream)
  1356                         Do t Output.Wri te("</orig inalReques t>")
  1357                         Do . .Errors.XM LExportToS tring(.tEr rorString)
  1358                         Do t Output.Wri te(tErrorS tring) 
  1359                         Do t Output.Wri te("</root >")
  1360                         Do t Output.Rew ind()
  1361       
  1362                         Set  pResponse= pRequest.% New()
  1363                         Set  pResponse. Name = $$$ PIXv3Revis eResponse
  1364                         Set  pResponse. DocType =  "MCCI_IN00 0002UV01"
  1365                         Set  tXSLArgume nts("messa geID")="'" _$System.U til.Create GUID()_"'"
  1366                         Set  tXSLArgume nts("creat ionTime")= "'"_##clas s(HS.Util. XSLTHelper ).timestam p()_"'"
  1367                         Set  tXSLArgume nts("typeC ode")="'"_ $S(..Error s.Errors.C ount():"CE ",1:"CA")_ "'"  
  1368                         #; s tream as i nput is an y stream,  it's not u sed in the  transform ation
  1369                         $$$H STRACESTAR TCALL
  1370                         Set  tSC = ..Tr ansformer. Transform( tOutput,"I HE/PIX/Ver sion1/MCCI 000002UV.x sl",.tTarg et,.tXSLAr guments)
  1371                         $$$H STRACEENDC ALL
  1372                         If $ $$ISERR(tS C) {
  1373                                  $$$HST RACE("Tran sform stat us","tSC", $system.St atus.GetEr rorText(tS C))
  1374                         } El se {
  1375                                  Set pR esponse.Co ntentStrea m     = tT arget
  1376                         }
  1377                
  1378                }  Catch eExc eption {
  1379                         Set  tSC = eExc eption.AsS tatus()
  1380                         Do . .Errors.lo gError("PI XError","E rror",$sys tem.Status .GetErrorT ext(tSC)) 
  1381                }
  1382                
  1383                Qu it tSC
  1384        ]]>
  1385       </Implemen tation>
  1386      </Method>
  1387     
  1388      <Method 
  1389       name="Proc essNotific ation"
  1390      >
  1391       <Descripti on>
  1392        HSPI sends  IDUpdateN otificatio ns - MPIID , and Prio rMPIID are  already s et
  1393        Or the inb ound HL7 r equest is  converted  to IDUpdat eNotificat ion and be ing sent o ut
  1394       </Descript ion>
  1395       <FormalSpe c>
  1396        pRequest:H S.Message. IDUpdateNo tification Request,pR esponse:HS .Message.A ddUpdateHu bResponse
  1397       </FormalSp ec>
  1398       <ReturnTyp e>
  1399        %Status
  1400       </ReturnTy pe>
  1401       <Implement ation>
  1402        <![CDATA[
  1403                #d im eExcept ion As %Ex ception.Ab stractExce ption
  1404                tr y {
  1405                         Set  pResponse= ##class(HS .Message.A ddUpdateHu bResponse) .%New(),pR esponse.Er rStatus=$$ $OK
  1406                         Set  tSC = ..On BeforeProc essNotific ation(pReq uest)
  1407                         If p Request.MP IID ="" Do  ..Errors. logError(" PIXError", "Error","U nable to l ocate MPII D") Quit
  1408                         
  1409                         If p Request.Pr iorMPIID]" " {
  1410                                  If pRe quest.Prio rMPIID'=pR equest.MPI ID {
  1411                                           Set tAA  = $Piece(p Request.Ad ditionalIn fo.GetAt(" priorID"), "_",1)
  1412                                           If tAA'= "" {
  1413                                                    Set tPatie ntId = pRe quest.Prio rMPIID_"^^ ^&"_tAA_"& ISO"
  1414                                                    Set tSendi ngCommunit y = ""
  1415                                                    For {
  1416                                                            Se t tSending Community  = $Order(^ HS.IHE.XCP DCache(tPa tientId, t SendingCom munity))
  1417                                                            If  tSendingC ommunity=" " Quit
  1418                                                            Se t ^HS.IHE. XCPDCache( tPatientId , tSending Community) =0
  1419                                                    }
  1420                                           }
  1421                                  }
  1422                                  $$$LOG INFO("MPI  Operations  Call with  MPIID:"_p Request.MP IID_" ")
  1423                                  Set:.. MPIOperati ons]"" tSC =..SendReq uestSync(. .MPIOperat ions,pRequ est,.pResp onse) 
  1424                                  $$$HST RACE("Resp onse from  MPIOperati ons Notifi cation "," pResponse" ,pResponse )
  1425                                  
  1426                                  If $$$ ISERR(tSC)  Do ..Erro rs.logErro r(5001,"Er ror",$syst em.Status. GetErrorTe xt(tSC)) Q uit
  1427                                  If pRe sponse.Err Status]"", $$$ISERR(p Response.E rrStatus)  Do ..Error s.logError ("5001","E rror",$sys tem.Status .GetErrorT ext(pRespo nse.ErrSta tus)) Quit
  1428                                  If '.. Errors.Err ors.Count( ) {
  1429                                           For tIdx  = 1:1:$l( ..NotifyOt hers,",")  {
  1430                                                    Set tHost  = $p(..Not ifyOthers, ",",tIdx)
  1431                                                    Continue:t Host="" 
  1432                                                    Set tSC2=. .SendReque stSync(tHo st,pReques t,.tOtherR esponse)
  1433                                                    If $$$ISER R(tSC2) {
  1434                                                            $$ $LOGSTATUS (tSC2)
  1435                                                    } ElseIf t OtherRespo nse.ErrSta tus]"",$$$ ISERR(tOth erResponse .ErrStatus ) { Do ..E rrors.logE rror("5001 ","Error", $system.St atus.GetEr rorText(tO therRespon se.ErrStat us)) }
  1436                                           }
  1437                                  }
  1438                         }
  1439                         Set  tSC = ..On AfterProce ssNotifica tion(pRequ est,.pResp onse)
  1440                }  Catch eExc eption {
  1441                         Set  tSC = eExc eption.AsS tatus()
  1442                         Do . .Errors.lo gError("PI XError","E rror",$sys tem.Status .GetErrorT ext(tSC)) 
  1443                }
  1444                Qu it tSC
  1445        ]]>
  1446       </Implemen tation>
  1447      </Method>
  1448     
  1449      <Method 
  1450       name="OnBe foreProces sNotificat ion"
  1451      >
  1452       <CodeMode>
  1453        expression
  1454       </CodeMode >
  1455       <FormalSpe c>
  1456        pRequest:H S.Message. IDUpdateNo tification Request
  1457       </FormalSp ec>
  1458       <ReturnTyp e>
  1459        %Status
  1460       </ReturnTy pe>
  1461       <Implement ation>
  1462        <![CDATA[$ $$OK
  1463        ]]>
  1464       </Implemen tation>
  1465      </Method>
  1466     
  1467      <Method 
  1468       name="OnAf terProcess Notificati on"
  1469      >
  1470       <CodeMode>
  1471        expression
  1472       </CodeMode >
  1473       <FormalSpe c>
  1474        pRequest:H S.Message. IDUpdateNo tification Request,pR esponse:HS .Message.A ddUpdateHu bResponse
  1475       </FormalSp ec>
  1476       <ReturnTyp e>
  1477        %Status
  1478       </ReturnTy pe>
  1479       <Implement ation>
  1480        <![CDATA[$ $$OK
  1481        ]]>
  1482       </Implemen tation>
  1483      </Method>
  1484     
  1485      <Method 
  1486       name="Noti fyMPIIDUpd ate"
  1487      >
  1488       <Descripti on>
  1489        NotifyMPII DUpdate is  called by  RevisedPa tientv2 an d RevisedP atientv3.
  1490       </Descript ion>
  1491       <FormalSpe c>
  1492        pRequest:H S.Message. IDUpdateNo tification Request
  1493       </FormalSp ec>
  1494       <ReturnTyp e>
  1495        %Status
  1496       </ReturnTy pe>
  1497       <Implement ation>
  1498        <![CDATA[
  1499                #d im eExcept ion As %Ex ception.Ab stractExce ption
  1500                tr y {
  1501                         Set  tSC = $$$O K
  1502                         #; i s this an  MPI ID upd ate then c hange the  request to  a IDUpdat eNotificat ion otherw ise we're  done
  1503                         If t Request.Pr iorMPIID=" " Quit
  1504                         
  1505                         $$$H STRACE("On MPISplit", "pRequest, tPriorMPII D,Errors", pRequest,t PriorMPIID ,..Errors. Errors.Cou nt())
  1506                         If ' ..Errors.E rrors.Coun t() && (.. MPIOperati ons]"") {
  1507                                  Set tS C=..SendRe questSync( ..MPIOpera tions,pReq uest,.tRes ponse)
  1508                                  If $$$ ISERR(tSC)  {
  1509                                           Do ..Err ors.logErr or("PIXErr or","Error ","Unable  to update  record "_$ system.Sta tus.GetErr orText(tSC )) 
  1510                                  } Else  {
  1511                                           If $$$IS ERR(tRespo nse.ErrSta tus) Do .. Errors.log Error("PIX Error","Er ror","Unab le to upda te record  "_$system. Status.Get ErrorText( tResponse. ErrStatus)
  1512                                  }
  1513                         }
  1514                }  Catch eExc eption {
  1515                         Set  tSC = eExc eption.AsS tatus()
  1516                         Do . .Errors.lo gError("PI XError","E rror",$sys tem.Status .GetErrorT ext(tSC)) 
  1517                }
  1518                
  1519                Qu it tSC
  1520        ]]>
  1521       </Implemen tation>
  1522      </Method>
  1523     
  1524      <Method 
  1525       name="HL7R esponse"
  1526      >
  1527       <FormalSpe c>
  1528        pSource:HS .Message.I DUpdateNot ificationR equest,*pT arget:EnsL ib.HL7.Mes sage,pOrig inalReques t:EnsLib.H L7.Message
  1529       </FormalSp ec>
  1530       <ReturnTyp e>
  1531        %Status
  1532       </ReturnTy pe>
  1533       <Implement ation>
  1534        <![CDATA[
  1535                Se t tSC = $$ $OK
  1536                
  1537                Tr y {
  1538                         #; I nstantiate  target me ssage
  1539                         Set  pTarget =  ##class(En sLib.HL7.M essage).%N ew()
  1540                         
  1541                         #; I HE require s 2.5, so  force the  document t ype assign ment               
  1542                         Set  pTarget.Do cType = "2 .5:ACK"
  1543                         
  1544                         #; F orce origi nal reques t's docume nt type to  be ADT_A0 5
  1545                         Set  pOriginalR equest.Doc Type = "2. 5:ADT_A05"
  1546                         
  1547                         #; M SH Segment  (MSH)
  1548                         Do p Target.Set ValueAt(.. AffinityDo main, "MSH :4.1")
  1549                         Do p Target.Set ValueAt("A CK", "MSH: 9.1")
  1550                         Do p Target.Set ValueAt("A 31", "MSH: 9.2")
  1551                         Do p Target.Set ValueAt("A CK", "MSH: 9.3")
  1552                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :5.1"), "M SH:3.1") / / Sending  Applicatio n
  1553                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :6.1"), "M SH:4.1") / / Sending  Facility
  1554                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :3.1"), "M SH:5.1") / / Receivin g Applicat ion
  1555                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :4.1"), "M SH:6.1") / / Receivin g Facility
  1556                         Do p Target.Set ValueAt($T ranslate($ ZDateTime( $Horolog,  3), "-: ",  ""), "MSH :7.1") //  Message Da te/Time
  1557                         Do p Target.Set ValueAt(## class(HS.I HE.Util).G etIdForHL7 (),"MSH:10 ") // Mess age Contro l ID
  1558                         Do p Target.Set ValueAt("P ","MSH:11" ) // Proce ssing ID ( P = Produc tion)
  1559                         Do p Target.Set ValueAt("2 .5", "MSH: 12")
  1560                         
  1561                         #; M essage Ack nowledgmen t (MSA)
  1562                         If ' ..Errors.E rrors.Coun t() {
  1563                                  Do pTa rget.SetVa lueAt("AA" , "MSA:1")
  1564                                  Do pTa rget.SetVa lueAt(pSou rce.MPIID,  "MSA:3")
  1565                         }
  1566                         Else  {
  1567                                  Do pTa rget.SetVa lueAt("AE" , "MSA:1")
  1568                                  If $$$ ISERR(pSou rce.ErrSta tus) {
  1569                                           Do pTarg et.SetValu eAt($Syste m.Status.G etOneError Text(pSour ce.ErrStat us), "ERR: 1")
  1570                                  } Else  {
  1571                                           Do pTarg et.SetValu eAt(..Erro rs.Errors. GetAt(1).D escription , "ERR:1")
  1572                                  }
  1573                                  
  1574                         }
  1575                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :10"), "MS A:2")
  1576                         
  1577                }  Catch eExc eption {
  1578                         Set  tSC = eExc eption.AsS tatus()
  1579                }
  1580                
  1581                Qu it tSC
  1582        ]]>
  1583       </Implemen tation>
  1584      </Method>
  1585     
  1586      <Method 
  1587       name="HL7E rrorRespon se"
  1588      >
  1589       <FormalSpe c>
  1590        pOriginalR equest:Ens Lib.HL7.Me ssage,*pTa rget:EnsLi b.HL7.Mess age
  1591       </FormalSp ec>
  1592       <ReturnTyp e>
  1593        %Status
  1594       </ReturnTy pe>
  1595       <Implement ation>
  1596        <![CDATA[
  1597                Se t tSC = $$ $OK
  1598                
  1599                Tr y {
  1600                         #; I nstantiate  target me ssage
  1601                         Set  pTarget =  ##class(En sLib.HL7.M essage).%N ew()
  1602                         
  1603                         #; I HE require s 2.5, so  force the  document t ype assign ment               
  1604                         Set  pTarget.Do cType = "2 .5:RSP_K21 "
  1605                         
  1606                         #; F orce origi nal reques t's docume nt type to  be QBP_Q2 1 (which i s used by  QBP_Q22)
  1607                         Set  pOriginalR equest.Doc Type = "2. 5:QBP_Q21"
  1608                         
  1609                         #; M essage Hea der (MSH)
  1610                         Do p Target.Set ValueAt("R SP", "MSH: 9.1")
  1611                         Do p Target.Set ValueAt("K 22", "MSH: 9.2")
  1612                         Do p Target.Set ValueAt("R SP_K21", " MSH:9.3")
  1613                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :5.1"), "M SH:3.1") / / Sending  Applicatio n
  1614                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :6.1"), "M SH:4.1") / / Sending  Facility
  1615                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :3.1"), "M SH:5.1") / / Receivin g Applicat ion
  1616                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :4.1"), "M SH:6.1") / / Receivin g Facility
  1617                         Do p Target.Set ValueAt($T ranslate($ ZDateTime( $Horolog,  8,5), ":T  ", ""), "M SH:7.1") / / Message  Date/Time
  1618                         Set  tUID = ..V AStation_# #class(HS. IHE.Util). GetIdForHL 7()
  1619                         Do p Target.Set ValueAt(tU ID,"MSH:10 ") // Mess age Contro l ID
  1620                         Do p Target.Set ValueAt(.. HL7Process ingID,"MSH :11") // P rocessing  ID (P = Pr oduction,  T = Test o r Dev)
  1621                         Do p Target.Set ValueAt("2 .4", "MSH: 12")
  1622       
  1623                         
  1624                         #; F or now jus t use the  first erro r to popul ate MSA an d QAK.
  1625                         Set  tErrorCode  = ..Error s.Errors.G etAt(1).Co de
  1626                         Set  tAckCode =  $Select(t ErrorCode> 99&(tError Code<200): "AE",1:"AR ")
  1627                         
  1628                         #; M essage Ack nowledgmen t (MSA) an d Query Ac knowledgme nt (QAK)
  1629                         Do p Target.Set ValueAt(tA ckCode, "M SA:1")
  1630                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("QPD :2"), "QAK :1")
  1631                         Do p Target.Set ValueAt(tA ckCode, "Q AK:2")
  1632                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("MSH :10"), "MS A:2")
  1633                         
  1634                         #; Q uery Param eter Defin ition (QPD )
  1635                         Do p Target.Set ValueAt(pO riginalReq uest.GetVa lueAt("QPD "), "QPD")
  1636                         
  1637                         /*
  1638                         For  i = 1:1:.. Errors.Err ors.Count( ) {
  1639                                  Set tL oc = ..Err ors.Errors .GetAt(i). Location
  1640                                  If tLo c'="" {
  1641                                           Set tSeg ID = $Piec e($Piece(t Loc,":",1) ,"(",1)
  1642                                           Set tSeg SQ = $Piec e($Piece($ Piece(tLoc ,":",1),"( ",2),")",1 )
  1643                                           If tSegS Q="" Set t SegSQ = 1
  1644                                           Set tFld Pos = $Pie ce($Piece( tLoc,":",2 ),"(",1)
  1645                                           Set tFld Rep = $Pie ce($Piece( $Piece(tLo c,":",2)," (",2),")", 1)
  1646                                           Do pTarg et.SetValu eAt(tSegID , "ERR("_i _"):2.1")
  1647                                           Do pTarg et.SetValu eAt(tSegSQ , "ERR("_i _"):2.2")
  1648                                           Do pTarg et.SetValu eAt(tFldPo s, "ERR("_ i_"):2.3")
  1649                                           Do pTarg et.SetValu eAt(tFldRe p, "ERR("_ i_"):2.4")
  1650                                  }
  1651                                  Do pTa rget.SetVa lueAt(..Er rors.Error s.GetAt(i) .Code, "ER R("_i_"):3 ")
  1652                                  Do pTa rget.SetVa lueAt(..Er rors.Error s.GetAt(i) .Severity,  "ERR("_i_ "):4")
  1653                                  Set tD esc = ..Er rors.Error s.GetAt(i) .Descripti on
  1654                                  If tDe sc'="" {
  1655                                           Set tDes c = $Trans late(tDesc ,pTarget.S eparators, $Extract("            ",1,$Lengt h(pTarget. Separators )))
  1656                                           Do pTarg et.SetValu eAt(tDesc,  "ERR("_i_ "):5")
  1657                                  }
  1658                         }
  1659                         */
  1660                         
  1661                         #; T he PDQv2 s pec seems  to imply t hat multip le ERR seg ments shou ld
  1662                         #; b e supporte d (ITI TF  Vol2a Rev  9.0 page 1 61 paragra ph 4265),  but
  1663                         #; d ocument ty pe RSP_K21  supports  only a sin gle ERR se gment.  So
  1664                         #; r eturn only  the first  error in  the collec tion.
  1665                         Set  tLoc = ..E rrors.Erro rs.GetAt(1 ).Location
  1666                         If t Loc'="" {
  1667                                  Set tS egID = $Pi ece($Piece (tLoc,":", 1),"(",1)
  1668                                  Set tS egSQ = $Pi ece($Piece ($Piece(tL oc,":",1), "(",2),")" ,1)
  1669                                  If tSe gSQ="" Set  tSegSQ =  1
  1670                                  Set tF ldPos = $P iece($Piec e(tLoc,":" ,2),"(",1)
  1671                                  Set tF ldRep = $P iece($Piec e($Piece(t Loc,":",2) ,"(",2),") ",1)
  1672                                  If tFl dRep="" Se t tFldRep  = 1
  1673                                  Do pTa rget.SetVa lueAt(tSeg ID, "ERR:2 .1")
  1674                                  Do pTa rget.SetVa lueAt(tSeg SQ, "ERR:2 .2")
  1675                                  Do pTa rget.SetVa lueAt(tFld Pos, "ERR: 2.3")
  1676                                  Do pTa rget.SetVa lueAt(tFld Rep, "ERR: 2.4")
  1677                         }
  1678                         Do p Target.Set ValueAt(.. Errors.Err ors.GetAt( 1).Code, " ERR:3")
  1679                         Do p Target.Set ValueAt(.. Errors.Err ors.GetAt( 1).Severit y, "ERR:4" )
  1680                         Set  tDesc = .. Errors.Err ors.GetAt( 1).Descrip tion
  1681                         If t Desc'="" {
  1682                                  Set tD esc = $Tra nslate(tDe sc,pTarget .Separator s,$Extract ("      ", 1,$Length( pTarget.Se parators)) )
  1683                                  Do pTa rget.SetVa lueAt(tDes c, "ERR:5" )
  1684                                  Do pTa rget.SetVa lueAt(tDes c,"ERR:1.4 .2")
  1685                         }
  1686                         
  1687                }  Catch eExc eption {
  1688                         Set  tSC = eExc eption.AsS tatus()
  1689                         Do . .Errors.lo gError("20 7","E",$sy stem.Statu s.GetError Text(tSC))
  1690                }
  1691                
  1692                Qu it tSC
  1693        ]]>
  1694       </Implemen tation>
  1695      </Method>
  1696     
  1697      <Method 
  1698       name="Gene ralHL7Resp onse"
  1699      >
  1700       <Descripti on>
  1701        Code to ge nerate XPI D_Notifica tion respo nse
  1702       </Descript ion>
  1703       <FormalSpe c>
  1704        pRequest:E nsLib.HL7. Message,*p Response:E nsLib.HL7. Message
  1705       </FormalSp ec>
  1706       <ReturnTyp e>
  1707        %Status
  1708       </ReturnTy pe>
  1709       <Implement ation>
  1710        <![CDATA[
  1711                Se t tSC = $$ $OK
  1712                
  1713                Tr y {
  1714                         #; I nstantiate  target me ssage
  1715                         Set  pResponse  = ##class( EnsLib.HL7 .Message). %New()
  1716                         
  1717                         #; I HE require s 2.5, so  force the  document t ype assign ment               
  1718                         Set  pResponse. DocType =  "2.5:ACK"
  1719                         
  1720                         #; M essage Hea der (MSH)
  1721                         Do p Response.S etValueAt( "ACK", "MS H:9.1")
  1722                         Do p Response.S etValueAt( pRequest.G etValueAt( "MSH:9.2") , "MSH:9.2 ")
  1723                         Do p Response.S etValueAt( pRequest.G etValueAt( "MSH:5.1") , "MSH:3.1 ") // Send ing Applic ation
  1724                         Do p Response.S etValueAt( pRequest.G etValueAt( "MSH:6.1") , "MSH:4.1 ") // Send ing Facili ty
  1725                         Do p Response.S etValueAt( pRequest.G etValueAt( "MSH:3.1") , "MSH:5.1 ") // Rece iving Appl ication
  1726                         Do p Response.S etValueAt( pRequest.G etValueAt( "MSH:4.1") , "MSH:6.1 ") // Rece iving Faci lity
  1727                         Do p Response.S etValueAt( $Translate ($ZDateTim e($Horolog , 8,5), ": T ", ""),  "MSH:7.1")  // Messag e Date/Tim e
  1728                         Set  tUID = ..V AStation_# #class(HS. IHE.Util). GetIdForHL 7()
  1729                         //Se t tOrigMsg Id = pRequ est.GetVal ueAt("MSH: 10")
  1730                         //Se t tUID = . .VAStation _tOrigMsgI d
  1731                         Do p Response.S etValueAt( tUID,"MSH: 10") // Me ssage Cont rol ID
  1732                         Do p Response.S etValueAt( ..HL7Proce ssingID,"M SH:11") //  Processin g ID (P =  Production , T = Test  or Dev)
  1733                         Do p Response.S etValueAt( "2.4", "MS H:12")
  1734                         Do p Response.S etValueAt( "AL", "MSH :15")
  1735                         Do p Response.S etValueAt( "NE", "MSH :16")
  1736       
  1737                         Set  tAckCode =  "AA"
  1738                         If . .Errors.Er rors.Count () {
  1739                                  #; For  now just  use the fi rst error  to populat e MSA 
  1740                                  Set tE rrorCode =  ..Errors. Errors.Get At(1).Code
  1741                                  Set tA ckCode = $ Select(tEr rorCode>19 9&(tErrorC ode<204):" AR",1:"AE" )
  1742                         }
  1743                         
  1744                         #; M essage Ack nowledgmen t (MSA)
  1745                         Do p Response.S etValueAt( tAckCode,  "MSA:1")
  1746                         Do p Response.S etValueAt( pRequest.G etValueAt( "MSH:10"),  "MSA:2")
  1747                         
  1748                         For  i = 1:1:.. Errors.Err ors.Count( ) {
  1749                                  Set tL oc = ..Err ors.Errors .GetAt(i). Location
  1750                                  If tLo c'="" {
  1751                                           Set tSeg ID = $Piec e($Piece(t Loc,":",1) ,"(",1)
  1752                                           Set tSeg SQ = $Piec e($Piece($ Piece(tLoc ,":",1),"( ",2),")",1 )
  1753                                           If tSegS Q="" Set t SegSQ = 1
  1754                                           Set tFld Pos = $Pie ce($Piece( tLoc,":",2 ),"(",1)
  1755                                           Set tFld Rep = $Pie ce($Piece( $Piece(tLo c,":",2)," (",2),")", 1)
  1756                                           Do pResp onse.SetVa lueAt(tSeg ID, "ERR(" _i_"):2.1" )
  1757                                           Do pResp onse.SetVa lueAt(tSeg SQ, "ERR(" _i_"):2.2" )
  1758                                           Do pResp onse.SetVa lueAt(tFld Pos, "ERR( "_i_"):2.3 ")
  1759                                           Do pResp onse.SetVa lueAt(tFld Rep, "ERR( "_i_"):2.4 ")
  1760                                  }
  1761                                  Do pRe sponse.Set ValueAt(.. Errors.Err ors.GetAt( i).Code, " ERR("_i_") :3")
  1762                                  Do pRe sponse.Set ValueAt(.. Errors.Err ors.GetAt( i).Severit y, "ERR("_ i_"):4")
  1763                                  Set tD esc = ..Er rors.Error s.GetAt(i) .Descripti on
  1764                                  If tDe sc'="" {
  1765                                           Set tDes c = $Trans late(tDesc ,pResponse .Separator s,$Extract ("           ",1,$Len gth(pRespo nse.Separa tors)))
  1766                                           Do pResp onse.SetVa lueAt(tDes c, "ERR("_ i_"):5")
  1767                                           Do pResp onse.SetVa lueAt(tDes c, "ERR("_ i_"):1.4.2 ")
  1768                                  }
  1769                         }
  1770                         
  1771                }  Catch eExc eption {
  1772                         Set  tSC = eExc eption.AsS tatus()
  1773                         $$$L OGSTATUS(t SC)
  1774                }
  1775                
  1776                Qu it tSC
  1777        ]]>
  1778       </Implemen tation>
  1779      </Method>
  1780     
  1781      <Method 
  1782       name="Proc essA31Subs criptionMe ssage"
  1783      >
  1784       <FormalSpe c>
  1785        pHL7Reques t:EnsLib.H L7.Message ,pAddUpdat eHubRespon se:HS.Mess age.AddUpd ateHubResp onse
  1786       </FormalSp ec>
  1787       <ReturnTyp e>
  1788        %Status
  1789       </ReturnTy pe>
  1790       <Implement ation>
  1791        <![CDATA[
  1792                                  Set tS C=$$$OK
  1793                                  set pA ddUpdateHu bRequest=# #class(HS. Message.Ad dUpdateHub Request).% New()
  1794                     Set pAdd UpdateHubR esponse=## class(HS.M essage.Add UpdateHubR esponse).% New()
  1795                     Set tSSN Nbr = "" ,  tICNNbr =  "", i=0,  j=0
  1796                     Set deli m = $E(pHL 7Request.G etValueAt( "MSH:2"),1 )
  1797                         Set  repDelim =  $E(pHL7Re quest.GetV alueAt("MS H:2"),2)
  1798       
  1799                     
  1800                                  For i  = 1:1:pHL7 Request.Ge tValueAt(" PID:3(*)")  {
  1801                          If  pHL7Reques t.GetValue At("PID:3( "_i_").6.2 ")="200M"  && (pHL7Re quest.GetV alueAt("PI D:3("_i_") .4.1")="US VHA") && ( pHL7Reques t.GetValue At("PID:3( "_i_").5") ="NI") {     
  1802                          Set  tICNNbr =  pHL7Reque st.GetValu eAt("PID:3 ("_i_").1" )
  1803                          $$$ LOGINFO("M aster Pati ent ID: "_ tICNNbr_"  ") 
  1804                          }
  1805                          If  pHL7Reques t.GetValue At("PID:3( "_i_").6.2 ")="200M"  && (pHL7Re quest.GetV alueAt("PI D:3("_i_") .4.1")="US SSA"){    
  1806                          Set  tSSNNbr =  pHL7Reque st.GetValu eAt("PID:3 ("_i_").1" )
  1807                          $$$ LOGINFO("S SN: "_tSSN Nbr_" ") Q uit
  1808                          }
  1809                          
  1810                      }
  1811                      
  1812                     // Get P atient Nam e
  1813                         For  i = 1:1:pH L7Request. GetValueAt ("PID:5(*) ") {
  1814                                  If pHL 7Request.G etValueAt( "PID:5("_i _").7")="L " {
  1815                                                    Set tPatie ntName = p HL7Request .GetValueA t("PID:5(" _i_")")
  1816                                                    $$$LOGINFO ("Patient  Name : "_t PatientNam e_"")                      
  1817                                                            Se t pAddUpda teHubReque st.LastNam e=$P(tPati entName,de lim,1)
  1818                                                            Se t pAddUpda teHubReque st.FirstNa me=$P(tPat ientName,d elim,2)
  1819                                                            Se t pAddUpda teHubReque st.MiddleN ame = $P(t PatientNam e,delim,3)
  1820                                                            Se t pAddUpda teHubReque st.Prefix  = $TR($P(t PatientNam e,delim,5) ,$C(34,34) ,"")
  1821                                                            Se t pAddUpda teHubReque st.Suffix  = $TR($p(t PatientNam e,delim,4) ,$C(34,34) ,"")
  1822                                  }
  1823                         }
  1824                
  1825                
  1826                                  Set pA ddUpdateHu bRequest.S SN = tSSNN br
  1827                                  
  1828                         Set  tAddress=# #class(HS. Types.Addr ess).%New( )
  1829                         Set  tBirthAddr ess=##clas s(HS.Types .Address). %New()
  1830                         
  1831                         //Ge t Patient  Birth Addr ess
  1832                                           For i =  1:1:pHL7Re quest.GetV alueAt("PI D:11(*)")  {
  1833                                                    If pHL7Req uest.GetVa lueAt("PID :11("_i_") .7.1")="N"  {
  1834                                                            Se t tBirthAd dress = pH L7Request. GetValueAt ("PID:11(" _i_")")
  1835                                                            Se t pAddUpda teHubReque st.BirthPl ace.Street Line = $TR ($P(tBirth Address,de lim,1),$C( 34,34),"")
  1836                                                            Se t pAddUpda teHubReque st.BirthPl ace.UnitNu mber = $TR ($P(tBirth Address,de lim,2),$C( 34,34),"")
  1837                                                            Se t pAddUpda teHubReque st.BirthPl ace.City =  $TR($P(tB irthAddres s,delim,3) ,$C(34,34) ,"")
  1838                                                            Se t pAddUpda teHubReque st.BirthPl ace.State  = $TR($P(t BirthAddre ss,delim,4 ),$C(34,34 ),"")
  1839                                                            Se t pAddUpda teHubReque st.BirthPl ace.Countr y = $TR($P (tBirthAdd ress,delim ,6),$C(34, 34),"")
  1840                                                            Se t pAddUpda teHubReque st.BirthPl ace.Postal Code = $TR ($P(tBirth Address,de lim,5),$C( 34,34),"")
  1841                                                            $$ $LOGINFO(" BirthPlace  City : "_ pAddUpdate HubRequest .BirthPlac e.City_"")
  1842                                                            $$ $LOGINFO(" BirthPlace  State : " _pAddUpdat eHubReques t.BirthPla ce.State_" ")
  1843                                                    }       
  1844                                           }
  1845                                           
  1846                                           //Get Pa tient Addr ess
  1847                                           Set tAdd ress=##cla ss(HS.Type s.Address) .%New()
  1848                                           For i =  1:1:pHL7Re quest.GetV alueAt("PI D:11(*)")  {
  1849                                                    If pHL7Req uest.GetVa lueAt("PID :11("_i_") .7.1")="P"  {
  1850                                                            Se t tPatient Address =  pHL7Reques t.GetValue At("PID:11 ("_i_")")
  1851                                                            $$ $LOGINFO(" Patient Ad dress Befo re: "_tPat ientAddres s_"")
  1852                                                            Se t tAddress .StreetLin e = $TR($P (tPatientA ddress,del im,1),$C(3 4,34),"")
  1853                                                            Se t tAddress .UnitNumbe r = $TR($P (tPatientA ddress,del im,2),$C(3 4,34),"")
  1854                                                            Se t tAddress .City = $T R($P(tPati entAddress ,delim,3), $C(34,34), "")
  1855                                                            Se t tAddress .State = $ TR($P(tPat ientAddres s,delim,4) ,$C(34,34) ,"")
  1856                                                            Se t tAddress .PostalCod e = $TR($P (tPatientA ddress,del im,5),$C(3 4,34),"")
  1857                                                            Se t tAddress .Country =  $TR($P(tP atientAddr ess,delim, 6),$C(34,3 4),"")
  1858                                                            Se t tAddress .Use = "HP "
  1859                                                            $$ $LOGINFO(" Patient Ad dress Afte r: "_tAddr ess.Street Line_ " "_ tAddress.C ity_ " "_t Address.St ate_ ""_tA ddress.Pos talCode_ " ")
  1860                                                            Do  pAddUpdat eHubReques t.Addresse s.Insert(t Address) 
  1861                                                    }
  1862                                           }
  1863                         
  1864                                  set tD ate = $TR( pHL7Reques t.GetValue At("PID:7" ),$C(34,34 ),"")
  1865                                  If tDa te '= "" s et pAddUpd ateHubRequ est.DOB =  $zdh($E(tD ate,1,4)_" -"_$E(tDat e,5,6)_"-" _$E(tDate, 7,8),3)
  1866                
  1867                                  set pA ddUpdateHu bRequest.S ex = pHL7R equest.Get ValueAt("P ID:8")
  1868                                  Set pA ddUpdateHu bRequest.A ssigningAu thority =  "USVHA"
  1869                                  Set pA ddUpdateHu bRequest.F acility =  "EF"
  1870                                  set pA ddUpdateHu bRequest.M RN = tICNN br    // M RN is ICN  number for  Enterpris e Facility
  1871                                  set pA ddUpdateHu bRequest.M PIID = tIC NNbr 
  1872                
  1873                                  set pA ddUpdateHu bRequest.M othersMaid enSurname  = pHL7Requ est.GetVal ueAt("PID: 6.1.1.1")
  1874                                  Set pA ddUpdateHu bRequest.B irthOrder  = $TR(pHL7 Request.Ge tValueAt(" PID:25"),$ C(34,34)," ")
  1875                                  
  1876                                  Set td eathDate =  $TR(pHL7R equest.Get ValueAt("P ID:29"),$C (34,34),"" )    
  1877                                  If $L( tdeathDate ) > 8 {
  1878                                           Set tdea thDate = $ translate( ##class(HS .Gateway.H L7.HL7ToSD A3).xmltim estamp(pHL 7Request.G etValueAt( "PID:29")) ,"TZ"," ")
  1879                                           Set tdea thDate = $ E(tdeathDa te, 1,19)
  1880                                           
  1881                                  } Else  {
  1882                                           Set tdea thDate = $ translate( ##class(HS .Gateway.H L7.HL7ToSD A3).xmltim estamp(pHL 7Request.G etValueAt( "PID:29")) ,"TZ"," ")
  1883                                           
  1884                                  }
  1885                                  
  1886                                  $$$LOG INFO("Deat h Date and  Time : "_ tdeathDate _"")
  1887                                  
  1888                                  If tde athDate '=  $C(34,34)  set pAddU pdateHubRe quest.Deat hTime = td eathDate
  1889                                  If (td eathDate)  '= $C(34,3 4) set pAd dUpdateHub Request.De athStatus  = 1
  1890                
  1891                         
  1892                                  Set pA ddUpdateHu bRequest.A ddOrUpdate ="A"
  1893                                  set pA ddUpdateHu bRequest.D oMPIUpdate =1
  1894                                  
  1895                              Do pAddUpd ateHubRequ est.Additi onalInfo.S etAt("A31" ,"Merge Me ssage Type ")
  1896                
  1897                                  $$$LOG INFO("VA M VI Operati ons Call w ith MPIID: "_tICNNbr_ " ")
  1898                                  Set:.. VAMVIOpera tions]"" t SC=..SendR equestSync (..VAMVIOp erations,p AddUpdateH ubRequest, .pAddUpdat eHubRespon se) 
  1899                                  $$$HST RACE("Resp onse from  VA MVI Ope rations No tification  ","pRespo nse",pAddU pdateHubRe sponse)
  1900                
  1901                Qu it $$$OK
  1902        ]]>
  1903       </Implemen tation>
  1904      </Method>
  1905     
  1906      <Method 
  1907       name="Upda teEFPatien t"
  1908      >
  1909       <FormalSpe c>
  1910        pHL7Reques t:EnsLib.H L7.Message ,pAddUpdat eHubRespon se:HS.Mess age.AddUpd ateHubResp onse,tFlag :%String
  1911       </FormalSp ec>
  1912       <ReturnTyp e>
  1913        %Status
  1914       </ReturnTy pe>
  1915       <Implement ation>
  1916        <![CDATA[
  1917                
  1918                Se t tSC=$$$O K
  1919                Se t pAddUpda teHubReque st=##class (HS.Messag e.AddUpdat eHubReques t).%New()
  1920            Set pA ddUpdateHu bResponse= ##class(HS .Message.A ddUpdateHu bResponse) .%New()
  1921            
  1922            Set tM essageType  = $ZConve rt(pHL7Req uest.GetVa lueAt("MSH :9.2"),"U" )
  1923            Set de lim = $E(p HL7Request .GetValueA t("MSH:2") ,1)
  1924            Set re pDelim = $ E(pHL7Requ est.GetVal ueAt("MSH: 2"),2)
  1925       
  1926            Set tS SNNbr = ""  , tICNNbr  = "", i=0
  1927                     
  1928                If  ((tFlag =  "1") && ( tMessageTy pe = "A43" )){      / // Delete  on a A43
  1929                        
  1930                         Set  tICNNbr =  pHL7Reques t.GetValue At("PIDgrp (1).MRG:1( 1).1")  // / Get Old  MPIID to D elete
  1931                         $$$L OGINFO("Pr ior Master  Patient I D:"_tICNNb r_" ")
  1932                         
  1933                }  ElseIf ((t Flag = "1" ) && (tMes sageType =  "A24")){     
  1934                                  For i  = 1:1:pHL7 Request.Ge tValueAt(" PID:3(*)")  {
  1935                                  If pHL 7Request.G etValueAt( "PIDi2:3(" _i_").6.2" )="200M" & & (pHL7Req uest.GetVa lueAt("PID i2:3("_i_" ).4.1")="U SVHA") &&  (pHL7Reque st.GetValu eAt("PIDi2 :3("_i_"). 5")="NI")  {    
  1936                                  Set tI CNNbr = pH L7Request. GetValueAt ("PIDi2:3( "_i_").1")
  1937                                  $$$LOG INFO("Prio r Master P atient ID: "_tICNNbr_ " ") Quit
  1938                                  }
  1939                          }
  1940                     
  1941                         } El seIf ((tFl ag = "0")  && (tMessa geType = " A24")){     /// Add o n A24
  1942                                  For i  = 1:1:pHL7 Request.Ge tValueAt(" PID:3(*)")  {
  1943                                           If pHL7R equest.Get ValueAt("P ID:3("_i_" ).6.2")="2 00M" && (p HL7Request .GetValueA t("PID:3(" _i_").4.1" )="USVHA")  && (pHL7R equest.Get ValueAt("P ID:3("_i_" ).5")="NI" ) {    
  1944                                  Set tI CNNbr = pH L7Request. GetValueAt ("PID:3("_ i_").1")
  1945                                  $$$LOG INFO("New  Master Pat ient ID:"_ tICNNbr_"  ") 
  1946                                           }
  1947                                           If (pHL7 Request.Ge tValueAt(" PID:3("_i_ ").6.2")=" 200M") &&  (pHL7Reque st.GetValu eAt("PID:3 ("_i_").4. 1")="USSSA ") {    
  1948                                  Set tS SNNbr = pH L7Request. GetValueAt ("PID:3("_ i_").1")
  1949                                  $$$LOG INFO("SSN:  "_tSSNNbr _" ") Quit
  1950                          }
  1951                          } 
  1952                         Set  pAddUpdate HubRequest .SSN = tSS NNbr 
  1953                         
  1954                         // G et Patient  Name
  1955                         For  i = 1:1:pH L7Request. GetValueAt ("PID:5(*) ") {
  1956                                  If pHL 7Request.G etValueAt( "PID:5("_i _").7")="L " {
  1957                                                    Set tPatie ntName = p HL7Request .GetValueA t("PID:5(" _i_")")
  1958                                                    $$$LOGINFO ("Patient  Name : "_t PatientNam e_"")                      
  1959                                                            Se t pAddUpda teHubReque st.LastNam e=$P(tPati entName,de lim,1)
  1960                                                            Se t pAddUpda teHubReque st.FirstNa me=$P(tPat ientName,d elim,2)
  1961                                                            Se t pAddUpda teHubReque st.MiddleN ame = $P(t PatientNam e,delim,3)
  1962                                                            Se t pAddUpda teHubReque st.Prefix  = $TR($P(t PatientNam e,delim,5) ,$C(34,34) ,"")
  1963                                                            Se t pAddUpda teHubReque st.Suffix  = $TR($p(t PatientNam e,delim,4) ,$C(34,34) ,"")
  1964                                  }
  1965                         }
  1966                                           
  1967                                           //Get Pa tient Birt h City and  State
  1968                                           For i =  1:1:pHL7Re quest.GetV alueAt("PI D:11(*)")  {
  1969                                                    If pHL7Req uest.GetVa lueAt("PID :11("_i_") .7.1")="N"  {
  1970                                                            Se t tBirthCi ty = pHL7R equest.Get ValueAt("P ID:11("_i_ ").3")
  1971                                                            Se t pAddUpda teHubReque st.BirthPl ace.City =  tBirthCit y
  1972                                                            Se t tBirthSt ate = pHL7 Request.Ge tValueAt(" PID:11("_i _").4") 
  1973                                                            Se t pAddUpda teHubReque st.BirthPl ace.State  = tBirthSt ate
  1974                                                            Se t tBirthCo untry = pH L7Request. GetValueAt ("PID:11(" _i_").6") 
  1975                                                            Se t pAddUpda teHubReque st.BirthPl ace.Countr y = tBirth Country
  1976                                                            
  1977                                                            $$ $LOGINFO(" BirthPlace  City : "_ tBirthCity _"")
  1978                                                            $$ $LOGINFO(" BirthPlace  City : "_ tBirthStat e_"")
  1979                                                    }
  1980                                                   
  1981                                           }
  1982                                           
  1983                                           //Get Pa tient Addr ess
  1984                                           Set tAdd ress=##cla ss(HS.Type s.Address) .%New()
  1985                                           For i =  1:1:pHL7Re quest.GetV alueAt("PI D:11(*)")  {
  1986                                                    If pHL7Req uest.GetVa lueAt("PID :11("_i_") .7.1")="P"  {
  1987                                                            Se t tPatient Address =  pHL7Reques t.GetValue At("PID:11 ("_i_")")
  1988                                                            $$ $LOGINFO(" Patient Ad dress : "_ tPatientAd dress_" ")
  1989                                                            Se t tAddress .StreetLin e = $TR($P (tPatientA ddress,del im,1),$C(3 4,34),"")
  1990                                                            Se t tAddress .City = $T R($P(tPati entAddress ,delim,3), $C(34,34), "")
  1991                                                            Se t tAddress .State = $ TR($P(tPat ientAddres s,delim,4) ,$C(34,34) ,"")
  1992                                                            Se t tAddress .PostalCod e = $TR($P (tPatientA ddress,del im,5),$C(3 4,34),"")
  1993                                                            Se t tAddress .Country =  $TR($P(tP atientAddr ess,delim, 6),$C(34,3 4),"")
  1994                                                            $$ $LOGINFO(" Patient Ad dress : "_ tAddress.S treetLine_ " "_tAddre ss.City_"  ")
  1995                                                            Do  pAddUpdat eHubReques t.Addresse s.Insert(t Address) 
  1996                                                    }
  1997                                           }
  1998                                           Set tDat e = $TR(pH L7Request. GetValueAt ("PID:7"), $C(34,34), "")
  1999                                           $$$LOGIN FO("Patien t Date of  Birth : "_ tDate_"")
  2000                                           If tDate  '= "" set  pAddUpdat eHubReques t.DOB = $z dh($E(tDat e,1,4)_"-" _$E(tDate, 5,6)_"-"_$ E(tDate,7, 8),3)
  2001                                           set pAdd UpdateHubR equest.Sex  = pHL7Req uest.GetVa lueAt("PID :8")
  2002                                           
  2003                                           set pAdd UpdateHubR equest.Mot hersMaiden Surname =  pHL7Reques t.GetValue At("PID:6. 1.1")
  2004                                           Set tdea thDate = $ TR(pHL7Req uest.GetVa lueAt("PID :29"),$C(3 4,34),"")     
  2005                                           If $L(td eathDate)  > 8 {
  2006                                                    Set tdeath Date = $tr anslate(## class(HS.G ateway.HL7 .HL7ToSDA3 ).xmltimes tamp(pHL7R equest.Get ValueAt("P ID:29"))," TZ"," ")
  2007                                                    Set tdeath Date = $E( tdeathDate , 1,19)
  2008                                           } Else {
  2009                                                    Set tdeath Date = $tr anslate(## class(HS.G ateway.HL7 .HL7ToSDA3 ).xmltimes tamp(pHL7R equest.Get ValueAt("P ID:29"))," TZ"," ")
  2010                                           }
  2011                                  
  2012                                           $$$LOGIN FO("Death  Date and T ime : "_td eathDate_" ")
  2013                                  
  2014                                           If tdeat hDate '= $ C(34,34) s et pAddUpd ateHubRequ est.DeathT ime = tdea thDate
  2015                                           If (tdea thDate) '=  $C(34,34)  set pAddU pdateHubRe quest.Deat hStatus =  1   
  2016            
  2017                }  ElseIf ((t Flag = "0" ) && (tMes sageType =  "A43")) {    /// Add  on A43
  2018                     
  2019                                  For i  = 1:1:pHL7 Request.Ge tValueAt(" PIDgrp(1). PID:3(*)")  {
  2020                          If  pHL7Reques t.GetValue At("PIDgrp (1).PID:3( "_i_").6.2 ")="200M"  && (pHL7Re quest.GetV alueAt("PI Dgrp(1).PI D:3("_i_") .4.1")="US VHA") && ( pHL7Reques t.GetValue At("PIDgrp (1).PID:3( "_i_").5") ="NI") {     
  2021                          Set  tICNNbr =  pHL7Reque st.GetValu eAt("PIDgr p(1).PID:3 ("_i_").1" )
  2022                          $$$ LOGINFO("N ew Master  Patient ID : "_tICNNb r_" ") 
  2023                          }
  2024                          If  pHL7Reques t.GetValue At("PIDgrp (1).PID:3( "_i_").6.2 ")="200M"  && (pHL7Re quest.GetV alueAt("PI Dgrp(1).PI D:3("_i_") .4.1")="US SSA"){    
  2025                          Set  tSSNNbr =  pHL7Reque st.GetValu eAt("PIDgr p(1).PID:3 ("_i_").1" )
  2026                          $$$ LOGINFO("S SN: "_tSSN Nbr_" ") Q uit
  2027                          }
  2028                                  }
  2029                                  
  2030                                  // Get  Patient N ame
  2031                                  For i  = 1:1:pHL7 Request.Ge tValueAt(" PIDgrp(1). PID:5(*)")  {
  2032                                  If pHL 7Request.G etValueAt( "PIDgrp(1) .PID:5("_i _").7")="L " {
  2033                                                            Se t tPatient Name = pHL 7Request.G etValueAt( "PIDgrp(1) .PID:5("_i _")")
  2034                                                            $$ $LOGINFO(" Patient Na me:: "_tPa tientName_ "")                      
  2035                                                            se t pAddUpda teHubReque st.LastNam e=$P(tPati entName,de lim,1)
  2036                                                            se t pAddUpda teHubReque st.FirstNa me=$P(tPat ientName,d elim,2)
  2037                                                            Se t pAddUpda teHubReque st.MiddleN ame = $P(t PatientNam e,delim,3)
  2038                                                            Se t pAddUpda teHubReque st.Prefix  = $TR($P(t PatientNam e,delim,5) ,$C(34,34) ,"")
  2039                                                            Se t pAddUpda teHubReque st.Suffix  = $TR($p(t PatientNam e,delim,4) ,$C(34,34) ,"")
  2040                                  
  2041                                  }
  2042                                  }
  2043                                  
  2044                                  Set pA ddUpdateHu bRequest.S SN = tSSNN br
  2045                                  
  2046                         Set  tAddress=# #class(HS. Types.Addr ess).%New( )
  2047                         Set  tBirthAddr ess=##clas s(HS.Types .Address). %New()
  2048                         
  2049                         For  i = 1:1:pH L7Request. GetValueAt ("PIDgrp(1 ).PID:11(* )") {
  2050                                                    If pHL7Req uest.GetVa lueAt("PID grp(1).PID :11("_i_") .7.1")="N"  {
  2051                                                                     Set  tBirthAddr ess = pHL7 Request.Ge tValueAt(" PIDgrp(1). PID:11("_i _")")                                                        
  2052                                                                     Set  pAddUpdate HubRequest .BirthPlac e.City = $ TR($P(tBir thAddress, delim,3),$ C(34,34)," ")
  2053                                                                     Set  pAddUpdate HubRequest .BirthPlac e.State =  $TR($P(tBi rthAddress ,delim,4), $C(34,34), "")
  2054                                                                     Set  pAddUpdate HubRequest .BirthPlac e.Country  = $TR($P(t BirthAddre ss,delim,6 ),$C(34,34 ),"")
  2055                                                                     $$$L OGINFO("Pa tient Birt h Address  : "_tBirth Address_"  ")
  2056                                                    }       
  2057                         }
  2058                
  2059                                  For i  = 1:1:pHL7 Request.Ge tValueAt(" PIDgrp(1). PID:11(*)" ) {
  2060                                                    If pHL7Req uest.GetVa lueAt("PID grp(1).PID :11("_i_") .7.1")="P"  {
  2061                                                            Se t tPatient Address =  pHL7Reques t.GetValue At("PIDgrp (1).PID:11 ("_i_")")
  2062                                                            Se t tAddress .StreetLin e = $TR($P (tPatientA ddress,del im,1),$C(3 4,34),"")
  2063                                                            Se t tAddress .City = $T R($P(tPati entAddress ,delim,3), $C(34,34), "")
  2064                                                            Se t tAddress .State = $ TR($P(tPat ientAddres s,delim,4) ,$C(34,34) ,"")
  2065                                                            Se t tAddress .PostalCod e = $TR($P (tPatientA ddress,del im,5),$C(3 4,34),"")
  2066                                                            Se t tAddress .Country =  $TR($P(tP atientAddr ess,delim, 6),$C(34,3 4),"")
  2067                                                            $$ $LOGINFO(" Patient Ad dress : "_ tAddress.S treetLine_ " "_tAddre ss.City_"  ")
  2068                                                            Do  pAddUpdat eHubReques t.Addresse s.Insert(t Address) 
  2069                                                    }
  2070                                  }
  2071                                  
  2072                                  Set tD ate = $TR( pHL7Reques t.GetValue At("PIDgrp (1).PID:7" ),$C(34,34 ),"")
  2073                                  $$$LOG INFO("Pati ent Date o f Birth :  "_tDate_"" )
  2074                                  If tDa te '= "" S et pAddUpd ateHubRequ est.DOB =  $zdh($E(tD ate,1,4)_" -"_$E(tDat e,5,6)_"-" _$E(tDate, 7,8),3)
  2075                                  Set pA ddUpdateHu bRequest.S ex = pHL7R equest.Get ValueAt("P IDgrp(1).P ID:8")
  2076                                  Set pA ddUpdateHu bRequest.M othersMaid enSurname  = pHL7Requ est.GetVal ueAt("PIDg rp(1).PID: 6.1.1.1")
  2077                                  
  2078                                  Set td eathDate =  $TR(pHL7R equest.Get ValueAt("P IDgrp(1).P ID:29"),$C (34,34),"" )    
  2079                                  If $L( tdeathDate ) > 8 {
  2080                                           Set tdea thDate = $ translate( ##class(HS .Gateway.H L7.HL7ToSD A3).xmltim estamp(pHL 7Request.G etValueAt( "PIDgrp(1) .PID:29")) ,"TZ"," ")
  2081                                           Set tdea thDate = $ E(tdeathDa te, 1,19)
  2082                                  } Else  {
  2083                                           Set tdea thDate = $ translate( ##class(HS .Gateway.H L7.HL7ToSD A3).xmltim estamp(pHL 7Request.G etValueAt( "PIDgrp(1) .PID:29")) ,"TZ"," ")         
  2084                                  }
  2085                                  
  2086                                  $$$LOG INFO("Deat h Date and  Time : "_ tdeathDate _"")
  2087                                  
  2088                                  If tde athDate '=  $C(34,34)  set pAddU pdateHubRe quest.Deat hTime = td eathDate
  2089                                  If (td eathDate)  '= $C(34,3 4) set pAd dUpdateHub Request.De athStatus  = 1
  2090            }
  2091            
  2092            
  2093                //  Build Up  the AddUpd ateHubRequ est
  2094                
  2095                Se t pAddUpda teHubReque st.Assigni ngAuthorit y = "USVHA "
  2096                Se t pAddUpda teHubReque st.Facilit y = "EF"
  2097                se t pAddUpda teHubReque st.MRN = t ICNNbr     // MRN is  ICN number  for Enter prise Faci lity
  2098                se t pAddUpda teHubReque st.MPIID =  tICNNbr 
  2099                
  2100                Se t pAddUpda teHubReque st.AddOrUp date="A"
  2101                se t pAddUpda teHubReque st.DoMPIUp date=1
  2102       
  2103                If  tFlag = 1  Set pAddU pdateHubRe quest.DoDe lete = 1
  2104                
  2105                Do  pAddUpdat eHubReques t.Addition alInfo.Set At(tMessag eType,"Mer ge Message  Type")
  2106       
  2107                $$ $LOGINFO(" VA MVI Ope rations Ca ll with MP IID:"_tICN Nbr_" ")
  2108                Se t:..VAMVIO perations] "" tSC=..S endRequest Sync(..VAM VIOperatio ns,pAddUpd ateHubRequ est,.pAddU pdateHubRe sponse) 
  2109                $$ $HSTRACE(" Response f rom VA MVI  Operation s Notifica tion ","pR esponse",p AddUpdateH ubResponse )
  2110       
  2111                Qu it $$$OK
  2112        ]]>
  2113       </Implemen tation>
  2114      </Method>
  2115     
  2116      <Method 
  2117       name="Trig gerInactiv ePatientLo ad"
  2118      >
  2119       <FormalSpe c>
  2120        pMPIID:%St ring
  2121       </FormalSp ec>
  2122       <Implement ation>
  2123        <![CDATA[
  2124                Qu it:(pMPIID ="")
  2125                Qu it:(..Inac tivePatien tLoad="")
  2126                
  2127                Se t tSearchR equest = # #class(HS. Message.Pa tientSearc hRequest). %New()
  2128                
  2129                Se t tSearchR equest.Sea rchMode =  "PIXPDQ"
  2130                // Set tSearc hRequest.N ame = "PDQ v3_QueryRe quest"
  2131                Se t tSearchR equest.MPI ID = pMPII D
  2132                Se t tSearchR equest.Ass igningAuth ority = "U SVHA"
  2133                
  2134                // inactive p atient dat a may be a vailable s o continue  with the  inactive p atient loa d process
  2135                Se t tSC = .. SendReques tAsync(..I nactivePat ientLoad,t SearchRequ est,0)
  2136                If  $$$ISERR( tSC) $$$LO GERROR("Er ror on sen ding to In active Pat ient Load  Process: " _$system.S tatus.GetE rrorText(t SC))
  2137        ]]>
  2138       </Implemen tation>
  2139      </Method>
  2140     
  2141      <Storage 
  2142       name="Defa ult"
  2143      >
  2144       <Type>
  2145        %Library.C acheStorag e
  2146       </Type>
  2147       <DefaultDa ta>
  2148        ProcessDef aultData
  2149       </DefaultD ata>
  2150       <Data 
  2151        name="Proc essDefault Data"
  2152       >
  2153        <Subscript >
  2154         "Process"
  2155        </Subscrip t>
  2156        <Value 
  2157         name="1"
  2158        >
  2159         <Value>
  2160          Errors
  2161         </Value>
  2162        </Value>
  2163        <Value 
  2164         name="2"
  2165        >
  2166         <Value>
  2167          IHEVersion
  2168         </Value>
  2169        </Value>
  2170        <Value 
  2171         name="3"
  2172        >
  2173         <Value>
  2174          MPIOperati ons
  2175         </Value>
  2176        </Value>
  2177        <Value 
  2178         name="4"
  2179        >
  2180         <Value>
  2181          NotifyOthe rs
  2182         </Value>
  2183        </Value>
  2184        <Value 
  2185         name="5"
  2186        >
  2187         <Value>
  2188          AffinityDo main
  2189         </Value>
  2190        </Value>
  2191        <Value 
  2192         name="6"
  2193        >
  2194         <Value>
  2195          Transforme r
  2196         </Value>
  2197        </Value>
  2198        <Value 
  2199         name="7"
  2200        >
  2201         <Value>
  2202          TraceOpera tions
  2203         </Value>
  2204        </Value>
  2205        <Value 
  2206         name="8"
  2207        >
  2208         <Value>
  2209          PartnerOpe ration
  2210         </Value>
  2211        </Value>
  2212        <Value 
  2213         name="9"
  2214        >
  2215         <Value>
  2216          VAStation
  2217         </Value>
  2218        </Value>
  2219        <Value 
  2220         name="10"
  2221        >
  2222         <Value>
  2223          HL7Process ingID
  2224         </Value>
  2225        </Value>
  2226        <Value 
  2227         name="11"
  2228        >
  2229         <Value>
  2230          VAMVIOpera tions
  2231         </Value>
  2232        </Value>
  2233        <Value 
  2234         name="12"
  2235        >
  2236         <Value>
  2237          InactivePa tientLoad
  2238         </Value>
  2239        </Value>
  2240       </Data>
  2241      </Storage>
  2242     </Class>
  2243    
  2244    
  2245     <Class 
  2246      name="HS.L ocal.VA.HS .Registry. HS.IHE.PIX v2.Consume r.Services "
  2247     >
  2248      <Descripti on>
  2249       HS.IHE.PIX v2.Consume r.Services  extends E nsLib.HL7. Service.TC PService t o
  2250       override O nDocumentE nd() to be  able to p ass the IP  Address o f the TCP
  2251       sender to  HS.IHE.PIX .Consumer. Process.
  2252      </Descript ion>
  2253      <Super>
  2254       EnsLib.HL7 .Service.T CPService
  2255      </Super>
  2256      <TimeChang ed>
  2257       64978,5752 0.624298
  2258      </TimeChan ged>
  2259      <TimeCreat ed>
  2260       62851,3739 5.695977
  2261      </TimeCrea ted>
  2262     
  2263      <Parameter  
  2264       name="UseO riginalCon trolId"
  2265      >
  2266       <Type>
  2267        %Boolean
  2268       </Type>
  2269       <Default>
  2270        0
  2271       </Default>
  2272      </Paramete r>
  2273     
  2274      <Property 
  2275       name="VASt ation"
  2276      >
  2277       <Type>
  2278        %String
  2279       </Type>
  2280       <InitialEx pression>
  2281        "200HSEP"
  2282       </InitialE xpression>
  2283      </Property >
  2284     
  2285      <Method 
  2286       name="OnDo cumentEnd"
  2287      >
  2288       <FormalSpe c>
  2289        pDocument: EnsLib.EDI .Document, pSource:%S tring,pSta tus:%Statu s
  2290       </FormalSp ec>
  2291       <ReturnTyp e>
  2292        %Status
  2293       </ReturnTy pe>
  2294       <Implement ation>
  2295        <![CDATA[
  2296                Se t pDocumen t.Envelope  = ..Adapt er.IOAddr
  2297                
  2298                Se t tSC = ## super(pDoc ument, pSo urce, pSta tus)
  2299                
  2300                Qu it tSC
  2301        ]]>
  2302       </Implemen tation>
  2303      </Method>
  2304     
  2305      <Method 
  2306       name="OnCo nstructRep ly"
  2307      >
  2308       <FormalSpe c>
  2309        <![CDATA[* pReplyDoc: EnsLib.EDI .Document, pOriginalD oc:EnsLib. EDI.Docume nt,&pReply Code:%Stri ng,&pSC:%S tatus,pEar lyAck:%Boo lean]]>
  2310       </FormalSp ec>
  2311       <ReturnTyp e>
  2312        %Status
  2313       </ReturnTy pe>
  2314       <Implement ation>
  2315        <![CDATA[
  2316                Se t tSC = $$ $OK
  2317                If  '$D(pRepl yDoc) {
  2318                         If $ Case(pOrig inalDoc.Na me,"FHS":1 ,"BHS":1,: 0) {
  2319                                  If ""  '= pOrigin alDoc.Pare ntId { ; t op doc
  2320                                           Set pRep lyDoc=$$$N ULLOREF
  2321                                  } Else  {
  2322                                           If ..%Fo rwardBatch Whole=1 {  ; no need  to check f or %Forwar dBatchWhol e>1 becaus e this is  runtime
  2323                                                    #; Make AC Ks for all  children
  2324                                                    If '$Case( ..AckMode, "Byte":1 , :pEarlyAck <0) {
  2325                                                            Se t pSC=pOri ginalDoc.G etChildIds Array(.tCh ildArray,p OriginalDo c.%Id(),1)
  2326                                                            Se t i="" For  { Set i=$ O(tChildAr ray(i),1,t ChildId)   Quit:""=i
  2327                                                                     Set  tChild=pOr iginalDoc. %OpenId(tC hildId)
  2328                                                                     Set  tRepliesAr ray=i, tRe pliesArray (i)=..cons tructReply (tChild,$S (..UseAckC ommitCodes &&(+tChild .GetValueA t("1:12.1" )>=2.3):"C ",1:"A")_" A",.pSC,pE arlyAck)   If $$$ISER R(pSC) $$$ LOGSTATUS( pSC) Quit
  2329                                                            }
  2330                                                    }
  2331                                           } Else {
  2332                                                    Merge tRep liesArray= ..%ReplyDo cuments  K ill ..%Rep lyDocument s  Set ..% ReplyDocum ents=0
  2333                                           }
  2334                                           Set:$$$I SOK(pSC) p ReplyDoc=. .construct BatchReply (pOriginal Doc,.tRepl iesArray,. pSC,pEarly Ack)
  2335                                  }
  2336                         } El se {
  2337                                  Set tI sErr=("A"' =$E(pReply Code,2))
  2338                                  If $Ca se(..AckMo de,"Byte": 1, :pEarly Ack<0) {
  2339                                           Set pRep lyDoc=$S(t IsErr:$C($ $$SingleBy teAckError Ascii),1:$ C($$$Singl eByteAckAc ceptAscii) )
  2340                                  } Else  {
  2341                                           Set pRep lyDoc=pOri ginalDoc.N ewReplyDoc ument(,..L ocalFacili tyApplicat ion)
  2342                                           Set pRep lyDoc.Sour ce=pOrigin alDoc.%Id( )
  2343                                           Do pRepl yDoc.SetVa lueAt(..VA Station_## class(HS.I HE.Util).G etIdForHL7 (),"1:10")  ; copy th e control  id to the  ack contro l id with  station Id
  2344                                           Set tTSt amp = $Tra nslate($ZD ateTime($H orolog, 8, 5), ":T ",  "")
  2345                                           Do pRepl yDoc.SetVa lueAt(tTSt amp, "1:7" )
  2346                                           Set tAck MSA=##clas s(EnsLib.H L7.Segment ).%New($LB ("",1))
  2347                                           Set tAck MSA.Separa tors=pRepl yDoc.Separ ators
  2348                                           Do tAckM SA.SetValu eAt("MSA", 0)
  2349                                           Do tAckM SA.SetValu eAt(pReply Code,1)
  2350                                           Do tAckM SA.SetValu eAt(pOrigi nalDoc.Get ValueAt("1 :10"),2)
  2351                                           Do:$G($$ $ExpectedS equenceNum ber) tAckM SA.SetValu eAt($$$Exp ectedSeque nceNumber, 4)
  2352                                           #; Depre cated sinc e v2.1 - D o tAckMSA. SetValueAt ($S(pForwa rdMsg:"D", 1:"F"),5// "DelayedAc knowledgme ntType")
  2353                                           Do pRepl yDoc.Appen dSegment(t AckMSA)
  2354                                           If ..Add NackERR&&t IsErr {
  2355                                                    // Now bui ld an ERR  segment in  case of e rror
  2356                                                    Set tAckER R=##class( EnsLib.HL7 .Segment). %New($LB(" ",1))
  2357                                                    Set tAckER R.Separato rs=pReplyD oc.Separat ors
  2358                                                    Do tAckERR .SetValueA t("ERR",0)
  2359                                                    #;Do tAckE RR.SetValu eAt("207"_ tAckERR.CS _"Applicat ion intern al error", 3) 
  2360                                                    Do tAckERR .SetValueA t("E",4)   // It's an  error
  2361                                                    Do tAckERR .SetValueA t($P($syst em.Status. GetErrorCo des(tSC)," ,"),5)
  2362                                                    Do tAckERR .SetValueA t(tAckERR. Escape($$$ StatusDisp layString( tSC)),8)
  2363                                                    Do pReplyD oc.AppendS egment(tAc kERR)
  2364                                           }
  2365                                           Set pRep lyDoc.IsMu table=0
  2366                                  }
  2367                         }
  2368                }
  2369                Se t:$IsObjec t(pReplyDo c) pReplyD oc.Origina lDocId=pOr iginalDoc. %Id()
  2370                $$ $sysTRACE( "Construct ed reply d ocument '" _pReplyDoc _"' for or iginal doc ument "_pO riginalDoc _" / "_pOr iginalDoc. %Id()_" re flecting s tatus: "_$ $$StatusDi splayStrin g(tSC))
  2371                Qu it $G(pRep lyDoc,$$$N ULLOREF)
  2372        ]]>
  2373       </Implemen tation>
  2374      </Method>
  2375     </Class>
  2376    
  2377    
  2378     <Class 
  2379      name="HS.L ocal.VA.HS .Registry. HS.IHE.XDS b.OnDemand .Operation s"
  2380     >
  2381      <Descripti on>
  2382       Custom on- demand pro cessor
  2383       - issues m etadata up date for c hanged ser viceTime
  2384       - adds sup ports for  multiple ( C62) docum ents
  2385      </Descript ion>
  2386      <Super>
  2387       HS.IHE.XDS b.OnDemand .Operation s
  2388      </Super>
  2389      <TimeChang ed>
  2390       64999,4357 7.633916
  2391      </TimeChan ged>
  2392      <TimeCreat ed>
  2393       64999,4357 7.633916
  2394      </TimeCrea ted>
  2395     
  2396      <Method 
  2397       name="deli verMessage "
  2398      >
  2399       <Descripti on>
  2400        CUSTOM: ov erride, qu it if all  docs remov ed
  2401       </Descript ion>
  2402       <FormalSpe c>
  2403        <![CDATA[p Metadata:H S.IHE.XDSb .Types.Met adata,pReq uest:HS.Me ssage.XMLM essage,&pR esponse:HS .Message.X MLMessage] ]>
  2404       </FormalSp ec>
  2405       <ReturnTyp e>
  2406        %Status
  2407       </ReturnTy pe>
  2408       <Implement ation>
  2409        <![CDATA[
  2410                Se t tSC = $$ $OK
  2411                Tr y {
  2412                         $$$H SPerfStart ("Check pr ior submis sions")
  2413                                  Set tI sOnDemand  = (pReques t.Addition alInfo.Get At("Delive ryType") =  "XDSb.OnD emand")
  2414                         
  2415                                  #; OnD emand repl acement ca n be skipp ed since t he metadat a will not  change,
  2416                                  #; but  the capab ility is r equired fo r IHE cert ification  and may be  useful so meday
  2417                                  Set tS C = ..setP revious(pM etadata,.t HasPreviou s) $$$Thro wOnError(t SC)
  2418                                  If tHa sPrevious  {
  2419                                           If tIsOn Demand, '. .IssueOnDe mandReplac ements {
  2420                                                    $$$HSPerfE nd
  2421                                                    $$$HSTRACE ("Skipping  on demand  replaceme nt")
  2422                                                    Quit
  2423                                           }
  2424                                           $$$Throw OnError(.. checkPrevi ous(pMetad ata))
  2425                                  }
  2426                         $$$H SPerfEnd
  2427       
  2428                         #; C USTOM: not hing to do  if all do cuments we re removed  by 'check Previous'
  2429                         Quit :pMetadata .Documents .Count()=0
  2430                         
  2431                         #; D etermine t he message  type (reg ister for  on-demand,  provide f or stable)
  2432                         $$$H SPerfStart ("Create X DSb Messag e")
  2433                                  If tIs OnDemand {
  2434                                           Set tPar ams("messa geName") =  $$$XDSbRe gisterOnDe mandReques t
  2435       
  2436                                           #; Set t he reposit ory for ea ch on-dema nd documen t
  2437                                           Set tThi sRepositor yOID = ##c lass(HS.Da ta.OIDMap) .OIDForTyp e(..OnDema ndReposito ryName,"Re pository")
  2438                                           Set i=""  For { Set  tDoc=pMet adata.Docu ments.GetN ext(.i) Qu it:i=""  
  2439                                                    Set tDoc.R epositoryU niqueId =  tThisRepos itoryOID
  2440                                           }
  2441                                  }
  2442                                  Else {           
  2443                                           Set tPar ams("messa geName") =  $$$XDSbPr ovideAndRe gisterRequ est
  2444                                  }
  2445                                  #; Cre ate and se nd the XDS b message               
  2446                                  Set tS C = ..Tran sformObjec ts(pMetada ta, ..Mess ageTransfo rm, .tRequ est, .tPar ams, "HS.M essage.XML Message",, 1) $$$Thro wOnError(t SC)
  2447                                  Set tS C = ##clas s(HS.IHE.U til).Merge Additional Info(pRequ est, tRequ est) $$$Th rowOnError (tSC)
  2448                                  Set tR equest.Str eamCollect ion = pReq uest.Strea mCollectio n
  2449                         $$$H SPerfEnd
  2450                         
  2451                         $$$H SPerfStart ("Register  or Provid e")            
  2452                                  Set tS C = ..OnMe ssage(tReq uest, .pRe sponse) $$ $ThrowOnEr ror(tSC)
  2453                         $$$H SPerfEnd
  2454                         
  2455                         #; U pdate subm issions if  successfu l
  2456                         $$$H SPerfStart ("Update S ubmissions ")             
  2457                                  Set tS C = ..upda teSubmissi ons(pMetad ata) $$$Th rowOnError (tSC)
  2458                         $$$H SPerfEnd
  2459                         
  2460                }  Catch ex {  Set tSC =  ex.AsStat us() }
  2461                Qu it tSC
  2462        ]]>
  2463       </Implemen tation>
  2464      </Method>
  2465     
  2466      <Method 
  2467       name="chec kPrevious"
  2468      >
  2469       <Descripti on>
  2470        CUSTOM: ov erride to  remove doc uments (an d their as sociations ) that hav e changes  we don't c are about
  2471       </Descript ion>
  2472       <FormalSpe c>
  2473        pMetadata: HS.IHE.XDS b.Types.Me tadata
  2474       </FormalSp ec>
  2475       <ReturnTyp e>
  2476        %Status
  2477       </ReturnTy pe>
  2478       <Implement ation>
  2479        <![CDATA[
  2480                Se t tSC = $$ $OK
  2481                Tr y {
  2482                         #dim  tAssoc As  HS.IHE.XD Sb.Types.A ssociation
  2483                         #dim  tPrevious  As HS.IHE .XDSb.Type s.Document
  2484                         #dim  tOutputLi st As HS.I HE.XDSb.Ty pes.Metada ta
  2485                         
  2486                         #; B uild a lis t of previ ous docume nts
  2487                         Set  tInputList  = ##class (HS.IHE.XD Sb.Types.M etadata).% New()
  2488                         Set  i="" For {  Set tAsso c = pMetad ata.Associ ations.Get Next(.i) Q uit:i=""
  2489                                  Contin ue:tAssoc. Type'="Rep laces"
  2490                                  If tAs soc.ChildU UID]"" {
  2491                                           Set tPre vious = ## class(HS.I HE.XDSb.Ty pes.Docume nt).%New()
  2492                                           Set tPre vious.Entr yUUID = tA ssoc.Child UUID
  2493                                           Do tInpu tList.Docu ments.Inse rt(tPrevio us)
  2494                                  }
  2495                         }
  2496                         If t InputList. Documents. Count() =  0 Quit
  2497                         
  2498                         #; Q uery regis try for pr evious doc ument stat us
  2499                         Set  tSC = ..qu eryGetDocu ments(tInp utList, .t OutputList ) $$$Throw OnError(tS C)
  2500                         
  2501                         #; C lean up if  previous  document i s no longe r approved
  2502                         Set  i="" For {  Set tPrev ious = tOu tputList.D ocuments.G etNext(.i)  Quit:i=""
  2503                                  If tPr evious.Ava ilabilityS tatus '= " Approved"  {
  2504                                           Set j=""  For { Set  tAssoc =  pMetadata. Associatio ns.GetPrev ious(.j) Q uit:j=""
  2505                                                    If tAssoc. ChildUUID  = tPreviou s.EntryUUI D {
  2506                                                            #;  Remove th e replace  associatio n
  2507                                                            Do  pMetadata .Associati ons.Remove At(j)
  2508                                                            
  2509                                                            #;  Remove en try from s ubmission  tracking t able
  2510                                                            #d im tResult  As HS.Uti l.WebServi ces.Servic eStatus
  2511                                                            Se t tSubmiss ion = ##cl ass(HS.Pus h.WebServi ces.Contai ners.Submi ssion).%Ne w()
  2512                                                            #;  CUSTOM: f ix - shoul d be Child UUID
  2513                                                            #; Set tSubmi ssion.Docu mentId = t Assoc.Pare ntUUID
  2514                                                            Se t tSubmiss ion.Docume ntId = tAs soc.ChildU UID
  2515                                                            $$ $HSTRACE(" Calling De leteSubmis sion","tSu bmission", tSubmissio n)
  2516                                                            Se t tSC = ## class(HS.U til.HubSer vices).Inv okeHubServ ice("HS.Pu sh.WebServ ices","HS. Push.WebSe rvicesClie nt","Delet eSubmissio n",.tResul t,tSubmiss ion)
  2517                                                            $$ $ThrowOnEr ror(tSC)
  2518                                                            $$ $ThrowOnEr ror(tResul t.Status)
  2519                                                    }
  2520                                           }
  2521                                  }
  2522                                  Else {
  2523                                           #; CUSTO M: remove  documents/ associatio ns unless  key fields  changed
  2524                                           #;
  2525                                           Set j=""  For { Set  tAssoc =  pMetadata. Associatio ns.GetPrev ious(.j) Q uit:j=""
  2526                                                    Continue:t Assoc.Type '="Replace s"
  2527                                                    Continue:t Assoc.Chil dUUID'=tPr evious.Ent ryUUID
  2528                                                    Set k="" F or { Set t Document =  pMetadata .Documents .GetPrevio us(.k) Qui t:k=""
  2529                                                            Co ntinue:tDo cument.Ent ryUUID'=tA ssoc.Paren tUUID
  2530                                                            Co ntinue:(tD ocument.Se rviceStart Time'=tPre vious.Serv iceStartTi me)
  2531                                                            Co ntinue:(tD ocument.Se rviceStopT ime'=tPrev ious.Servi ceStopTime )
  2532                                                            Se t tRemoved (tDocument .EntryUUID ) = ""
  2533                                                            Do  pMetadata .Documents .RemoveAt( k)
  2534                                                            Do  pMetadata .Associati ons.Remove At(j)
  2535                                                    }
  2536                                           }
  2537                                           #; secon d pass to  remove any  associati ons tied t o a remove d document  (eg HasMe mber)
  2538                                           Set tUUI D="" For {  Set tUUID  = $O(tRem oved(tUUID )) Quit:tU UID=""
  2539                                                    Set j="" F or { Set t Assoc = pM etadata.As sociations .GetPrevio us(.j) Qui t:j=""
  2540                                                            If  ((tAssoc. ChildUUID= tUUID)||(t Assoc.Pare ntUUID=tUU ID)) {
  2541                                                                     Do p Metadata.A ssociation s.RemoveAt (j)
  2542                                                            }
  2543                                                    }
  2544                                           }
  2545                                  }
  2546                         }
  2547                         
  2548                }  Catch ex {  Set tSC =  ex.AsStat us() }
  2549                Qu it tSC
  2550        ]]>
  2551       </Implemen tation>
  2552      </Method>
  2553     
  2554      <Method 
  2555       name="quer yGetDocume nts"
  2556      >
  2557       <Descripti on>
  2558        CUSTOM: ov erride to  include fi elds to ch eck for re placement
  2559       </Descript ion>
  2560       <FormalSpe c>
  2561        pInput:HS. IHE.XDSb.T ypes.Metad ata,*pOutp ut:HS.IHE. XDSb.Types .Metadata
  2562       </FormalSp ec>
  2563       <ReturnTyp e>
  2564        %Status
  2565       </ReturnTy pe>
  2566       <Implement ation>
  2567        <![CDATA[
  2568                #d im tDocume nt As HS.I HE.XDSb.Ty pes.Docume nt
  2569                #;  When on t he hub, on ly used by  checkPrev ious, whic h only sen ds EntryUU ID and nee ds Availab ilityStatu s and Entr yUUID
  2570                Se t tSC = $$ $OK
  2571                Se t pOutput  = ##class( HS.IHE.XDS b.Types.Me tadata).%N ew()
  2572                Tr y {
  2573                         Set  i="" For {  Set tDocu ment=pInpu t.Document s.GetNext( .i) Quit:i =""
  2574                                  If ##c lass(HS.Re gistry.Doc ument).IID IndexExist s(tDocumen t.EntryUUI D,.tID) {
  2575                                           #dim tDo c As HS.Re gistry.Doc ument
  2576                                           Set tDoc  = ##class (HS.Regist ry.Documen t).%OpenId (tID)
  2577                                           Set tDoc ument.Avai labilitySt atus = tDo c.Status
  2578                                           Set tDoc ument.Serv iceStartTi me = tDoc. ServiceSta rtTime
  2579                                           Set tDoc ument.Serv iceStopTim e = tDoc.S erviceStop Time
  2580                                           Do pOutp ut.Documen ts.Insert( tDocument)                             
  2581                                  } Else  {
  2582                                           $$$Throw Status($$$ ERROR($$$G eneralErro r,"Documen t does not  exist: "_ tDocument. EntryUUID) )
  2583                                  }
  2584                         }
  2585                }  Catch ex {  Set tSC =  ex.AsStat us() }
  2586                $$ $HSTRACE(" Query Resu lt","pOutp ut",pOutpu t)
  2587                Qu it tSC
  2588        ]]>
  2589       </Implemen tation>
  2590      </Method>
  2591     </Class>
  2592    
  2593    
  2594     <Class 
  2595      name="HS.L ocal.VA.HS .Registry. HS.IHE.XDS b.Registry .Operation s"
  2596     >
  2597      <Super>
  2598       HS.IHE.XDS b.Registry .Operation s
  2599      </Super>
  2600      <TimeChang ed>
  2601       65034,4197 1.289033
  2602      </TimeChan ged>
  2603      <TimeCreat ed>
  2604       65020,9404 .108725
  2605      </TimeCrea ted>
  2606     
  2607      <Parameter  
  2608       name="SETT INGS"
  2609      >
  2610       <Type>
  2611        %String
  2612       </Type>
  2613       <Default>
  2614        PatientSea rch,Inacti vePatientL oad,Inacti vePatientT imeout,Ina ctivePatie ntCheckInt erval
  2615       </Default>
  2616      </Paramete r>
  2617     
  2618      <Property 
  2619       name="Pati entSearch"
  2620      >
  2621       <Descripti on>
  2622        Patient Se arch with  MVI Operat ion
  2623       </Descript ion>
  2624       <Type>
  2625        Ens.DataTy pe.ConfigN ame
  2626       </Type>
  2627       <InitialEx pression>
  2628        "VA.MVI.PD Qv3.Consum er.Operati ons"
  2629       </InitialE xpression>
  2630      </Property >
  2631     
  2632      <Property 
  2633       name="Inac tivePatien tLoad"
  2634      >
  2635       <Descripti on>
  2636        Inactive P atient Loa d Process
  2637       </Descript ion>
  2638       <Type>
  2639        Ens.DataTy pe.ConfigN ame
  2640       </Type>
  2641       <InitialEx pression>
  2642        "VA.Inacti vePatientL oad.Proces s"
  2643       </InitialE xpression>
  2644      </Property >
  2645     
  2646      <Property 
  2647       name="Inac tivePatien tTimeout"
  2648      >
  2649       <Descripti on>
  2650        Timeout fo r getting  inactive p atient dat a loaded ( in seconds )
  2651       </Descript ion>
  2652       <Type>
  2653        %Integer
  2654       </Type>
  2655       <InitialEx pression>
  2656        10
  2657       </InitialE xpression>
  2658      </Property >
  2659     
  2660      <Property 
  2661       name="Inac tivePatien tCheckInte rval"
  2662      >
  2663       <Descripti on>
  2664        How often  to re-chec k if inact ive patien t data has  been load ed (in sec onds) - un til Inacti vePatientT imeout is  reached
  2665       </Descript ion>
  2666       <Type>
  2667        %Integer
  2668       </Type>
  2669       <InitialEx pression>
  2670        2
  2671       </InitialE xpression>
  2672      </Property >
  2673     
  2674      <Method 
  2675       name="quer yFindDocum ents"
  2676      >
  2677       <FormalSpe c>
  2678        <![CDATA[& pQueryPara ms]]>
  2679       </FormalSp ec>
  2680       <ReturnTyp e>
  2681        %Status
  2682       </ReturnTy pe>
  2683       <Implement ation>
  2684        <![CDATA[
  2685                Tr y {
  2686                         If ( ..Inactive PatientLoa d '= "") {
  2687                                  
  2688                                  If '$D (pQueryPar ams("$XDSD ocumentEnt ryPatientI d")) Quit   //proceed  to standa rd handlin g (will in clude stan dard error )
  2689                                  
  2690                                  Set tI dx=$o(pQue ryParams(" $XDSDocume ntEntryPat ientId","" ))
  2691                                  Set tP atientID=$ o(pQueryPa rams("$XDS DocumentEn tryPatient Id",tIdx," "))
  2692                                  
  2693                                  Set tM PIID = $p( tPatientID ,"^",1)
  2694                                  If (tM PIID = "")  Quit  //p roceed to  standard h andling (l ikely no e rror, but  empty Regi stryObject List)
  2695                                  
  2696                                  If ##c lass(HS.Lo cal.VA.HS. Registry.I nactivePat ientLoad.A ctive).ICN IndexExist s(tMPIID)  Quit  //al ready acti ve
  2697                                  
  2698                                  If ($L (tMPIID) <  17) {
  2699                                           Do ..Out putSet.log Error("XDS RegistryEr ror","Erro r","Inacti ve Patient  Load: Une xpected Pa tient ID")
  2700                                           Quit
  2701                                  }
  2702                                  
  2703                                  Set tS earchReque st = ##cla ss(HS.Mess age.Patien tSearchReq uest).%New ()
  2704                                  Set tS earchRespo nse = ##cl ass(HS.Mes sage.Patie ntSearchRe sponse).%N ew()
  2705                                  
  2706                                  Set tS earchReque st.SearchM ode = "PIX PDQ"
  2707                                  Set tS earchReque st.MPIID =  tMPIID
  2708                                  Set tS earchReque st.Assigni ngAuthorit y = "USVHA "
  2709                                  
  2710                              $$$ThrowOn Error(..Se ndRequestS ync(..Pati entSearch, tSearchReq uest,.tSea rchRespons e)) 
  2711                                  $$$HST RACE("Resp onse from  MVI Lookup  (in inact ive load l ogic) ","t SearchRequ est,tSearc hResponse" ,tSearchRe quest,tSea rchRespons e)
  2712                                  
  2713                                  Set tI sActive =  0
  2714                                  
  2715                                  // No  Response f rom MVI wi th Timeout /SOAP Faul t
  2716                                  If '$i sObject(tS earchRespo nse) || (t SearchResp onse=$$$NU LLOREF) {
  2717                                           
  2718                                           $$$LOGER ROR("No va lid respon se to Requ est for IC N: "_tSear chRequest. MPIID)
  2719                                           Do ..Out putSet.log Error("XDS RegistryEr ror","Erro r","Inacti ve Patient  Load: No  Valid Resp onse from  MVI")
  2720                                           
  2721                                  } Else If (tSearc hResponse. ResultsCou nt = 0) {  // No Erro r from MVI  but no Pa tient Matc h
  2722                                           
  2723                                           $$$LOGAL ERT("No Pa tient Matc h Found fo r ICN: "_t SearchRequ est.MPIID)
  2724                                           Do ..Out putSet.log Error("XDS RegistryEr ror","Erro r","Inacti ve Patient  Load: No  Patient Ma tch")
  2725                                           
  2726                                  } Else If '##clas s(HS.Local .VA.HS.Reg istry.Inac tivePatien tLoad.Proc ess).HasTr eatingFaci lities(tSe archRespon se) {
  2727                                           
  2728                                           $$$LOGAL ERT("No Tr eating Fac ility Foun d for ICN:  "_tSearch Request.MP IID)
  2729                                           Do ..Out putSet.log Error("XDS RegistryEr ror","Erro r","Inacti ve Patient  Load: No  Treating F acility Ma tch")
  2730                                           
  2731                                  } Else If ##class (HS.Local. VA.HS.Regi stry.Inact ivePatient Load.Proce ss).HasTre atingFacil ities(tSea rchRespons e,1) {
  2732                                           
  2733                                           //inacti ve patient  data like ly availab le so cont inue with  the inacti ve patient  load proc ess
  2734                                           $$$Throw OnError(.. SendReques tAsync(..I nactivePat ientLoad,t SearchResp onse))
  2735                                           
  2736                                           For tRet ryIdx=1:1: (..Inactiv ePatientTi meout \ .. InactivePa tientCheck Interval)  {
  2737                                                    Hang ..Ina ctivePatie ntCheckInt erval
  2738                                                    Set tIsAct ive = '##c lass(HS.Lo cal.VA.HS. Registry.I nactivePat ientLoad.P rocess).Ha sTreatingF acilities( tSearchRes ponse,1)
  2739                                                    If tIsActi ve Quit
  2740                                           }
  2741                                           
  2742                                           If 'tIsA ctive {
  2743                                                    $$$LOGALER T("Inactiv e Patient  Found for  ICN: "_tSe archReques t.MPIID)
  2744                                                    Do ..Outpu tSet.logEr ror("XDSRe gistryErro r","Error" ,"Inactive  Patient F ound. Atte mpting to  reactivate . Please t ry again l ater.")
  2745                                           }
  2746                                           
  2747                                  } Else  {
  2748                                           Set tIsA ctive = 1
  2749                                  }
  2750                                  
  2751                                  If tIs Active {
  2752                                           //patien t found an d not inac tive - kee p track of  it to avo id future  MVI querie s, and pro ceed to st andard han dling
  2753                                           Set tAct ive = ##cl ass(HS.Loc al.VA.HS.R egistry.In activePati entLoad.Ac tive).%New ()
  2754                                           Set tAct ive.ICN =  tSearchReq uest.MPIID
  2755                                           Do tActi ve.%Save()   //ignore  error her e, most li kely it wo uld be due  to concur rency mean ing record  is alread y created
  2756                                  }
  2757                         }
  2758                         
  2759                }  Catch eExc eption {
  2760                         Do . .OutputSet .logError( "XDSRegist ryError"," Error","In active Pat ient Load:  Internal  Error")
  2761                }
  2762                
  2763                Qu it ##super (.pQueryPa rams)
  2764        ]]>
  2765       </Implemen tation>
  2766      </Method>
  2767     </Class>
  2768    
  2769    
  2770    
  2771    
  2772     <Class 
  2773      name="HS.L ocal.VA.HS .Registry. InactivePa tientLoad. Active"
  2774     >
  2775      <Super>
  2776       %Persisten t
  2777      </Super>
  2778      <TimeChang ed>
  2779       65020,4319 6.997556
  2780      </TimeChan ged>
  2781      <TimeCreat ed>
  2782       65020,4319 6.663826
  2783      </TimeCrea ted>
  2784     
  2785      <Property 
  2786       name="ICN"
  2787      >
  2788       <Type>
  2789        %String
  2790       </Type>
  2791      </Property >
  2792     
  2793      <Property 
  2794       name="Time Checked"
  2795      >
  2796       <Type>
  2797        %TimeStamp
  2798       </Type>
  2799       <InitialEx pression>
  2800        $zdt($now( ),3,1,3)
  2801       </InitialE xpression>
  2802      </Property >
  2803     
  2804      <Index 
  2805       name="ICNI ndex"
  2806      >
  2807       <Propertie s>
  2808        ICN
  2809       </Properti es>
  2810       <Unique>
  2811        1
  2812       </Unique>
  2813      </Index>
  2814     
  2815      <Storage 
  2816       name="Defa ult"
  2817      >
  2818       <Type>
  2819        %Library.C acheStorag e
  2820       </Type>
  2821       <DataLocat ion>
  2822        ^HS.Local. VA.HS.Regi C1B2.Activ eD
  2823       </DataLoca tion>
  2824       <DefaultDa ta>
  2825        ActiveDefa ultData
  2826       </DefaultD ata>
  2827       <IdLocatio n>
  2828        ^HS.Local. VA.HS.Regi C1B2.Activ eD
  2829       </IdLocati on>
  2830       <IndexLoca tion>
  2831        ^HS.Local. VA.HS.Regi C1B2.Activ eI
  2832       </IndexLoc ation>
  2833       <StreamLoc ation>
  2834        ^HS.Local. VA.HS.Regi C1B2.Activ eS
  2835       </StreamLo cation>
  2836       <Data 
  2837        name="Acti veDefaultD ata"
  2838       >
  2839        <Structure >
  2840         listnode
  2841        </Structur e>
  2842        <Subscript />
  2843        <Value 
  2844         name="1"
  2845        >
  2846         <Value>
  2847          %%CLASSNAM E
  2848         </Value>
  2849        </Value>
  2850        <Value 
  2851         name="2"
  2852        >
  2853         <Value>
  2854          ICN
  2855         </Value>
  2856        </Value>
  2857        <Value 
  2858         name="3"
  2859        >
  2860         <Value>
  2861          TimeChecke d
  2862         </Value>
  2863        </Value>
  2864       </Data>
  2865      </Storage>
  2866     </Class>
  2867    
  2868    
  2869     <Class 
  2870      name="HS.L ocal.VA.HS .Registry. InactivePa tientLoad. Info"
  2871     >
  2872      <Super>
  2873       %Persisten t
  2874      </Super>
  2875      <TimeChang ed>
  2876       64999,2845 8.716279
  2877      </TimeChan ged>
  2878      <TimeCreat ed>
  2879       64999,2572 5.94938
  2880      </TimeCrea ted>
  2881     
  2882      <Property 
  2883       name="DFN"
  2884      >
  2885       <Type>
  2886        %String
  2887       </Type>
  2888      </Property >
  2889     
  2890      <Property 
  2891       name="Stat ion"
  2892      >
  2893       <Type>
  2894        %String
  2895       </Type>
  2896      </Property >
  2897     
  2898      <Property 
  2899       name="Time Requested"
  2900      >
  2901       <Type>
  2902        %TimeStamp
  2903       </Type>
  2904       <InitialEx pression>
  2905        $zdt($now( ),3,1,3)
  2906       </InitialE xpression>
  2907      </Property >
  2908     
  2909      <Index 
  2910       name="DFNI ndex"
  2911      >
  2912       <Propertie s>
  2913        DFN,Statio n
  2914       </Properti es>
  2915       <Unique>
  2916        1
  2917       </Unique>
  2918      </Index>
  2919     
  2920      <Storage 
  2921       name="Defa ult"
  2922      >
  2923       <Type>
  2924        %Library.C acheStorag e
  2925       </Type>
  2926       <DataLocat ion>
  2927        ^HS.Local. VA.HS.Regi stC1B2.Inf oD
  2928       </DataLoca tion>
  2929       <DefaultDa ta>
  2930        InfoDefaul tData
  2931       </DefaultD ata>
  2932       <IdLocatio n>
  2933        ^HS.Local. VA.HS.Regi stC1B2.Inf oD
  2934       </IdLocati on>
  2935       <IndexLoca tion>
  2936        ^HS.Local. VA.HS.Regi stC1B2.Inf oI
  2937       </IndexLoc ation>
  2938       <StreamLoc ation>
  2939        ^HS.Local. VA.HS.Regi stC1B2.Inf oS
  2940       </StreamLo cation>
  2941       <Data 
  2942        name="Info DefaultDat a"
  2943       >
  2944        <Value 
  2945         name="1"
  2946        >
  2947         <Value>
  2948          %%CLASSNAM E
  2949         </Value>
  2950        </Value>
  2951        <Value 
  2952         name="2"
  2953        >
  2954         <Value>
  2955          DFN
  2956         </Value>
  2957        </Value>
  2958        <Value 
  2959         name="3"
  2960        >
  2961         <Value>
  2962          Station
  2963         </Value>
  2964        </Value>
  2965        <Value 
  2966         name="4"
  2967        >
  2968         <Value>
  2969          TimeReques ted
  2970         </Value>
  2971        </Value>
  2972       </Data>
  2973      </Storage>
  2974     </Class>
  2975    
  2976    
  2977     <Class 
  2978      name="HS.L ocal.VA.HS .Registry. InactivePa tientLoad. Operation"
  2979     >
  2980      <Super>
  2981       Ens.Busine ssOperatio n
  2982      </Super>
  2983      <TimeChang ed>
  2984       65037,4527 5.87245
  2985      </TimeChan ged>
  2986      <TimeCreat ed>
  2987       65002,5403 3.505466
  2988      </TimeCrea ted>
  2989     
  2990      <Property 
  2991       name="Adap ter"
  2992      >
  2993       <Type>
  2994        EnsLib.HTT P.Outbound Adapter
  2995       </Type>
  2996      </Property >
  2997     
  2998      <Parameter  
  2999       name="INVO CATION"
  3000      >
  3001       <Default>
  3002        Queue
  3003       </Default>
  3004      </Paramete r>
  3005     
  3006      <XData 
  3007       name="Mess ageMap"
  3008      >
  3009       <Data>
  3010        <![CDATA[
  3011        <MapItems>
  3012                <M apItem Mes sageType=" HS.Local.V A.HS.Regis try.Messag e.Inactive PatientLoa d.LoadRequ est"> 
  3013                         <Met hod>Load</ Method>
  3014                </ MapItem>
  3015        </MapItems >
  3016        ]]>
  3017       </Data>
  3018      </XData>
  3019     
  3020      <Method 
  3021       name="Load "
  3022      >
  3023       <FormalSpe c>
  3024        pRequest:H S.Local.VA .HS.Regist ry.Message .InactiveP atientLoad .LoadReque st,*pRespo nse:Ens.Re sponse
  3025       </FormalSp ec>
  3026       <ReturnTyp e>
  3027        %Status
  3028       </ReturnTy pe>
  3029       <Implement ation>
  3030        <![CDATA[
  3031                #d im tStatus  As %Statu s = $$$OK
  3032                Tr y {
  3033                         #dim  tHttpRequ est As %Ne t.HttpRequ est = ##cl ass(%Net.H ttpRequest ).%New()
  3034                         Set  tServiceNa me = "Inac tivePatien tLoad."_pR equest.Sta tion
  3035       
  3036                         Set  tServiceOb j = ##clas s(HS.Regis try.Servic e.HTTP).En dPointForN ameType(tS erviceName , "HTTP")
  3037                         If $ IsObject(t ServiceObj ) {
  3038                                  Set tH ttpRequest .SSLConfig uration =  tServiceOb j.SSLConfi g
  3039                                  Set tH ttpRequest .Server =  tServiceOb j.Host
  3040                                  Set tH ttpRequest .Port = tS erviceObj. Port
  3041                                  Set:(t HttpReques t.Port="")  tHttpRequ est.Port =  80
  3042                                  Set tH ttpRequest .Https = ( tServiceOb j.SSLConfi g'="")
  3043                                  Set tH ttpRequest .Timeout=$ Select(tSe rviceObj.T imeout="": 30,tServic eObj.Timeo ut=-1:2123 456789,1:t ServiceObj .Timeout)
  3044                                  If tSe rviceObj.H TTPCredent ialsConfig '="" {
  3045                                           Set tCre dentialsOb j = ##clas s(Ens.Conf ig.Credent ials).%Ope nId(tServi ceObj.HTTP Credential sConfig)
  3046                                           If '$IsO bject($Get (tCredenti alsObj)) {
  3047                                                    Set tStatu s = $$$ERR OR($$$Gene ralError,  "Invalid H TTP Creden tials Conf ig defined  for Servi ce Registr y entry "_ tServiceNa me)
  3048                                                    Quit
  3049                                           }
  3050                                           Set tHtt pRequest.U sername =  tCredentia lsObj.User name
  3051                                           Set tHtt pRequest.P assword =  tCredentia lsObj.Pass word
  3052                                  }
  3053                         } El se {
  3054                                  Set tS tatus = $$ $ERROR($$$ GeneralErr or, "Servi ce Registr y entry fo r "_tServi ceName_" n ot found")
  3055                                  Quit
  3056                         }
  3057                         
  3058                         #dim  tHttpResp onse As %N et.HttpRes ponse = tH ttpRequest .HttpRespo nse
  3059                         
  3060                         $$$L OGINFO("St ation Numb er : "_pRe quest.Stat ion_" "_"D FN Number:  "_pReques t.DFN)
  3061                         set  tEncodedDF N = $Syste m.Encrypti on.Base64E ncode(pReq uest.DFN)
  3062                         If t ServiceObj .SSLConfig  = "" {
  3063                                  Set tP rotocol =  "http://" 
  3064                         } El se {
  3065                                  Set tP rotocol =  "https://"  
  3066                         }
  3067                         Set  tUrl = tPr otocol_tSe rviceObj.H ost_":"_tS erviceObj. Port_tServ iceObj.URL _"/"_tEnco dedDFN
  3068                         //$$ $LOGINFO(" REST URL :  "_tUrl)
  3069                         Set  tStatus =  tHttpReque st.Get(tUr l)
  3070                         Quit :$$$ISERR( tStatus)
  3071                         
  3072                         If $ $$ISOK(tSt atus) && ( tHttpReque st.HttpRes ponse.Stat usCode'=20 0) {
  3073                                  Set tS tatus=$$$E RROR($$$En sErrHTTPSt atus,tHttp Request.Ht tpResponse .StatusCod e,tHttpReq uest.HttpR esponse.St atusLine)
  3074                                  Quit
  3075                                  }
  3076                         
  3077                         Set  tReturn =  tHttpReque st.HttpRes ponse.Data .Read()
  3078                         $$$L OGINFO("JS ON Respons e :"_tRetu rn)
  3079                         Set  tReturnIte ms = ##cla ss(%Dynami cAbstractO bject).%Fr omJSON(tHt tpRequest. HttpRespon se.Data)
  3080                     Set tGet Status = t ReturnItem s.%Get("Re sponse")
  3081                     //$$$LOG INFO("Stat us Code :" _tGetStatu s.StatusCo de)
  3082                     
  3083                         If t GetStatus. StatusCode  = 0 {
  3084                                  Set tS tatus = $$ $ERROR($$$ GeneralErr or,"OnDema nd Request  DFN Not F ound")
  3085                                  Quit
  3086                         }
  3087                         
  3088                         
  3089                }  Catch (tEx ) {
  3090                         Set  tStatus =  tEx.AsStat us()
  3091                }
  3092                Qu it tStatus
  3093        ]]>
  3094       </Implemen tation>
  3095      </Method>
  3096     </Class>
  3097    
  3098    
  3099     <Class 
  3100      name="HS.L ocal.VA.HS .Registry. InactivePa tientLoad. Process"
  3101     >
  3102      <Super>
  3103       Ens.Busine ssProcess, HS.Util.Tr ace.Helper
  3104      </Super>
  3105      <TimeChang ed>
  3106       65022,5269 4.990337
  3107      </TimeChan ged>
  3108      <TimeCreat ed>
  3109       64998,6693 7.87972
  3110      </TimeCrea ted>
  3111     
  3112      <Parameter  
  3113       name="SETT INGS"
  3114      >
  3115       <Type>
  3116        %String
  3117       </Type>
  3118       <Default>
  3119        PatientSea rch,Target ,LoadProce ssingInter val
  3120       </Default>
  3121      </Paramete r>
  3122     
  3123      <Property 
  3124       name="Pati entSearch"
  3125      >
  3126       <Descripti on>
  3127        Patient Se arch with  MVI Operat ion
  3128       </Descript ion>
  3129       <Type>
  3130        Ens.DataTy pe.ConfigN ame
  3131       </Type>
  3132       <InitialEx pression>
  3133        "VA.MVI.PD Qv3.Consum er.Operati ons"
  3134       </InitialE xpression>
  3135      </Property >
  3136     
  3137      <Property 
  3138       name="Targ et"
  3139      >
  3140       <Descripti on>
  3141        Inactive P atient Loa d Operatio n
  3142       </Descript ion>
  3143       <Type>
  3144        Ens.DataTy pe.ConfigN ame
  3145       </Type>
  3146       <InitialEx pression>
  3147        "VA.Inacti vePatientL oad.Operat ion"
  3148       </InitialE xpression>
  3149      </Property >
  3150     
  3151      <Property 
  3152       name="Load Processing Interval"
  3153      >
  3154       <Type>
  3155        %Integer
  3156       </Type>
  3157       <InitialEx pression>
  3158        "10080"
  3159       </InitialE xpression>
  3160      </Property >
  3161     
  3162      <Method 
  3163       name="OnRe quest"
  3164      >
  3165       <FormalSpe c>
  3166        pRequest:E ns.Request ,*pRespons e:Ens.Resp onse
  3167       </FormalSp ec>
  3168       <ReturnTyp e>
  3169        %Status
  3170       </ReturnTy pe>
  3171       <Implement ation>
  3172        <![CDATA[
  3173                tr y {
  3174                         Set  tSC=$$$OK
  3175                         #; r equest fro m HS.Hub.M PI.PostPro cessor
  3176                         If p Request.%I sA("HS.Mes sage.Patie ntSearchRe quest") {
  3177                                  Set tS C = ..Sear chAndLoadP atient(pRe quest,.pRe sponse)
  3178                         } El seIf pRequ est.%IsA(" HS.Message .PatientSe archRespon se") {
  3179                                  Set tS C = ..Load Patient(pR equest,.pR esponse)
  3180                         } El se {
  3181                                  $$$LOG ERROR("Unh andled req uest:"_pRe quest)
  3182                         }
  3183                }  catch ex {
  3184                         set  tSC=ex.AsS tatus()
  3185                }
  3186                Qu it tSC
  3187        ]]>
  3188       </Implemen tation>
  3189      </Method>
  3190     
  3191      <Method 
  3192       name="Sear chAndLoadP atient"
  3193      >
  3194       <FormalSpe c>
  3195        pRequest:H S.Message. PatientSea rchRequest ,*pRespons e:%Library .Persisten t
  3196       </FormalSp ec>
  3197       <ReturnTyp e>
  3198        %Status
  3199       </ReturnTy pe>
  3200       <Implement ation>
  3201        <![CDATA[
  3202                tr y {
  3203                         Set  tSC=$$$OK
  3204                         Set  pResponse  = ""
  3205                         
  3206                         Set  tSearchRes ponse = ## class(HS.M essage.Pat ientSearch Response). %New()
  3207                         
  3208                     $$$Throw OnError(.. SendReques tSync(..Pa tientSearc h,pRequest ,.tSearchR esponse)) 
  3209                         $$$H STRACE("Re sponse fro m MVI Look up (in ina ctive load  logic) ", "pRequest, tSearchRes ponse",pRe quest,tSea rchRespons e)
  3210                         
  3211                      // No R esponse fr om MVI wit h Timeout/ SOAP Fault
  3212                         If ' $isObject( tSearchRes ponse) ||  (tSearchRe sponse=$$$ NULLOREF)  {
  3213                                  
  3214                                  $$$LOG ERROR("No  valid resp onse to Re quest for  ICN: "_pRe quest.MPII D)
  3215                                  set tS C=$$$ERROR ($$$Genera lError,"No  Valid Res ponse from  MVI")
  3216                                  
  3217                         } El seIf (tSea rchRespons e.ResultsC ount = 0)  { // No Er ror from M VI but no  Patient Ma tch
  3218                                  
  3219                                  $$$LOG ALERT("No  Patient Ma tch Found  for ICN: " _pRequest. MPIID)
  3220                                  set tS C=$$$ERROR ($$$Genera lError,"No  Patient M atch")
  3221                                  
  3222                         } El se {
  3223                                  set tS C=..LoadPa tient(tSea rchRespons e)
  3224                         }
  3225                }  catch ex {
  3226                         set  tSC=ex.AsS tatus()
  3227                }
  3228                Qu it tSC
  3229        ]]>
  3230       </Implemen tation>
  3231      </Method>
  3232     
  3233      <Method 
  3234       name="Load Patient"
  3235      >
  3236       <FormalSpe c>
  3237        pRequest:H S.Message. PatientSea rchRespons e,*pRespon se:%Librar y.Persiste nt
  3238       </FormalSp ec>
  3239       <ReturnTyp e>
  3240        %Status
  3241       </ReturnTy pe>
  3242       <Implement ation>
  3243        <![CDATA[
  3244                tr y {
  3245                         Set  tSC=$$$OK
  3246                         Set  pResponse  = ""
  3247                         
  3248                         Set  tIdentifie rs = pRequ est.Result s.GetAt(1) .Identifie rs
  3249                         #dim  tIdentifi er As HS.T ypes.Ident ifier
  3250                         For  tIdx=1:1:t Identifier s.Count()  {
  3251                                  Set tD FN = ""
  3252                                  Set tS tation = " "                
  3253                                  Set tI dentifier  = tIdentif iers.GetAt (tIdx)
  3254                                  If ($P (tIdentifi er.Extensi on, "^",2)  = "PI") & & (tIdenti fier.Root  = "USVHA")  {
  3255                                           Set tDFN  = $P(tIde ntifier.Ex tension, " ^",1)
  3256                                           Set tSta tion = $P( tIdentifie r.Extensio n, "^",3)
  3257                                  }
  3258                                  Contin ue:(tStati on="")
  3259                                  Contin ue:(tDFN=" ")
  3260                                  Set tS ervice=##c lass(HS.Re gistry.Ser vice.HTTP) .EndPointF orNameType ("Inactive PatientLoa d."_tStati on,"HTTP")
  3261                                  Contin ue:(tServi ce="")
  3262                                  $$$HST RACE("In L oadPatient : Service  Registry I nfo","tSer vice,tDFN, tSC",tServ ice,tDFN,t SC)
  3263                                  
  3264                                  Contin ue:(##clas s(HS.Regis try.Patien t).MRNInde xExists(tD FN,tStatio n,tStation ))
  3265                                  
  3266                                  Set tI nfo = ##cl ass(HS.Loc al.VA.HS.R egistry.In activePati entLoad.In fo).DFNInd exOpen(tDF N,tStation )
  3267                                  $$$HST RACE("In L oadPatient  : DFN","t Info,tSC", tInfo,tSC)
  3268                                  If (tI nfo = "")  {
  3269                                           Set tInf o = ##clas s(HS.Local .VA.HS.Reg istry.Inac tivePatien tLoad.Info ).%New()
  3270                                           Set tInf o.DFN = tD FN
  3271                                           Set tInf o.Station  = tStation
  3272                                           Set tSC  = tInfo.%S ave()
  3273                                  } Else  {
  3274                                           Set tCur rentTime =  $zdt($now (),3,1,3)
  3275                                           Set tTim ePassed =  $System.SQ L.DATEDIFF ("minute", tInfo.Time Requested, tCurrentTi me)
  3276                                           If (tTim ePassed <  ..LoadProc essingInte rval) {
  3277                                                    Continue
  3278                                           } Else {
  3279                                                    Set tInfo. TimeReques ted = tCur rentTime
  3280                                                    Set tSC =  tInfo.%Sav e()
  3281                                           }
  3282                                  }
  3283                                  If $$$ ISERR(tSC)  $$$LOGERR OR("Error  on saving  Inactive P atient Loa d Info")
  3284                                  Contin ue:($$$ISE RR(tSC))
  3285                                  
  3286                                  
  3287                                  Set tL oadMessage  = ##class (HS.Local. VA.HS.Regi stry.Messa ge.Inactiv ePatientLo ad.LoadReq uest).%New ()
  3288                                  Set tL oadMessage .DFN = tDF N
  3289                                  Set tL oadMessage .Station =  tStation
  3290                                  
  3291                                  Set tS C = ..Send RequestAsy nc(..Targe t,tLoadMes sage,0)
  3292                                  If $$$ ISERR(tSC)  $$$LOGERR OR("Error  on sending  to Inacti ve Patient  Load Oper ation: "_$ system.Sta tus.GetErr orText(tSC ))
  3293                         }
  3294                         
  3295                }  catch ex {
  3296                         set  tSC=ex.AsS tatus()
  3297                         $$$L OGERROR("E rror in In active Pat ient Load  Process: " _$system.S tatus.GetE rrorText(t SC))
  3298                }
  3299                Qu it tSC
  3300        ]]>
  3301       </Implemen tation>
  3302      </Method>
  3303     
  3304      <Method 
  3305       name="HasT reatingFac ilities"
  3306      >
  3307       <Descripti on>
  3308        Check faci lities in  the search  response  against th e inactive  load endp oints defi ned in Ser vice Regis try.
  3309        When pAlso InactiveCh eck is set  to 0, the  method ch ecks for a ny treatin g faciliti es that pa tient may  have. 
  3310        When pAlso InactiveCh eck is set  to 1, the  method ch ecks for a ny treatin g faciliti es that ha ve not yet  been load ed.
  3311       </Descript ion>
  3312       <ClassMeth od>
  3313        1
  3314       </ClassMet hod>
  3315       <FormalSpe c>
  3316        pRequest:H S.Message. PatientSea rchRespons e,pAlsoIna ctiveCheck :%Boolean= 0
  3317       </FormalSp ec>
  3318       <ReturnTyp e>
  3319        %Boolean
  3320       </ReturnTy pe>
  3321       <Implement ation>
  3322        <![CDATA[
  3323                Se t tIdentif iers = pRe quest.Resu lts.GetAt( 1).Identif iers
  3324                #d im tIdenti fier As HS .Types.Ide ntifier
  3325                Fo r tIdx=1:1 :tIdentifi ers.Count( ) {
  3326                         Set  tDFN = ""
  3327                         Set  tStation =  ""                
  3328                         Set  tIdentifie r = tIdent ifiers.Get At(tIdx)
  3329                         If ( $P(tIdenti fier.Exten sion, "^", 2) = "PI")  && (tIden tifier.Roo t = "USVHA ") {
  3330                                  Set tD FN = $P(tI dentifier. Extension,  "^",1)
  3331                                  Set tS tation = $ P(tIdentif ier.Extens ion, "^",3 )
  3332                                  $$$LOG INFO(("DFN : "_tDFN_"  "))
  3333                                  $$$LOG INFO(("Sta tion: "_tS tation_" " ))
  3334                         }
  3335                         Cont inue:(tSta tion="")
  3336                         Cont inue:(tDFN ="")
  3337                         Set  tService=# #class(HS. Registry.S ervice.HTT P).EndPoin tForNameTy pe("Inacti vePatientL oad."_tSta tion,"HTTP ")
  3338                         $$$L OGINFO(("E ndpoint: " _tService_ " "))
  3339                         Cont inue:(tSer vice="")
  3340                         
  3341                         If p AlsoInacti veCheck {
  3342                                  Contin ue:(##clas s(HS.Regis try.Patien t).MRNInde xExists(tD FN,tStatio n,tStation ))
  3343                         }
  3344                         Retu rn 1
  3345                }
  3346                         
  3347                Re turn 0
  3348        ]]>
  3349       </Implemen tation>
  3350      </Method>
  3351     
  3352      <Method 
  3353       name="Filt erFacility "
  3354      >
  3355       <ClassMeth od>
  3356        1
  3357       </ClassMet hod>
  3358       <FormalSpe c>
  3359        <![CDATA[& pRequest:H S.Message. PatientSea rchRespons e,pDFN:%St ring,pStat ion:%Strin g]]>
  3360       </FormalSp ec>
  3361       <Implement ation>
  3362        <![CDATA[
  3363                Tr y {
  3364                         Set  tIdentifie rs = pRequ est.Result s.GetAt(1) .Identifie rs
  3365                         #dim  tIdentifi er As HS.T ypes.Ident ifier
  3366                         For  tIdx=tIden tifiers.Co unt():-1:1  {
  3367                                  Set tI dentifier  = tIdentif iers.GetAt (tIdx)
  3368                                  If ($P (tIdentifi er.Extensi on, "^",2)  = "PI") & & (tIdenti fier.Root  = "USVHA")  {
  3369                                           If ($P(t Identifier .Extension , "^",1) =  pDFN) &&  ($P(tIdent ifier.Exte nsion, "^" ,3) = pSta tion) {
  3370                                                    Do tIdenti fiers.Remo veAt(tIdx)
  3371                                           }
  3372                                  }
  3373                         }
  3374                }  Catch {}
  3375        ]]>
  3376       </Implemen tation>
  3377      </Method>
  3378     
  3379      <Storage 
  3380       name="Defa ult"
  3381      >
  3382       <Type>
  3383        %Library.C acheStorag e
  3384       </Type>
  3385       <DefaultDa ta>
  3386        ProcessDef aultData
  3387       </DefaultD ata>
  3388       <Data 
  3389        name="Proc essDefault Data"
  3390       >
  3391        <Subscript >
  3392         "Process"
  3393        </Subscrip t>
  3394        <Value 
  3395         name="1"
  3396        >
  3397         <Value>
  3398          PatientSea rch
  3399         </Value>
  3400        </Value>
  3401        <Value 
  3402         name="2"
  3403        >
  3404         <Value>
  3405          Target
  3406         </Value>
  3407        </Value>
  3408        <Value 
  3409         name="3"
  3410        >
  3411         <Value>
  3412          TraceOpera tions
  3413         </Value>
  3414        </Value>
  3415        <Value 
  3416         name="4"
  3417        >
  3418         <Value>
  3419          LoadProces singInterv al
  3420         </Value>
  3421        </Value>
  3422       </Data>
  3423      </Storage>
  3424     </Class>
  3425    
  3426    
  3427     <Package 
  3428      name="HS.L ocal.VA.HS .Registry. InactivePa tientLoad"  
  3429      sqlname="H S_Local_VA _HS_Regist ry_Inactiv ePatientLo ad"
  3430     />
  3431    
  3432    
  3433     <Class 
  3434      name="HS.L ocal.VA.HS .Registry. MVI.Operat ions"
  3435     >
  3436      <Super>
  3437       HS.MPI.Abs tractSOAPB asedMPIOpe rations,HS .Util.Trac e.Helper
  3438      </Super>
  3439      <TimeChang ed>
  3440       65028,5256 7.555299
  3441      </TimeChan ged>
  3442      <TimeCreat ed>
  3443       64813,3688 2.908817
  3444      </TimeCrea ted>
  3445     
  3446      <Parameter  
  3447       name="INVO CATION"
  3448      >
  3449       <Default>
  3450        InProc
  3451       </Default>
  3452      </Paramete r>
  3453     
  3454      <Parameter  
  3455       name="SETT INGS"
  3456      >
  3457       <Type>
  3458        %String
  3459       </Type>
  3460       <Default>
  3461        PatientSea rch,Regist erInterest ,InactiveP atientLoad
  3462       </Default>
  3463      </Paramete r>
  3464     
  3465      <Parameter  
  3466       name="XSLT DIR"
  3467      >
  3468       <Descripti on>
  3469        XSLT subdi r for styl esheets
  3470       </Descript ion>
  3471       <Type>
  3472        %String
  3473       </Type>
  3474      </Paramete r>
  3475     
  3476      <Parameter  
  3477       name="XSLT SPEC"
  3478      >
  3479       <Descripti on>
  3480        XSLT files pec for st ylesheets
  3481       </Descript ion>
  3482       <Type>
  3483        %String
  3484       </Type>
  3485       <Default>
  3486        *.xsl
  3487       </Default>
  3488      </Paramete r>
  3489     
  3490      <Property 
  3491       name="Pati entSearch"
  3492      >
  3493       <Descripti on>
  3494        Patient Se arch with  MVI Operat ion
  3495       </Descript ion>
  3496       <Type>
  3497        Ens.DataTy pe.ConfigN ame
  3498       </Type>
  3499       <InitialEx pression>
  3500        "VA.MVI.PD Qv3.Consum er.Operati ons"
  3501       </InitialE xpression>
  3502      </Property >
  3503     
  3504      <Property 
  3505       name="Regi sterIntere st"
  3506      >
  3507       <Descripti on>
  3508        Patient Se arch with  Register I nterest
  3509       </Descript ion>
  3510       <Type>
  3511        Ens.DataTy pe.ConfigN ame
  3512       </Type>
  3513       <InitialEx pression>
  3514        "VA.MVI.PD Qv3.Consum er.Operati ons.DFN"
  3515       </InitialE xpression>
  3516      </Property >
  3517     
  3518      <Property 
  3519       name="ESRO perations"
  3520      >
  3521       <Descripti on>
  3522        ESR Operat ion for Se condary De mographics
  3523       </Descript ion>
  3524       <Type>
  3525        Ens.DataTy pe.ConfigN ame
  3526       </Type>
  3527       <InitialEx pression>
  3528        "VA.ESR.Op erations"
  3529       </InitialE xpression>
  3530      </Property >
  3531     
  3532      <Property 
  3533       name="Inac tivePatien tLoad"
  3534      >
  3535       <Descripti on>
  3536        Inactive P atient Loa d Process
  3537       </Descript ion>
  3538       <Type>
  3539        Ens.DataTy pe.ConfigN ame
  3540       </Type>
  3541       <InitialEx pression>
  3542        "VA.Inacti vePatientL oad.Proces s"
  3543       </InitialE xpression>
  3544      </Property >
  3545     
  3546      <XData 
  3547       name="Mess ageMap"
  3548      >
  3549       <Data>
  3550        <![CDATA[
  3551        <MapItems>
  3552                <M apItem Mes sageType=" HS.Message .PatientSe archReques t"> 
  3553                         <Met hod>Patien tSearch</M ethod>
  3554                </ MapItem>
  3555                <M apItem Mes sageType=" HS.Message .AddUpdate HubRequest ">
  3556                         <Met hod>Mainta inPatient< /Method>
  3557                </ MapItem>
  3558                <M apItem Mes sageType=" HS.Message .AddPatien tRequest">
  3559                         <Met hod>AddPat ient</Meth od>
  3560                </ MapItem>
  3561        </MapItems >
  3562        ]]>
  3563       </Data>
  3564      </XData>
  3565     
  3566      <Method 
  3567       name="Pati entSearch"
  3568      >
  3569       <Descripti on>
  3570        Patient Se arch Metho d
  3571       </Descript ion>
  3572       <FormalSpe c>
  3573        pRequest:H S.Message. PatientSea rchRequest ,*pRespons e:HS.Messa ge.Patient SearchResp onse
  3574       </FormalSp ec>
  3575       <ReturnTyp e>
  3576        %Status
  3577       </ReturnTy pe>
  3578       <Implement ation>
  3579        <![CDATA[
  3580          
  3581          
  3582          #dim tSC  As %Statu s = $$$OK
  3583          #dim exc eption As  %Exception rchRespons e.Abstract Exception
  3584          #dim tRe sponse As  HS.Message .PatientSe archRespon se
  3585          
  3586          Set pRes ponse=##Cl ass(HS.Mes sage.Patie ntSearchRe sponse).%N ew()
  3587          Do pRequ est.Additi onalInfo.S etAt(1,"Se archReques t")
  3588          
  3589          
  3590                tr y {
  3591                         
  3592                         $$$T hrowOnErro r(..SendRe questSync( ..PatientS earch, pRe quest, .pR esponse))
  3593                         $$$H STRACE("Re sponse fro m MVI Look up ","pRes ponse",pRe sponse)
  3594       
  3595                      // No R esponse fr om MVI wit h Timeout/ SOAP Fault
  3596                         If ' $isObject( pResponse)  || (pResp onse=$$$NU LLOREF) {
  3597                                           $$$LOGER ROR("No va lid respon se to Requ est for IC N: "_pRequ est.FirstN ame_" "_pR equest.Las tName_", S tation Num ber: "_pRe quest.Faci lity)
  3598                         } 
  3599                         // N o Error fr om MVI but  no Patien t Match
  3600                         If ( pResponse. ResultsCou nt = 0) {        
  3601                                           $$$LOGAL ERT("No Pa tient Matc h Found fo r Patient  Name: "_pR equest.Fir stName_" " _pRequest. LastName_" , Station  Number: "_ pRequest.F acility)                           
  3602                         } 
  3603                         
  3604                
  3605          } catch  exception  {
  3606                s  tSC = exce ption.AsSt atus()    
  3607          }
  3608          
  3609          quit tSC
  3610        ]]>
  3611       </Implemen tation>
  3612      </Method>
  3613     
  3614      <Method 
  3615       name="AddP atient"
  3616      >
  3617       <FormalSpe c>
  3618        pRequest:H S.Message. AddPatient Request,*p Response:H S.Message. AddPatient Response
  3619       </FormalSp ec>
  3620       <ReturnTyp e>
  3621        %Status
  3622       </ReturnTy pe>
  3623       <Implement ation>
  3624        <![CDATA[
  3625       
  3626                #d im excepti on as %Exc eption.Abs tractExcep tion
  3627                #d im tSC as  %Status =  $$$OK
  3628                #d im tSearch Request as  HS.Messag e.PatientS earchReque st
  3629                #d im tSearch Response a s HS.Messa ge.Patient SearchResp onse
  3630                #d im tAddUpd ateRequest  As HS.Mes sage.AddPa tientReque st
  3631                #d im tESRRes ponse as H S.Local.VA .HS.Regist ry.Message .ESR.getEE SummaryRes ponse
  3632                
  3633                Se t tKey = " "
  3634                Se t tKeyType  = ""
  3635                
  3636                If  (pRequest .Facility  = "EF") {
  3637                                  Set pR esponse =  ##class(HS .Message.A ddPatientR esponse).% New()
  3638                                  Set pR esponse.Pa tientId =  pRequest.M PIID
  3639                                  Set pR esponse.MP IUpdateFla g = 0
  3640                                  Quit $ $$OK      
  3641                }
  3642                         
  3643                tr y {
  3644                         ///  Convert pR equest fro m HS.Messa ge.AddPati entRequest  to HS.Mes sage.Patie ntSearchRe quest
  3645                         Set  tSearchReq uest = ##c lass(HS.Me ssage.Pati entSearchR equest).%N ew()
  3646                         Set  tSearchRes ponse = ## class(HS.M essage.Pat ientSearch Response). %New()
  3647                         
  3648                         Set  tSearchReq uest.Searc hMode = "P IXPDQ"
  3649                         Set  tSearchReq uest.Name  = "PDQv3_Q ueryReques t"
  3650                         Set  tSearchReq uest.Facil ity = pReq uest.Facil ity
  3651                         Set  tSearchReq uest.MRN =  pRequest. MRN
  3652                         Set  tSearchReq uest.Assig ningAuthor ity = pReq uest.Assig ningAuthor ity
  3653                     Do tSear chRequest. Additional Info.SetAt (1,"Regist erInterest ")
  3654                
  3655                         // R egister In terest wit h MVI
  3656                     set tSC  = ..SendRe questSync( ..Register Interest,t SearchRequ est,.tSear chResponse
  3657                         $$$H STRACE("Re sponse fro m MVI Look up with Re gister Int erest ","t SearchRequ est,tSearc hResponse, tSC",tSear chRequest, tSearchRes ponse,tSC)
  3658                         
  3659                      // No R esponse fr om MVI wit h Timeout/ SOAP Fault
  3660                         If ' $isObject( tSearchRes ponse) ||  (tSearchRe sponse=$$$ NULLOREF)  {
  3661                                  
  3662                                  $$$LOG ERROR("No  valid resp onse to Re quest for  ICN: "_pRe quest.Firs tName_" "_ pRequest.L astName_",  Station N umber: "_p Request.Fa cility)
  3663                                  Quit
  3664                                           
  3665                         } El seIf (tSea rchRespons e.ResultsC ount = 0)  { // No Er ror from M VI but no  Patient Ma tch
  3666                         
  3667                                  $$$LOG ALERT("No  Patient Ma tch Found  for Patien t MRN: "_p Request.MR N_", Stati on Number:  "_pReques t.Facility )
  3668                                  set tS C=$$$ERROR ($$$Genera lError,"No  Patient M atch")
  3669                                  Quit
  3670                         
  3671                         }
  3672                
  3673                         set  tSC = ..Ca llESR(tSea rchRespons e.Results. GetAt(1).M PIID, .tde mo)
  3674                                  
  3675                         If $ isObject(t demo){
  3676                                  #dim t Match As H S.Message. PatientSea rchMatch
  3677                                  Set tM atch = ##c lass(HS.Me ssage.Pati entSearchM atch).%New ()
  3678       
  3679                                  Set tR eligion =  tdemo.reli gion
  3680                                  Set tE thnicGroup  = tdemo.e thnicity
  3681                                  Set tF acility =  tdemo.pref erredFacil ity
  3682                                  Set tM aritalStat us = tdemo .maritalSt atus
  3683                                  
  3684                                  For tI =1:1:tdemo .races.Cou nt() {
  3685                                           Set tRac eIn=tdemo. races.GetA t(tI)
  3686                                           Set tRac eOut=##cla ss(HS.SDA3 .CodeTable Detail.Rac e).%New()
  3687                                           Set tRac eOut.Code= tRaceIn
  3688                                           Set tRac eOut.Descr iption=tRa ceIn
  3689                                           Do tMatc h.Extensio n.Authorit ativeRaces .Insert(tR aceOut)          
  3690                                  }
  3691                                  
  3692                                  Set tM atch.Relig iousAffili ation = tR eligion
  3693                                  Set tM atch.Ethni cGroup = t EthnicGrou p
  3694                                  Set tM atch.Marit alStatus =  tMaritalS tatus
  3695                                  Set tM atch.Exten sion.Prefe rredFacili ty = tFaci lity
  3696                                  
  3697                                  Do tSe archRespon se.Results .Insert(tM atch)
  3698                         }
  3699                         
  3700                //  Now add E nterprise  Facility p atient to  Patient Re gistry
  3701                         $$$H STRACE("Ad d MVI Pati ent","tSea rchRespons e", tSearc hResponse)
  3702                         set  tSC = ..Ad dMVIPatien t(tSearchR esponse,.t AddUpdateR equest)
  3703                         $$$H STRACE("Cr eate MVI p atient","t SC,tSearch Reponse,tA ddUpdateRe quest",tSC ,tSearchRe sponse,tAd dUpdateReq uest)
  3704       
  3705                se t tSC = .. SendReques tSync("HS. Hub.MPI.Ma nager",tAd dUpdateReq uest,.tRes ponse)
  3706                         $$$H STRACE("Fi nish Add P atient","t SC,tAddUpd ateRequest ,tResponse ",tSC,tAdd UpdateRequ est,tRespo nse)
  3707                         
  3708                         If ( ..Inactive PatientLoa d '= "") {
  3709                                  //inac tive patie nt data ma y be avail able so co ntinue wit h the inac tive patie nt load pr ocess
  3710                                  
  3711                                  // Rem ove the DF N currentl y being lo aded. Crea te a Clone  of the Se archRespon se to send  to Inacti ve Load Pr ocess. 
  3712                                  Set tN ewSearchRe sponse=tSe archRespon se.%Constr uctClone(1 )
  3713                                  Do ##c lass(HS.Lo cal.VA.HS. Registry.I nactivePat ientLoad.P rocess).Fi lterFacili ty(.tNewSe archRespon se,pReques t.MRN,pReq uest.Facil ity)
  3714                                  
  3715                                  Set tS C2 = ..Sen dRequestAs ync(..Inac tivePatien tLoad,tNew SearchResp onse)
  3716                                  If $$$ ISERR(tSC2 ) $$$LOGER ROR("Error  on sendin g to Inact ive Patien t Load Pro cess: "_$s ystem.Stat us.GetErro rText(tSC2 ))
  3717                         }
  3718                         
  3719                         Set  pResponse  = ##class( HS.Message .AddPatien tResponse) .%New()
  3720                         Set  pResponse. PatientId  = tSearchR esponse.Re sults.GetA t(1).MPIID
  3721                         Set  pResponse. MPIUpdateF lag = 1
  3722       
  3723                }  catch exce ption {
  3724                         $$$L OGALERT(ex ception.Co de_": "_ex ception.Na me)
  3725                     s tSC =  exception. AsStatus()
  3726                }
  3727                
  3728                Qu it tSC
  3729        ]]>
  3730       </Implemen tation>
  3731      </Method>
  3732     
  3733      <Method 
  3734       name="AddM VIPatient"
  3735      >
  3736       <ClassMeth od>
  3737        1
  3738       </ClassMet hod>
  3739       <FormalSpe c>
  3740        pRequest:H S.Message. PatientSea rchRespons e,*pAddUpd ateRequest :HS.Messag e.AddUpdat eHubReques t
  3741       </FormalSp ec>
  3742       <ReturnTyp e>
  3743        %Status
  3744       </ReturnTy pe>
  3745       <Implement ation>
  3746        <![CDATA[
  3747                
  3748                Se t tSC=$$$O K
  3749                se t pAddUpda teRequest= ##class(HS .Message.A ddUpdateHu bRequest). %New()
  3750       
  3751                se t pAddUpda teRequest. LastName =  pRequest. Results.Ge tAt(1).Las tName
  3752                se t pAddUpda teRequest. FirstName  = pRequest .Results.G etAt(1).Fi rstName
  3753                se t pAddUpda teRequest. MiddleName  = pReques t.Results. GetAt(1).M iddleName
  3754                se t pAddUpda teRequest. Suffix = p Request.Re sults.GetA t(1).Suffi x
  3755                se t pAddUpda teRequest. Prefix = p Request.Re sults.GetA t(1).Prefi x
  3756                
  3757                se t tAddress =##class(H S.Types.Ad dress).%Ne w()
  3758                If  '(pReques t.Results. GetAt(1).A ddresses.% IsNull())  {
  3759                         set  tAddress.S treetLine= pRequest.R esults.Get At(1).Addr esses.GetA t(1).Stree tLine
  3760                         set  tAddress.C ity=pReque st.Results .GetAt(1). Addresses. GetAt(1).C ity
  3761                         set  tAddress.S tate=pRequ est.Result s.GetAt(1) .Addresses .GetAt(1). State
  3762                         set  tAddress.C ountry=pRe quest.Resu lts.GetAt( 1).Address es.GetAt(1 ).Country
  3763                         set  tAddress.P ostalCode= pRequest.R esults.Get At(1).Addr esses.GetA t(1).Posta lCode
  3764                         set  tAddress.U se = pRequ est.Result s.GetAt(1) .Addresses .GetAt(1). Use            
  3765                         do p AddUpdateR equest.Add resses.Ins ert(tAddre ss)
  3766                }
  3767                se t pAddUpda teRequest. DOB = pReq uest.Resul ts.GetAt(1 ).DOB
  3768                se t pAddUpda teRequest. BirthOrder  = pReques t.Results. GetAt(1).B irthOrder
  3769                se t pAddUpda teRequest. Communicat ionPrefere nce = pReq uest.Resul ts.GetAt(1 ).Communic ationPrefe rence
  3770                se t pAddUpda teRequest. CreatedBy  = pRequest .Results.G etAt(1).Cr eatedBy
  3771                se t pAddUpda teRequest. CustomClas sName = pR equest.Res ults.GetAt (1).Custom ClassName
  3772                se t pAddUpda teRequest. CustomXMLS tring = pR equest.Res ults.GetAt (1).Custom XMLString
  3773                se t pAddUpda teRequest. DeathTime  = pRequest .Results.G etAt(1).De athTime
  3774                If  pAddUpdat eRequest.D eathTime]" " set pAdd UpdateRequ est.DeathS tatus = 1 
  3775                se t pAddUpda teRequest. Language =  pRequest. Results.Ge tAt(1).Lan guage
  3776                se t pAddUpda teRequest. LastEntere dBy = pReq uest.Resul ts.GetAt(1 ).LastEnte redBy
  3777                se t pAddUpda teRequest. LastEntere dOn = pReq uest.Resul ts.GetAt(1 ).LastEnte redOn
  3778       
  3779                se t pAddUpda teRequest. MothersMai denSurname  = pReques t.Results. GetAt(1).M othersMaid enSurname
  3780                
  3781                se t pAddUpda teRequest. VIP = pReq uest.Resul ts.GetAt(1 ).VIP
  3782                
  3783                se t pAddUpda teRequest. BirthPlace .City = pR equest.Res ults.GetAt (1).BirthP lace.City
  3784                se t pAddUpda teRequest. BirthPlace .Country =  pRequest. Results.Ge tAt(1).Bir thPlace.Co untry
  3785                se t pAddUpda teRequest. BirthPlace .Descripti on = pRequ est.Result s.GetAt(1) .BirthPlac e.Descript ion
  3786                se t pAddUpda teRequest. BirthPlace .POBox = p Request.Re sults.GetA t(1).Birth Place.POBo x
  3787                se t pAddUpda teRequest. BirthPlace .PostalCod e = pReque st.Results .GetAt(1). BirthPlace .PostalCod e
  3788                se t pAddUpda teRequest. BirthPlace .Precinct  = pRequest .Results.G etAt(1).Bi rthPlace.P recinct
  3789                se t pAddUpda teRequest. BirthPlace .PrimaryFl ag = pRequ est.Result s.GetAt(1) .BirthPlac e.PrimaryF lag
  3790                se t pAddUpda teRequest. BirthPlace .State = p Request.Re sults.GetA t(1).Birth Place.Stat e
  3791                se t pAddUpda teRequest. BirthPlace .StreetLin e = pReque st.Results .GetAt(1). BirthPlace .StreetLin e
  3792                se t pAddUpda teRequest. BirthPlace .UnitNumbe r = pReque st.Results .GetAt(1). BirthPlace .UnitNumbe r
  3793                se t pAddUpda teRequest. BirthPlace .Use = pRe quest.Resu lts.GetAt( 1).BirthPl ace.Use
  3794                
  3795                If  '(pReques t.Results. GetAt(1).F athersName .%IsNull() )  {
  3796                         set  pAddUpdate Request.Fa thersName. Family = p Request.Re sults.GetA t(1).Fathe rsName.Fam ily
  3797                         set  pAddUpdate Request.Fa thersName. Given= pRe quest.Resu lts.GetAt( 1).Fathers Name.Given
  3798                         set  pAddUpdate Request.Fa thersName. Middle = p Request.Re sults.GetA t(1).Fathe rsName.Mid dle
  3799                         set  pAddUpdate Request.Fa thersName. Prefix = p Request.Re sults.GetA t(1).Fathe rsName.Pre fix
  3800                         set  pAddUpdate Request.Fa thersName. Suffix = p Request.Re sults.GetA t(1).Fathe rsName.Suf fix
  3801                         set  pAddUpdate Request.Fa thersName. Type = pRe quest.Resu lts.GetAt( 1).Fathers Name.Type
  3802                }
  3803                If  '(pReques t.Results. GetAt(1).M othersName .%IsNull() )  {
  3804                         set  pAddUpdate Request.Mo thersName. Family = p Request.Re sults.GetA t(1).Mothe rsName.Fam ily
  3805                         set  pAddUpdate Request.Mo thersName. Given= pRe quest.Resu lts.GetAt( 1).Mothers Name.Given
  3806                         set  pAddUpdate Request.Mo thersName. Middle = p Request.Re sults.GetA t(1).Mothe rsName.Mid dle
  3807                         set  pAddUpdate Request.Mo thersName. Prefix = p Request.Re sults.GetA t(1).Mothe rsName.Pre fix
  3808                         set  pAddUpdate Request.Mo thersName. Suffix = p Request.Re sults.GetA t(1).Mothe rsName.Suf fix
  3809                         set  pAddUpdate Request.Mo thersName. Type = pRe quest.Resu lts.GetAt( 1).Mothers Name.Type
  3810                }
  3811                If  '(pReques t.Results. GetAt(1).S pousesName .%IsNull() )  {
  3812                         set  pAddUpdate Request.Sp ousesName. Family = p Request.Re sults.GetA t(1).Spous esName.Fam ily
  3813                         set  pAddUpdate Request.Sp ouseName.G iven= pReq uest.Resul ts.GetAt(1 ).SpouseNa me.Given
  3814                         set  pAddUpdate Request.Sp ouseName.M iddle = pR equest.Res ults.GetAt (1).Spouse Name.Middl e
  3815                         set  pAddUpdate Request.Sp ouseName.P refix = pR equest.Res ults.GetAt (1).Spouse Name.Prefi x
  3816                         set  pAddUpdate Request.Sp ouseName.S uffix = pR equest.Res ults.GetAt (1).Spouse Name.Suffi x
  3817                         set  pAddUpdate Request.Sp ouseName.T ype = pReq uest.Resul ts.GetAt(1 ).SpouseNa me.Type
  3818                }
  3819                
  3820                
  3821                se t pAddUpda teRequest. Sex=pReque st.Results .GetAt(1). Sex
  3822                Se t pAddUpda teRequest. AssigningA uthority =  "USVHA"
  3823                Se t pAddUpda teRequest. Facility=" EF"
  3824                se t pAddUpda teRequest. MRN = pReq uest.Resul ts.GetAt(1 ).MPIID     // MRN is  ICN numbe r for Ente rprise Fac ility
  3825                se t pAddUpda teRequest. MPIID = pR equest.Res ults.GetAt (1).MPIID
  3826                se t pAddUpda teRequest. SSN = pReq uest.Resul ts.GetAt(1 ).SSN
  3827                
  3828                //  Insert Se condary De mographics  Values
  3829                 I f $IsObjec t(pRequest .Results.G etAt(2)) {
  3830                         //If  pRequest. Results.Ge tAt(2).Rac e]"" Set p AddUpdateR equest.Rac e = pReque st.Results .GetAt(2). Race 
  3831                         If p Request.Re sults.GetA t(2).Exten sion.Autho ritativeRa ces.Count( ) Set pAdd UpdateRequ est.Extens ion.Author itativeRac es = pRequ est.Result s.GetAt(2) .Extension .Authorita tiveRaces
  3832                If  pRequest. Results.Ge tAt(2).Rel igiousAffi liation]""  Set pAddU pdateReque st.Religio usAffiliat ion = pReq uest.Resul ts.GetAt(2 ).Religiou sAffiliati on
  3833                If  pRequest. Results.Ge tAt(2).Mar italStatus ]"" Set pA ddUpdateRe quest.Mari talStatus  = pRequest .Results.G etAt(2).Ma ritalStatu
  3834                If  pRequest. Results.Ge tAt(2).Eth nicGroup]" " Set pAdd UpdateRequ est.Ethnic Group = pR equest.Res ults.GetAt (2).Ethnic Group                     
  3835                If  pRequest. Results.Ge tAt(2).Ext ension.Pre ferredFaci lity]"" Se t pAddUpda teRequest. Extension. PreferredF acility =  pRequest.R esults.Get At(2).Exte nsion.Pref erredFacil ity
  3836                 }  
  3837                Se t pAddUpda teRequest. AddOrUpdat e="A"
  3838                se t pAddUpda teRequest. DoMPIUpdat e=1
  3839       
  3840                Qu it $$$OK
  3841        ]]>
  3842       </Implemen tation>
  3843      </Method>
  3844     
  3845      <Method 
  3846       name="Call ESR"
  3847      >
  3848       <FormalSpe c>
  3849        pMPIID:%St ring,*pDem o:HS.Local .VA.HS.Reg istry.Mess age.ESR.De mographicI nfo=""
  3850       </FormalSp ec>
  3851       <ReturnTyp e>
  3852        %Status
  3853       </ReturnTy pe>
  3854       <Implement ation>
  3855        <![CDATA[
  3856                #d im tSC as  %Status =  $$$OK
  3857                #d im tESRRes ponse as H S.Local.VA .HS.Regist ry.Message .ESR.getEE SummaryRes ponse
  3858                
  3859                Se t tKey = " " , tKeyTy pe = ""
  3860                
  3861                //  Create ES R Request  and call E SR for Sec ondary Dem o Informat ion
  3862                se t tRequest  = ##class (HS.Messag e.XMLMessa ge).%New()
  3863            set tS ummaryRequ est = ##cl ass(HS.Loc al.VA.HS.R egistry.Me ssage.ESR. getEESumma ryRequest) .%New()
  3864            set tn amespaces  = ##class( %XML.Names paces).%Ne w()
  3865            set tS tream = ## class(%Str eam.Global Character) .%New()
  3866            
  3867            set tK ey = pMPII D     ;ICN  number
  3868            set tK eyType = " VPID"
  3869            set tR equestName  = "Second aryDemogra phics"
  3870              set tSumma ryRequest  ="<getEESu mmaryReque st xmlns=" "http://ja xws.webser vices.esr DOMAIN . EXT  /schemas"" ><key>"_tK ey_"</key> <keyType>" _tKeyType_ "</keyType ><requestN ame>"_tReq uestName_" </requestN ame></getE ESummaryRe quest>"
  3871            
  3872            set tS C=tStream. Write(tSum maryReques t)
  3873            do tSt ream.%Save ()
  3874            Set tS C = tReque st.Content Stream.Cop yFrom(tStr eam)
  3875             
  3876            $$$HST RACE("ESR  Request"," tRequest", tRequest)
  3877            
  3878            set tE SRResponse  = ##class (HS.Local. VA.HS.Regi stry.Messa ge.ESR.get EESummaryR esponse).% New()
  3879            
  3880            //Call  Out to ES R Operatio ns
  3881            set tS C = ..Send RequestSyn c(..ESROpe rations,tR equest,.tE SRResponse )
  3882            $$$HST RACE("Resp onse from  ESR ","tES RResponse, tSC",tESRR esponse,tS C)
  3883            
  3884            If $$$ ISOK(tSC) 
  3885            
  3886                Se t tESRStre am1 = ##cl ass(%Strea m.GlobalCh aracter).% New()
  3887                         Do t ESRRespons e.XMLExpor tToStream( .tESRStrea m1)
  3888                         
  3889                         Set  tReader1 =   ##class( %XML.Reade r).%New()
  3890                         Do t Reader1.Co rrelate("g etEESummar yResponse" , "HS.Loca l.VA.HS.Re gistry.Mes sage.ESR.g etEESummar yResponse" )
  3891                         Set  tSC = tRea der1.OpenS tream(tESR Stream1)
  3892                         If $ $$ISERR(tS C) $$$Thro wOnError(t SC)
  3893                                           
  3894                         #dim  tgetSumma ry As HS.L ocal.VA.HS .Registry. Message.ES R.getEESum maryRespon se
  3895                                  
  3896                         Do t Reader1.Ne xt(.tgetSu mmary,.tSC
  3897                         If $ $$ISERR(tS C) $$$Thro wOnError(t SC)
  3898                
  3899                //  Insert Se condary De mographic  Informatio n    
  3900                If  '(tgetSum mary.summa ry.%IsNull ()) {   
  3901                                  
  3902                                           Set tESR Stream = # #class(%St ream.Globa lCharacter ).%New()
  3903                                           Do tESRR esponse.XM LExportToS tream(.tES RStream)
  3904                                           Set tESR Stream = $ TR(tESRStr eam.Read() ,"-")
  3905       
  3906                                           $$$HSTRA CE("Copy E SR Respons e ","tESRS tream,tSC" ,tESRStrea m,tSC)
  3907                                           
  3908                                           Set tRea der =  ##c lass(%XML. Reader).%N ew()
  3909                                           Do tRead er.Correla te("demogr aphics", " HS.Local.V A.HS.Regis try.Messag e.ESR.Demo graphicInf o")
  3910                                           Set tSC  = tReader. OpenStream (tESRStrea m)
  3911                                           If $$$IS ERR(tSC) $ $$ThrowOnE rror(tSC)
  3912                                           
  3913                                           Do tRead er.Next(.p Demo,.tSC)  
  3914                                           If $$$IS ERR(tSC) $ $$ThrowOnE rror(tSC)
  3915                         }  
  3916                         Else  {
  3917                                  $$$LOG ALERT("No  secondary  demographi cs for ICN  Number: " _pMPIID)  
  3918                         }                                                    
  3919                          
  3920            } Else  {
  3921                
  3922                $$ $LOGALERT( "Unable to  retrieve  ESR second ary demogr aphics for  ICN Numbe r: "_pMPII D)  
  3923           }
  3924       
  3925                Qu it tSC
  3926        ]]>
  3927       </Implemen tation>
  3928      </Method>
  3929     
  3930      <Method 
  3931       name="Main tainPatien t"
  3932      >
  3933       <FormalSpe c>
  3934        pRequest:H S.Message. AddUpdateH ubRequest, *pResponse :HS.Messag e.AddUpdat eHubRespon se
  3935       </FormalSp ec>
  3936       <ReturnTyp e>
  3937        %Status
  3938       </ReturnTy pe>
  3939       <Implement ation>
  3940        <![CDATA[
  3941                #d im excepti on as %Exc eption.Abs tractExcep tion
  3942                #d im tSC as  %Status =  $$$OK
  3943                
  3944                
  3945                tr y {
  3946                         
  3947                         If ' (pRequest. DoDelete) 
  3948                                  Set tS C = ..Call ESR(pReque st.MPIID,  .tdemo)  
  3949                                  If $is Object(tde mo){
  3950                                                   
  3951                                           Set tRel igion = td emo.religi on
  3952                                           Set tEth nicGroup =  tdemo.eth nicity
  3953                                           Set tFac ility = td emo.prefer redFacilit y
  3954                                           Set tMar italStatus  = tdemo.m aritalStat us
  3955                                           
  3956                                           For tI=1 :1:tdemo.r aces.Count () {
  3957                                                    Set tRaceI n=tdemo.ra ces.GetAt( tI)
  3958                                                    Set tRaceO ut=##class (HS.SDA3.C odeTableDe tail.Race) .%New()
  3959                                                    Set tRaceO ut.Code=tR aceIn
  3960                                                    Set tRaceO ut.Descrip tion=tRace In
  3961                                                    Do pReques t.Extensio n.Authorit ativeRaces .Insert(tR aceOut)                 
  3962                                           }
  3963                                           
  3964                                           Set pReq uest.Relig iousAffili ation = tR eligion
  3965                                           Set pReq uest.Ethni cGroup = t EthnicGrou p
  3966                                           Set pReq uest.Marit alStatus =  tMaritalS tatus
  3967                                           Set pReq uest.Exten sion.Prefe rredFacili ty = tFaci lity
  3968                                  }
  3969                         }
  3970                
  3971                         set  tSC = ..Se ndRequestS ync("HS.Hu b.MPI.Mana ger",pRequ est,.pResp onse)
  3972                         $$$H STRACE("Fi nish Maint ain Patien t","tSC,pR equest,pRe sponse",tS C,pRequest ,pResponse )
  3973                         
  3974                }  catch exce ption {
  3975                         $$$L OGALERT(ex ception.Co de_": "_ex ception.Na me)
  3976                     s tSC =  exception. AsStatus()
  3977                }
  3978                Qu it tSC
  3979        ]]>
  3980       </Implemen tation>
  3981      </Method>
  3982     
  3983      <Method 
  3984       name="Remo vePatient"
  3985      >
  3986       <Descripti on>
  3987        Process an  HS.Messag e.RemovePa tientReque st 
  3988       </Descript ion>
  3989       <FormalSpe c>
  3990        pRequest:H S.Message. RemovePati entRequest ,*pRespons e:HS.Messa ge.RemoveP atientResp onse
  3991       </FormalSp ec>
  3992       <ReturnTyp e>
  3993        %Status
  3994       </ReturnTy pe>
  3995       <Implement ation>
  3996        <![CDATA[
  3997            set pR esponse=## class(HS.M essage.Rem ovePatient Response). %New()
  3998            set pR esponse.Ac cepted=1
  3999            Quit $ $$OK
  4000        ]]>
  4001       </Implemen tation>
  4002      </Method>
  4003     </Class>
  4004    
  4005    
  4006    
  4007    
  4008     <Class 
  4009      name="HS.L ocal.VA.HS .Registry. Message.ES R.Demograp hicInfo"
  4010     >
  4011      <Procedure Block>
  4012       1
  4013      </Procedur eBlock>
  4014      <Super>
  4015       %SerialObj ect,%XML.A daptor
  4016      </Super>
  4017      <TimeChang ed>
  4018       64982,4975 2.261866
  4019      </TimeChan ged>
  4020      <TimeCreat ed>
  4021       64932,5006 7.810683
  4022      </TimeCrea ted>
  4023     
  4024      <Parameter  
  4025       name="ELEM ENTQUALIFI ED"
  4026      >
  4027       <Default>
  4028        1
  4029       </Default>
  4030      </Paramete r>
  4031     
  4032      <Parameter  
  4033       name="NAME SPACE"
  4034      >
  4035       <Default>
  4036        http://jax ws.webserv ices.esr DOMAIN . EXT  /schemas
  4037       </Default>
  4038      </Paramete r>
  4039     
  4040      <Parameter  
  4041       name="XMLN AME"
  4042      >
  4043       <Default>
  4044        demographi cInfo
  4045       </Default>
  4046      </Paramete r>
  4047     
  4048      <Parameter  
  4049       name="XMLS EQUENCE"
  4050      >
  4051       <Default>
  4052        0
  4053       </Default>
  4054      </Paramete r>
  4055     
  4056      <Property 
  4057       name="appo intmentReq uestDate"
  4058      >
  4059       <Type>
  4060        %TimeStamp
  4061       </Type>
  4062       <Parameter  
  4063        name="XMLN AME" 
  4064        value="app ointmentRe questDate"
  4065       />
  4066      </Property >
  4067     
  4068      <Property 
  4069       name="appo intmentReq uestRespon se"
  4070      >
  4071       <Type>
  4072        %Boolean
  4073       </Type>
  4074       <Parameter  
  4075        name="XMLN AME" 
  4076        value="app ointmentRe questRespo nse"
  4077       />
  4078      </Property >
  4079     
  4080      <Property 
  4081       name="clai mFolderLoc ation"
  4082      >
  4083       <Type>
  4084        %String
  4085       </Type>
  4086       <Parameter  
  4087        name="MAXL EN"
  4088       />
  4089       <Parameter  
  4090        name="XMLN AME" 
  4091        value="cla imFolderLo cation"
  4092       />
  4093      </Property >
  4094     
  4095      <Property 
  4096       name="clai mFolderNum ber"
  4097      >
  4098       <Type>
  4099        %String
  4100       </Type>
  4101       <Parameter  
  4102        name="MAXL EN"
  4103       />
  4104       <Parameter  
  4105        name="XMLN AME" 
  4106        value="cla imFolderNu mber"
  4107       />
  4108      </Property >
  4109     
  4110      <Property 
  4111       name="ethn icity"
  4112      >
  4113       <Type>
  4114        %String
  4115       </Type>
  4116       <Parameter  
  4117        name="MAXL EN"
  4118       />
  4119       <Parameter  
  4120        name="XMLN AME" 
  4121        value="eth nicity"
  4122       />
  4123      </Property >
  4124     
  4125      <Property 
  4126       name="mari talStatus"
  4127      >
  4128       <Type>
  4129        %String
  4130       </Type>
  4131       <Parameter  
  4132        name="MAXL EN"
  4133       />
  4134       <Parameter  
  4135        name="XMLN AME" 
  4136        value="mar italStatus "
  4137       />
  4138      </Property >
  4139     
  4140      <Property 
  4141       name="pref erredFacil ity"
  4142      >
  4143       <Type>
  4144        %String
  4145       </Type>
  4146       <Parameter  
  4147        name="MAXL EN"
  4148       />
  4149       <Parameter  
  4150        name="XMLN AME" 
  4151        value="pre ferredFaci lity"
  4152       />
  4153      </Property >
  4154     
  4155      <Property 
  4156       name="race s"
  4157      >
  4158       <Type>
  4159        %String
  4160       </Type>
  4161       <Collectio n>
  4162        list
  4163       </Collecti on>
  4164       <Parameter  
  4165        name="MAXL EN"
  4166       />
  4167       <Parameter  
  4168        name="XMLI TEMNAME" 
  4169        value="rac e"
  4170       />
  4171       <Parameter  
  4172        name="XMLN AME" 
  4173        value="rac es"
  4174       />
  4175       <Parameter  
  4176        name="XMLP ROJECTION"  
  4177        value="COL LECTION"
  4178       />
  4179      </Property >
  4180     
  4181      <Property 
  4182       name="reli gion"
  4183      >
  4184       <Type>
  4185        %String
  4186       </Type>
  4187       <Parameter  
  4188        name="MAXL EN"
  4189       />
  4190       <Parameter  
  4191        name="XMLN AME" 
  4192        value="rel igion"
  4193       />
  4194      </Property >
  4195     
  4196      <Storage 
  4197       name="Defa ult"
  4198      >
  4199       <Type>
  4200        %Library.C acheSerial State
  4201       </Type>
  4202       <State>
  4203        Demographi cInfoState
  4204       </State>
  4205       <StreamLoc ation>
  4206        ^HS.Local. V7F80.Demo graphicF7F AS
  4207       </StreamLo cation>
  4208       <Data 
  4209        name="Demo graphicInf oState"
  4210       >
  4211        <Value 
  4212         name="1"
  4213        >
  4214         <Value>
  4215          appointmen tRequestDa te
  4216         </Value>
  4217        </Value>
  4218        <Value 
  4219         name="2"
  4220        >
  4221         <Value>
  4222          appointmen tRequestRe sponse
  4223         </Value>
  4224        </Value>
  4225        <Value 
  4226         name="3"
  4227        >
  4228         <Value>
  4229          claimFolde rLocation
  4230         </Value>
  4231        </Value>
  4232        <Value 
  4233         name="4"
  4234        >
  4235         <Value>
  4236          claimFolde rNumber
  4237         </Value>
  4238        </Value>
  4239        <Value 
  4240         name="5"
  4241        >
  4242         <Value>
  4243          ethnicity
  4244         </Value>
  4245        </Value>
  4246        <Value 
  4247         name="6"
  4248        >
  4249         <Value>
  4250          maritalSta tus
  4251         </Value>
  4252        </Value>
  4253        <Value 
  4254         name="7"
  4255        >
  4256         <Value>
  4257          preferredF acilities
  4258         </Value>
  4259        </Value>
  4260        <Value 
  4261         name="8"
  4262        >
  4263         <Value>
  4264          races
  4265         </Value>
  4266        </Value>
  4267        <Value 
  4268         name="9"
  4269        >
  4270         <Value>
  4271          religion
  4272         </Value>
  4273        </Value>
  4274        <Value 
  4275         name="10"
  4276        >
  4277         <Value>
  4278          preferredF acility
  4279         </Value>
  4280        </Value>
  4281       </Data>
  4282      </Storage>
  4283     </Class>
  4284    
  4285    
  4286     <Class 
  4287      name="HS.L ocal.VA.HS .Registry. Message.ES R.eeSummar y"
  4288     >
  4289      <Procedure Block>
  4290       1
  4291      </Procedur eBlock>
  4292      <Super>
  4293       %SerialObj ect,%XML.A daptor
  4294      </Super>
  4295      <TimeChang ed>
  4296       64986,2495 5.591157
  4297      </TimeChan ged>
  4298      <TimeCreat ed>
  4299       64932,5007 2.931706
  4300      </TimeCrea ted>
  4301     
  4302      <Parameter  
  4303       name="ELEM ENTQUALIFI ED"
  4304      >
  4305       <Default>
  4306        1
  4307       </Default>
  4308      </Paramete r>
  4309     
  4310      <Parameter  
  4311       name="NAME SPACE"
  4312      >
  4313       <Default>
  4314        http://jax ws.webserv ices.esr DOMAIN . EXT  /schemas
  4315       </Default>
  4316      </Paramete r>
  4317     
  4318      <Parameter  
  4319       name="XMLN AME"
  4320      >
  4321       <Default>
  4322        eeSummary
  4323       </Default>
  4324      </Paramete r>
  4325     
  4326      <Parameter  
  4327       name="XMLS EQUENCE"
  4328      >
  4329       <Default>
  4330        0
  4331       </Default>
  4332      </Paramete r>
  4333     
  4334      <Property 
  4335       name="demo graphics"
  4336      >
  4337       <Type>
  4338        HS.Local.V A.HS.Regis try.Messag e.ESR.Demo graphicInf o
  4339       </Type>
  4340       <Parameter  
  4341        name="XMLN AME" 
  4342        value="dem ographics"
  4343       />
  4344      </Property >
  4345     
  4346      <Storage 
  4347       name="Defa ult"
  4348      >
  4349       <Type>
  4350        %Library.C acheSerial State
  4351       </Type>
  4352       <State>
  4353        eeSummaryS tate
  4354       </State>
  4355       <StreamLoc ation>
  4356        ^HS.Local. VA.HS.R7F8 0.eeSummar yS
  4357       </StreamLo cation>
  4358       <Data 
  4359        name="eeSu mmaryState "
  4360       >
  4361        <Value 
  4362         name="1"
  4363        >
  4364         <Value>
  4365          demographi cs
  4366         </Value>
  4367        </Value>
  4368       </Data>
  4369      </Storage>
  4370     </Class>
  4371    
  4372    
  4373     <Class 
  4374      name="HS.L ocal.VA.HS .Registry. Message.ES R.getEESum maryReques t"
  4375     >
  4376      <Procedure Block>
  4377       1
  4378      </Procedur eBlock>
  4379      <Super>
  4380       Ens.Reques t
  4381      </Super>
  4382      <TimeChang ed>
  4383       64986,2492 7.565292
  4384      </TimeChan ged>
  4385      <TimeCreat ed>
  4386       64932,4048 5.394837
  4387      </TimeCrea ted>
  4388     
  4389      <Parameter  
  4390       name="RESP ONSECLASSN AME"
  4391      >
  4392       <Default>
  4393        HS.Local.V A.HS.Regis try.Messag e.ESR.getE ESummaryRe sponse
  4394       </Default>
  4395      </Paramete r>
  4396     
  4397      <Parameter  
  4398       name="NAME SPACE"
  4399      >
  4400       <Default>
  4401        http://jax ws.webserv ices.esr DOMAIN . EXT  /schemas,s ch
  4402       </Default>
  4403      </Paramete r>
  4404     
  4405      <Property 
  4406       name="key"
  4407      >
  4408       <Type>
  4409        %String
  4410       </Type>
  4411      </Property >
  4412     
  4413      <Property 
  4414       name="keyT ype"
  4415      >
  4416       <Type>
  4417        %String
  4418       </Type>
  4419      </Property >
  4420     
  4421      <Property 
  4422       name="requ estName"
  4423      >
  4424       <Type>
  4425        %String
  4426       </Type>
  4427      </Property >
  4428     
  4429      <Storage 
  4430       name="Defa ult"
  4431      >
  4432       <Type>
  4433        %Library.C acheStorag e
  4434       </Type>
  4435       <DefaultDa ta>
  4436        getEESumma ryRequestD efaultData
  4437       </DefaultD ata>
  4438       <Data 
  4439        name="getE ESummaryRe questDefau ltData"
  4440       >
  4441        <Subscript >
  4442         "getEESumm aryRequest "
  4443        </Subscrip t>
  4444        <Value 
  4445         name="1"
  4446        >
  4447         <Value>
  4448          key
  4449         </Value>
  4450        </Value>
  4451        <Value 
  4452         name="2"
  4453        >
  4454         <Value>
  4455          keyType
  4456         </Value>
  4457        </Value>
  4458        <Value 
  4459         name="3"
  4460        >
  4461         <Value>
  4462          requestNam e
  4463         </Value>
  4464        </Value>
  4465       </Data>
  4466      </Storage>
  4467     </Class>
  4468    
  4469    
  4470     <Class 
  4471      name="HS.L ocal.VA.HS .Registry. Message.ES R.getEESum maryRespon se"
  4472     >
  4473      <Procedure Block>
  4474       1
  4475      </Procedur eBlock>
  4476      <Super>
  4477       Ens.Respon se,HS.Mess age.XMLMes sage
  4478      </Super>
  4479      <TimeChang ed>
  4480       64982,4986 3.730342
  4481      </TimeChan ged>
  4482      <TimeCreat ed>
  4483       64932,4048 5.397919
  4484      </TimeCrea ted>
  4485     
  4486      <Property 
  4487       name="summ ary"
  4488      >
  4489       <Type>
  4490        HS.Local.V A.HS.Regis try.Messag e.ESR.eeSu mmary
  4491       </Type>
  4492      </Property >
  4493     
  4494      <Property 
  4495       name="eesV ersion"
  4496      >
  4497       <Type>
  4498        %String
  4499       </Type>
  4500      </Property >
  4501     
  4502      <Property 
  4503       name="invo cationDate "
  4504      >
  4505       <Type>
  4506        %TimeStamp
  4507       </Type>
  4508      </Property >
  4509     
  4510      <Property 
  4511       name="noDa taMessage"
  4512      >
  4513       <Type>
  4514        %String
  4515       </Type>
  4516      </Property >
  4517     
  4518      <Storage 
  4519       name="Defa ult"
  4520      >
  4521       <Type>
  4522        %Library.C acheStorag e
  4523       </Type>
  4524       <DefaultDa ta>
  4525        getEESumma ryResponse DefaultDat a
  4526       </DefaultD ata>
  4527       <Data 
  4528        name="Addi tionalInfo "
  4529       >
  4530        <Attribute >
  4531         Additional Info
  4532        </Attribut e>
  4533        <Structure >
  4534         subnode
  4535        </Structur e>
  4536        <Subscript >
  4537         "HS.Local. VA.HS.Regi stry.Messa ge.ESR.get EESummaryR esponse.Ad ditionalIn fo"
  4538        </Subscrip t>
  4539       </Data>
  4540       <Data 
  4541        name="Cust omAuditInf o"
  4542       >
  4543        <Attribute >
  4544         CustomAudi tInfo
  4545        </Attribut e>
  4546        <Structure >
  4547         subnode
  4548        </Structur e>
  4549        <Subscript >
  4550         "HS.Local. VA.HS.Regi stry.Messa ge.ESR.get EESummaryR esponse.Cu stomAuditI nfo"
  4551        </Subscrip t>
  4552       </Data>
  4553       <Data 
  4554        name="getE ESummaryRe sponseDefa ultData"
  4555       >
  4556        <Subscript >
  4557         "getEESumm aryRespons e"
  4558        </Subscrip t>
  4559        <Value 
  4560         name="1"
  4561        >
  4562         <Value>
  4563          summary
  4564         </Value>
  4565        </Value>
  4566        <Value 
  4567         name="2"
  4568        >
  4569         <Value>
  4570          eesVersion
  4571         </Value>
  4572        </Value>
  4573        <Value 
  4574         name="3"
  4575        >
  4576         <Value>
  4577          invocation Date
  4578         </Value>
  4579        </Value>
  4580        <Value 
  4581         name="4"
  4582        >
  4583         <Value>
  4584          noDataMess age
  4585         </Value>
  4586        </Value>
  4587        <Value 
  4588         name="5"
  4589        >
  4590         <Value>
  4591          DocType
  4592         </Value>
  4593        </Value>
  4594        <Value 
  4595         name="6"
  4596        >
  4597         <Value>
  4598          Name
  4599         </Value>
  4600        </Value>
  4601        <Value 
  4602         name="7"
  4603        >
  4604         <Value>
  4605          ContentStr eam
  4606         </Value>
  4607        </Value>
  4608        <Value 
  4609         name="8"
  4610        >
  4611         <Value>
  4612          StreamColl ection
  4613         </Value>
  4614        </Value>
  4615        <Value 
  4616         name="9"
  4617        >
  4618         <Value>
  4619          SOAPFault
  4620         </Value>
  4621        </Value>
  4622        <Value 
  4623         name="10"
  4624        >
  4625         <Value>
  4626          SAMLData
  4627         </Value>
  4628        </Value>
  4629       </Data>
  4630      </Storage>
  4631     </Class>
  4632    
  4633    
  4634     <Class 
  4635      name="HS.L ocal.VA.HS .Registry. Message.In activePati entLoad.Lo adRequest"
  4636     >
  4637      <Super>
  4638       Ens.Reques t
  4639      </Super>
  4640      <TimeChang ed>
  4641       65003,5399 3.187957
  4642      </TimeChan ged>
  4643      <TimeCreat ed>
  4644       65002,5367 3.553191
  4645      </TimeCrea ted>
  4646     
  4647      <Property 
  4648       name="DFN"
  4649      >
  4650       <Type>
  4651        %String
  4652       </Type>
  4653      </Property >
  4654     
  4655      <Property 
  4656       name="Stat ion"
  4657      >
  4658       <Type>
  4659        %String
  4660       </Type>
  4661      </Property >
  4662     
  4663      <Storage 
  4664       name="Defa ult"
  4665      >
  4666       <Type>
  4667        %Library.C acheStorag e
  4668       </Type>
  4669       <DefaultDa ta>
  4670        LoadReques tDefaultDa ta
  4671       </DefaultD ata>
  4672       <Data 
  4673        name="Load RequestDef aultData"
  4674       >
  4675        <Structure >
  4676         listnode
  4677        </Structur e>
  4678        <Subscript >
  4679         "LoadReque st"
  4680        </Subscrip t>
  4681        <Value 
  4682         name="1"
  4683        >
  4684         <Value>
  4685          DFN
  4686         </Value>
  4687        </Value>
  4688        <Value 
  4689         name="2"
  4690        >
  4691         <Value>
  4692          Station
  4693         </Value>
  4694        </Value>
  4695       </Data>
  4696      </Storage>
  4697     </Class>
  4698    
  4699    
  4700    
  4701    
  4702     <Class 
  4703      name="HS.L ocal.VA.HS .Registry. Util"
  4704     >
  4705      <Descripti on>
  4706       All Utilit ies functi ons to pur ge, load a nd update  Registry r elated com ponents. 
  4707      </Descript ion>
  4708      <Super>
  4709       %Registere dObject
  4710      </Super>
  4711      <TimeChang ed>
  4712       65050,5889 3.155578
  4713      </TimeChan ged>
  4714      <TimeCreat ed>
  4715       65021,4407 0.426115
  4716      </TimeCrea ted>
  4717     
  4718      <Method 
  4719       name="Ense mblePurgeS etup"
  4720      >
  4721       <Descripti on>
  4722        This sets  up purge t ask for th e HSREGIST RY namespa ce
  4723        Usage: w # #class(HS. Local.VA.H S.Registry .Util).Ens emblePurge Setup()
  4724       </Descript ion>
  4725       <ClassMeth od>
  4726        1
  4727       </ClassMet hod>
  4728       <ReturnTyp e>
  4729        %Status
  4730       </ReturnTy pe>
  4731       <Implement ation>
  4732        <![CDATA[
  4733                         Set  tSC = $$$O K
  4734                         Try 
  4735                         {
  4736                                           Set tTas kClass = " Ens.Util.T asks.Purge ",tTaskNam e = "Purge EnsembleMe ssages"
  4737                                           Set tRS  = ##class( %SQL.State ment).%Exe cDirect(," select ID  from %SYS. Task where  Namespace  = ? and T askClass =  ? ", $Nam espace,tTa skClass) 
  4738                         
  4739                                           If (tRS. %Next()) {
  4740                                                            Se t tTaskObj  = ##class (%SYS.Task ).%OpenId( tRS.ID)
  4741                                           }
  4742                                           Else {
  4743                                                            Se t tTaskObj  = ##class (%SYS.Task ).%New()
  4744                                           }
  4745                                           
  4746                                           Set tTas kObj.NameS pace = $Na mespace
  4747                                           Set tTas kObj.Name  = tTaskNam e
  4748                                           Set tTas kObj.TaskC lass = tTa skClass
  4749                                           Set tTas kObj.Descr iption = " This HS ta sk purges  any Ensemb le Message  based on  purge days "
  4750                                           Set tTas kObj.RunAs User = "HS _Services"
  4751                         
  4752                                           /// set  known sett ings for t his task
  4753                                           Set tTas kInstance  = ##class( Ens.Util.T asks.Purge ).%New()
  4754                                           Set tSC  = tTaskObj .AssignSet tings(tTas kInstance)
  4755                                           
  4756                                           /// run  every day
  4757                                           Set tTas kObj.TimeP eriod = 0
  4758                                           Set tTas kObj.TimeP eriodEvery  = 1
  4759                                           Set tTas kObj.Start Date = +$H +1
  4760                                           Set tTas kObj.Statu s = 1
  4761                                           Set tTas kObj.Daily Frequency  = 0
  4762                                           Set tTas kObj.Daily FrequencyT ime = 0
  4763                                           Set tTas kObj.Daily StartTime  = 12600
  4764                                           Set tTas kObj.Daily EndTime =  12600
  4765                                           Set tTas kObj.Delet eAfterRun  = 0
  4766                                           Set tTas kObj.Email Output = 0
  4767                                           Set tTas kObj.Resch eduleOnSta rt = 1
  4768                                  Set tT askObj.Set tings=$lb( "BodiesToo ","1","Kee pIntegrity ","1","Num berOfDaysT oKeep","7" ,"TypesToP urge","all ")
  4769       
  4770                                           Set tSC  = tTaskObj .%Save()
  4771                                           If $$$IS ERR(tSC) $ $$ThrowOnE rror(tSC)
  4772                                           Set tTas kObj = ""
  4773                         }
  4774                         Catc h ex
  4775                         {
  4776                                           Set tSC  = ex.AsSta tus()
  4777                         }                
  4778                         Quit  tSC
  4779        ]]>
  4780       </Implemen tation>
  4781      </Method>
  4782     
  4783      <Method 
  4784       name="Impo rtInactive LoadEntrie s"
  4785      >
  4786       <Descripti on>
  4787        Import the  Service R egistry En tries for  all Health Connect En dpoints fo r the Inac tive On-De mand Load.  This also  setups Fa cility Reg istry entr ies.  
  4788        Usage: w # #class(HS. Local.VA.H S.Registry .Util).Imp ortInactiv eLoadEntri es("C:\Use rs\ DN S     ridhV\Docu ments\MVI  Integratio n\Install  and Setup" ,"Inactive LoadEndpts .txt")
  4789       </Descript ion>
  4790       <ClassMeth od>
  4791        1
  4792       </ClassMet hod>
  4793       <FormalSpe c>
  4794        pDir:%Stri ng="C:\Use rs\ DN S     ridhV\Docu ments\MVI  Integratio n\Install  and Setup" ,pFile="In activeLoad Endpts.txt "
  4795       </FormalSp ec>
  4796       <Implement ation>
  4797        <![CDATA[
  4798                
  4799                se t tStatus= $$$OK
  4800                tr y
  4801                {
  4802                         set  tOriginalN s=$namespa ce
  4803                         If t OriginalNs  '= "ENSEM BLE"  zn " ENSEMBLE"
  4804                         
  4805                         if p File'?." "
  4806                         {
  4807                                  set tC nt=0 ;init
  4808                                  #dim t File As %F ile
  4809                                  set tF ile=##clas s(%File).% New(pDir_" \"_pFile)
  4810                                  if tFi le.Exists( pDir_"\"_p File)
  4811                                  {
  4812                                           set tSC  = tFile.Op en("R")
  4813                                           write !, "File size  = "_tFile .Size
  4814                                           while 't File.AtEnd
  4815                                           {
  4816                                                    set tCnt=$ Increment( tCnt)
  4817                                                    set tLine= tFile.Read Line()
  4818                                                    if ($Piece (tLine,"," ,1)'?." ") &&($Piece( tLine,",", 1)'="Facil ityCode")  ;Skip Head er Record  and Blank  Records
  4819                                                    {
  4820                                                            wr ite !!!,"= ========== ========== ========== ========== ========== ====="
  4821                                                            wr ite !,"Rec ord #"_tCn t_": "_tLi ne
  4822                                                                     
  4823                                                                     // A dd Service  Registry  Entries
  4824                                                                     Set  tServiceOb j = ##clas s(HS.Regis try.Servic e.HTTP).%N ew()
  4825                                                                     Set  tServiceOb j.Type = " HTTP"
  4826                                                                     Set  tFacility  = $Piece(t Line,",",1 )
  4827                                                                     Set  tServiceOb j.Name = " InactivePa tientLoad. "_tFacilit y
  4828                                                                     Set  tStatus =  tServiceOb j.ParseURL ($Piece(tL ine,",",4) )
  4829                                                                     Set  tServiceOb j.HTTPCred entialsCon fig = $Pie ce(tLine," ,",5)
  4830                                                                     Set  tServiceOb j.Status =  $Piece(tL ine,",",6)
  4831                                                                     
  4832                                                                     Set  tExistingI D = ##clas s(HS.Regis try.Servic e.Abstract ).IDForNam eType(tSer viceObj.Na me,tServic eObj.Type)
  4833                                                                     If t ExistingID '="" Write  !, "Servi ce Registr y Entry wi th this Na me and Typ e already  exists" Qu it
  4834                                                                     Set  tStatus=tS erviceObj. %Save()
  4835                                                                     
  4836                                                                     // A dd Facilit y Registry  Entry
  4837                                                                     Set  tFacCode =  $Piece(tL ine,",",1)
  4838                                                                     Set  tFacName =  $Piece(tL ine,",",2)
  4839                                                                     Set  tGateway =  $Piece(tL ine,",",3)
  4840                                                                     
  4841                                                                     Set  tExistingF acID = ##c lass(HS.UI .Hub.Facil ities).Fac ilityExist s(tFacCode )     
  4842                                                                     If t ExistingFa cID = 1 {
  4843                                                                              Write  !, "Facili ty Registr y Entry wi th this Na me and Cod e already  exists"
  4844                                                                     }
  4845                                                                     Else  { 
  4846                                                                              Set tR esult = ""
  4847                                                                              Set tF acObj  =   ##class(HS .Types.Fac ilityInfo) .%New()
  4848                                                                              Set tF acObj.Name  = tFacNam e
  4849                                                                              Set tF acObj.Faci lityCode =  tFacCode
  4850                                                                              write  !,"Record  #"_tCnt_":  "_tGatewa y
  4851                                                                              //Set  tSC=##Clas s(HS.Gatew ay.Config) .FindByNam e(tGateway ,.tGWID)
  4852                                                                              //Set  tStatus =  tFacObj.Ga tewaySetOb jectId(tGW ID)
  4853                                                                              Set tS tatus = ## class(HS.F acility.Co nfig).Save Facility(t FacObj)
  4854                                                                                       If $$$IS ERR(tStatu s) {
  4855                                                                                                Set tResul t = $Syste m.Status.G etErrorTex t(tStatus)
  4856                                                                                                Quit
  4857                                                                                       }
  4858                                                                          Set tSC =  ##class(HS .AssignAut h.Config). AddAssigni ngAuthorit y(tFacCode ,tFacName)
  4859                                                                     }
  4860                                                                     
  4861                                                            }
  4862                                                            
  4863                                           }
  4864                                           
  4865                                  }
  4866                                  else
  4867                                  {
  4868                                           write !, "File does n't exist:  "_pDir_"\ "_pFile
  4869                                  }
  4870                         }
  4871                }
  4872                ca tch ex
  4873                         {
  4874                                  set tS tatus = ex .AsStatus( )
  4875                         }
  4876                
  4877                qu it tStatus
  4878        ]]>
  4879       </Implemen tation>
  4880      </Method>
  4881     
  4882      <Method 
  4883       name="Impo rtSRSettin gs"
  4884      >
  4885       <Descripti on>
  4886        Script to  import MVI , ESR and  Terminolog y setting  for Servic e Registry
  4887        Usage: w # #class(HS. Local.VA.H S.Registry .Util).Imp ortSRSetti ngs("C:\Us ers\ DN S     ridhV\Docu ments\MVI  Integratio n\Install  and Setup" ,"ServiceR egistryEnd Points.txt ")
  4888       </Descript ion>
  4889       <ClassMeth od>
  4890        1
  4891       </ClassMet hod>
  4892       <FormalSpe c>
  4893        pDir:%Stri ng="C:\Use rs\ DN S     ridhV\Docu ments\MVI  Integratio n\Install  and Setup" ,pFile="Se rviceRegis tryEndpoin ts.txt"
  4894       </FormalSp ec>
  4895       <Implement ation>
  4896        <![CDATA[
  4897                
  4898                se t tStatus= $$$OK
  4899                tr y
  4900                {
  4901                         set  tOriginalN s=$namespa ce
  4902                         zn " HSREGISTRY "
  4903                         
  4904                         if p File'?." "
  4905                         {
  4906                                  set tC nt=0 ;init
  4907                                  #dim t File As %F ile
  4908                                  set tF ile=##clas s(%File).% New(pDir_" \"_pFile)
  4909                                  if tFi le.Exists( pDir_"\"_p File)
  4910                                  {
  4911                                           set tSC  = tFile.Op en("R")
  4912                                           write !, "File size  = "_tFile .Size
  4913                                           while 't File.AtEnd
  4914                                           {
  4915                                                    set tCnt=$ Increment( tCnt)
  4916                                                    set tLine= tFile.Read Line()
  4917                                                    if ($Piece (tLine,"," ,1)'?." ") &&($Piece( tLine,",", 1)'="SiteC ode") ;Ski p Header R ecord and  Blank Reco rds
  4918                                                    {
  4919                                                            wr ite !!!,"= ========== ========== ========== ========== ========== ====="
  4920                                                            wr ite !,"Rec ord #"_tCn t_": "_tLi ne
  4921                                                            
  4922                                                            Se t tService Obj = ##cl ass(HS.Reg istry.Serv ice.SOAP). %New()
  4923                                                            Se t tService Obj.Type =  "SOAP"
  4924                                                            Se t tName =  $Piece(tLi ne,",",1)
  4925                                                                              
  4926                                                                              If tNa me = "MVI"  {
  4927                                                                                       Set tSer viceObj.Na me = "MVI. PDQv3.Cons umer"
  4928                                                                                       Set tSta tus = tSer viceObj.Pa rseURL($Pi ece(tLine, ",",2))
  4929                                                                                       Set tSer viceObj.St atus = $Pi ece(tLine, ",",4)
  4930                                                                                       Set tSer viceObj.De viceFuncti on = "PDQv 3ConsumerD evice"
  4931                                                                                       Set tSer viceObj.SS LConfig =  $Piece(tLi ne,",",3)
  4932                                                                              } Else If tName =  "ESR" {
  4933                                                                                       Set tSer viceObj.Na me = "VA.E SR"
  4934                                                                                       Set tSta tus = tSer viceObj.Pa rseURL($Pi ece(tLine, ",",2))
  4935                                                                                       Set tSer viceObj.SS LConfig =  $Piece(tLi ne,",",3)
  4936                                                                                       Set tSer viceObj.St atus = $Pi ece(tLine, ",",5)
  4937                                                                                       Set tSer viceObj.HT TPCredenti alsConfig  = $Piece(t Line,",",4 )     
  4938                                                                              } Else If tName =  "Terminol ogy" {
  4939                                                                                       Set tSer viceObj.Na me = "VA.C TService"
  4940                                                                                       Set tSta tus = tSer viceObj.Pa rseURL($Pi ece(tLine, ",",2))
  4941                                                                                       Set tSer viceObj.HT TPCredenti alsConfig  = $Piece(t Line,",",3 )
  4942                                                                                       Set tSer viceObj.St atus = $Pi ece(tLine, ",",4)    
  4943                                                                              }                                                                              
  4944                                                                     Set  tExistingI D = ##clas s(HS.Regis try.Servic e.Abstract ).IDForNam eType(tSer viceObj.Na me,tServic eObj.Type)
  4945                                                                     If t ExistingID '="" Write  !, "Servi ce Registr y Entry wi th this Na me and Typ e already  exists" Qu it
  4946                                                                     Set  tStatus=tS erviceObj. %Save()
  4947                                                    }
  4948                                           }
  4949                                           
  4950                                  }
  4951                                  else
  4952                                  {
  4953                                           write !, "File does n't exist:  "_pDir_"\ "_pFile
  4954                                  }
  4955                         }
  4956                         
  4957                }
  4958                ca tch ex
  4959                         {
  4960                                  set tS tatus = ex .AsStatus( )
  4961                         }
  4962                
  4963                qu it tStatus
  4964        ]]>
  4965       </Implemen tation>
  4966      </Method>
  4967     
  4968      <Method 
  4969       name="Load CompilePac kages"
  4970      >
  4971       <Descripti on>
  4972        Give the p roject xml  file to l oad the pa ckages. pR egistryPac kageFile =  "C:\Users \ DN S     ridhV\Docu ments\MVI  Integratio n\Install  and Setup\ MVI_ESR_HS _Local_Fin al_iDev.xm l"
  4973        Usage: w # #class(HS. Local.VA.H S.Registry .Util).Loa dCompilePa ckages("C: \Users\ DN S     ridhV\Docu ments\MVI  Integratio n\Install  and Setup\ VA_XDSb_Re gistry_Ope rations.xm l", 1)
  4974       </Descript ion>
  4975       <ClassMeth od>
  4976        1
  4977       </ClassMet hod>
  4978       <FormalSpe c>
  4979        pRegistryP ackageFile :%String,p LoadOption s:%Integer =0
  4980       </FormalSp ec>
  4981       <ReturnTyp e>
  4982        %Status
  4983       </ReturnTy pe>
  4984       <Implement ation>
  4985        <![CDATA[
  4986                se t tSC=$$$O K
  4987                tr y
  4988                {
  4989                                  set tO riginalNs= $namespace
  4990                                  zn "HS REGISTRY"
  4991                                  set tP ackage="HS .Local.VA. HS.Registr y*"
  4992                                  
  4993                                  if pLo adOptions= 1 ;load an d compile
  4994                                  {
  4995                                           ;;;DELET E PACKAGE? ???
  4996                                           do $Syst em.OBJ.Loa d(pRegistr yPackageFi le,"cklr")
  4997                                           write !, "Loaded an d compiled  the "_tPa ckage_" pa ckage from  "_pRegist ryPackageF ile
  4998                                           
  4999                                  }
  5000                                  elseif  pLoadOpti ons=2 ;com pile only
  5001                                  {
  5002                                           do $Syst em.OBJ.Com pile(pRegi stryPackag eFile,"ckb ")
  5003                                           write !, "Compiled  the "_tPac kage_" pac kage"
  5004                                  }
  5005                                  else ; bypass
  5006                                  {
  5007                                           write !, "BYPASS lo ad and com pile of th e "_tPacka ge_" packa ge"
  5008                                  }
  5009                                  zn tOr iginalNs
  5010                }
  5011                ca tch ex
  5012                {
  5013                         set  tSC = ex.A sStatus()
  5014                }
  5015                
  5016                qu it tSC
  5017        ]]>
  5018       </Implemen tation>
  5019      </Method>
  5020     
  5021      <Method 
  5022       name="Setu pOIDEntrie s"
  5023      >
  5024       <Descripti on>
  5025        Setup OID  Registry E ntries for  MVI ESR I ntegration .
  5026        Usage: w # #class(HS. Local.VA.H S.Registry .Util).Set upOIDEntri es()
  5027       </Descript ion>
  5028       <ClassMeth od>
  5029        1
  5030       </ClassMet hod>
  5031       <ReturnTyp e>
  5032        %Status
  5033       </ReturnTy pe>
  5034       <Implement ation>
  5035        <![CDATA[
  5036                Se t tSC = $$ $OK
  5037                
  5038                Tr y {
  5039                         #; D evice OID
  5040                         Set  tSC = ##cl ass(HS.Dat a.OIDMap). FileOID("2 00HSEP", " Device", " 99.1.3.6.1 .4.1.21367 .2010.1.2. 300.3.4",  "MVI Stati on Number" )
  5041                         Set  tSC = ##cl ass(HS.Dat a.OIDMap). FileOID("P DQv3Consum erDevice",  "Device",  "1.3.6.1. 4.1.21367. 2010.1.2.3 00.3.4", " MVI Connec tion")
  5042                         Set  tSC = ##cl ass(HS.Dat a.OIDMap). FileOID("P IXv3Manage rDevice",  "Device",  "1.3.6.1.4 .21.367.1. 2.300.3.1" )
  5043                         
  5044                         #; A ssigning A uthorities
  5045                         Set  tSC = ##cl ass(HS.Dat a.OIDMap). FileOID("U SVHA", "As signingAut hority", " 2.16.840.1 .113883.4. 349", "US  Dept of Ve terans Aff airs", "Co deSystem,A ssigningAu thority")
  5046                         
  5047                         #; H ome commun ity
  5048                         Set  tSC = ##cl ass(HS.Dat a.OIDMap). FileOID("H omeCommuni ty", "Assi gningAutho rity", "1. 3.6.1.4.1. 21367.2010 .1.2.300",  "Home Com munity","H omeCommuni ty")
  5049                         
  5050                         #; A A Registry
  5051                     Set tSC  = ##class( HS.AssignA uth.Config ).AddAssig ningAuthor ity("USVHA ","Dept of  Veterans  Affairs"," ")
  5052                         
  5053                }
  5054                Ca tch eExcep tion {
  5055                         Set  tSC = eExc eption.AsS tatus()
  5056                }
  5057       
  5058                Qu it tSC
  5059        ]]>
  5060       </Implemen tation>
  5061      </Method>
  5062     </Class>
  5063    
  5064    
  5065     <Document 
  5066      name="VA.M VI.2.5.HL7 "
  5067     >
  5068      <Category 
  5069       name="VA.M VI.2.5" 
  5070       descriptio n="Custom  schema for  MVI maint enance mes sages" 
  5071       base="2.5"
  5072      >
  5073      
  5074       <MessageTy pe 
  5075        name='ADT_ A08' 
  5076        structure= 'ADT_A01' 
  5077        returntype ='base:ACK _A08' 
  5078        descriptio n='ADT mes sage - Upd ate patien t informat ion'
  5079       />
  5080       <MessageTy pe 
  5081        name='ADT_ A24' 
  5082        structure= 'ADT_A24' 
  5083        returntype ='base:ACK _A24' 
  5084        descriptio n='ADT mes sage - Lin k patient  informatio n'
  5085       />
  5086       <MessageTy pe 
  5087        name='ADT_ A31' 
  5088        structure= 'ADT_A05' 
  5089        returntype ='base:ACK _A31' 
  5090        descriptio n='ADT mes sage - Upd ate person  informati on'
  5091       />
  5092       <MessageTy pe 
  5093        name='ADT_ A43' 
  5094        structure= 'ADT_A43' 
  5095        returntype ='base:ACK '
  5096       />
  5097      
  5098       <MessageSt ructure 
  5099        name='ADT_ A01' 
  5100        definition ='base:MSH ~[~{~base: SFT~}~]~ba se:EVN~bas e:PID~[~ba se:PD1~]~[ ~{~base:RO L~}~]~[~{~ base:NK1~} ~]~base:PV 1~[~base:P V2~]~[~{~b ase:ROL~}~ ]~[~{~base :DB1~}~]~[ ~{~base:OB X~}~]~[~{~ base:AL1~} ~]~[~{~bas e:DG1~}~]~ [~base:DRG ~]~[~{~bas e:PR1~[~{~ base:ROL~} ~]~}~]~[~{ ~base:GT1~ }~]~[~{~ba se:IN1~[~b ase:IN2~]~ [~{~base:I N3~}~]~[~{ ~base:ROL~ }~]~}~]~[~ base:ACC~] ~[~base:UB 1~]~[~base :UB2~]~[~b ase:PDA~]~ [~ZPD~]~[~ ZSP~]~[~ZE L~]'
  5101       />
  5102       <MessageSt ructure 
  5103        name='ADT_ A05' 
  5104        definition ='base:MSH ~[~{~base: SFT~}~]~ba se:EVN~bas e:PID~[~ba se:PD1~]~[ ~{~base:RO L~}~]~[~{~ base:NK1~} ~]~base:PV 1~[~base:P V2~]~[~{~b ase:ROL~}~ ]~[~{~base :DB1~}~]~[ ~{~base:OB X~}~]~[~{~ base:AL1~} ~]~[~{~bas e:DG1~}~]~ [~base:DRG ~]~[~{~bas e:PR1~[~{~ base:ROL~} ~]~}~]~[~{ ~base:GT1~ }~]~[~{~ba se:IN1~[~b ase:IN2~]~ [~{~base:I N3~}~]~[~{ ~base:ROL~ }~]~}~]~[~ base:ACC~] ~[~base:UB 1~]~[~base :UB2~]~[~Z PD~]~[~ZSP ~]~[~ZEL~] '
  5105       />
  5106       <MessageSt ructure 
  5107        name='ADT_ A24' 
  5108        definition ='base:MSH ~[~{~base: SFT~}~]~ba se:EVN~bas e:PID~[~ba se:PD1~]~[ ~base:PV1~ ]~[~{~base :DB1~}~]~b ase:PID~[~ base:PD1~] ~[~base:PV 1~]~[~{~ba se:DB1~}~] '
  5109       />
  5110       <MessageSt ructure 
  5111        name='ADT_ A43' 
  5112        definition ='base:MSH ~[~{~base: SFT~}~]~ba se:EVN~{~b ase:PID~[~ base:PD1~] ~base:MRG~ }'
  5113       />
  5114      
  5115       <SegmentSt ructure 
  5116        name='ZEL'  
  5117        descriptio n='VA Spec ific Patie nt Eligibi lity'
  5118       >
  5119            
  5120        <SegmentSu bStructure  
  5121         piece='1' 
  5122         descriptio n='Set ID'  
  5123         datatype=' base:SI' 
  5124         max_length ='1' 
  5125         required=' R' 
  5126         ifrepeatin g='0'
  5127        />
  5128            
  5129        <SegmentSu bStructure  
  5130         piece='2' 
  5131         descriptio n='Eligibi lity or Pr imary Elig ibility Co de' 
  5132         datatype=' base:ID' 
  5133         max_length ='2' 
  5134         required=' O' 
  5135         ifrepeatin g='0'
  5136        />
  5137            
  5138        <SegmentSu bStructure  
  5139         piece='3' 
  5140         descriptio n='Primary  Long ID' 
  5141         datatype=' base:CX' 
  5142         max_length ='16' 
  5143         required=' O' 
  5144         ifrepeatin g='0'
  5145        />
  5146            
  5147        <SegmentSu bStructure  
  5148         piece='4' 
  5149         descriptio n='Primary  Short ID'  
  5150         datatype=' base:CX' 
  5151         max_length ='16' 
  5152         required=' O' 
  5153         ifrepeatin g='0'
  5154        />
  5155            
  5156        <SegmentSu bStructure  
  5157         piece='5' 
  5158         descriptio n='Disabil ity Retire ment from  Military' 
  5159         datatype=' base:ID' 
  5160         max_length ='1' 
  5161         required=' O' 
  5162         ifrepeatin g='0'
  5163        />
  5164            
  5165        <SegmentSu bStructure  
  5166         piece='6' 
  5167         descriptio n='Claim N umber' 
  5168         datatype=' base:NM' 
  5169         max_length ='8' 
  5170         required=' O' 
  5171         ifrepeatin g='0'
  5172        />
  5173            
  5174        <SegmentSu bStructure  
  5175         piece='7' 
  5176         descriptio n='Claim F older Loca tion' 
  5177         datatype=' base:ST' 
  5178         max_length ='40' 
  5179         required=' O' 
  5180         ifrepeatin g='0'
  5181        />
  5182            
  5183        <SegmentSu bStructure  
  5184         piece='8' 
  5185         descriptio n='Veteran  (Y/N)' 
  5186         datatype=' base:ID' 
  5187         max_length ='1' 
  5188         required=' O' 
  5189         ifrepeatin g='0'
  5190        />
  5191            
  5192        <SegmentSu bStructure  
  5193         piece='9' 
  5194         descriptio n='Type' 
  5195         datatype=' base:ST' 
  5196         max_length ='30' 
  5197         required=' O' 
  5198         ifrepeatin g='0'
  5199        />
  5200            
  5201        <SegmentSu bStructure  
  5202         piece='10'  
  5203         descriptio n='Eligibi lity Statu s' 
  5204         datatype=' base:ID' 
  5205         max_length ='8' 
  5206         required=' O' 
  5207         ifrepeatin g='0'
  5208        />
  5209            
  5210        <SegmentSu bStructure  
  5211         piece='11'  
  5212         descriptio n='Eligibi lity Statu s Date' 
  5213         datatype=' base:DT' 
  5214         required=' O' 
  5215         ifrepeatin g='0'
  5216        />
  5217            
  5218        <SegmentSu bStructure  
  5219         piece='12'  
  5220         descriptio n='Eligibi lity Inter im Respons e' 
  5221         datatype=' base:DT' 
  5222         max_length ='8' 
  5223         required=' O' 
  5224         ifrepeatin g='0'
  5225        />
  5226            
  5227        <SegmentSu bStructure  
  5228         piece='13'  
  5229         descriptio n='Eligibi lity Verif  Methos' 
  5230         datatype=' base:ST' 
  5231         max_length ='50' 
  5232         required=' O' 
  5233         ifrepeatin g='0'
  5234        />
  5235            
  5236        <SegmentSu bStructure  
  5237         piece='14'  
  5238         descriptio n='Receivi ng A and A  Benefits'  
  5239         datatype=' base:ID' 
  5240         max_length ='1' 
  5241         required=' O' 
  5242         ifrepeatin g='0'
  5243        />
  5244            
  5245        <SegmentSu bStructure  
  5246         piece='15'  
  5247         descriptio n='Receivi ng Housebo und Benefi ts' 
  5248         datatype=' base:ID' 
  5249         max_length ='1' 
  5250         required=' O' 
  5251         ifrepeatin g='0'
  5252        />
  5253            
  5254        <SegmentSu bStructure  
  5255         piece='16'  
  5256         descriptio n='Receivi ng a VA Pe nsion' 
  5257         datatype=' base:ID' 
  5258         max_length ='1' 
  5259         required=' O' 
  5260         ifrepeatin g='0'
  5261        />
  5262            
  5263        <SegmentSu bStructure  
  5264         piece='17'  
  5265         descriptio n='Receivi ng a VA Di sability' 
  5266         datatype=' base:ID' 
  5267         max_length ='1' 
  5268         required=' O' 
  5269         ifrepeatin g='0'
  5270        />
  5271            
  5272        <SegmentSu bStructure  
  5273         piece='18'  
  5274         descriptio n='Agent O range Expo sure Indic ated' 
  5275         datatype=' base:ID' 
  5276         max_length ='1' 
  5277         required=' O' 
  5278         ifrepeatin g='0'
  5279        />
  5280            
  5281        <SegmentSu bStructure  
  5282         piece='19'  
  5283         descriptio n='Radiati on Exposur e Indicate d' 
  5284         datatype=' base:ID' 
  5285         max_length ='1' 
  5286         required=' O' 
  5287         ifrepeatin g='0'
  5288        />
  5289            
  5290        <SegmentSu bStructure  
  5291         piece='20'  
  5292         descriptio n='Environ mental Con taminants'  
  5293         datatype=' base:ID' 
  5294         max_length ='1' 
  5295         required=' O' 
  5296         ifrepeatin g='0'
  5297        />
  5298            
  5299        <SegmentSu bStructure  
  5300         piece='21'  
  5301         descriptio n='Total A nnual VA C heck Amoun t' 
  5302         datatype=' base:NM' 
  5303         max_length ='5' 
  5304         required=' O' 
  5305         ifrepeatin g='0'
  5306        />
  5307            
  5308        <SegmentSu bStructure  
  5309         piece='22'  
  5310         descriptio n='Radiati on Exposur e Method' 
  5311         datatype=' base:CE' 
  5312         max_length ='22' 
  5313         required=' O' 
  5314         ifrepeatin g='0'
  5315        />
  5316       </SegmentS tructure>
  5317       <SegmentSt ructure 
  5318        name='ZPD'  
  5319        descriptio n='VA Spec ific Patie nt Informa tion'
  5320       >
  5321            
  5322        <SegmentSu bStructure  
  5323         piece='1' 
  5324         descriptio n='Set ID  Patient ID
  5325         datatype=' base:SI' 
  5326         max_length ='4' 
  5327         required=' R' 
  5328         ifrepeatin g='0'
  5329        />
  5330            
  5331        <SegmentSu bStructure  
  5332         piece='2' 
  5333         descriptio n='Remarks
  5334         datatype=' base:ST' 
  5335         max_length ='60' 
  5336         required=' O' 
  5337         ifrepeatin g='0'
  5338        />
  5339            
  5340        <SegmentSu bStructure  
  5341         piece='3' 
  5342         descriptio n='Place o f Birth [C ity]' 
  5343         datatype=' base:ST' 
  5344         max_length ='20' 
  5345         required=' O' 
  5346         ifrepeatin g='0'
  5347        />
  5348            
  5349        <SegmentSu bStructure  
  5350         piece='4' 
  5351         descriptio n='Place o f Birth [S tate]' 
  5352         datatype=' base:ST' 
  5353         max_length ='2' 
  5354         required=' O' 
  5355         ifrepeatin g='0'
  5356        />
  5357            
  5358        <SegmentSu bStructure  
  5359         piece='5' 
  5360         descriptio n='Current  Means Tes t Status' 
  5361         datatype=' base:ID' 
  5362         max_length ='2' 
  5363         required=' O' 
  5364         ifrepeatin g='0'
  5365        />
  5366            
  5367        <SegmentSu bStructure  
  5368         piece='6' 
  5369         descriptio n='Fathers  Name' 
  5370         datatype=' base:ST' 
  5371         max_length ='35' 
  5372         required=' O' 
  5373         ifrepeatin g='0'
  5374        />
  5375            
  5376        <SegmentSu bStructure  
  5377         piece='7' 
  5378         descriptio n='Mothers  Name' 
  5379         datatype=' base:ST' 
  5380         max_length ='35' 
  5381         required=' O' 
  5382         ifrepeatin g='0'
  5383        />
  5384            
  5385        <SegmentSu bStructure  
  5386         piece='8' 
  5387         descriptio n='Rated I ncompetent
  5388         datatype=' base:ID' 
  5389         max_length ='1' 
  5390         required=' O' 
  5391         ifrepeatin g='0'
  5392        />
  5393            
  5394        <SegmentSu bStructure  
  5395         piece='9' 
  5396         descriptio n='Date of  Death' 
  5397         datatype=' base:TS' 
  5398         max_length ='19' 
  5399         required=' O' 
  5400         ifrepeatin g='0'
  5401        />
  5402            
  5403        <SegmentSu bStructure  
  5404         piece='10'  
  5405         descriptio n='Collate ral Sponso rs Name' 
  5406         datatype=' base:ST' 
  5407         max_length ='48' 
  5408         required=' O' 
  5409         ifrepeatin g='0'
  5410        />
  5411            
  5412        <SegmentSu bStructure  
  5413         piece='11'  
  5414         descriptio n='Active  Health Ins urance' 
  5415         datatype=' base:ID' 
  5416         max_length ='1' 
  5417         required=' O' 
  5418         ifrepeatin g='0'
  5419        />
  5420            
  5421        <SegmentSu bStructure  
  5422         piece='12'  
  5423         descriptio n='Eligibl e for Medi caid' 
  5424         datatype=' base:ID' 
  5425         max_length ='1' 
  5426         required=' O' 
  5427         ifrepeatin g='0'
  5428        />
  5429            
  5430        <SegmentSu bStructure  
  5431         piece='13'  
  5432         descriptio n='Date Me dicaid Las t Asked' 
  5433         datatype=' base:TS' 
  5434         max_length ='19' 
  5435         required=' O' 
  5436         ifrepeatin g='0'
  5437        />
  5438            
  5439        <SegmentSu bStructure  
  5440         piece='14'  
  5441         descriptio n='Race' 
  5442         datatype=' base:ID' 
  5443         max_length ='1' 
  5444         required=' O' 
  5445         ifrepeatin g='0'
  5446        />
  5447            
  5448        <SegmentSu bStructure  
  5449         piece='15'  
  5450         descriptio n='Religio us Prefere nce' 
  5451         datatype=' base:ID' 
  5452         max_length ='3' 
  5453         required=' O' 
  5454         ifrepeatin g='0'
  5455        />
  5456            
  5457        <SegmentSu bStructure  
  5458         piece='16'  
  5459         descriptio n='Homeles s Indicato r' 
  5460         datatype=' base:ID' 
  5461         max_length ='1' 
  5462         required=' O' 
  5463         ifrepeatin g='0'
  5464        />
  5465            
  5466        <SegmentSu bStructure  
  5467         piece='17'  
  5468         descriptio n='Pow Sta tus Indica ted' 
  5469         datatype=' base:ST' 
  5470         max_length ='1' 
  5471         required=' O' 
  5472         ifrepeatin g='0'
  5473        />
  5474            
  5475        <SegmentSu bStructure  
  5476         piece='18'  
  5477         descriptio n='Type of  Insurance
  5478         datatype=' base:ID' 
  5479         max_length ='2' 
  5480         required=' O' 
  5481         ifrepeatin g='0'
  5482        />
  5483            
  5484        <SegmentSu bStructure  
  5485         piece='19'  
  5486         descriptio n='Medicat ion Copaym ent Exempt ion' 
  5487         datatype=' base:ID' 
  5488         max_length ='2' 
  5489         required=' 0' 
  5490         ifrepeatin g='0'
  5491        />
  5492            
  5493        <SegmentSu bStructure  
  5494         piece='20'  
  5495         descriptio n='Pow Con finement L ocation' 
  5496         datatype=' base:CE' 
  5497         max_length ='22' 
  5498         required=' O' 
  5499         ifrepeatin g='0'
  5500        />
  5501            
  5502        <SegmentSu bStructure  
  5503         piece='21'  
  5504         descriptio n='Primary  Care Team
  5505         datatype=' base:ST' 
  5506         max_length ='30' 
  5507         required=' O' 
  5508         ifrepeatin g='0'
  5509        />
  5510            
  5511        <SegmentSu bStructure  
  5512         piece='22'  
  5513         descriptio n='GI Insu rance Poli cy' 
  5514         datatype=' base:IS' 
  5515         max_length ='3' 
  5516         required=' O' 
  5517         ifrepeatin g='0'
  5518        />
  5519            
  5520        <SegmentSu bStructure  
  5521         piece='23'  
  5522         descriptio n='Amount  of GI Insu rance' 
  5523         datatype=' base:NM' 
  5524         max_length ='10' 
  5525         required=' O' 
  5526         ifrepeatin g='0'
  5527        />
  5528            
  5529        <SegmentSu bStructure  
  5530         piece='24'  
  5531         descriptio n='Most Re cent Date  of Care' 
  5532         datatype=' base:DT' 
  5533         max_length ='8' 
  5534         required=' O' 
  5535         ifrepeatin g='0'
  5536        />
  5537            
  5538        <SegmentSu bStructure  
  5539         piece='25'  
  5540         descriptio n='Most Re cent Locat ion of Car e' 
  5541         datatype=' base:NM' 
  5542         max_length ='10' 
  5543         required=' O' 
  5544         ifrepeatin g='0'
  5545        />
  5546            
  5547        <SegmentSu bStructure  
  5548         piece='26'  
  5549         descriptio n='2nd Mos t Recent D ate of Car e' 
  5550         datatype=' base:DT' 
  5551         max_length ='8' 
  5552         required=' O' 
  5553         ifrepeatin g='0'
  5554        />
  5555            
  5556        <SegmentSu bStructure  
  5557         piece='27'  
  5558         descriptio n='2nd Mos t Recent L ocation of  Care' 
  5559         datatype=' base:ST' 
  5560         max_length ='10' 
  5561         required=' O' 
  5562         ifrepeatin g='0'
  5563        />
  5564            
  5565        <SegmentSu bStructure  
  5566         piece='28'  
  5567         descriptio n='Date Ru led Incomp etent (Civ il)' 
  5568         datatype=' base:DT' 
  5569         max_length ='8' 
  5570         required=' O' 
  5571         ifrepeatin g='0'
  5572        />
  5573            
  5574        <SegmentSu bStructure  
  5575         piece='29'  
  5576         descriptio n='Date Ru led Incomp etent (VA)
  5577         datatype=' base:DT' 
  5578         max_length ='8' 
  5579         required=' O' 
  5580         ifrepeatin g='0'
  5581        />
  5582            
  5583        <SegmentSu bStructure  
  5584         piece='30'  
  5585         descriptio n='Spinal  Cord Injur y' 
  5586         datatype=' base:ID' 
  5587         max_length ='3' 
  5588         required=' O' 
  5589         ifrepeatin g='0'
  5590        />
  5591            
  5592        <SegmentSu bStructure  
  5593         piece='31'  
  5594         descriptio n='Source  of Notific ation' 
  5595         datatype=' base:ST' 
  5596         max_length ='3' 
  5597         required=' O' 
  5598         ifrepeatin g='0'
  5599        />
  5600            
  5601        <SegmentSu bStructure  
  5602         piece='32'  
  5603         descriptio n='Date of  Death Las t Updated'  
  5604         datatype=' base:DT' 
  5605         max_length ='8' 
  5606         required=' O' 
  5607         ifrepeatin g='0'
  5608        />
  5609            
  5610        <SegmentSu bStructure  
  5611         piece='33'  
  5612         descriptio n='Filipin o Veteran  Proof' 
  5613         datatype=' base:IS' 
  5614         max_length ='3' 
  5615         required=' O' 
  5616         ifrepeatin g='0'
  5617        />
  5618            
  5619        <SegmentSu bStructure  
  5620         piece='34'  
  5621         descriptio n='Psuedo  SSN Reason
  5622         datatype=' base:ST' 
  5623         max_length ='1' 
  5624         required=' O' 
  5625         ifrepeatin g='0'
  5626        />
  5627            
  5628        <SegmentSu bStructure  
  5629         piece='35'  
  5630         descriptio n='Agency  or Allied  Country' 
  5631         datatype=' base:ID' 
  5632         max_length ='15' 
  5633         required=' O' 
  5634         ifrepeatin g='0'
  5635        />
  5636            
  5637        <SegmentSu bStructure  
  5638         piece='36'  
  5639         descriptio n='Not Def ined' 
  5640         datatype=' base:ST' 
  5641         max_length ='20' 
  5642         required=' O' 
  5643         ifrepeatin g='0'
  5644        />
  5645            
  5646        <SegmentSu bStructure  
  5647         piece='37'  
  5648         descriptio n='Not Def ined' 
  5649         datatype=' base:ST' 
  5650         max_length ='20' 
  5651         required=' O' 
  5652         ifrepeatin g='0'
  5653        />
  5654            
  5655        <SegmentSu bStructure  
  5656         piece='38'  
  5657         descriptio n='Not Def ined' 
  5658         datatype=' base:ST' 
  5659         max_length ='20' 
  5660         required=' O' 
  5661         ifrepeatin g='0'
  5662        />
  5663            
  5664        <SegmentSu bStructure  
  5665         piece='39'  
  5666         descriptio n='Not Def ined' 
  5667         datatype=' base:ST' 
  5668         max_length ='20' 
  5669         required=' O' 
  5670         ifrepeatin g='0'
  5671        />
  5672            
  5673        <SegmentSu bStructure  
  5674         piece='40'  
  5675         descriptio n='Emergen cy Respons e Indicato r' 
  5676         datatype=' base:IS' 
  5677         max_length ='1' 
  5678         required=' O' 
  5679         ifrepeatin g='0'
  5680        />
  5681       </SegmentS tructure>
  5682       <SegmentSt ructure 
  5683        name='ZSP'  
  5684        descriptio n='VA Spec ific Servi ce Period'
  5685       >
  5686            
  5687        <SegmentSu bStructure  
  5688         piece='1' 
  5689         descriptio n='Set ID'  
  5690         datatype=' base:SI' 
  5691         max_length ='4' 
  5692         required=' R' 
  5693         ifrepeatin g='0'
  5694        />
  5695            
  5696        <SegmentSu bStructure  
  5697         piece='2' 
  5698         descriptio n='Service  Connected
  5699         datatype=' base:ID' 
  5700         max_length ='1' 
  5701         required=' R' 
  5702         ifrepeatin g='0'
  5703        />
  5704            
  5705        <SegmentSu bStructure  
  5706         piece='3' 
  5707         descriptio n='Service  Connected  Percentag e' 
  5708         datatype=' base:NM' 
  5709         max_length ='3' 
  5710         required=' O' 
  5711         ifrepeatin g='0'
  5712        />
  5713            
  5714        <SegmentSu bStructure  
  5715         piece='4' 
  5716         descriptio n='Period  of Service
  5717         datatype=' base:ID' 
  5718         max_length ='2' 
  5719         required=' O' 
  5720         ifrepeatin g='0'
  5721        />
  5722            
  5723        <SegmentSu bStructure  
  5724         piece='5' 
  5725         descriptio n='Vietnam  Service I ndicated' 
  5726         datatype=' base:ST' 
  5727         max_length ='1' 
  5728         required=' O' 
  5729         ifrepeatin g='0'
  5730        />
  5731       </SegmentS tructure>
  5732      
  5733      </Category >
  5734     </Document >
  5735   </Export>