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

PSO581PO.m

Go to the documentation of this file.
PSO581PO ;ALB/BWF^PSO*7*581 POST INIT ; 10/25/2019 11:14am
 ;;7.0;OUTPATIENT PHARMACY;**581**;DEC 1997;Build 126
 D CONV5245,NCIT,ERXPOP,REFREN
 S DIK="^PS(52.45,",DIK(1)="2.1^E" D ENALL^DIK K DIK
 K ^TMP("PSO581PO")
 Q
 ;;INCOMING COLUMNS
 ;; 1 - NCIt Subset Code
 ;; 2 - NCPDP Subset Preferred Term
 ;; 3 - NCIt code
 ;; 4 - NCPDP Preferred Term
 ;; 5 - NCPDP Synonym (this is blank for all records except 1)
 ;; 6 - NCIt Preferred Term
 ;; 7 - NCI Definition
NCIT ;
 N DONE,LINE,I,CODTYPE,X,NCICODE,BDESC,FDESC,NIEN,REC,DATA,FDARY,REC,G,FDA,ERR,Y,SUBT
 S DONE=0
 S CODTYPE="NCI"
 K ^TMP($J,"WP")
 S X=0 F  S X=$O(^TMP("PSO581PO","NCI",X)) Q:'X  D
 .S DATA=$G(^TMP("PSO581PO","NCI",X,0))
 .S NCICODE=$P(DATA,$C(9),3)
 .S BDESC=$P(DATA,$C(9),6),BDESC=$$UP^XLFSTR(BDESC)
 .S FDESC=$P(DATA,$C(9),7)
 .S SUBT=$P($P(DATA,$C(9),2)," ",2)
 .; if this code already exists, update it and quit.
 .I $D(^PS(52.45,"C","NCI",NCICODE)) D  Q
 ..S EIEN=$O(^PS(52.45,"C","NCI",NCICODE,0)) Q:'EIEN
 ..S FDA(52.45,EIEN_",",.01)=NCICODE
 ..S FDA(52.45,EIEN_",",.02)=BDESC
 ..S FDA(52.45,EIEN_",",.03)=CODTYPE
 ..S FDA(52.45,EIEN_",",.04)="NCIt"
 ..S FDA(52.45,EIEN_",",2.1)=SUBT
 ..D FILE^DIE(,"FDA") K FDA
 ..D TXT2ARY^PSOERXD1(.FDARY,FDESC,,80)
 ..S Y=0 F  S Y=$O(FDARY(Y)) Q:'Y  D
 ...S ^TMP($J,"WP",Y)=$G(FDARY(Y))
 ..D WP^DIE(52.45,EIEN_",",1,"K","^TMP($J,""WP"")")
 ..K EIEN,^TMP($J,"WP"),FDARY,FDESC
 .S FDA(52.45,"+1,",.01)=NCICODE
 .S FDA(52.45,"+1,",.02)=BDESC
 .S FDA(52.45,"+1,",.03)=CODTYPE
 .S FDA(52.45,"+1,",.04)="NCIt"
 .S FDA(52.45,"+1,",2.1)=SUBT
 .D UPDATE^DIE(,"FDA","NIEN") K FDA
 .S REC=$O(NIEN(0)),NIEN=$G(NIEN(REC))
 .D TXT2ARY^PSOERXD1(.FDARY,FDESC,,80)
 .S Y=0 F  S Y=$O(FDARY(Y)) Q:'Y  D
 ..S ^TMP($J,"WP",Y)=$G(FDARY(Y))
 .D WP^DIE(52.45,NIEN_",",1,"K","^TMP($J,""WP"")")
 .K NIEN,^TMP($J,"WP"),FDARY,FDESC
 Q
 ; convert 52.45, field .03 from a set of codes into two separate free text fields
CONV5245 ;
 N IEN,A,CDESC,FDA
 S IEN=0 F  S IEN=$O(^PS(52.45,IEN)) Q:'IEN  D
 .S A=$$GET1^DIQ(52.45,IEN,.03,"E")
 .S CDESC=$S(A="REA":"SERVICE REASON",A="RES":"SERVICE RESULT",A="PSC":"PROFESSIONAL SERVICE",A="ERX":"ERX STATUS",A="DCS":"DRUG COVERAGE",1:"")
 .I CDESC="" S CDESC=$S(A="PAV":"PRIOR AUTHORIZATION",A="CAQ":"CO-AGENT QUALIFIER",A="REJ":"REJECT REASON",A="REM":"REMOVAL REASON",A="DDB":"DRUG DB QUALIFIER",A="CLQ":"CODE LIST QUALIFIER",A="ERR":"ERROR",1:"")
 .S FDA(52.45,IEN_",",.04)=CDESC D FILE^DIE(,"FDA") K FDA
 Q
ERXPOP ;
 N I,DONE,NIEN,ELINE,ECODE,EDESC,ELONG,EIEN,TYPE,SUB,CTTEXT,FDA,Y,FDARY,NIEN
 F TYPE="QCQ","PAY","CIQ","PCQ","CAQ","ACR","DDB","ICQ","PQC","ERX","MRC","MRSC","CLQ" D
 .S SUB=TYPE
 .I TYPE="QCQ" S CTTEXT="QUANTITY CODE LIST QUALIFIER"
 .I TYPE="PAY" S CTTEXT="PAYER TYPE"
 .I TYPE="CIQ" S CTTEXT="COMPOUND INGREDIENT PRODUCT CODE QUALIFIER"
 .I TYPE="PCQ" S CTTEXT="PATIENT CODIFIED NOTE QUALIFIER"
 .I TYPE="CAQ" S CTTEXT="CO-AGENT QUALIFIER"
 .I TYPE="ACR" S CTTEXT="ALTERNATE CONTACT RELATIONSHIP"
 .I TYPE="DDB" S CTTEXT="DRUG DB QUALIFIER"
 .I TYPE="ICQ" S CTTEXT="INGREDIENT CODE QUALIFIER"
 .I TYPE="PQC" S CTTEXT="PRODUCT QUALIFIER CODE"
 .I TYPE="ERX" S CTTEXT="ERX STATUS"
 .I TYPE="MRC" S CTTEXT="MESSAGE REQUEST CODE"
 .I TYPE="MRSC" S CTTEXT="MESSAGE REQUEST SUB-CODE"
 .I TYPE="CLQ" S CTTEXT="CODE LIST QUALIFIER"
 .S DONE=0
 .F I=1:1 D  Q:DONE
 ..K NIEN
 ..S ELINE=$G(^TMP("PSO581PO",TYPE,I,0))
 ..I ELINE=" Q"!(ELINE="") S DONE=1 Q
 ..S ECODE=$P(ELINE,U),EDESC=$P(ELINE,U,2),ELONG=$P(ELINE,U,3)
 ..I $D(^PS(52.45,"C",SUB,ECODE)) D  Q
 ...S EIEN=$O(^PS(52.45,"C",SUB,ECODE,0)) Q:'EIEN
 ...S FDA(52.45,EIEN_",",.01)=ECODE
 ...S FDA(52.45,EIEN_",",.02)=EDESC
 ...S FDA(52.45,EIEN_",",.03)=SUB
 ...S FDA(52.45,EIEN_",",.04)=CTTEXT
 ...D FILE^DIE(,"FDA") K FDA
 ...D TXT2ARY^PSOERXD1(.FDARY,ELONG,,80)
 ...S Y=0 F  S Y=$O(FDARY(Y)) Q:'Y  D
 ....S ^TMP($J,"WP",Y)=$G(FDARY(Y))
 ...D WP^DIE(52.45,EIEN_",",1,"K","^TMP($J,""WP"")")
 ...K NIEN,^TMP($J,"WP"),FDARY,ELONG
 ..S FDA(52.45,"+1,",.01)=ECODE
 ..S FDA(52.45,"+1,",.02)=EDESC
 ..S FDA(52.45,"+1,",.03)=SUB
 ..S FDA(52.45,"+1,",.04)=CTTEXT
 ..D UPDATE^DIE(,"FDA","NIEN") K FDA
 ..S REC=$O(NIEN(0)),NIEN=$G(NIEN(REC))
 ..D TXT2ARY^PSOERXD1(.FDARY,ELONG,,80)
 ..S Y=0 F  S Y=$O(FDARY(Y)) Q:'Y  D
 ...S ^TMP($J,"WP",Y)=$G(FDARY(Y))
 ..D WP^DIE(52.45,NIEN_",",1,"K","^TMP($J,""WP"")")
 ..K NIEN,^TMP($J,"WP"),FDARY,ELONG
 Q
 ; change eRx status entries from 'refill' to 'rx renewal'
REFREN ;
 N CODE,SIEN,STAT,FDA,NSTAT,P1,P2
 S CODE="" F  S CODE=$O(^PS(52.45,"C","ERX",CODE)) Q:CODE=""  D
 .S SIEN=0 F  S SIEN=$O(^PS(52.45,"C","ERX",CODE,SIEN)) Q:'SIEN  D
 ..I CODE="IRA" S FDA(52.45,SIEN_",",.02)="INBOUND RXRENEWAL ERROR ACKNOWLEDGED" D FILE^DIE(,"FDA") K FDA Q
 ..; only convert the refill/renewal status entries
 ..Q:$E(CODE)'="R"
 ..S STAT=$$GET1^DIQ(52.45,SIEN,.02,"E")
 ..Q:STAT'["REFILL"
 ..; the word 'refill' only occurs once per instance, so simply gathering 2 pieces is sufficient for this activity
 ..S P1=$P(STAT,"REFILL",1),P2=$P(STAT,"REFILL",2)
 ..S NSTAT=P1_"RXRENEWAL"_P2
 ..S FDA(52.45,SIEN_",",.02)=NSTAT D FILE^DIE(,"FDA") K FDA
 Q