GMVDCUTL ;HOIFO/DAD,FT-VITALS COMPONENT: UTILITIES ;9/29/00 09:18
;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
;
; This routine uses the following IAs:
; #10104 - ^XLFSTR calls (supported)
;
VITIEN(GMVITTYP) ;
; Convert a vital type abbr / PCE abbr / name to an IEN
; Input:
; A vital type IEN or abbr or PCE abbr or name
; Output:
; A pointer to the GMRV Vital Type file (#120.51)
N GMVABR,GMVNAM,GMVPCE
S GMVABR=$S($G(GMVITTYP)]"":+$O(^GMRD(120.51,"C",GMVITTYP,0)),1:0)
S GMVPCE=$S($G(GMVITTYP)]"":+$O(^GMRD(120.51,"APCE",GMVITTYP,0)),1:0)
S GMVNAM=$S($G(GMVITTYP)]"":+$O(^GMRD(120.51,"B",GMVITTYP,0)),1:0)
S GMVD0=$S(GMVITTYP=+GMVITTYP:GMVITTYP,GMVABR:GMVABR,GMVPCE:GMVPCE,GMVNAM:GMVNAM,1:-1)
S GMVD0=$S($D(^GMRD(120.51,GMVD0,0))#2:GMVD0,1:-1)
Q GMVD0
;
QUAIEN(GMVITQUA) ;
; Convert a vital qualifier name to an IEN
; Input:
; A vital qualifier IEN or name or synonym
; Output:
; A pointer to the GMRV Vital Qualifier file (#120.52)
N GMVD0,GMVIEN,GMVNAM
S GMVNAM=$S($G(GMVITQUA)]"":+$O(^GMRD(120.52,"B",GMVITQUA,0)),1:-1)
S GMVD0=$S(GMVITQUA=+GMVITQUA:GMVITQUA,GMVNAM>0:GMVNAM,1:-1)
S GMVD0=$S($D(^GMRD(120.52,GMVD0,0))#2:GMVD0,1:-1)
I GMVD0'>0,$G(GMVITQUA)]"" D
. S GMVIEN=0
. F S GMVIEN=$O(^GMRD(120.52,GMVIEN)) Q:GMVIEN'>0 D Q:GMVD0>0
.. I $P($G(^GMRD(120.52,GMVIEN,0)),U,2)=GMVITQUA S GMVD0=GMVIEN
.. Q
. Q
Q GMVD0
;
CATIEN(GMVITCAT) ;
; Convert a vital category name to an IEN
; Input:
; A vital category IEN or name
; Output:
; A pointer to the GMRV Vital Category file (#120.53)
N GMVCAT,GMVD0
S GMVCAT=$S($G(GMVITCAT)]"":+$O(^GMRD(120.53,"B",GMVITCAT,0)),1:0)
S GMVD0=$S(GMVITCAT=+GMVITCAT:GMVITCAT,GMVCAT:GMVCAT,1:-1)
S GMVD0=$S($D(^GMRD(120.53,GMVD0,0))#2:GMVD0,1:-1)
Q GMVD0
;
REAIEN(GMVITREA) ;
; Convert an entered in error reason external form to an internal form
; Input:
; A vital entered in error reason in internal/external form
; Output:
; A vital entered in error reason in internal form
N GMVD0,GMVDATA
S GMVDATA=$$GET1^DID(120.506,.01,"","POINTER")
S GMVITREA(0)=$P(GMVDATA,":"_GMVITREA_";")
S GMVITREA(0)=$P(GMVITREA(0),";",$L(GMVITREA(0),";"))
S GMVD0=$S(GMVITREA=+GMVITREA:GMVITREA,GMVITREA(0):GMVITREA(0),1:-1)
S GMVD0=$S(";"_GMVDATA[(";"_GMVD0_":"):GMVD0,1:-1)
Q GMVD0
;
MEASYS(GMVMSYS) ;
; Validates and returns the measurement system
; Input:
; GMVMSYS = Measurement system (Optional)
; M = Metric, C - US Customary (Default)
; Output:
; M = Metric, C - US Customary (Default)
S GMVMSYS=$$UP^XLFSTR($G(GMVMSYS))
Q $S("^C^M^"[(U_GMVMSYS_U):GMVMSYS,1:"C")
;
FMTPARAM(GMVIN,GMVOUT) ;
; Reformat the validate/save list parameter
; Input:
; GMVIN = The list parameter data as it comes from the RPC broker
; See remote procedure GMV SAVE VITALS or GMV VALIDATE VITALS
; for a description of the format of the data
; GMVOUT = A closed array reference used to store the reformatted data
; Output:
; @GMVOUT@("V",##) = Measurements
; @GMVOUT@("I",##) = Entered in error IENS
; @GMVOUT@("Q",##,##) = Qualifiers
; @GMVOUT@("R",##,##) = Entered in error reasons
; GMVDFN = PatientDFN
; GMVDTDUN = DateTimeTaken
; GMVHOSPL = HospitalLocation
; GMVDTENT = DateTimeEntered
; GMVENTBY = EnteredBy
; GMVERRBY = EnteredInErrorBy
; GMVMSYS = MeasurementSystem
;
N GMV,GMVDATA,GMVMAJOR,GMVMINOR,GMVRET,GMVS2V,GMVTYPE,GMVVAR,GMVVARTY
K @GMVOUT
F GMV=1:1 S GMVDATA=$P($T(SUBVAR+GMV),";;",2) Q:GMVDATA="" D
. S GMVVAR=$P(GMVDATA,U,2),GMVVARTY=$P(GMVDATA,U,3)
. S GMVS2V($P(GMVDATA,U))=GMVVAR_U_GMVVARTY
. S @(GMVVAR_"=-1")
. Q
S GMV=""
F S GMV=$O(GMVIN(GMV)) Q:GMV="" D
. I (GMV?1U1"^"1.N)!(GMV?1U1"^"1.N1"^"1.N) D
.. S GMVTYPE=$P(GMV,U),GMVMAJOR=$P(GMV,U,2),GMVMINOR=$P(GMV,U,3)
.. I "^I^V^"[(U_GMVTYPE_U) D ; Entered in Error IENS & Measurements
... S @GMVOUT@(GMVTYPE,GMVMAJOR)=GMVIN(GMV)
... Q
.. I "^Q^R^"[(U_GMVTYPE_U) D ; Qualifiers & Reasons entered in error
... S @GMVOUT@(GMVTYPE,GMVMAJOR,GMVMINOR)=GMVIN(GMV)
... Q
.. Q
. E D
.. S GMVDATA=$G(GMVS2V(GMV))
.. S GMVVAR=$P(GMVDATA,U),GMVVARTY=$P(GMVDATA,U,2)
.. I GMVVARTY="D" D
... K GMVRET
... D DT^DILF("RSTX",GMVIN(GMV),.GMVRET)
... S GMVIN(GMV)=$G(GMVRET)
... Q
.. I GMVVARTY="U",$$UP^XLFSTR(GMVIN(GMV))="DUZ" D
... S GMVIN(GMV)=DUZ
... Q
.. I GMVVAR]"",GMVIN(GMV)]"" S @(GMVVAR_"="""_GMVIN(GMV)_"""")
.. Q
. Q
Q
SUBVAR ;;Subscript ^ Variable ^ DataType (D-Date/Time, L-Literal, U-User)
;;PatientDFN^GMVDFN^L
;;DateTimeTaken^GMVDTDUN^D
;;HospitalLocation^GMVHOSPL^L
;;DateTimeEntered^GMVDTENT^D
;;EnteredBy^GMVENTBY^U
;;EnteredInErrorBy^GMVERRBY^U
;;MeasurementSystem^GMVMSYS^L
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMVDCUTL 4877 printed Dec 13, 2024@01:58:35 Page 2
GMVDCUTL ;HOIFO/DAD,FT-VITALS COMPONENT: UTILITIES ;9/29/00 09:18
+1 ;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #10104 - ^XLFSTR calls (supported)
+5 ;
VITIEN(GMVITTYP) ;
+1 ; Convert a vital type abbr / PCE abbr / name to an IEN
+2 ; Input:
+3 ; A vital type IEN or abbr or PCE abbr or name
+4 ; Output:
+5 ; A pointer to the GMRV Vital Type file (#120.51)
+6 NEW GMVABR,GMVNAM,GMVPCE
+7 SET GMVABR=$SELECT($GET(GMVITTYP)]"":+$ORDER(^GMRD(120.51,"C",GMVITTYP,0)),1:0)
+8 SET GMVPCE=$SELECT($GET(GMVITTYP)]"":+$ORDER(^GMRD(120.51,"APCE",GMVITTYP,0)),1:0)
+9 SET GMVNAM=$SELECT($GET(GMVITTYP)]"":+$ORDER(^GMRD(120.51,"B",GMVITTYP,0)),1:0)
+10 SET GMVD0=$SELECT(GMVITTYP=+GMVITTYP:GMVITTYP,GMVABR:GMVABR,GMVPCE:GMVPCE,GMVNAM:GMVNAM,1:-1)
+11 SET GMVD0=$SELECT($DATA(^GMRD(120.51,GMVD0,0))#2:GMVD0,1:-1)
+12 QUIT GMVD0
+13 ;
QUAIEN(GMVITQUA) ;
+1 ; Convert a vital qualifier name to an IEN
+2 ; Input:
+3 ; A vital qualifier IEN or name or synonym
+4 ; Output:
+5 ; A pointer to the GMRV Vital Qualifier file (#120.52)
+6 NEW GMVD0,GMVIEN,GMVNAM
+7 SET GMVNAM=$SELECT($GET(GMVITQUA)]"":+$ORDER(^GMRD(120.52,"B",GMVITQUA,0)),1:-1)
+8 SET GMVD0=$SELECT(GMVITQUA=+GMVITQUA:GMVITQUA,GMVNAM>0:GMVNAM,1:-1)
+9 SET GMVD0=$SELECT($DATA(^GMRD(120.52,GMVD0,0))#2:GMVD0,1:-1)
+10 IF GMVD0'>0
IF $GET(GMVITQUA)]""
Begin DoDot:1
+11 SET GMVIEN=0
+12 FOR
SET GMVIEN=$ORDER(^GMRD(120.52,GMVIEN))
if GMVIEN'>0
QUIT
Begin DoDot:2
+13 IF $PIECE($GET(^GMRD(120.52,GMVIEN,0)),U,2)=GMVITQUA
SET GMVD0=GMVIEN
+14 QUIT
End DoDot:2
if GMVD0>0
QUIT
+15 QUIT
End DoDot:1
+16 QUIT GMVD0
+17 ;
CATIEN(GMVITCAT) ;
+1 ; Convert a vital category name to an IEN
+2 ; Input:
+3 ; A vital category IEN or name
+4 ; Output:
+5 ; A pointer to the GMRV Vital Category file (#120.53)
+6 NEW GMVCAT,GMVD0
+7 SET GMVCAT=$SELECT($GET(GMVITCAT)]"":+$ORDER(^GMRD(120.53,"B",GMVITCAT,0)),1:0)
+8 SET GMVD0=$SELECT(GMVITCAT=+GMVITCAT:GMVITCAT,GMVCAT:GMVCAT,1:-1)
+9 SET GMVD0=$SELECT($DATA(^GMRD(120.53,GMVD0,0))#2:GMVD0,1:-1)
+10 QUIT GMVD0
+11 ;
REAIEN(GMVITREA) ;
+1 ; Convert an entered in error reason external form to an internal form
+2 ; Input:
+3 ; A vital entered in error reason in internal/external form
+4 ; Output:
+5 ; A vital entered in error reason in internal form
+6 NEW GMVD0,GMVDATA
+7 SET GMVDATA=$$GET1^DID(120.506,.01,"","POINTER")
+8 SET GMVITREA(0)=$PIECE(GMVDATA,":"_GMVITREA_";")
+9 SET GMVITREA(0)=$PIECE(GMVITREA(0),";",$LENGTH(GMVITREA(0),";"))
+10 SET GMVD0=$SELECT(GMVITREA=+GMVITREA:GMVITREA,GMVITREA(0):GMVITREA(0),1:-1)
+11 SET GMVD0=$SELECT(";"_GMVDATA[(";"_GMVD0_":"):GMVD0,1:-1)
+12 QUIT GMVD0
+13 ;
MEASYS(GMVMSYS) ;
+1 ; Validates and returns the measurement system
+2 ; Input:
+3 ; GMVMSYS = Measurement system (Optional)
+4 ; M = Metric, C - US Customary (Default)
+5 ; Output:
+6 ; M = Metric, C - US Customary (Default)
+7 SET GMVMSYS=$$UP^XLFSTR($GET(GMVMSYS))
+8 QUIT $SELECT("^C^M^"[(U_GMVMSYS_U):GMVMSYS,1:"C")
+9 ;
FMTPARAM(GMVIN,GMVOUT) ;
+1 ; Reformat the validate/save list parameter
+2 ; Input:
+3 ; GMVIN = The list parameter data as it comes from the RPC broker
+4 ; See remote procedure GMV SAVE VITALS or GMV VALIDATE VITALS
+5 ; for a description of the format of the data
+6 ; GMVOUT = A closed array reference used to store the reformatted data
+7 ; Output:
+8 ; @GMVOUT@("V",##) = Measurements
+9 ; @GMVOUT@("I",##) = Entered in error IENS
+10 ; @GMVOUT@("Q",##,##) = Qualifiers
+11 ; @GMVOUT@("R",##,##) = Entered in error reasons
+12 ; GMVDFN = PatientDFN
+13 ; GMVDTDUN = DateTimeTaken
+14 ; GMVHOSPL = HospitalLocation
+15 ; GMVDTENT = DateTimeEntered
+16 ; GMVENTBY = EnteredBy
+17 ; GMVERRBY = EnteredInErrorBy
+18 ; GMVMSYS = MeasurementSystem
+19 ;
+20 NEW GMV,GMVDATA,GMVMAJOR,GMVMINOR,GMVRET,GMVS2V,GMVTYPE,GMVVAR,GMVVARTY
+21 KILL @GMVOUT
+22 FOR GMV=1:1
SET GMVDATA=$PIECE($TEXT(SUBVAR+GMV),";;",2)
if GMVDATA=""
QUIT
Begin DoDot:1
+23 SET GMVVAR=$PIECE(GMVDATA,U,2)
SET GMVVARTY=$PIECE(GMVDATA,U,3)
+24 SET GMVS2V($PIECE(GMVDATA,U))=GMVVAR_U_GMVVARTY
+25 SET @(GMVVAR_"=-1")
+26 QUIT
End DoDot:1
+27 SET GMV=""
+28 FOR
SET GMV=$ORDER(GMVIN(GMV))
if GMV=""
QUIT
Begin DoDot:1
+29 IF (GMV?1U1"^"1.N)!(GMV?1U1"^"1.N1"^"1.N)
Begin DoDot:2
+30 SET GMVTYPE=$PIECE(GMV,U)
SET GMVMAJOR=$PIECE(GMV,U,2)
SET GMVMINOR=$PIECE(GMV,U,3)
+31 ; Entered in Error IENS & Measurements
IF "^I^V^"[(U_GMVTYPE_U)
Begin DoDot:3
+32 SET @GMVOUT@(GMVTYPE,GMVMAJOR)=GMVIN(GMV)
+33 QUIT
End DoDot:3
+34 ; Qualifiers & Reasons entered in error
IF "^Q^R^"[(U_GMVTYPE_U)
Begin DoDot:3
+35 SET @GMVOUT@(GMVTYPE,GMVMAJOR,GMVMINOR)=GMVIN(GMV)
+36 QUIT
End DoDot:3
+37 QUIT
End DoDot:2
+38 IF '$TEST
Begin DoDot:2
+39 SET GMVDATA=$GET(GMVS2V(GMV))
+40 SET GMVVAR=$PIECE(GMVDATA,U)
SET GMVVARTY=$PIECE(GMVDATA,U,2)
+41 IF GMVVARTY="D"
Begin DoDot:3
+42 KILL GMVRET
+43 DO DT^DILF("RSTX",GMVIN(GMV),.GMVRET)
+44 SET GMVIN(GMV)=$GET(GMVRET)
+45 QUIT
End DoDot:3
+46 IF GMVVARTY="U"
IF $$UP^XLFSTR(GMVIN(GMV))="DUZ"
Begin DoDot:3
+47 SET GMVIN(GMV)=DUZ
+48 QUIT
End DoDot:3
+49 IF GMVVAR]""
IF GMVIN(GMV)]""
SET @(GMVVAR_"="""_GMVIN(GMV)_"""")
+50 QUIT
End DoDot:2
+51 QUIT
End DoDot:1
+52 QUIT
SUBVAR ;;Subscript ^ Variable ^ DataType (D-Date/Time, L-Literal, U-User)
+1 ;;PatientDFN^GMVDFN^L
+2 ;;DateTimeTaken^GMVDTDUN^D
+3 ;;HospitalLocation^GMVHOSPL^L
+4 ;;DateTimeEntered^GMVDTENT^D
+5 ;;EnteredBy^GMVENTBY^U
+6 ;;EnteredInErrorBy^GMVERRBY^U
+7 ;;MeasurementSystem^GMVMSYS^L
+8 ;;