Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AGMP72P3

AGMP72P3.m

Go to the documentation of this file.
AGMP72P3 ; IHS/SD/KJH - AG*7.2*3 Post Install ;
 ;;7.2;IHS PATIENT REGISTRATION;**3**;JAN 07, 2011;Build 4
 ;
 Q
POST ; Post Install Entry Point
 D BMES^XPDUTL("Starting Post-Install")
 D PAT
 D HLO
 D CNT
 D BMES^XPDUTL("Post-Install is complete")
 Q
 ;
PAT ;
 N DFNIEN,CNT,CNT2,PICN,TFLIEN,TICN,DIE,DA,DR,DTOUT
 D BMES^XPDUTL("  Updating ICNs in the VA Patient file")
 ; Loop through patients and update the ICN
 S DFNIEN=0,CNT=0,CNT2=0
 F  S DFNIEN=$O(^DPT(DFNIEN)) Q:'DFNIEN  D
 . S CNT=CNT+1
 . I CNT#10000=1 W "."
 . ; Get the ICN from the VA PATIENT file
 . S PICN=$$GET1^DIQ(2,DFNIEN_",",991.01,"E")
 . ; Get the ICN from the Treating Facility List (TFL), if there is a record for the patient
 . S TICN=""
 . S TFLIEN=$O(^DGCN(391.91,"B",DFNIEN,""))
 . I TFLIEN S TICN=$$GET1^DIQ(391.91,TFLIEN_",",9999999.02,"E")
 . ; Quit if the ICNs are the same - no need to update
 . I PICN=TICN Q
 . K DIE,DA,DR
 . S DIE="^DPT("
 . S DA=DFNIEN
 . I TICN="" S DR="991.01////@"
 . E  S DR="991.01////^S X=TICN"
 . L +^DPT(DA):5 I '$T D BMES^XPDUTL("    Could not lock patient "_$P($G(^DPT(DA,0)),"^",1)_" ("_DA_"). ICN should be "_TICN) Q
 . D ^DIE L -^DPT(DA) S CNT2=CNT2+1
 . Q
 D BMES^XPDUTL("    "_CNT2_" patients updated")
 Q
 ;
HLO ;
 N QUEUE,HL778IEN,MSG,CNT,CNT2
 D BMES^XPDUTL("  Clearing Invalid Entries on the HLO queue")
 S QUEUE="",CNT=0,CNT2=0
 F  S QUEUE=$O(^HLB("QUEUE","OUT",QUEUE)) Q:QUEUE=""  D
 . S HL778IEN=""
 . F  S HL778IEN=$O(^HLB("QUEUE","OUT",QUEUE,"MPI RPMS",HL778IEN)) Q:'HL778IEN  D
 .. S CNT=CNT+1
 .. I CNT#1000=1 W "."
 .. S MSG=$G(^HLB(HL778IEN,0))
 .. I MSG="" K ^HLB("QUEUE","OUT",QUEUE,"MPI RPMS",HL778IEN) S CNT2=CNT2+1 Q
 .. I MSG'["MPI RPMS" K ^HLB("QUEUE","OUT",QUEUE,"MPI RPMS",HL778IEN) S CNT2=CNT2+1 Q
 .. I $P(MSG,U,9),$P(MSG,U,20)="SU" K ^HLB("QUEUE","OUT",QUEUE,"MPI RPMS",HL778IEN) S CNT2=CNT2+1 Q
 D BMES^XPDUTL("    "_CNT2_" entries corrected")
 Q
CNT ; Find latest message number that was used in each category and reset the message IEN counters.
 N INTCP,INNOTCP,OUTTCP,OUTNOTCP,OUT
 D BMES^XPDUTL("  Checking/resetting HLO message counters")
 ; Global ^HLA; File 777
 ;^HLC("FILE777","OUT") 0 thru 99999999999
 S OUT=$O(^HLA(100000000000),-1)
 S ^HLC("FILE777","OUT")=OUT
 ;^HLC("FILE777","IN","TCP") 100000000000 thru 199999999999
 S INTCP=$O(^HLA(200000000000),-1)
 I INTCP<100000000000 S INTCP=0
 E  S INTCP=INTCP#100000000000
 S ^HLC("FILE777","IN","TCP")=INTCP
 ;^HLC("FILE777","IN","NOT TCP") 200000000000 thru 299999999999
 S INNOTCP=$O(^HLA(300000000000),-1)
 I INNOTCP<200000000000 S INNOTCP=0
 E  S INNOTCP=INNOTCP#200000000000
 S ^HLC("FILE777","IN","NOT TCP")=INNOTCP
 ; Global HLB; File 778
 ;^HLC("FILE778","OUT","TCP") 0 thru 99999999999
 S OUTTCP=$O(^HLB(100000000000),-1)
 S ^HLC("FILE778","OUT","TCP")=OUTTCP
 ;^HLC("FILE778","OUT","NOT TCP") 100000000000 thru 199999999999
 S OUTNOTCP=$O(^HLB(200000000000),-1)
 I OUTNOTCP<100000000000 S OUTNOTCP=0
 E  S OUTTCP=OUTTCP#100000000000
 S ^HLC("FILE778","OUT","NOT TCP")=OUTNOTCP
 ;^HLC("FILE778","IN","TCP") 200000000000 thru 299999999999
 S INTCP=$O(^HLB(300000000000),-1)
 I INTCP<200000000000 S INTCP=0
 E  S INTCP=INTCP#200000000000
 S ^HLC("FILE778","IN","TCP")=INTCP
 ;^HLC("FILE778","IN","NOT TCP") 300000000000 thru 399999999999
 S INNOTCP=$O(^HLB(400000000000),-1)
 I INNOTCP<300000000000 S INNOTCP=0
 E  S INNOTCP=INNOTCP#300000000000
 S ^HLC("FILE778","IN","NOT TCP")=INNOTCP
 Q