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

AMH30P4D.m

Go to the documentation of this file.
AMH30P4D ; IHS/CMI/LAB - POST INIT BH ;   [ 12/23/04  7:30 AM ]
 ;;3.0;IHS BEHAVIORAL HEALTH;**4**;JAN 27, 2003
 ;
 ;convert suicide form data elements
 ;only do this once
 S AMHX=0 F  S AMHX=$O(^AMHPSUIC(AMHX)) Q:AMHX'=+AMHX  D
 .Q:$P($G(^AMHPSUIC(AMHX,99)),U)=1  ;already converted this form
 .D EMPLOY
 .D RELATION
 .D EDUC
 .D LOCACT
 .D INTER
 .D PREVIOUS
 .D SUB
 .S DIE="^AMHPSUIC(",DR="9901///1",DA=AMHX D ^DIE
 .D ^XBFMK
 .Q
OVERDOSE ;
 S AMHX=0 F  S AMHX=$O(^XTMP("AMH30P4","OVERDOSE DRUGS",AMHX)) Q:AMHX'=+AMHX  D
 .S AMHY=0 F  S AMHY=$O(^XTMP("AMH30P4","OVERDOSE DRUGS",AMHX,AMHY)) Q:AMHY'=+AMHY  D
 ..S AMHZ=0 F  S AMHZ=$O(^XTMP("AMH30P4","OVERDOSE DRUGS",AMHX,AMHY,AMHZ)) Q:AMHZ'=+AMHZ  D
 ...S AMHD=^XTMP("AMH30P4","OVERDOSE DRUGS",AMHX,AMHY,AMHZ)
 ...S AMHND="",AMHNDT=""
 ...I AMHD="ALCOHOL" S AMHND="ALCOHOL" D UPDOD Q
 ...I AMHD="AMPHETAMINE" S AMHND="AMPHETAMINE/STIMULANT" D UPDOD Q
 ...I AMHD="BARBITURATES" S AMHND="SEDATIVES/BENZODIAZEPINES/BARBITURATES" D UPDOD Q
 ...I AMHD="BENZODIAZEPINES/OTHER SEDATIVES/HYPNOTIC/ANXIOLYTIC" S AMHND="SEDATIVES/BENZODIAZEPINES/BARBITURATES" D UPDOD Q
 ...I AMHD="CANNABIS" S AMHND="OTHER",AMHNDT="CANNABIS" D UPDOD Q
 ...I AMHD="COCAINE" S AMHND="OTHER",AMHNDT="COCAINE" D UPDOD Q
 ...I AMHD="HALLUCINOGENS" S AMHND="OTHER",AMHNDT="HALLUCINOGENS" D UPDOD Q
 ...I AMHD="HEROIN" S AMHND="NON-PRESCRIBED OPIATES (E.G. HEROIN)" D UPDOD Q
 ...I AMHD="INHALANTS" S AMHND="OTHER",AMHNDT="INHALANTS" D UPDOD Q
 ...I AMHD="NICOTINE" S AMHND="OTHER",AMHNDT="NICOTINE" D UPDOD Q
 ...I AMHD="OTHER OPIATES/PAIN MEDS" S AMHND="PRESCRIBED OPIATES (NARCOTICS)" D UPDOD Q
 ...I AMHD="THIS IS THE DRUG" S AMHND="@" D UPDOD Q
 ...I AMHD="TRICYCLIC ANTIDEPRESSANT (TCA)" S AMHND="TRICYCLIC ANTIDEPRESSANT (TCA)" D UPDOD Q
 ...I AMHD="TYLENOL (ACETAMINOPHEN)" S AMHND="ACETAMINOPHEN (E.G. TYLENOL)" D UPDOD Q
 ...W !!,"NO DRUG ",AMHD H 2
 ...Q
SUBSTAN ;
 S AMHX=0 F  S AMHX=$O(^XTMP("AMH30P4","SUBSTANCE DRUGS",AMHX)) Q:AMHX'=+AMHX  D
 .S AMHY=0 F  S AMHY=$O(^XTMP("AMH30P4","SUBSTANCE DRUGS",AMHX,AMHY)) Q:AMHY'=+AMHY  D
 ..S AMHZ=0 F  S AMHZ=$O(^XTMP("AMH30P4","SUBSTANCE DRUGS",AMHX,AMHY,AMHZ)) Q:AMHZ'=+AMHZ  D
 ...S AMHD=^XTMP("AMH30P4","SUBSTANCE DRUGS",AMHX,AMHY,AMHZ)
 ...S AMHND="",AMHNDT=""
 ...I AMHD="ALCOHOL" S AMHND="ALCOHOL" D UPDSA Q
 ...I AMHD="AMPHETAMINE" S AMHND="AMPHETAMINE/STIMULANT" D UPDSA Q
 ...I AMHD="BARBITURATES" S AMHND="SEDATIVES/BENZODIAZEPINES/BARBITURATES" D UPDSA Q
 ...I AMHD="BENZODIAZEPINES/OTHER SEDATIVES/HYPNOTIC/ANXIOLYTIC" S AMHND="SEDATIVES/BENZODIAZEPINES/BARBITURATES" D UPDSA Q
 ...I AMHD="CANNABIS" S AMHND="CANNABIS (MARIJUANA)",AMHNDT="" D UPDSA Q
 ...I AMHD="COCAINE" S AMHND="COCAINE",AMHNDT="" D UPDSA Q
 ...I AMHD="HALLUCINOGENS" S AMHND="HALLUCINOGENS",AMHNDT="" D UPDSA Q
 ...I AMHD="HEROIN" S AMHND="NON-PRESCRIBED OPIATES (E.G. HEROIN)" D UPDSA Q
 ...I AMHD="INHALANTS" S AMHND="INHALANTS" D UPDSA Q
 ...I AMHD="NICOTINE" S AMHND="OTHER",AMHNDT="NICOTINE" D UPDSA Q
 ...I AMHD="OTHER OPIATES/PAIN MEDS" S AMHND="PRESCRIBED OPIATES (NARCOTICS)" D UPDSA Q
 ...I AMHD="THIS IS THE DRUG" S AMHND="@" D UPDSA Q
 ...I AMHD="TRICYCLIC ANTIDEPRESSANT (TCA)" S AMHND="OTHER",AMHNDT="TRICYCLIC ANTIDEPRESSANT (TCA)" D UPDSA Q
 ...I AMHD="TYLENOL (ACETAMINOPHEN)" S AMHND="OTHER",AMHNDT="ACETAMINOPHEN (E.G. TYLENOL)" D UPDSA Q
 ...W !!,"NO DRUG ",AMHD H 2
 ...Q
 Q
UPDSA ;
 ;D ^XBFMK
 ;S DA=AMHZ,DA(1)=AMHY,DA(2)=AMHX
 ;S DIE="^AMHPSUIC("_DA(2)_",12,"_DA(1)_",11,"
 S X=$O(^AMHTSSU("AA",AMHND,0))
 I X="" W !!,"SUB drug missing ",AMHX," ",AMHY Q
 ;S DR=".01///`"_X_";.02///"_AMHNDT
 ;D ^DIE
 ;I $D(Y) W !!,"SUBSTANCE drug conversion for ien ",AMHX," failed."
 ;D ^XBFMK
 S ^AMHPSUIC(AMHX,15,0)="^9002011.651501PA^0^0"
 S $P(^AMHPSUIC(AMHX,15,AMHZ,0),U)=X
 S ^AMHPSUIC(AMHX,15,"B",X,AMHZ)=""
 S Y=0,C=0 F  S Y=$O(^AMHPSUIC(AMHX,15,"B",Y)) Q:Y'=+Y  S C=C+1
 S $P(^AMHPSUIC(AMHX,15,0),U,3)=C,$P(^AMHPSUIC(AMHX,15,0),U,4)=C
 Q
UPDOD ;
 ;D ^XBFMK
 ;S DA=AMHZ,DA(1)=AMHY,DA(2)=AMHX
 ;S DIE="^AMHPSUIC("_DA(2)_",11,"_DA(1)_",11,"
 S X=$O(^AMHTSDRG("AA",AMHND,0))
 I X="" W !!,"drug missing ",AMHX," ",AMHZ Q
 ;S DR=".01///`"_X_";.02///"_AMHNDT
 ;D ^DIE
 ;I $D(Y) W !!,"overdose drug conversion for ien ",AMHX," failed."
 ;D ^XBFMK
 S O=$P(^AMHPSUIC(AMHX,11,AMHY,11,AMHZ,0),U)
 K ^AMHPSUIC(AMHX,11,AMHY,11,"B",O,AMHZ)
 S $P(^AMHPSUIC(AMHX,11,AMHY,11,AMHZ,0),U)=X
 S ^AMHPSUIC(AMHX,11,AMHY,11,"B",X,AMHZ)=""
 Q
SUB ; CONVERT 3'S TO 2
 S AMHY=0 F  S AMHY=$O(^AMHPSUIC(AMHX,12,AMHY)) Q:AMHY'=+AMHY  D
 .S S=$P(^AMHPSUIC(AMHX,12,AMHY,0),U)
 .S N=$S(S=1:1,S=2:2,S=3:2,S=4:"U",1:S)
 .Q:$P(^AMHPSUIC(AMHX,0),U,26)=2  S DA=AMHX,DIE="^AMHPSUIC(",DR=".26///"_N D ^DIE
 .I $D(Y) W !!,"error updating substance used from 3 to 2 ien ",AMHX
 .D ^XBFMK
 .Q
 Q
EMPLOY ;
 S (O,N)=""
 S O=$P(^AMHPSUIC(AMHX,0),U,5)
 S N=$S(O="U":"UNK",O="Y":"F",O="N":"UE",1:O)
 D ^XBFMK
 S DIE="^AMHPSUIC(",DA=AMHX,DR=".05///"_N D ^DIE
 I $D(Y) W !,"error converting employed on form ien ",AMHX
 D ^XBFMK
 Q
PREVIOUS ;
 S (O,N)=""
 S O=$P(^AMHPSUIC(AMHX,0),U,14)
 S N=$S(O=0:0,O=1:1,O=2:2,O=3:3,O=4:3,O=5:3,O=6:3,O=9:"U",1:O)
 D ^XBFMK
 S DIE="^AMHPSUIC(",DA=AMHX,DR=".14///"_N D ^DIE
 I $D(Y) W !,"error converting PREVIOUS ATTEMPTS on form ien ",AMHX
 D ^XBFMK
 Q
RELATION ;
 S (O,N)=""
 S O=$P(^AMHPSUIC(AMHX,0),U,8)
 S N=$S(O=6:9,1:O)
 D ^XBFMK
 S DIE="^AMHPSUIC(",DA=AMHX,DR=".08///"_N D ^DIE
 I $D(Y) W !,"error converting RELATIONSHIP STATUS on form ien ",AMHX
 D ^XBFMK
 Q
INTER ;
 S $P(^AMHPSUIC(AMHX,0),U,16)=""
 S $P(^AMHPSUIC(AMHX,0),U,17)=""
 Q
LOCACT ;
 S (O,N)=""
 S O=$P(^AMHPSUIC(AMHX,0),U,15)
 S N=$S(O=1:1,O=2:2,O=3:7,O=4:3,O=5:4,1:O)
 D ^XBFMK
 S DIE="^AMHPSUIC(",DA=AMHX,DR=".15///"_N D ^DIE
 I $D(Y) W !,"error converting LOCATION OF ACT on form ien ",AMHX
 D ^XBFMK
 Q
EDUC ;
 S (O,N)=""
 S O=$P(^AMHPSUIC(AMHX,0),U,11)
 S N=$S(O=1:1,O=2:3,O=3:6,O=4:2,O=5:4,1:O)
 D ^XBFMK
 S DIE="^AMHPSUIC(",DA=AMHX,DR=".11///"_N D ^DIE
 I $D(Y) W !,"error converting EDUCATION LEVEL on form ien ",AMHX
 D ^XBFMK
 Q