EASEZFM ;ALB/jap,TM - Filing 1010EZ Data to Patient Database ; 3/13/09 4:51pm
 ;;1.0;ENROLLMENT APPLICATION SYSTEM;**1,93**;Mar 15, 2001;Build 2
 ;
QUE ;entry point from queued background job
 ;
 ;check signature verification before continuing
 K ^TMP("1010EZERROR",$J)
 Q:'$G(EASAPP)
 Q:'$D(^EAS(712,EASAPP,0))
 S EASEZNEW=$P(^EAS(712,EASAPP,0),U,11)
 S X=$G(^EAS(712,EASAPP,1))
 ;recheck signature status
 I ('$P(X,U,1))&('$P(X,U,2)) D RESET Q
 ;
 L +^EAS(712,EASAPP):60 I '$T D RESET Q
 ;check incoming data
 D CHECK
 ;
 ;get EZ1010 data into ^TMP("EZDATA" array
 D EN^EASEZC1(EASAPP,.EASDFN)
 ;
 ;store file #2 data
 L +^DPT(EASDFN):60 I '$T D RESET Q
 D F2^EASEZF1(EASAPP,EASDFN)
 L -^DPT(EASDFN)
 ;
 ;store file #408.12, #408.13, #408.21, #408.22 data
 D F408^EASEZF2(EASAPP,EASDFN)
 ;
 ;store file #355.33 data;
 ;call IB API to file health insurance and Medicare data
 D IBINS^EASEZF5(EASAPP,EASDFN)
 ;
 ;update 'new patient' remark
 I EASEZNEW D
 .S REM="New Patient record added by ELECTRONIC 10-10EZ."
 .S DA=EASDFN,DIE="^DPT(",DR=".091///^S X=REM"
 .D ^DIE
 ;update processing status if not already done
 I $P($G(^EAS(712,EASAPP,2)),U,5)="" D SETDATE^EASEZU2(EASAPP,"FIL")
 ;remove the task id
 S $P(^EAS(712,EASAPP,2),U,11)=""
 L -^EAS(712,EASAPP)
 I $D(^TMP("1010EZERROR",$J)) D MAILERR
 S ZTREQ="@"
 Q
 ;
CHECK ;check data
 ;returns '0' if any invalid data found; otherwise '1'
 N SUBIEN,X,CHK,DIK,DA
 ;remove any 'noise' from incoming data
 S SUBIEN=0 F  S SUBIEN=$O(^EAS(712,EASAPP,10,SUBIEN)) Q:+SUBIEN=0  D
 .S CHK=$P($G(^EAS(712,EASAPP,10,SUBIEN,1)),U,1)
 .I (CHK="/")!(CHK="//")!(CHK="-")!(CHK="--")!(CHK=" ")!(CHK="") D
 ..S DA=SUBIEN,DA(1)=EASAPP,DIK="^EAS(712,"_DA(1)_",10,"
 ..D ^DIK
 Q
 ;
CLEAN ; cleanup
 K ^TMP("EZDATA",$J),^TMP("EZINDEX",$J),^TMP("EZTEMP",$J),^TMP("EZDISP",$J)
 Q
 ;
MAILERR ;notify user if any data elements failed FM validator
 ;
 N XMY,XMSUB,XMDUZ,XMTEXT,Y
 ;fill-in first 6 lines of message
 S ^TMP("1010EZERROR",$J,1,0)="Errors were returned by the FileMan validator when filing 1010EZ"
 S ^TMP("1010EZERROR",$J,2,0)="data for --"
 S ^TMP("1010EZERROR",$J,3,0)="Applicant:     "_$P($G(^EAS(712,EASAPP,0)),U,4)
 S ^TMP("1010EZERROR",$J,4,0)="Application #: "_EASAPP
 S Y=DT D DD^%DT
 S ^TMP("1010EZERROR",$J,5,0)="Filing Date:   "_Y
 S ^TMP("1010EZERROR",$J,6,0)=" "
 ;setup call to MailMan
 S XMSUB="EAS 1010EZ Error Report for APP #"_EASAPP,XMDUZ=.5
 S XMY(DUZ)=""
 S XMTEXT="^TMP(""1010EZERROR"",$J,"
 D ^XMD
 K ^TMP("1010EZERROR",$J)
 Q
 ;
RESET ;remove filing date if can't continue
 S FDT=$P(^EAS(712,EASAPP,2),U,5),$P(^EAS(712,EASAPP,2),U,5)=""
 S $P(^EAS(712,EASAPP,2),U,6)="",$P(^EAS(712,EASAPP,2),U,11)=""
 I FDT K ^EAS(712,"FIL",FDT,EASAPP)
 D APPINDEX^EASEZU2(EASAPP)
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEASEZFM   2820     printed  Sep 23, 2025@19:30:39                                                                                                                                                                                                     Page 2
EASEZFM   ;ALB/jap,TM - Filing 1010EZ Data to Patient Database ; 3/13/09 4:51pm
 +1       ;;1.0;ENROLLMENT APPLICATION SYSTEM;**1,93**;Mar 15, 2001;Build 2
 +2       ;
QUE       ;entry point from queued background job
 +1       ;
 +2       ;check signature verification before continuing
 +3        KILL ^TMP("1010EZERROR",$JOB)
 +4        if '$GET(EASAPP)
               QUIT 
 +5        if '$DATA(^EAS(712,EASAPP,0))
               QUIT 
 +6        SET EASEZNEW=$PIECE(^EAS(712,EASAPP,0),U,11)
 +7        SET X=$GET(^EAS(712,EASAPP,1))
 +8       ;recheck signature status
 +9        IF ('$PIECE(X,U,1))&('$PIECE(X,U,2))
               DO RESET
               QUIT 
 +10      ;
 +11       LOCK +^EAS(712,EASAPP):60
           IF '$TEST
               DO RESET
               QUIT 
 +12      ;check incoming data
 +13       DO CHECK
 +14      ;
 +15      ;get EZ1010 data into ^TMP("EZDATA" array
 +16       DO EN^EASEZC1(EASAPP,.EASDFN)
 +17      ;
 +18      ;store file #2 data
 +19       LOCK +^DPT(EASDFN):60
           IF '$TEST
               DO RESET
               QUIT 
 +20       DO F2^EASEZF1(EASAPP,EASDFN)
 +21       LOCK -^DPT(EASDFN)
 +22      ;
 +23      ;store file #408.12, #408.13, #408.21, #408.22 data
 +24       DO F408^EASEZF2(EASAPP,EASDFN)
 +25      ;
 +26      ;store file #355.33 data;
 +27      ;call IB API to file health insurance and Medicare data
 +28       DO IBINS^EASEZF5(EASAPP,EASDFN)
 +29      ;
 +30      ;update 'new patient' remark
 +31       IF EASEZNEW
               Begin DoDot:1
 +32               SET REM="New Patient record added by ELECTRONIC 10-10EZ."
 +33               SET DA=EASDFN
                   SET DIE="^DPT("
                   SET DR=".091///^S X=REM"
 +34               DO ^DIE
               End DoDot:1
 +35      ;update processing status if not already done
 +36       IF $PIECE($GET(^EAS(712,EASAPP,2)),U,5)=""
               DO SETDATE^EASEZU2(EASAPP,"FIL")
 +37      ;remove the task id
 +38       SET $PIECE(^EAS(712,EASAPP,2),U,11)=""
 +39       LOCK -^EAS(712,EASAPP)
 +40       IF $DATA(^TMP("1010EZERROR",$JOB))
               DO MAILERR
 +41       SET ZTREQ="@"
 +42       QUIT 
 +43      ;
CHECK     ;check data
 +1       ;returns '0' if any invalid data found; otherwise '1'
 +2        NEW SUBIEN,X,CHK,DIK,DA
 +3       ;remove any 'noise' from incoming data
 +4        SET SUBIEN=0
           FOR 
               SET SUBIEN=$ORDER(^EAS(712,EASAPP,10,SUBIEN))
               if +SUBIEN=0
                   QUIT 
               Begin DoDot:1
 +5                SET CHK=$PIECE($GET(^EAS(712,EASAPP,10,SUBIEN,1)),U,1)
 +6                IF (CHK="/")!(CHK="//")!(CHK="-")!(CHK="--")!(CHK=" ")!(CHK="")
                       Begin DoDot:2
 +7                        SET DA=SUBIEN
                           SET DA(1)=EASAPP
                           SET DIK="^EAS(712,"_DA(1)_",10,"
 +8                        DO ^DIK
                       End DoDot:2
               End DoDot:1
 +9        QUIT 
 +10      ;
CLEAN     ; cleanup
 +1        KILL ^TMP("EZDATA",$JOB),^TMP("EZINDEX",$JOB),^TMP("EZTEMP",$JOB),^TMP("EZDISP",$JOB)
 +2        QUIT 
 +3       ;
MAILERR   ;notify user if any data elements failed FM validator
 +1       ;
 +2        NEW XMY,XMSUB,XMDUZ,XMTEXT,Y
 +3       ;fill-in first 6 lines of message
 +4        SET ^TMP("1010EZERROR",$JOB,1,0)="Errors were returned by the FileMan validator when filing 1010EZ"
 +5        SET ^TMP("1010EZERROR",$JOB,2,0)="data for --"
 +6        SET ^TMP("1010EZERROR",$JOB,3,0)="Applicant:     "_$PIECE($GET(^EAS(712,EASAPP,0)),U,4)
 +7        SET ^TMP("1010EZERROR",$JOB,4,0)="Application #: "_EASAPP
 +8        SET Y=DT
           DO DD^%DT
 +9        SET ^TMP("1010EZERROR",$JOB,5,0)="Filing Date:   "_Y
 +10       SET ^TMP("1010EZERROR",$JOB,6,0)=" "
 +11      ;setup call to MailMan
 +12       SET XMSUB="EAS 1010EZ Error Report for APP #"_EASAPP
           SET XMDUZ=.5
 +13       SET XMY(DUZ)=""
 +14       SET XMTEXT="^TMP(""1010EZERROR"",$J,"
 +15       DO ^XMD
 +16       KILL ^TMP("1010EZERROR",$JOB)
 +17       QUIT 
 +18      ;
RESET     ;remove filing date if can't continue
 +1        SET FDT=$PIECE(^EAS(712,EASAPP,2),U,5)
           SET $PIECE(^EAS(712,EASAPP,2),U,5)=""
 +2        SET $PIECE(^EAS(712,EASAPP,2),U,6)=""
           SET $PIECE(^EAS(712,EASAPP,2),U,11)=""
 +3        IF FDT
               KILL ^EAS(712,"FIL",FDT,EASAPP)
 +4        DO APPINDEX^EASEZU2(EASAPP)
 +5        QUIT