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

PXRPC1.m

Go to the documentation of this file.
PXRPC1 ;ISL/JLC - PCE DATA2PCE RPC Cont ;Nov 26, 2021@08:49:19
 ;;1.0;PCE PATIENT CARE ENCOUNTER;**217**;Aug 12, 1996;Build 134
 ;
 ; References to ICDEX supported by ICR #5747
 ;
DQSAVE(PCELIST,PXPCEARR,PROBLEMS,SRC,PXPCEIMMRD) ;
 ;
 ; Called from DQSAVE^PXRPC
 ;
 N TYP,CODE,IEN,I,X
 N CAT,NARR,PXENCDT
 N PRV,CPT,ICD,IMM,SC,SK,PED,HF,XAM,TRT,ICR,MOD,MODCNT,MODIDX,MODS
 N COM,COMMENT,COMMENTS,SVCAT
 N DFN,PXAPREDT
 ; Vars for Info Source (IMMIS) Imm. Admin Route (IMMRT), Body Site (IMMAL), Lot, Manufacturer, Exp. Date & Comments
 N IMMISNM,IMMISIEN,IMMRTNM,IMMRTIEN,IMMRTERR,IMMALNAME,IMMALIEN,IMMALERR,IMMLOT,IMMMANUF,IMMEXPDT,IMMCOMM,IMMCOMMS,IMMLOTIEN
 N NUM,REMARK,SEQ,IMMDSG,IMMCVX,IMMCVXER,IMMOVERRIDE,IMMRDCOM,SKRDCOM,PXVIMM
 S (PRV,CPT,ICD,IMM,SC,SK,PED,HF,XAM,TRT,ICR)=0
 S I="" F  S I=$O(PCELIST(I)) Q:'I  S X=PCELIST(I) D
 . S X=PCELIST(I),TYP=$P(X,U),CODE=$P(X,U,2),CAT=$P(X,U,3),NARR=$P(X,U,4)
 . I $E(TYP,1,3)="PRV" D  Q
 . . Q:'$L(CODE)
 . . S PRV=PRV+1
 . . S PXAPREDT=1 ;Set the flag to allow editing of primary provider
 . . S PXPCEARR("PROVIDER",PRV,"NAME")=CODE
 . . S PXPCEARR("PROVIDER",PRV,"PRIMARY")=$P(X,U,6)
 . . I $E(TYP,4)="-" S PXPCEARR("PROVIDER",PRV,"DELETE")=1
 . I TYP="VST" D  Q
 . . I CODE="DT" S (PXENCDT,PXPCEARR("ENCOUNTER",1,"ENC D/T"))=$P(X,U,3) Q
 . . I CODE="PT" S PXPCEARR("ENCOUNTER",1,"PATIENT")=$P(X,U,3),DFN=$P(X,U,3) Q
 . . I CODE="HL" S PXPCEARR("ENCOUNTER",1,"HOS LOC")=$P(X,U,3) Q
 . . I CODE="PR" S PXPCEARR("ENCOUNTER",1,"PARENT")=$P(X,U,3) Q
 . . I CODE="ET" S PXPCEARR("ENCOUNTER",1,"ENCOUNTER TYPE")=$P(X,U,3) Q
 . . ;prevents checkout!
 . . I CODE="VC" S (SVCAT,PXPCEARR("ENCOUNTER",1,"SERVICE CATEGORY"))=$P(X,U,3) Q
 . . I CODE="SC" S PXPCEARR("ENCOUNTER",1,"SC")=$P(X,U,3) Q
 . . I CODE="AO" S PXPCEARR("ENCOUNTER",1,"AO")=$P(X,U,3) Q
 . . I CODE="IR" S PXPCEARR("ENCOUNTER",1,"IR")=$P(X,U,3) Q
 . . I CODE="EC" S PXPCEARR("ENCOUNTER",1,"EC")=$P(X,U,3) Q
 . . I CODE="MST" S PXPCEARR("ENCOUNTER",1,"MST")=$P(X,U,3) Q
 . . I CODE="HNC" S PXPCEARR("ENCOUNTER",1,"HNC")=$P(X,U,3) Q
 . . I CODE="CV" S PXPCEARR("ENCOUNTER",1,"CV")=$P(X,U,3) Q
 . . I CODE="SHD" S PXPCEARR("ENCOUNTER",1,"SHAD")=$P(X,U,3) Q
 . . I CODE="OL" D  Q
 . . . I +$P(X,U,3) S PXPCEARR("ENCOUNTER",1,"INSTITUTION")=$P(X,U,3)
 . . . E  I $P(X,U,4)'="",$P(X,U,4)'="0" S PXPCEARR("ENCOUNTER",1,"OUTSIDE LOCATION")=$P(X,U,4)
 . I $E(TYP,1,3)="CPT" D  Q
 . . Q:'$L(CODE)
 . . S CPT=CPT+1
 . . S IEN=$$CODEN^ICPTCOD(CODE) ;ICR #1995
 . . S PXPCEARR("PROCEDURE",CPT,"PROCEDURE")=IEN
 . . I +$P(X,U,9) D
 . . . S MODS=$P(X,U,9),MODCNT=+MODS
 . . . F MODIDX=1:1:MODCNT D
 . . . . S MOD=$P($P(MODS,";",MODIDX+1),"/")
 . . . . S PXPCEARR("PROCEDURE",CPT,"MODIFIERS",MOD)=""
 . . S:$L(CAT) PXPCEARR("PROCEDURE",CPT,"CATEGORY")=CAT
 . . S:$L(NARR) PXPCEARR("PROCEDURE",CPT,"NARRATIVE")=NARR
 . . S:$L($P(X,U,5)) PXPCEARR("PROCEDURE",CPT,"QTY")=$P(X,U,5)
 . . S:$P(X,U,6)>0 PXPCEARR("PROCEDURE",CPT,"ENC PROVIDER")=$P(X,U,6)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="PROCEDURE^"_CPT
 . . I $E(TYP,4)="-" S PXPCEARR("PROCEDURE",CPT,"DELETE")=1,PXPCEARR("PROCEDURE",CPT,"QTY")=0
 . I $E(TYP,1,3)="POV" D  Q
 . . N PXDXI,PXDX
 . . Q:'$L(CODE)
 . . F PXDXI=1:1:$L(CODE,"/") D
 . . . N CSYS,CDT,IEN,LEXIEN
 . . . S PXDX=$P(CODE,"/",PXDXI)
 . . . S ICD=ICD+1
 . . . I (PXDX]""),(PXDX'[".") S PXDX=PXDX_"."
 . . . S IEN=$P($$CODEN^ICDEX(PXDX,80),"~",1)
 . . . I IEN'>0 Q
 . . . S PXPCEARR("DX/PL",ICD,"DIAGNOSIS")=IEN
 . . . S PXPCEARR("DX/PL",ICD,"PRIMARY")=$S(PXDXI=1:$P(X,U,5),1:0)
 . . . S CDT=$S($G(SVCAT)="E":DT,1:$G(PXENCDT))
 . . . S CSYS=$$CSI^ICDEX(80,IEN)
 . . . S LEXIEN=$P($$EXP^LEXCODE(PXDX,CSYS,CDT),U),PXPCEARR("DX/PL",ICD,"LEXICON TERM")=$S(LEXIEN>0:LEXIEN,1:"")
 . . . S:$L(CAT) PXPCEARR("DX/PL",ICD,"CATEGORY")=CAT
 . . . S:$L(NARR) PXPCEARR("DX/PL",ICD,"NARRATIVE")=NARR
 . . . S:$P(X,U,6)>0 PXPCEARR("DX/PL",ICD,"ENC PROVIDER")=$P(X,U,6)
 . . . I $L($P(X,U,7)),($P(X,U,7)=1),(PXDXI=1) S PXPCEARR("DX/PL",ICD,"PL ADD")=$P(X,U,7),PROBLEMS(ICD)=NARR_U_CODE
 . . . S:$L($P(X,U,10))>0&(PXDXI=1) COMMENT($P(X,U,10))="DX/PL^"_ICD
 . . . I $E(TYP,4)="-" S PXPCEARR("DX/PL",ICD,"DELETE")=1
 . I $E(TYP,1,3)="IMM" D  Q
 . . ; If the CVX Code is present, then use it to find the corresponding Immunization,
 . . ; but only if the Immunization IEN is not specified
 . . S IMMCVX=$P(X,U,11)
 . . I CODE="",IMMCVX'="" D
 . . . D CVXTOIEN^PXAPIIM(.CODE,IMMCVX)
 . . . S CODE=$P(CODE,U,1)
 . . Q:'$L(CODE)
 . . ;
 . . ; if this is for a smallpox reading, file this as an update against the original
 . . ; Visit/V Immunization entry.
 . . ; (Piece 30 is for the V Immunization IEN. It should only be populated when doing
 . . ;  a reading).
 . . S PXVIMM=$P(X,U,30)
 . . I PXVIMM D  Q
 . . . I '$D(^AUPNVIMM(PXVIMM,0)) D  Q
 . . . . S PXPCEIMMRD("IMMUNIZATION",1,"ERROR")="V Immunization IEN (#"_PXVIMM_") does not exist. Cannot save reading."
 . . . I $G(DFN),DFN'=$P($G(^AUPNVIMM(PXVIMM,0)),U,2) D  Q
 . . . . S PXPCEIMMRD("IMMUNIZATION",1,"ERROR")="Patient IEN does not match previous V Immunization entry (#"_PXVIMM_"). Cannot save reading."
 . . . S PXPCEIMMRD("IMMUNIZATION",1,"VISIT")=$P($G(^AUPNVIMM(PXVIMM,0)),U,3)
 . . . S PXPCEIMMRD("IMMUNIZATION",1,"IMMUN")=CODE
 . . . ; Reading fields (for smallpox)
 . . . S:$P(X,U,25)'="" PXPCEIMMRD("IMMUNIZATION",1,"RESULT")=$P(X,U,25)
 . . . S:$P(X,U,26)'="" PXPCEIMMRD("IMMUNIZATION",1,"READING")=$P(X,U,26)
 . . . S:$P(X,U,27)'="" PXPCEIMMRD("IMMUNIZATION",1,"D/T READ")=$P(X,U,27)
 . . . S:$P(X,U,28)>0 PXPCEIMMRD("IMMUNIZATION",1,"READER")=$P(X,U,28)
 . . . I $P(X,U,29)>0 S IMMRDCOM($P(X,U,29))="IMMUNIZATION^1"
 . . ;
 . . S IMM=IMM+1
 . . S PXPCEARR("IMMUNIZATION",IMM,"IMMUN")=CODE
 . . I IMMCVX'="" S PXPCEARR("IMMUNIZATION",IMM,"CVX")=IMMCVX
 . . S:$L($P(X,U,5)) PXPCEARR("IMMUNIZATION",IMM,"SERIES")=$P(X,U,5)
 . . S:$L($P(X,U,7)) PXPCEARR("IMMUNIZATION",IMM,"REACTION")=$P(X,U,7)
 . . S:$L($P(X,U,8)) PXPCEARR("IMMUNIZATION",IMM,"CONTRAINDICATED")=$P(X,U,8)
 . . S:$L($P(X,U,9)) PXPCEARR("IMMUNIZATION",IMM,"REFUSED")=$P(X,U,9)
 . . S:$P(X,U,6)>0 PXPCEARR("IMMUNIZATION",IMM,"ENC PROVIDER")=$P(X,U,6)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="IMMUNIZATION^"_IMM
 . . ; These are the additional fields being added by PX*1.0*209
 . . S IMMISIEN=$$IMMSRC^PXRPC($P(X,U,12))
 . . S:IMMISIEN PXPCEARR("IMMUNIZATION",IMM,"INFO SOURCE")=IMMISIEN
 . . S IMMRTIEN=$$IMMROUTE^PXRPC($P(X,U,14))
 . . S:IMMRTIEN PXPCEARR("IMMUNIZATION",IMM,"ADMIN ROUTE")=IMMRTIEN
 . . S IMMALIEN=$$IMMLOC^PXRPC($P(X,U,15))
 . . S:IMMALIEN'="" PXPCEARR("IMMUNIZATION",IMM,"ANATOMIC LOC")=IMMALIEN
 . . S IMMLOT=$$IMMLOT^PXRPC($P(X,U,16),$P(X,U,17),$P(X,U,18))
 . . S IMMLOTIEN=$P(IMMLOT,"^",1)
 . . S IMMCOMM=$P(IMMLOT,"^",2)
 . . S:IMMLOTIEN PXPCEARR("IMMUNIZATION",IMM,"LOT NUM")=IMMLOTIEN
 . . S IMMDSG=$$IMMDSG^PXRPC($P(X,U,13))
 . . I $P(IMMDSG,U,1)'="" D
 . . . S PXPCEARR("IMMUNIZATION",IMM,"DOSE")=$P(IMMDSG,U,1)
 . . . I $P(IMMDSG,U,2) S PXPCEARR("IMMUNIZATION",IMM,"DOSE UNITS")=$P(IMMDSG,U,2)
 . . I $P(IMMDSG,U,3)'="" D  ; add Dosage to comments
 . . . S IMMCOMM=$S($G(IMMCOMM)'="":IMMCOMM_"; ",1:"")_$P(IMMDSG,U,3)
 . . I IMMCOMM'="" D
 . . . ; If we have something to add to the Imm comment, either add it to the existing comment
 . . . ; (if one exists) or just set it in the COMMENT field.
 . . . I $L($P(X,U,10)) S IMMCOMMS($P(X,U,10))=IMMCOMM ; This will get added later to the existing comment
 . . . E  S PXPCEARR("IMMUNIZATION",IMM,"COMMENT")=IMMCOMM
 . . S:$P(X,U,19)>0 PXPCEARR("IMMUNIZATION",IMM,"EVENT D/T")=$P(X,U,19)
 . . I $P(X,U,20)'="" S PXPCEARR("IMMUNIZATION",IMM,"ORD PROVIDER")=$P(X,U,20)
 . . I $P(X,U,21)'="" D IMMVIS^PXRPC($P(X,U,21),.PXPCEARR,IMM)
 . . I $P(X,U,22)'="" D IMMRMRKS^PXRPC($P(X,U,22),IMM,.REMARK)
 . . I $P(X,U,23)'="" S PXPCEARR("IMMUNIZATION",IMM,"WARNING ACK")=$P(X,U,23)
 . . I $P(X,U,24)>0 S IMMOVERRIDE($P(X,U,24))="IMMUNIZATION^"_IMM
 . . I $P(X,U,31)'="" S PXPCEARR("IMMUNIZATION",IMM,"ORD BY POLICY")=$P(X,U,31)
 . . I $E(TYP,4)="-" S PXPCEARR("IMMUNIZATION",IMM,"DELETE")=1
 . I $E(TYP,1,2)="SK" D  Q
 . . Q:'$L(CODE)
 . . S SK=SK+1
 . . S PXPCEARR("SKIN TEST",SK,"TEST")=CODE
 . . S:$L($P(X,U,5)) PXPCEARR("SKIN TEST",SK,"RESULT")=$P(X,U,5)
 . . S:$P(X,U,6)>0 PXPCEARR("SKIN TEST",SK,"ENC PROVIDER")=$P(X,U,6)
 . . S:$L($P(X,U,7)) PXPCEARR("SKIN TEST",SK,"READING")=$P(X,U,7)
 . . S:$L($P(X,U,8)) PXPCEARR("SKIN TEST",SK,"D/T READ")=$P(X,U,8)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="SKIN TEST^"_SK
 . . S:$P(X,U,11)>0 PXPCEARR("SKIN TEST",SK,"READER")=$P(X,U,11)
 . . I $P(X,U,14)>0 S SKRDCOM($P(X,U,14))="SKIN TEST^"_SK
 . . S IMMALIEN=$$IMMLOC^PXRPC($P(X,U,15))
 . . S:IMMALIEN PXPCEARR("SKIN TEST",SK,"ANATOMIC LOC")=IMMALIEN
 . . I $P(X,U,16)>0 S PXPCEARR("SKIN TEST",SK,"PLACEMENT")=$P(X,U,16)
 . . S:$L($P(X,U,19)) PXPCEARR("SKIN TEST",SK,"EVENT D/T")=$P(X,U,19)
 . . S:$P(X,U,20)>0 PXPCEARR("SKIN TEST",SK,"ORD PROVIDER")=$P(X,U,20)
 . . I $E(TYP,3)="-" S PXPCEARR("SKIN TEST",SK,"DELETE")=1
 . I $E(TYP,1,3)="PED" D  Q
 . . Q:'$L(CODE)
 . . S PED=PED+1
 . . S PXPCEARR("PATIENT ED",PED,"TOPIC")=CODE
 . . S:$L($P(X,U,5)) PXPCEARR("PATIENT ED",PED,"UNDERSTANDING")=$P(X,U,5)
 . . S:$P(X,U,6)>0 PXPCEARR("PATIENT ED",PED,"ENC PROVIDER")=$P(X,U,6)
 . . I $P(X,U,7)'="" S PXPCEARR("PATIENT ED",PED,"MAGNITUDE")=$P(X,U,7)
 . . I $P(X,U,8)'="" S PXPCEARR("PATIENT ED",PED,"UCUM CODE")=$P(X,U,8)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="PATIENT ED^"_PED
 . . I $E(TYP,4)="-" S PXPCEARR("PATIENT ED",PED,"DELETE")=1
 . I $E(TYP,1,2)="HF" D  Q
 . . Q:'$L(CODE)
 . . S HF=HF+1
 . . S PXPCEARR("HEALTH FACTOR",HF,"HEALTH FACTOR")=CODE
 . . S:$L($P(X,U,5)) PXPCEARR("HEALTH FACTOR",HF,"LEVEL/SEVERITY")=$P(X,U,5)
 . . S:$P(X,U,6)'>0 $P(X,U,6)=$G(PXPCEARR("PROVIDER",1,"NAME"))
 . . S:$P(X,U,6)>0 PXPCEARR("HEALTH FACTOR",HF,"ENC PROVIDER")=$P(X,U,6)
 . . I $P(X,U,7)'="" S PXPCEARR("HEALTH FACTOR",HF,"MAGNITUDE")=$P(X,U,7)
 . . I $P(X,U,8)'="" S PXPCEARR("HEALTH FACTOR",HF,"UCUM CODE")=$P(X,U,8)
 . . S:$L($P(X,U,11)) PXPCEARR("HEALTH FACTOR",HF,"EVENT D/T")=$P($P(X,U,11),";",1)
 . . S:$L($P(X,U,11)) SRC=$P($P(X,U,11),";",2)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="HEALTH FACTOR^"_HF
 . . I $E(TYP,3)="-" S PXPCEARR("HEALTH FACTOR",HF,"DELETE")=1
 . I $E(TYP,1,3)="XAM" D  Q
 . . Q:'$L(CODE)
 . . S XAM=XAM+1
 . . S PXPCEARR("EXAM",XAM,"EXAM")=CODE
 . . S:$L($P(X,U,5)) PXPCEARR("EXAM",XAM,"RESULT")=$P(X,U,5)
 . . S:$P(X,U,6)>0 PXPCEARR("EXAM",XAM,"ENC PROVIDER")=$P(X,U,6)
 . . I $P(X,U,7)'="" S PXPCEARR("EXAM",XAM,"MAGNITUDE")=$P(X,U,7)
 . . I $P(X,U,8)'="" S PXPCEARR("EXAM",XAM,"UCUM CODE")=$P(X,U,8)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="EXAM^"_XAM
 . . I $E(TYP,4)="-" S PXPCEARR("EXAM",XAM,"DELETE")=1
 . I $E(TYP,1,3)="TRT" D  Q
 . . Q:'$L(CODE)
 . . S TRT=TRT+1
 . . S PXPCEARR("TREATMENT",TRT,"IMMUN")=CODE
 . . S:$L(CAT) PXPCEARR("TREATMENT",TRT,"CATEGORY")=CAT
 . . S:$L(NARR) PXPCEARR("TREATMENT",TRT,"NARRATIVE")=NARR
 . . S:$L($P(X,U,5)) PXPCEARR("TREATMENT",TRT,"QTY")=$P(X,U,5)
 . . S:$P(X,U,6)>0 PXPCEARR("TREATMENT",TRT,"ENC PROVIDER")=$P(X,U,6)
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="TREATMENT^"_TRT
 . . I $E(TYP,4)="-" S PXPCEARR("TREATMENT",TRT,"DELETE")=1,PXPCEARR("TREATMENT",TRT,"QTY")=0
 . I $E(TYP,1,3)="ICR" D  Q
 . . Q:'$L(CODE)
 . . S ICR=ICR+1
 . . S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"CONTRA/REFUSAL")=CODE
 . . I $P(X,U,5)'="" S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"IMMUN")=+$$TRIM^XLFSTR($P(X,U,5))
 . . I $P(X,U,6)'="" S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"WARN UNTIL DATE")=$$TRIM^XLFSTR($P(X,U,6))
 . . I $P(X,U,7)'="" S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"EVENT D/T")=$$TRIM^XLFSTR($P(X,U,7))
 . . I $P(X,U,8)'="" S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"ENC PROVIDER")=$$TRIM^XLFSTR($P(X,U,8))
 . . I $P(X,U,9)'="" S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"REFUSED VACCINE GROUP")=$$TRIM^XLFSTR($P(X,U,9))
 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="IMM CONTRA/REFUSAL^"_ICR
 . . I $E(TYP,4)="-" S PXPCEARR("IMM CONTRA/REFUSAL",ICR,"DELETE")=1
 . I $E(TYP,1,2)="SC" D  Q
 . . Q:'$L(CODE)
 . . S SC=SC+1
 . . S PXPCEARR("STD CODES",SC,"CODE")=CODE
 . . I $P(X,U,5)'="" S PXPCEARR("STD CODES",SC,"CODING SYSTEM")=$P(X,U,5)
 . . I $P(X,U,6)'="" S PXPCEARR("STD CODES",SC,"ENC PROVIDER")=$P(X,U,6)
 . . I $P(X,U,7)'="" S PXPCEARR("STD CODES",SC,"MAGNITUDE")=$P(X,U,7)
 . . I $P(X,U,8)'="" S PXPCEARR("STD CODES",SC,"UCUM CODE")=$P(X,U,8)
 . . I $L($P(X,U,9)),($P(X,U,9)=1) S PXPCEARR("STD CODES",SC,"PL ADD")=$P(X,U,9) ;???,PROBLEMS(ICD)=NARR_U_CODE
 . . I $P(X,U,10)'="" S COMMENT($P(X,U,10))="STD CODES^"_SC
 . . I $P(X,U,11)'="" S PXPCEARR("STD CODES",SC,"EVENT D/T")=$P(X,U,11)
 . . I $P(X,U,12)'="" S PXPCEARR("STD CODES",SC,"ORD PROVIDER")=$P(X,U,12)
 . . I $E(TYP,3)="-" S PXPCEARR("STD CODES",SC,"DELETE")=1
 . I $E(TYP,1,3)="COM" D  Q
 . . Q:'$L(CODE)
 . . Q:'$L(CAT)
 . . S COMMENTS(CODE)=$$CTRL^XMXUTIL1($P(X,U,3))  ; Strip control characters when filing comments
 ;
 ;Store the comments
 S COM=""
 ;F  S COM=$O(COMMENT(COM)) Q:COM=""  S:$D(COMMENTS(COM)) PXAPI($P(COMMENT(COM),"^",1),$P(COMMENT(COM),"^",2),"COMMENT")=COMMENTS(COM)
 F  S COM=$O(COMMENT(COM)) Q:COM=""  D:$D(COMMENTS(COM))
 . I $G(IMMCOMMS(COM))'="" D
 . . I COMMENTS(COM)="@" S COMMENTS(COM)=""
 . . S COMMENTS(COM)=COMMENTS(COM)_$S(COMMENTS(COM)="":"",1:" ")_IMMCOMMS(COM)
 . S PXPCEARR($P(COMMENT(COM),"^",1),$P(COMMENT(COM),"^",2),"COMMENT")=COMMENTS(COM)
 ;
 ;Store the Remarks (currently used by immunizations) - PX,210
 S COM=""
 F  S COM=$O(REMARK(COM)) Q:COM=""  I $D(COMMENTS(COM)) D
 . S TYP=$P(REMARK(COM),"^",1)
 . S NUM=$P(REMARK(COM),"^",2)
 . S SEQ=$O(PXPCEARR(TYP,NUM,"REMARKS",""),-1)+1
 . S PXPCEARR(TYP,NUM,"REMARKS",SEQ,0)=COMMENTS(COM)
 ;
 ;Store the Immunization Override Reason - PX,215
 S COM=""
 F  S COM=$O(IMMOVERRIDE(COM)) Q:COM=""  I $G(COMMENTS(COM))'="" D
 . S TYP=$P(IMMOVERRIDE(COM),"^",1)
 . S NUM=$P(IMMOVERRIDE(COM),"^",2)
 . S PXPCEARR(TYP,NUM,"OVERRIDE REASON")=COMMENTS(COM)
 ;
 ;Store the Skin Test Reading Comment - PX*1*216
 S COM=""
 F  S COM=$O(SKRDCOM(COM)) Q:COM=""  I $G(COMMENTS(COM))'="" D
 . S TYP=$P(SKRDCOM(COM),"^",1)
 . S NUM=$P(SKRDCOM(COM),"^",2)
 . S PXPCEARR(TYP,NUM,"READING COMMENT")=COMMENTS(COM)
 ;
 ;Store the Immunization Reading Comment (for smallpox)
 S COM=""
 F  S COM=$O(IMMRDCOM(COM)) Q:COM=""  I $G(COMMENTS(COM))'="" D
 . S TYP=$P(IMMRDCOM(COM),"^",1)
 . S NUM=$P(IMMRDCOM(COM),"^",2)
 . S PXPCEIMMRD(TYP,NUM,"READING COMMENT")=COMMENTS(COM)
 ;
 I $D(PXPCEARR("ENCOUNTER",1)),$G(PXPCEARR("ENCOUNTER",1,"ENCOUNTER TYPE"))="" D
 . S PXPCEARR("ENCOUNTER",1,"ENCOUNTER TYPE")="P"
 ;
 Q