 ; ACSPNT3.m --> PROCESS RECEIVED HL7 MESSAGE (ADT-A31) FROM ACS COMPUMD.
 ; ...continued from ACSPNT.m to process health record number
 ; ...*p1 adds coordinating master of record to patient
 ;
 ; DBS CALLS:
 ; D UPDATE^DIE ADDS NEW RECORDS
 ;
 ; GLOBAL/LOCAL VARIABLES:
 ; FAC          USER'S INSTITUTION(FACILITY)
 ; PFIEN        INTERNAL ENTRY NUMBER IN PATIENT FILE - FROM ACSPNT
 ; APN          ACS PATIENT NUMBER - FROM ACSPNT
 ; HRNROOT      ROOT FOR HRN FILE
 ; HRNSROOT     ROOT FOR HRN SUBFILE
 ; HRNIEN       INTERNAL ENTRY NUMBER FOR HRN FILE
 ; HRNSIEN      INTERNAL ENTRY NUMBER FOR HUN SUBFILE
 ; HRNERR       ERR FOR UPDATE HRN FILE
 ; HRNSERR      ERR FOR UPDATE HRN SUBFILE
 ; PATROOT      ROOT FOR PATIENT FILE *p1
 ; PATIEN       INTERNAL ENTRY NUMBER FOR PATIENT FILE *p1
 ; PATERR       ERR FOR PATIENT FILE *p1
 ; DATE         DATE IN INTERNAL FILEMAN FORMAT
 ; ^CHECK       TEMP STORAGE FOR ERR MESSAGES
 ;
 ; COMMENTS:
 ; ;)           TEMPORARY COMMENT/LINE OF CODE
 ;
 ; FILEMAN FILES:
 ; ^AUPNPAT     IHS PATIENT (#9000001)  9000001.41 - HRN SUBFILE
 ; ^DPT         PATIENT FILE (#2)       2.991 - ICN SUBFILE *p1
 ;
 ; last update 6.26.2007 0954
 ; *p1 added 6.26.2007 - this adds ICN to patient only because it is required, and the ICN is not correct
 ;                       for use with MPI as it should be. .04="1" for locally assigned ICN.
 ;
EN  ;entry point, init
 N FAC,HRNROOT,HRNSROOT,HRNIEN,HRNSIEN,HRNERR,HRNSERR
 N PFIEN,APN,DATE
 N PATROOT,PATIEN,PATERR
 S PFIEN=FDAIEN(1)
 S APN=PIDSEG("NO")
 S FAC=DUZ(2)
 D DT^DILF(,"NOW",.DATE)
UPDATE ;
 S HRNROOT(9000001,"?+1,",.01)=PFIEN
 S HRNROOT(9000001,"?+1,",.02)=DATE
 S HRNROOT(9000001,"?+1,",.03)=DATE
 S HRNROOT(9000001,"?+1,",.11)=DUZ  ;"establishing user"
 S HRNROOT(9000001,"?+1,",.12)=DUZ  ;"USER LAST UPDATE"
 S HRNROOT(9000001,"?+1,",.16)=DATE
 D UPDATE^DIE("S","HRNROOT","HRNIEN","HRNERR")
 M ^CHECK("HRNERR")=HRNERR ;)
 S HRNSIEN(1)=FAC
 S HRNSIEN="?+1,"_HRNIEN(1)_","
 S HRNSROOT(9000001.41,HRNSIEN,.01)=FAC
 S HRNSROOT(9000001.41,HRNSIEN,.02)=APN
 D UPDATE^DIE(,"HRNSROOT","HRNSIEN","HRNSERR")
 M ^CHECK("HRNSERR")=HRNSERR ;)
FILECMR	; this section is *p1
 S PATROOT(2,PFIEN_",",991.01)=PFIEN
 S PATROOT(2,PFIEN_",",991.03)=FAC
 S PATROOT(2,PFIEN_",",991.04)="1" ;locally assigned ICN
 D FILE^DIE("S","PATROOT","PATERR")
 M ^CHECK("PATCMRERR")=PATERR ;)
REXIT   ;EXIT
 K FAC,HRNROOT,HRNSROOT,HRNIEN,HRNSIEN,HRNERR,HRNSERR
 K PFIEN,APN,DATE
 K PATROOT,PATIEN,PATERR
 Q
