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

GMRAP053.m

Go to the documentation of this file.
GMRAP053 ;ISP/RFR - PATCH 53 INSTALL CODE ;04/07/2017  12:48
 ;;4.0;Adverse Reaction Tracking;**53**;Mar 29, 1996;Build 306
 Q
POST ;POST-INSTALLATION
 N ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSK
 D BMES^XPDUTL("  Queueing the data clean-up task...")
 S ZTRTN="CLEAN^GMRAP053",ZTDESC="GMRA*4*53 DATA CLEAN-UP"
 S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,0,0,2),ZTIO=""
 D ^%ZTLOAD
 I +$G(ZTSK)>0 D MES^XPDUTL("    Successfully queued the task with task #"_ZTSK)
 I '+$G(ZTSK) D MES^XPDUTL("    Failed to queue the task"),CLEAN
 Q
CLEAN ;STRIP TRAILING COMMA FROM OTHER SIGN/SYMPTOM
 I '$D(ZTQUEUED) D BMES^XPDUTL("  Beginning data clean-up process...")
 N NEXTSTOP,OTHREAC,GMRAREAC,GMRAIEN,VALUE,NEWVALUE,CHAR,COMMA,ORIGVAL,FDA,FILEERR,TEXTLINE,LINE
 N EXIT,RECIPS,CHGCOUNT,LENGTH
 K ^TMP("GMRA MSG",$J)
 S OTHREAC=+$O(^GMRD(120.83,"B","OTHER REACTION",0))
 I 'OTHREAC D  G EXIT
 .S ^TMP("GMRA MSG",$J,1,0)="ERROR: Could not find the OTHER REACTION entry in the SIGN/SYMPTOMS file"
 .S ^TMP("GMRA MSG",$J,2,0)="       (#120.83)."
 .S LINE=3 D RESTEXT(.LINE)
 S GMRAREAC=0 F  S GMRAREAC=$O(^GMR(120.8,GMRAREAC)) Q:'+GMRAREAC!($G(ZTSTOP))!($G(EXIT))  D
 .I $G(NEXTSTOP)=""!($G(NEXTSTOP)=$H) D
 ..S ZTSTOP=$$S^%ZTLOAD Q:ZTSTOP
 ..S NEXTSTOP=$$HADD^XLFDT($H,0,0,0,30)
 .Q:ZTSTOP
 .S GMRAIEN=0 F  S GMRAIEN=$O(^GMR(120.8,GMRAREAC,10,"B",OTHREAC,GMRAIEN)) Q:'+GMRAIEN  D
 ..S VALUE=$P($G(^GMR(120.8,GMRAREAC,10,GMRAIEN,0)),U,2),ORIGVAL=VALUE,COMMA=0
 ..I VALUE[",," D
 ...S LENGTH=$L(VALUE)
 ...F CHAR=1:1 Q:CHAR>LENGTH  D
 ....I $E(VALUE,CHAR)=",",'COMMA S COMMA=CHAR
 ....I COMMA>0&(($E(VALUE,CHAR)'=",")!(CHAR=LENGTH)) D
 .....I CHAR>=(COMMA+1) S VALUE=$E(VALUE,1,COMMA)_$S(CHAR'=LENGTH:$E(VALUE,CHAR,LENGTH),1:""),CHAR=COMMA,LENGTH=$L(VALUE)
 .....S COMMA=0
 ..I $E(VALUE,1)="," S VALUE=$E(VALUE,2,$L(VALUE))
 ..I $E(VALUE,$L(VALUE))="," S VALUE=$E(VALUE,1,$L(VALUE)-1)
 ..I VALUE'=ORIGVAL D
 ...S FDA(120.81,GMRAIEN_","_GMRAREAC_",",1)=VALUE
 ...D FILE^DIE("K","FDA","FILEERR")
 ...I $D(FILEERR) D ERROR(.FILEERR,.LINE,GMRAREAC) S EXIT=1
 ...I '$D(FILEERR) D OUTPUT(.LINE,GMRAREAC,VALUE,ORIGVAL) S CHGCOUNT=1+$G(CHGCOUNT)
EXIT ;FINAL ENVIRONMENT CLEAN-UP AND EXIT
 K:$G(ZTSTOP)=0 ZTSTOP
 S LINE=1+$G(LINE),^TMP("GMRA MSG",$J,LINE,0)=" "
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="NUMBER OF REACTIONS CHANGED: "_+$G(CHGCOUNT)
 N XMMG,XMDUZ,XMZ,XMERR,DIFROM,XMTEXT,XMSUB,XMY
 S XMDUZ="GMRA, CLEAN-UP",XMSUB="GMRA*4*53 CLEAN-UP STATUS",XMTEXT="^TMP(""GMRA MSG"",$J,"
 S XMY(DUZ)="",XMY("G.OR CACS")=""
 D ^XMD
 I $D(XMMG)>0 D
 .M ^XTMP("GMRA*4*53 CLEAN-UP STATUS")=^TMP("GMRA MSG",$J)
 .S ^XTMP("GMRA*4*53 CLEAN-UP STATUS",0)=$$FMADD^XLFDT(DT,31)_U_DT_U_"PATCH GMRA*4*53 CLEAN-UP STATUS REPORT"
 K ^TMP("GMRA MSG",$J)
 I $D(ZTQUEUED),'$D(ZTSTOP) S ZTREQ="@"
 I '$D(ZTQUEUED) D MES^XPDUTL("    Data clean-up process has exited")
 Q
OUTPUT(LINE,IEN,VALUE,ORIGVAL) ;ADD CHANGE TO MESSAGE BODY
 I '+$G(LINE) D
 .S LINE=1,^TMP("GMRA MSG",$J,LINE,0)=$$LJ^XLFSTR("PATIENT NAME",31)_"REACTANT"
 .S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  ORIGINAL VALUE"
 .S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  --------------"
 .S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  NEW VALUE"
 .S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)=$$REPEAT^XLFSTR("=",77)
 I LINE>5 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)=$$REPEAT^XLFSTR("-*",33)
 N DFN
 S DFN=+$P($G(^GMR(120.8,IEN,0)),U)
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)=$$LJ^XLFSTR($P($G(^DPT(DFN,0)),U),31)_$E($P($G(^GMR(120.8,IEN,0)),U,2),1,45)
 Q:$G(ORIGVAL)=""
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  "_ORIGVAL
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  "_$$REPEAT^XLFSTR("-",$L(ORIGVAL))
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  "_VALUE
 Q
ERROR(ERRDATA,LINE,DFN) ;ADD FILEMAN ERROR TO MESSAGE BODY
 D OUTPUT(.LINE,DFN)
 N ERRNUM,ERRORS,ITEM,TEXT,ERROR
 S ERRNUM=0 F  S ERRNUM=$O(ERRDATA("DIERR",ERRNUM)) Q:'+ERRNUM  D
 .S ERROR=$G(ERRDATA("DIERR",ERRNUM)) Q:ERROR=""
 .Q:$D(ERRORS(ERROR))
 .S ITEM=0 F  S ITEM=$O(ERRDATA("DIERR",ERRNUM,"TEXT",ITEM)) Q:ITEM=""  D
 ..S TEXT=$S($G(TEXT)'="":TEXT_" ",1:"")_$G(ERRDATA("DIERR",ERRNUM,"TEXT",ITEM))
 .S ERRORS(ERROR)=""
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  FILEMAN ERROR:"
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  "_TEXT
 D RESTEXT(.LINE)
 Q
RESTEXT(LINE) ;ADD RESTART TEXT TO MESSAGE BODY
 S LINE=1+$G(LINE),^TMP("GMRA MSG",$J,LINE,0)=" "
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="Contact the help desk for assistance."
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="When the issue is resolved, execute the following command from the"
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="programmer's prompt to complete the clean-up:"
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)=" "
 S LINE=1+LINE,^TMP("GMRA MSG",$J,LINE,0)="  D POST^GMRAP053"
 Q