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

SDES2EDITPATDEMO.m

Go to the documentation of this file.
SDES2EDITPATDEMO ;ALB/BLB,BWF,JDJ - SDES2 EDIT PATIENT DEMOGRAPHICS ;JUN 17,2024
 ;;5.3;Scheduling;**877,878,881**;Aug 13, 1993;Build 10
 ;;Per VHA Directive 6402, this routine should not be modified
 ;---------------------------------------------------------------
 Q
 ;
EDITDEMOGRAPHICS(JSON,SDCONTEXT,PATIENT) ;
 N ERRORS,RETURN
 ;
 D VALIDATE(.ERRORS,.PATIENT,.SDCONTEXT)
 I $D(ERRORS) S ERRORS("EditPatientDemographics")="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ;
 D EDITDEMO($G(PATIENT("DFN")))
 S RETURN("EditPatientDemographics")=1
 D BUILDJSON^SDES2JSON(.JSON,.RETURN)
 Q
 ;
VALIDATE(ERRORS,PATIENT,SDCONTEXT) ;
 N RACECOUNT
 ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,2,$G(PATIENT("DFN")),1,,1,2)
 ;
 S RACECOUNT=0
 F  S RACECOUNT=$O(PATIENT("RACE",RACECOUNT)) Q:'RACECOUNT  D
 .I $G(PATIENT("RACE",RACECOUNT))="" K PATIENT("RACE",RACECOUNT) Q
 .D VALDEMO(.ERRORS,$E($G(PATIENT("RACE",RACECOUNT)),1,30),"RACE")
 I $G(PATIENT("ETHNICITY"))'="" D VALDEMO(.ERRORS,$G(PATIENT("ETHNICITY")),"ETHNICITY")
 I $G(PATIENT("MARITAL STATUS"))'="" D VALDEMO(.ERRORS,$G(PATIENT("MARITAL STATUS")),"MARITAL STATUS")
 I $G(PATIENT("RELIGION"))'="" D VALDEMO(.ERRORS,$G(PATIENT("RELIGION")),"RELIGION")
 Q
 ;
EDITDEMO(DFN) ;
 N TOPLEVELFDA,ETHNICITYFDA,RACEFDA,ETHNICITYIEN,RACECOUNT,SUBIEN,IENS,ERROR
 ;
 ; top level patient
 I $L($G(PATIENT("RELIGION"))) D
 .S TOPLEVELFDA(2,DFN_",",.08)=$$GETDEMOIEN($G(PATIENT("RELIGION")),"RELIGION")
 I $L($G(PATIENT("MARITAL STATUS"))) D
 .S TOPLEVELFDA(2,DFN_",",.05)=$$GETDEMOIEN($G(PATIENT("MARITAL STATUS")),"MARITAL STATUS")
 I $D(TOPLEVELFDA) D
 .D FILE^DIE(,"TOPLEVELFDA") K TOPLEVELFDA
 ;
 ; sub level race
 I $D(PATIENT("RACE")) D
 .S SUBIEN=0
 .F  S SUBIEN=$O(^DPT(DFN,.02,SUBIEN)) Q:'SUBIEN  D
 ..S IENS=SUBIEN_","_DFN_","
 ..S RACEFDA(2.02,IENS,.01)="@"
 ..D FILE^DIE(,"RACEFDA") K RACEFDA
 .;
 .S RACECOUNT=0
 .F  S RACECOUNT=$O(PATIENT("RACE",RACECOUNT)) Q:'RACECOUNT  D
 ..S IENS="+1,"_DFN_","
 ..S RACEFDA(2.02,IENS,.01)=$$GETDEMOIEN($E($G(PATIENT("RACE",RACECOUNT)),1,30),"RACE")
 ..S RACEFDA(2.02,IENS,.02)=1
 ..D UPDATE^DIE(,"RACEFDA",,"ERROR") K RACEFDA
 ;
 ; sub level ethnicity
 I $L($G(PATIENT("ETHNICITY"))) D
 .S ETHNICITYIEN=0,ETHNICITYIEN=$O(^DPT(DFN,.06,ETHNICITYIEN))
 .;
 .I '$G(ETHNICITYIEN) D  Q
 ..S ETHNICITYFDA(2.06,"+1,"_DFN_",",.01)=$$GETDEMOIEN($G(PATIENT("ETHNICITY")),"ETHNICITY")
 ..S ETHNICITYFDA(2.06,"+1,"_DFN_",",.02)=1
 ..D UPDATE^DIE(,"ETHNICITYFDA") K ETHNICITYFDA
 .;
 .S ETHNICITYFDA(2.06,ETHNICITYIEN_","_DFN_",",.01)=$$GETDEMOIEN($G(PATIENT("ETHNICITY")),"ETHNICITY")
 .S ETHNICITYFDA(2.06,ETHNICITYIEN_","_DFN_",",.02)=1
 .D FILE^DIE(,"ETHNICITYFDA") K ETHNICITYFDA
 Q
 ;
GETDEMOIEN(DEMO,TYPE) ;
 Q $S(TYPE="RELIGION":$O(^DIC(13,"B",DEMO,"")),TYPE="RACE":$O(^DIC(10,"B",DEMO,"")),TYPE="ETHNICITY":$O(^DIC(10.2,"B",DEMO,"")),TYPE="MARITAL STATUS":$O(^DIC(11,"B",DEMO,"")),1:"")
 ;
VALDEMO(ERRORS,DEMOGRAPHIC,TYPE) ;
 N FILENUM,DEMOIEN
 I '$L(DEMOGRAPHIC) Q
 S FILENUM=$S(TYPE="RELIGION":13,TYPE="RACE":10,TYPE="ETHNICITY":10.2,TYPE="MARITAL STATUS":11,1:"")
 I FILENUM="" D ERRLOG^SDES2JSON(.ERRORS,565) Q
 I '$D(^DIC(FILENUM,"B",DEMOGRAPHIC)) D ERRLOG^SDES2JSON(.ERRORS,565) Q
 S DEMOIEN=$O(^DIC(FILENUM,"B",DEMOGRAPHIC,0))
 I 'DEMOIEN D ERRLOG^SDES2JSON(.ERRORS,52,"Unable to locate "_DEMOGRAPHIC) Q
 I TYPE="RACE" D:+$$INACTIVE^DGUTL4(DEMOIEN,1) ERRLOG^SDES2JSON(.ERRORS,52,"Inactive Race: "_DEMOGRAPHIC)
 I TYPE="ETHNICITY" D:+$$INACTIVE^DGUTL4(DEMOIEN,2) ERRLOG^SDES2JSON(.ERRORS,52,"Inactive Ethnicity: "_DEMOGRAPHIC)
 Q