IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[ENT_YBBYS_278_MANUEL_PAKET]') AND OBJECTPROPERTY(id,N'IsVIew') = 1)
BEGIN
    INSERT INTO SCRIPT_BACKUPS (SCRIPTNAME,SCRIPT,SCRIPTDATE) SELECT 'ENT_YBBYS_278_MANUEL_PAKET' SCRIPTNAME,OBJECT_DEFINITION(OBJECT_ID('ENT_YBBYS_278_MANUEL_PAKET')) AS SCRIPT,GETDATE() AS SCRIPTDATE
    DROP VIEW ENT_YBBYS_278_MANUEL_PAKET
END

GO

CREATE VIEW ENT_YBBYS_278_MANUEL_PAKET
AS
SELECT HastaId,	
	FullName,	
	HbysDosyaId,	
	VisitId,	
	KimlikEntegreReferansKodu,	
	BedName,	
	ZoneName,
	SNOTAKIPNO SYSTakipNo,
	Tarih,	
	Saat,	
	KayitTarihi,	
	KayitSaati,	
	ManuelMi,	
	ABPMean,	
	ABPdias,	
	ABPsys,	
	Diastolik,	
	HR,	
	Fio2,	
	SPO2,	
	Sistolik,	
	Temp,	
	PH,	
	PO2,	
	PCO2,	
	HCO3,	
	CLac,	
	CGlu,	
	TVe,	
	RR,	
	PEEP,	
	VentilatorModu,	
	Ptepe	
	from HYYBBYS_MANUEL_GIRIS I WITH(NOLOCK)
INNER JOIN HYYBBYS_MANUEL_GIRIS_DETAY ISL WITH(NOLOCK) ON I.HYYBBYSID=ISL.HYYBBYSID
INNER JOIN HDOSYA H  WITH(NOLOCK) ON H.HDOSYAID=HbysDosyaId
WHERE HR IS NOT NULL AND SPO2 IS NOT NULL AND PH IS NOT NULL AND 
      PO2 IS NOT NULL AND PCO2 IS NOT NULL AND HCO3 IS NOT NULL AND  CLac IS NOT NULL AND CGlu IS NOT NULL