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

AMHGSVF.m

Go to the documentation of this file.
AMHGSVF ; IHS/CMI/MAW - AMHG Save Visit Form Data (frmVisitDataEntry) 2/12/2009 3:01:26 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1,3,4,5,6,10**;JUN 02, 2010;Build 15
 ;
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("PN^AMHGSVF(.RETVAL,.AMHSTR)")
 Q
 ;
VISIT(RETVAL,AMHSTR) ;-- save visit form, called from method SaveVisit in clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHPP,AMHPRO,AMHCLN,AMHTOC,AMHARR,AMHEDT,AMHLOC,AMHAW,AMHCOM,AMHP,AMHER,AMHGN,AMHTIG,AMHTM,AMHESIG,AMHTMP,AMHATG
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHPP=$P(AMHSTR,P,3)
 S AMHPRO=$P(AMHSTR,P,4)
 S AMHPRO=$$SCI^AMHGT(9002011,.02,AMHPRO)
 S AMHCLN=$P(AMHSTR,P,5)
 S AMHTOC=$P(AMHSTR,P,6)
 S AMHARR=$TR($P(AMHSTR,P,7),":")
 S AMHEDT=+$P(AMHSTR,P,8)
 ;S AMHTM=+$$TM^AMHGU($P(AMHEDT,".",2))
 S AMHTMP=+$P(AMHEDT,".",2)
 S AMHLOC=$P(AMHSTR,P,9)
 S AMHAW=$P(AMHSTR,P,10)
 S AMHAW=$$SCI^AMHGT(9002011,.11,AMHAW)
 S AMHCOM=$P(AMHSTR,P,11)
 S AMHP=$P(AMHSTR,P,12)
 S AMHGN=$P(AMHSTR,P,13)
 S AMHTIG=$P(AMHSTR,P,14)
 S AMHESIG=$P(AMHSTR,P,15)
 S AMHATG=$P(AMHSTR,P,16)
 D MODV^AMHGEVF(.AMHIEN,AMHDM,AMHREC,AMHPP,AMHPRO,AMHCLN,AMHTOC,AMHARR,AMHEDT,AMHLOC,AMHAW,AMHCOM,AMHP,AMHGN,AMHTIG,AMHATG)
 ;cmi/maw v4.0p10 update the call below to not change the record if an edit and already signed
 I $G(AMHESIG) D UPDREC^AMHGESIG(AMHIEN,DUZ)
 S @RETVAL@(AMHI)="T00010BMXIEN"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=+$G(AMHIEN)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
POV(RETVAL,AMHSTR) ;-- save POV called from method SavePOV in clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHA2,AMHA3,AMHA4,AMHA5,AMHP,AMHER,AMHGAF
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHA2=$P(AMHSTR,P,3)
 S AMHA3=$P(AMHSTR,P,4)
 S AMHA4=$P(AMHSTR,P,5)
 S AMHA5=$P(AMHSTR,P,6)
 S AMHP=$P(AMHSTR,P,7)
 S AMHGAF=$P(AMHSTR,P,8)
 N AMH2,AMH4
 D ARRAY^AMHGU(.AMH2,AMHA2)
 D ARRAY^AMHGU(.AMH4,AMHA4)
 D AXIS2(AMHDM,AMHREC,AMHP,.AMH2)
 D AXIS3(AMHDM,AMHREC,AMHP,AMHA3)
 D AXIS4(AMHDM,AMHREC,AMHP,.AMH4)
 D AXIS5(AMHDM,AMHREC,AMHP,AMHA5,AMHGAF)
 ;D VAUD^AMHGEVF(AMHREC)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
AXIS2(D,RC,P,A2) ;EP -- add/modify pov
 N AMHDA,R,AMHN
 S R="~"
 D CLNPOV(RC)  ;ihs/cmi/maw patch 3 remove all povs before readding or editing since primary and secondary not segregated
 S AMHDA=0 F  S AMHDA=$O(A2(AMHDA)) Q:'AMHDA  D
 . N STR,PIEN,PCODE,PNARR
 . S STR=$G(A2(AMHDA))
 . S PIEN=$P(STR,R)
 . S PCODE=$P(STR,R,2)
 . S PNARR=$P(STR,R,3)
 . I $G(PNARR)]"" D
 ..S AMHN=$$FNDNARR^AMHGU(PNARR,1)
 . D ADDPOV^AMHGEVF(PIEN,P,RC,$G(AMHN))
 . Q
 . ;below code was used before patch 3 not needed anymore
 . I D="A" D ADDPOV^AMHGEVF(PIEN,P,RC,$G(AMHN)) Q
 . I D="E" D  Q
 .. N AMHPREC
 .. S AMHPREC=$$FNDPOV^AMHGU(PIEN,RC)
 .. I 'AMHPREC D ADDPOV^AMHGEVF(PIEN,P,RC,$G(AMHN)) Q
 .. D EDITPOV^AMHGEVF(AMHPREC,$G(AMHN))
 I D="E" D  Q
 . D DELPOV^AMHGEVF(RC,.A2)
 Q
 ;
CLNPOV(REC) ;-- clean out all POV records first
 N IEN
 S IEN=0 F  S IEN=$O(^AMHRPRO("AD",REC,IEN)) Q:'IEN  D
 . S DIK="^AMHRPRO(",DA=IEN D ^DIK
 Q
 ;
AXIS3(D,RC,P,A3) ;-- file axis 3 data
 Q:$G(A3)=""
 N AMHWP
 D ARRAYT^AMHGU(.AMHWP,A3)  ;parse the text into an array
 N AMHFDA,AMHIENS,AMHERRR
 S AMHIENS=RC_","
 D WP^AMHGU(.AMHERRR,9002011,AMHIENS,5301,.AMHWP)
 Q
 ;
AXIS4(D,RC,P,A4) ;-- file axis 4 data
 N AMHDA,R
 S R="~"
 I D="E" D CLNA4^AMHGEVF(RC)
 S AMHDA=0 F  S AMHDA=$O(A4(AMHDA)) Q:'AMHDA  D
 . N STR,PIEN,PCODE,PNARR
 . S STR=$G(A4(AMHDA))
 . S PIEN=$P(STR,R)
 . S PCODE=$P(STR,R,2)
 . S PNARR=$P(STR,R,3)
 . D ADDAXIS4^AMHGEVF(PIEN,P,RC,PNARR) Q
 Q
 ;
AXIS5(D,RC,P,A5,GAF) ;-- file axis 5 data
 N AMHFDA,AMHIENS,AMHERRR,AMHA5
 S AMHIENS=RC_","
 S AMHFDA(9002011,AMHIENS,.14)=A5
 S AMHFDA(9002011,AMHIENS,1115)=GAF
 D FILE^DIE("K","AMHFDA","AMHERRR(1)")
 I '$D(AMHERRR) S AMHA5=RC
 Q
 ;
ACT(RETVAL,AMHSTR) ;-- save activity tab, called from method SaveActivity in clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHACT,AMHVF,AMHAT,AMHIU,AMHLSS,AMHNS,AMHER,AMHCPT,AMHSP
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHACT=$P(AMHSTR,P,3)
 S AMHVF=$P(AMHSTR,P,4)
 S AMHAT=$P(AMHSTR,P,5)
 S AMHIU=$P(AMHSTR,P,6)
 S AMHLSS=$P(AMHSTR,P,7)
 S AMHNS=$P(AMHSTR,P,8)
 S AMHCPT=$P(AMHSTR,P,9)
 S AMHSP=$P(AMHSTR,P,10)
 S AMHP=$P(AMHSTR,P,11)
 D ACT^AMHGEVF(.AMHIEN,AMHDM,AMHREC,AMHACT,AMHVF,AMHAT,AMHIU,AMHLSS,AMHNS,AMHP)
 D CPT(AMHDM,AMHREC,AMHP,AMHCPT)
 D SP(AMHDM,AMHREC,AMHP,AMHSP)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
CPT(D,RC,P,CPT) ;-- file cpt codes from activity tab
 N ACPT,QTY,MOD1,MOD2,R
 S R="~"
 D ARRAY^AMHGU(.ACPT,.CPT)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(ACPT(AMHDA)) Q:'AMHDA  D
 . N CPT
 . S CPT=+$P(ACPT(AMHDA),R)
 . S QTY=+$P(ACPT(AMHDA),R,4)
 . I QTY<1 S QTY=1
 . S MOD1=$P(ACPT(AMHDA),R,5)
 . S MOD2=$P(ACPT(AMHDA),R,6)
 . D MODCPT^AMHGEVF(CPT,QTY,MOD1,MOD2,P,RC)
 I D="E" D DELCPT^AMHGEVF(RC,.ACPT)
 Q
 ;
SP(D,RC,P,SP) ;EP -- file secondary providers from activity tab
 N ASP
 D ARRAY^AMHGU(.ASP,.SP)
 I D="E" D DELPRV^AMHGEVF(RC,.ASP,"S")
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(ASP(AMHDA)) Q:'AMHDA  D
 . N PRV
 . S PRV=+$G(ASP(AMHDA))
 . D MODPRV^AMHGEVF(PRV,D,RC,P,"S")
 ;ihs/cmi/maw 01.16.2013 v4.0p3 moved call to above to cleanup secondary providers
 ;I D="E" D DELPRV^AMHGEVF(RC,.ASP,"S")
 Q
 ;
PN(RETVAL,AMHSTR) ;-- file progress notes tab called from SaveProgressNotes method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHCC,AMHPN,AMHCMT,AMHPD,AMHPLN,AMHP,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHCC=$P(AMHSTR,P,3)
 S AMHPN=$P(AMHSTR,P,4)
 S AMHCMT=$P(AMHSTR,P,5)
 S AMHPD=$P(AMHSTR,P,6)
 S AMHPLN=$P(AMHSTR,P,7)
 S AMHP=$P(AMHSTR,P,8)
 D CCPD^AMHGEVF(AMHDM,AMHREC,AMHCC,AMHPD,AMHPLN,AMHP)
 D PN^AMHGEVF(AMHDM,AMHREC,AMHPN,AMHP)
 D CMT^AMHGEVF(AMHDM,AMHREC,AMHCMT,AMHP)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
RX(RETVAL,AMHSTR) ;-- file rx notes tab, called from the SaveRX method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHRX,AMHP,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHRX=$P(AMHSTR,P,3)
 S AMHP=$P(AMHSTR,P,4)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 D RX^AMHGEVF(AMHDM,AMHREC,AMHRX,AMHP)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
EDU(RETVAL,AMHSTR) ;-- file the education topics from the wellness tab, called from the SaveEducationTopics method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHEDU,AMHP,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHEDU=$P(AMHSTR,P,3)
 S AMHP=$P(AMHSTR,P,4)
 N EDU
 D ARRAY^AMHGU(.EDU,AMHEDU)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(EDU(AMHDA)) Q:'AMHDA  D
 . N EDUE,EDUI,TIME,LOU,CMT,CPT,STA,GOAL,IG,REA,PRVI
 . S EDU=$P(EDU(AMHDA),R)
 . S EDUI=$O(^AUTTEDT("B",EDU,0))
 . S TIME=$P(EDU(AMHDA),R,2)
 . S LOU=$$SCI^AMHGT(9002011.05,.08,$P(EDU(AMHDA),R,3))
 . S CMT=$P(EDU(AMHDA),R,4)
 . S CPT=$P(EDU(AMHDA),R,5)
 . I $G(CPT)]"" S CPT=$O(^ICPT("B",CPT,0))
 . S STA=$$SCI^AMHGT(9002011.05,.11,$P(EDU(AMHDA),R,6))
 . S GOAL=$P(EDU(AMHDA),R,7)
 . S IG=$P(EDU(AMHDA),R,8)
 . S REA=$S($P(EDU(AMHDA),R,9)]"":$O(^AUTTRTL("B",$P(EDU(AMHDA),R,9),0)),1:"")
 . S PRVI=$P(EDU(AMHDA),R,10)
 . D MODEDU^AMHGEVF(AMHDM,AMHREC,AMHP,EDUI,TIME,LOU,CMT,CPT,STA,GOAL,IG,REA,PRVI)
 I AMHDM="E" D DELEDU^AMHGEVF(AMHREC,.EDU)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
HF(RETVAL,AMHSTR) ;-- file the health factors from the wellness tab, called from the SaveHealthFactors method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHHF,AMHP,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHHF=$P(AMHSTR,P,3)
 S AMHP=$P(AMHSTR,P,4)
 N HF
 D ARRAY^AMHGU(.HF,AMHHF)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(HF(AMHDA)) Q:'AMHDA  D
 . N HFE,HFI,LS,QTY,CMT
 . S HFE=$P(HF(AMHDA),R)
 . S HFI=$O(^AUTTHF("B",HFE,0))
 . S LS=$$SCI^AMHGT(9002011.08,.04,$P(HF(AMHDA),R,2))
 . S QTY=$P(HF(AMHDA),R,3)
 . S CMT=$P(HF(AMHDA),R,4)
 . D MODHF^AMHGEVF(AMHDM,AMHREC,AMHP,HFI,LS,QTY,CMT)
 I AMHDM="E" D DELHF^AMHGEVF(AMHREC,.HF)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SCREEN(RETVAL,AMHSTR) ;file screening from the wellness tab, called from the SaveScreening method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHA,AMHAC,AMHD,AMHDC,AMHIP,AMHIPC,AMHPP,AMHP,AMHER,AMHAPRV,AMHDPRV,AMHIPRV
 N AMHS,AMHSC,AMHSPRV
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHA=$$SCI^AMHGT(9002011,1403,$P(AMHSTR,P,3))
 S AMHAC=$P(AMHSTR,P,4)
 S AMHD=$$SCI^AMHGT(9002011,1405,$P(AMHSTR,P,5))
 S AMHDC=$P(AMHSTR,P,6)
 S AMHIP=$$SCI^AMHGT(9002011,1401,$P(AMHSTR,P,7))
 S AMHIPC=$P(AMHSTR,P,8)
 S AMHPP=$P(AMHSTR,P,9)
 S AMHP=$P(AMHSTR,P,10)
 S AMHAPRV=$P(AMHSTR,P,11)
 S AMHDPRV=$P(AMHSTR,P,12)
 S AMHIPRV=$P(AMHSTR,P,13)
 S AMHS=$$SCI^AMHGT(9002011,1407,$P(AMHSTR,P,14))
 S AMHSC=$P(AMHSTR,P,15)
 S AMHSPRV=$P(AMHSTR,P,16)
 D SCREEN^AMHGEVF(AMHDM,AMHREC,AMHP,AMHPP,AMHA,AMHAC,AMHD,AMHDC,AMHIP,AMHIPC,AMHAPRV,AMHDPRV,AMHIPRV,AMHS,AMHSC,AMHSPRV)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
MSR(RETVAL,AMHSTR) ;-- file measurements from the measurements tab, called from the SaveMeasurements tab of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHMSR,AMHP,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHMSR=$P(AMHSTR,P,3)
 S AMHP=$P(AMHSTR,P,4)
 N MSR
 D ARRAY^AMHGU(.MSR,AMHMSR)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(MSR(AMHDA)) Q:'AMHDA  D
 . N MSRE,MSRI,VAL,PRVI
 . S MSRE=$P(MSR(AMHDA),R)
 . S MSRI=$O(^AUTTMSR("B",MSRE,0))
 . S VAL=$P(MSR(AMHDA),R,3)
 . S PRVI=$P(MSR(AMHDA),R,4)
 . D MODMSR^AMHGEVF(AMHDM,AMHREC,AMHP,MSRI,VAL,PRVI)
 I AMHDM="E" D DELMSR^AMHGEVF(AMHREC,.MSR)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
ASS(RETVAL,AMHSTR) ;-- save assessment from assessment tab, called from SaveAssessment method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHA,AMHP,AMHER,AMHIT,AMHPP,AMHPRG,AMHEDT
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHA=$P(AMHSTR,P,3)
 S AMHP=$P(AMHSTR,P,4)
 S AMHIT=$P(AMHSTR,P,5)
 S AMHPP=$P(AMHSTR,P,6)
 S AMHPRG=$$SCI^AMHGT(9002011,.02,$P(AMHSTR,P,7))
 S AMHEDT=$P($P(AMHSTR,P,8),".")
 D ASS^AMHGEVF(AMHDM,AMHREC,AMHA,AMHP,AMHIT,AMHPP,AMHPRG,AMHEDT)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
CD(RETVAL,AMHSTR) ;-- save CD data from CD Data tab, called from SaveCDData method of clsVisitDataEntry
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHCDC,AMHCDT,AMHTOC,AMHDIR,AMHDIA,AMHP,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHDM=$P(AMHSTR,P)
 S AMHREC=$P(AMHSTR,P,2)
 S AMHCDC=$P(AMHSTR,P,3)
 S AMHCDT=$P(AMHSTR,P,4)
 S AMHTOC=$P(AMHSTR,P,5)
 S AMHDIR=$P(AMHSTR,P,6)
 S AMHDIA=$P(AMHSTR,P,7)
 S AMHP=$P(AMHSTR,P,8)
 D CD^AMHGEVF(AMHDM,AMHREC,AMHP,AMHCDC,AMHCDT,AMHTOC,AMHDIR,AMHDIA)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
DEL(RETVAL,AMHSTR) ;-- mark a record as deleted
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHDM,AMHREC,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 I $G(AMHSTR)="" D CATSTR^AMHGU(.AMHSTR,.AMHSTR)
 K ^AMHTMP($J)
 S AMHREC=$P(AMHSTR,P)
 D EN^AMHGVDEL(.AMHREC,AMHREC)
 I $E($G(RET),1,2)="-1" D
 . S AMHER="0~"_$P(RET,$C(30),2)
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:AMHREC)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;