Create
Procedure
	[dbo].[Pr_TaminPrescriptionOld_SetReceptionId]
(
		@NationalCode Varchar(15),
		@TrackingCode Varchar(50),
		@ReceptionId Bigint,
		@EPRSC_ID BigInt
)
As

Declare
		@TaminPrescriptionId Int
		--@registeR_ID Int

Select
		
		@TaminPrescriptionId = s.[Id]
		--@registeR_ID = s.[registeR_ID]
	From [dbo].[tbl_TaminHeadOld] As h
	Left Join [dbo].[tbl_TaminPrescriptionOld] As s On s.[HeadId] = h.[Id] And s.[EPRSC_ID] = @EPRSC_ID And s.[DateCreate] = [dbo].[Fn_GetPersianDate]()
	Where	[NationalCode] = @NationalCode
	And		[TrackingCode] = @TrackingCode
	And		s.[EPRSC_ID] = @EPRSC_ID
	And		s.[Id] Is Not Null





Update
	[dbo].[tbl_TaminPrescriptionOld]
		Set
			[ReceptionId] = @ReceptionId
	Where [Id] = @TaminPrescriptionId

Update
	[dbo].[tblReception]
		Set
			[mOnlineRecNo] = @TrackingCode
	Where [mNumber] = @ReceptionId
