<!--- #10798: request.patientLockBlocked = true when Agency.Patient_Lock = 1 --->
<cfset request.patientLockBlocked = false />
<cftry>
	<cfif isDefined("getTimeZone") AND isDefined("getTimeZone.Patient_Lock") AND Val(getTimeZone.Patient_Lock) EQ 1>
		<cfset request.patientLockBlocked = true />
	<cfelse>
		<cfset _plAgencyId = 0 />
		<cfif isDefined("session.AgencyId") AND Val(session.AgencyId) GT 0>
			<cfset _plAgencyId = Val(session.AgencyId) />
		<cfelseif isDefined("session.AgencyID") AND Val(session.AgencyID) GT 0>
			<cfset _plAgencyId = Val(session.AgencyID) />
		</cfif>
		<cfif _plAgencyId GT 0>
			<cfquery name="_qPatientLock" datasource="#Application.DataSrc#">
				SELECT IFNULL(Patient_Lock, 0) AS Patient_Lock
				FROM #Request.prefix_db_lookup#.Agency
				WHERE Agency_ID = <cfqueryparam value="#_plAgencyId#" cfsqltype="cf_sql_integer">
			</cfquery>
			<cfif _qPatientLock.recordcount GT 0 AND Val(_qPatientLock.Patient_Lock) EQ 1>
				<cfset request.patientLockBlocked = true />
			</cfif>
		</cfif>
	</cfif>
	<cfcatch type="any">
		<!--- Column missing until migration #10798 runs --->
		<cfset request.patientLockBlocked = false />
	</cfcatch>
</cftry>
