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

GMRAY17.m

Go to the documentation of this file.
  1. GMRAY17 ;SLC/DAN Post-init for patch 17 ;10/20/03 14:24
  1. ;;4.0;Adverse Reaction Tracking;**17**;Mar 29, 1996
  1. ;
  1. ;DBIA SECTION
  1. ;10063 - %ZTLOAD
  1. ;3744 - $$TESTPAT^VADPT
  1. ;10018 - DIE
  1. ;10013 - DIK
  1. ;2056 - DIQ
  1. ;10103 - XLFDT
  1. ;10104 - XLFSTR
  1. ;10070 - XMD
  1. ;10141 - XPDUTL
  1. ;
  1. Q ;Entry point to queue process during install
  1. N ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSK
  1. S ZTRTN="DQ^GMRAY17",ZTDESC="GMRA*4*17 POST INSTALL ROUTINE",ZTIO="",ZTDTH=$H
  1. D ^%ZTLOAD I '$G(ZTSK) D BMES^XPDUTL("POST INSTALL NOT QUEUED - RUN DQ^GMRA17 AFTER INSTALL FINISHES") Q
  1. D BMES^XPDUTL("Post-install queued as task # "_$G(ZTSK))
  1. Q
  1. ;
  1. DQ ;Dequeue
  1. D POST,MAIL
  1. Q
  1. ;
  1. POST ;Post-init entry point
  1. ;Update lower case entries
  1. N NAME,IEN,AIEN,DA,DIE,DR,RIEN,SIEN,ROOT,GMRAI,GMRA0,LCV,CNT,PCNT,PROB,DIK,FILE,FILEIEN
  1. ;Re-index 120.85 as previous bug may have left xrefs unset
  1. S DIK="^GMR(120.85," D IXALL^DIK
  1. F ROOT="^GMRD(120.82,""B"")","^GMRD(120.82,""D"")" D
  1. .S NAME=""
  1. .F S NAME=$O(@ROOT@(NAME)) Q:NAME="" I NAME?.E1L.E D
  1. ..S IEN=0 F S IEN=$O(@ROOT@(NAME,IEN)) Q:'+IEN I '$P(^GMRD(120.82,IEN,0),U,3) D
  1. ...S DIE="^GMRD(120.82,"_$S(ROOT["""D""":"DA(1),3,",1:""),DR=".01///"_$$UP^XLFSTR(NAME)
  1. ...I ROOT["""D""" S DA(1)=IEN,DA=$O(@ROOT@(NAME,IEN,0))
  1. ...I ROOT["""B""" S DA=IEN
  1. ...D ^DIE K DA
  1. ...S AIEN=0 F S AIEN=$O(^GMR(120.8,"C",NAME,AIEN)) Q:'+AIEN I $P(^GMR(120.8,AIEN,0),U,3)=(IEN_";GMRD(120.82,") S DIE="^GMR(120.8,",DA=AIEN,DR=".02////"_$$UP^XLFSTR(NAME) D ^DIE K DA D
  1. ....I $D(^GMR(120.85,"C",AIEN)) D ;Observed reaction for this reactant
  1. .....S RIEN=0 F S RIEN=$O(^GMR(120.85,"C",AIEN,RIEN)) Q:'+RIEN D
  1. ......S SIEN=$O(^GMR(120.85,RIEN,3,"B",NAME,0)) Q:'+SIEN
  1. ......S DA(1)=RIEN,DA=SIEN,DIE="^GMR(120.85,DA(1),3,",DR=".01////^S X=$$UP^XLFSTR(NAME)" D ^DIE
  1. ;
  1. ;Find entries in 120.8 that are missing the reactant or are missing additional required data and take appropriate action.
  1. K DA
  1. S GMRAI=0 F S GMRAI=$O(^GMR(120.8,GMRAI)) Q:'+GMRAI D
  1. .I '$D(^GMR(120.8,GMRAI,0)) Q ;Don't process if missing zero node
  1. .S GMRA0=$G(^GMR(120.8,GMRAI,0))
  1. .I $L(GMRA0,U)=1 S DIK="^GMR(120.8,",DA=GMRAI D ^DIK Q ;Delete entry if only the 1st piece of the zero node is present
  1. .I $P(GMRA0,U,4)'=+$P(GMRA0,U,4) D FIXDATE
  1. .I $P(GMRA0,U,6)="o",$P(GMRA0,U,20)["D" D CHECKOBS
  1. .I $D(^GMR(120.8,GMRAI,10,"B",-1)) D FIXREACT ;If -1 is stored as reactant delete it
  1. .I $P(GMRA0,U,2)="",$P(GMRA0,U,3)'="" D ;If no reactant but pointer is present then set reactant
  1. ..S ENTRY=$P(GMRA0,U,3)
  1. ..S FILE=+$P(@("^"_$P(ENTRY,";",2)_"0)"),U,2)
  1. ..S FILEIEN=$P(ENTRY,";")
  1. ..S NAME=$$GET1^DIQ(FILE,FILEIEN,$S(FILE'=50.67:.01,1:4))
  1. ..S DIE="^GMR(120.8,",DA=GMRAI,DR=".02////"_NAME D ^DIE
  1. ;Check observed data to make sure it's matched to the right patient
  1. S LCV=0 F S LCV=$O(^GMR(120.85,LCV)) Q:'+LCV D
  1. .S GMRA0=$G(^GMR(120.85,LCV,0)) Q:GMRA0=""
  1. .I $P(GMRA0,U,2)'=$P($G(^GMR(120.8,$P(GMRA0,U,15),0)),U) S DIK="^GMR(120.85,",DA=LCV D ^DIK
  1. Q
  1. ;
  1. FIXDATE ;Update origination date to get rid of trailing zeros. Problem was caused by a bug in XLFDT
  1. N DIE,DR,DA
  1. S DIE="^GMR(120.8,",DA=GMRAI,DR="4////"_+$P(GMRA0,U,4)
  1. D ^DIE
  1. Q
  1. ;
  1. CHECKOBS ;Check observation data to make sure it's present and accurate
  1. Q:$D(^GMR(120.8,GMRAI,"ER"))!($$TESTPAT^VADPT($P(GMRA0,U)))!($$DECEASED^GMRAFX($P(GMRA0,U))) ;Stop if allergy entered in error, test patient or deceased patient
  1. I $P(GMRA0,U,12)=1 D
  1. .I '$D(^GMR(120.85,"C",GMRAI)) S PROB($P(GMRA0,U),GMRAI)="OBS" Q ;Marked as observed but no data
  1. .S J=0 F S J=$O(^GMR(120.85,"C",GMRAI,J)) Q:'+J I '$O(^GMR(120.85,J,2,0)) S PROB($P(GMRA0,U),GMRAI)="SS" ;Has observed data but no sign/symptoms
  1. Q
  1. ;
  1. MAIL ;Send message indicating post install is finished
  1. N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,GMRATXT
  1. S XMDUZ="PATCH GMRA*4*17 POST-INSTALL",XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
  1. S GMRATXT(1)="The post-install routine for patch GMRA*4*17"
  1. S GMRATXT(2)="finished on "_$$FMTE^XLFDT($$NOW^XLFDT)_"."
  1. S GMRATXT(3)=""
  1. S CNT=3 I $D(PROB) D
  1. .S CNT=CNT+1,GMRATXT(CNT)="The following patients have observed allergy entries that are"
  1. .S CNT=CNT+1,GMRATXT(CNT)="signed off (accepted) but are missing required data. Please review each"
  1. .S CNT=CNT+1,GMRATXT(CNT)="entry and and update (if data is known), mark it as entered in error,"
  1. .S CNT=CNT+1,GMRATXT(CNT)="or leave it alone."
  1. .S CNT=CNT+1,GMRATXT(CNT)=""
  1. .S PCNT=0
  1. .F S PCNT=$O(PROB(PCNT)) Q:'+PCNT D
  1. ..S DFN=PCNT D DEM^VADPT
  1. ..S IEN=0 F S IEN=$O(PROB(PCNT,IEN)) Q:'+IEN D
  1. ...S CNT=CNT+1
  1. ...S GMRATXT(CNT)=VADM(1)_" "_$P($P(VADM(2),U,2),"-",3)_" "_$P(^GMR(120.8,IEN,0),U,2)_" missing "_$S(PROB(PCNT,IEN)="OBS":"observation date",1:"sign/symptoms")
  1. ..S CNT=CNT+1,GMRATXT(CNT)=""
  1. S CNT=CNT+1,GMRATXT(CNT)="You should"_$S($D(PROB):" also ",1:" ")_"run option GMRA PRINT-NOT SIGNED OFF to get a listing"
  1. S CNT=CNT+1,GMRATXT(CNT)="of all entries that have not yet been signed off. These entries"
  1. S CNT=CNT+1,GMRATXT(CNT)="should be reviewed and updated if possible. They can be left alone"
  1. S CNT=CNT+1,GMRATXT(CNT)="if additional data is unavailable."
  1. S XMTEXT="GMRATXT(",XMSUB="PATCH GMRA*4*17 Post Install COMPLETED"
  1. D ^XMD
  1. Q
  1. ;
  1. FIXREACT ;delete any sign/symptoms erroneously stored as -1
  1. N DIK,DA,RIEN
  1. S DA(1)=GMRAI,DA=$O(^GMR(120.8,GMRAI,10,"B",-1,0)),DIK="^GMR(120.8,DA(1),10," D ^DIK
  1. ;Now check 120.85 for corresponding entries
  1. S RIEN=$O(^GMR(120.85,"C",GMRAI,0)) Q:'+RIEN
  1. S DA(1)=RIEN,DA=$O(^GMR(120.85,RIEN,2,"B",-1,0)),DIK="^GMR(120.85,DA(1),2," D ^DIK
  1. Q