Skip to content

Commit

Permalink
Added Ushauri_Hei script,removed [TracingCalls],[TracingSMS],[Tracing…
Browse files Browse the repository at this point in the history
…HomeVisits] columns on the fact_appointments and the ODS_UShauri_Appointments
DennisGibz committed Apr 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent da9270b commit 240512c
Showing 3 changed files with 66 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -48,9 +48,7 @@ BEGIN
Missedappointmentdate.Datekey AS MissedAppointmentSMSSendDateKey,
Missedappointmentsmsdeliverystatus,
Missedappointmentsmsdeliveryfailurereason,
Tracingcalls,
Tracingsms,
Tracinghomevisits,
TracingOutCost,
Tracingoutcome,
Tracingdate.Datekey AS TracingOutcomeDateKey,
Datereturnedtocare.Datekey AS DateReturnedToCareDateKey,
61 changes: 61 additions & 0 deletions Scripts/ODS/Mhealth/Load_Ushauri_HEI.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
BEGIN

MERGE [ODS].[dbo].[Ushauri_HEI] AS a
USING(SELECT Distinct
PatientPK As UshauriPatientPK,PatientPKHash As UshauriPatientPKHash,PartnerName,SiteCode,SiteType,Emr,Project,
FacilityName,PatientMNCH_ID,PatientHEI_ID,[1stDNAPCRDate],[2ndDNAPCRDate],
[3rdDNAPCRDate],ConfirmatoryPCRDate,BasellineVLDate,FinalyAntibodyDate,[1stDNAPCR],[2ndDNAPCR],[3rdDNAPCR],ConfirmatoryPCR,
BasellineVL,FinalyAntibody,HEIExitDate,HEIHIVStatus,HEIExitCriteria,DateCreated,DateModified,[1stDNAPCRDate_Date],
[2ndDNAPCRDate_Date],[3rdDNAPCRDate_Date],ConfirmatoryPCRDate_Date,BasellineVLDate_Date,FinalyAntibodyDate_Date,
HEIExitDate_Date,DateCreated_Date,DateModified_Date

FROM [MhealthCentral].[dbo].[pmtct_MNCH_HEI](NoLock) P
) AS b
ON(
a.[UshauriPatientPK] = b.UshauriPatientPK
and a.SiteCode = b.SiteCode
and a.PatientHEI_ID = b.PatientHEI_ID

)

WHEN NOT MATCHED THEN
INSERT(UshauriPatientPK,UshauriPatientPKHash,PartnerName,SiteCode,SiteType,Emr,Project,FacilityName,PatientMNCH_ID,PatientHEI_ID,[1stDNAPCRDate],[2ndDNAPCRDate],[3rdDNAPCRDate],ConfirmatoryPCRDate,BasellineVLDate,FinalyAntibodyDate,[1stDNAPCR],[2ndDNAPCR],[3rdDNAPCR],ConfirmatoryPCR,BasellineVL,FinalyAntibody,HEIExitDate,HEIHIVStatus,HEIExitCriteria,DateCreated,DateModified,[1stDNAPCRDate_Date],[2ndDNAPCRDate_Date],[3rdDNAPCRDate_Date],ConfirmatoryPCRDate_Date,BasellineVLDate_Date,FinalyAntibodyDate_Date,HEIExitDate_Date,DateCreated_Date,DateModified_Date,LoadDate)
VALUES(UshauriPatientPK,UshauriPatientPKHash,PartnerName,SiteCode,SiteType,Emr,Project,FacilityName,PatientMNCH_ID,PatientHEI_ID,[1stDNAPCRDate],[2ndDNAPCRDate],[3rdDNAPCRDate],ConfirmatoryPCRDate,BasellineVLDate,FinalyAntibodyDate,[1stDNAPCR],[2ndDNAPCR],[3rdDNAPCR],ConfirmatoryPCR,BasellineVL,FinalyAntibody,HEIExitDate,HEIHIVStatus,HEIExitCriteria,DateCreated,DateModified,[1stDNAPCRDate_Date],[2ndDNAPCRDate_Date],[3rdDNAPCRDate_Date],ConfirmatoryPCRDate_Date,BasellineVLDate_Date,FinalyAntibodyDate_Date,HEIExitDate_Date,DateCreated_Date,DateModified_Date,Getdate())

WHEN MATCHED THEN
UPDATE SET
a.[PartnerName] = b.[PartnerName],
a.[SiteType] = b.[SiteType],
a.[Emr] = b.[Emr],
a.[Project] = b.[Project],
a.[FacilityName] = b.[FacilityName],
a.[1stDNAPCRDate] = b.[1stDNAPCRDate],
a.[2ndDNAPCRDate] = b.[2ndDNAPCRDate],
a.[3rdDNAPCRDate] = b.[3rdDNAPCRDate],
a.[ConfirmatoryPCRDate] = b.[ConfirmatoryPCRDate],
a.[BasellineVLDate] = b.[BasellineVLDate],
a.[FinalyAntibodyDate] = b.[FinalyAntibodyDate],
a.[1stDNAPCR] = b.[1stDNAPCR],
a.[2ndDNAPCR] = b.[2ndDNAPCR],
a.[3rdDNAPCR] = b.[3rdDNAPCR],
a.[ConfirmatoryPCR] = b.[ConfirmatoryPCR],
a.[BasellineVL] = b.[BasellineVL],
a.[FinalyAntibody] = b.[FinalyAntibody],
a.[HEIExitDate] = b.[HEIExitDate],
a.[HEIHIVStatus] = b.[HEIHIVStatus],
a.[HEIExitCriteria] = b.[HEIExitCriteria],
a.[DateCreated] = b.[DateCreated],
a.[DateModified] = b.[DateModified],
a.[1stDNAPCRDate_Date] = b.[1stDNAPCRDate_Date],
a.[2ndDNAPCRDate_Date] = b.[2ndDNAPCRDate_Date],
a.[3rdDNAPCRDate_Date] = b.[3rdDNAPCRDate_Date],
a.[ConfirmatoryPCRDate_Date] = b.[ConfirmatoryPCRDate_Date],
a.[BasellineVLDate_Date] = b.[BasellineVLDate_Date],
a.[FinalyAntibodyDate_Date] = b.[FinalyAntibodyDate_Date],
a.[HEIExitDate_Date] = b.[HEIExitDate_Date],
a.[DateCreated_Date] = b.[DateCreated_Date],
a.[DateModified_Date] = b.[DateModified_Date]
;


END
10 changes: 4 additions & 6 deletions Scripts/ODS/Mhealth/Load_Ushauri_PatientAppointments.sql
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ BEGIN
TwoWeekSMSDeliveryFailureReason,OneWeekSMSSent,OneWeekSMSSendDate_Date As OneWeekSMSSendDate,OneWeekSMSDeliveryStatus,
OneWeekSMSDeliveryFailureReason,OneDaySMSSent,OneDaySMSSendDate_Date As OneDaySMSSendDate,OneDaySMSDeliveryStatus,OneDaySMSDeliveryFailureReason,
MissedAppointmentSMSSent,MissedAppointmentSMSSendDate_Date As MissedAppointmentSMSSendDate,MissedAppointmentSMSDeliveryStatus,MissedAppointmentSMSDeliveryFailureReason,
TracingCalls,TracingSMS,TracingHomeVisits,TracingOutcome,TracingOutcomeDate_Date As TracingOutcomeDate,DateReturnedToCare_Date As DateReturnedToCare,DaysDefaulted
TracingOutCost,TracingOutcome,TracingOutcomeDate_Date As TracingOutcomeDate,DateReturnedToCare_Date As DateReturnedToCare,DaysDefaulted
FROM [mhealthCentral].[dbo].[CT_PatientAppointments](NoLock) P
) AS b
ON(
@@ -22,8 +22,8 @@ BEGIN
)

WHEN NOT MATCHED THEN
INSERT([UshauriPatientPK],PatientPKHash,SiteCode,SiteType,PatientID,PatientIDHash,NUPI,PartnerName,FacilityID,FacilityName,DOB,Gender,MaritalStatus,PatientResidentCounty,PatientResidentLocation,PatientResidentSubCounty,PatientResidentSubLocation,PatientResidentVillage,PatientResidentWard,RegistrationDate,RegistrationAtCCC,RegistrationAtPMTCT,RegistrationAtTBClinic,StatusAtCCC,StatusAtPMTCT,StatusAtTBClinic,AgeAtAppointment,AppointmentID,AppointmentDate,AppointmentType,AppointmentStatus,EntryPoint,VisitType,DateAttended,ConsentForSMS,SMSLanguage,SMSTargetGroup,SMSPreferredSendTime,FourWeekSMSSent,FourWeekSMSSendDate,FourWeekSMSDeliveryStatus,FourWeekSMSDeliveryFailureReason,ThreeWeekSMSSent,ThreeWeekSMSSendDate,ThreeWeekSMSDeliveryStatus,ThreeWeekSMSDeliveryFailureReason,TwoWeekSMSSent,TwoWeekSMSSendDate,TwoWeekSMSDeliveryStatus,TwoWeekSMSDeliveryFailureReason,OneWeekSMSSent,OneWeekSMSSendDate,OneWeekSMSDeliveryStatus,OneWeekSMSDeliveryFailureReason,OneDaySMSSent,OneDaySMSSendDate,OneDaySMSDeliveryStatus,OneDaySMSDeliveryFailureReason,MissedAppointmentSMSSent,MissedAppointmentSMSSendDate,MissedAppointmentSMSDeliveryStatus,MissedAppointmentSMSDeliveryFailureReason,TracingCalls,TracingSMS,TracingHomeVisits,TracingOutcome,TracingOutcomeDate,DateReturnedToCare,DaysDefaulted,LoadDate)
VALUES(PatientPK,PatientPKHash,SiteCode,SiteType,PatientID,PatientIDHash,NUPI,PartnerName,FacilityID,FacilityName,DOB,Gender,MaritalStatus,PatientResidentCounty,PatientResidentLocation,PatientResidentSubCounty,PatientResidentSubLocation,PatientResidentVillage,PatientResidentWard,RegistrationDate,RegistrationAtCCC,RegistrationAtPMTCT,RegistrationAtTBClinic,StatusAtCCC,StatusAtPMTCT,StatusAtTBClinic,AgeAtAppointment,AppointmentID,AppointmentDate,AppointmentType,AppointmentStatus,EntryPoint,VisitType,DateAttended,ConsentForSMS,SMSLanguage,SMSTargetGroup,SMSPreferredSendTime,FourWeekSMSSent,FourWeekSMSSendDate,FourWeekSMSDeliveryStatus,FourWeekSMSDeliveryFailureReason,ThreeWeekSMSSent,ThreeWeekSMSSendDate,ThreeWeekSMSDeliveryStatus,ThreeWeekSMSDeliveryFailureReason,TwoWeekSMSSent,TwoWeekSMSSendDate,TwoWeekSMSDeliveryStatus,TwoWeekSMSDeliveryFailureReason,OneWeekSMSSent,OneWeekSMSSendDate,OneWeekSMSDeliveryStatus,OneWeekSMSDeliveryFailureReason,OneDaySMSSent,OneDaySMSSendDate,OneDaySMSDeliveryStatus,OneDaySMSDeliveryFailureReason,MissedAppointmentSMSSent,MissedAppointmentSMSSendDate,MissedAppointmentSMSDeliveryStatus,MissedAppointmentSMSDeliveryFailureReason,TracingCalls,TracingSMS,TracingHomeVisits,TracingOutcome,TracingOutcomeDate,DateReturnedToCare,DaysDefaulted,Getdate())
INSERT([UshauriPatientPK],PatientPKHash,SiteCode,SiteType,PatientID,PatientIDHash,NUPI,PartnerName,FacilityID,FacilityName,DOB,Gender,MaritalStatus,PatientResidentCounty,PatientResidentLocation,PatientResidentSubCounty,PatientResidentSubLocation,PatientResidentVillage,PatientResidentWard,RegistrationDate,RegistrationAtCCC,RegistrationAtPMTCT,RegistrationAtTBClinic,StatusAtCCC,StatusAtPMTCT,StatusAtTBClinic,AgeAtAppointment,AppointmentID,AppointmentDate,AppointmentType,AppointmentStatus,EntryPoint,VisitType,DateAttended,ConsentForSMS,SMSLanguage,SMSTargetGroup,SMSPreferredSendTime,FourWeekSMSSent,FourWeekSMSSendDate,FourWeekSMSDeliveryStatus,FourWeekSMSDeliveryFailureReason,ThreeWeekSMSSent,ThreeWeekSMSSendDate,ThreeWeekSMSDeliveryStatus,ThreeWeekSMSDeliveryFailureReason,TwoWeekSMSSent,TwoWeekSMSSendDate,TwoWeekSMSDeliveryStatus,TwoWeekSMSDeliveryFailureReason,OneWeekSMSSent,OneWeekSMSSendDate,OneWeekSMSDeliveryStatus,OneWeekSMSDeliveryFailureReason,OneDaySMSSent,OneDaySMSSendDate,OneDaySMSDeliveryStatus,OneDaySMSDeliveryFailureReason,MissedAppointmentSMSSent,MissedAppointmentSMSSendDate,MissedAppointmentSMSDeliveryStatus,MissedAppointmentSMSDeliveryFailureReason,TracingOutCost,TracingOutcome,TracingOutcomeDate,DateReturnedToCare,DaysDefaulted,LoadDate)
VALUES(PatientPK,PatientPKHash,SiteCode,SiteType,PatientID,PatientIDHash,NUPI,PartnerName,FacilityID,FacilityName,DOB,Gender,MaritalStatus,PatientResidentCounty,PatientResidentLocation,PatientResidentSubCounty,PatientResidentSubLocation,PatientResidentVillage,PatientResidentWard,RegistrationDate,RegistrationAtCCC,RegistrationAtPMTCT,RegistrationAtTBClinic,StatusAtCCC,StatusAtPMTCT,StatusAtTBClinic,AgeAtAppointment,AppointmentID,AppointmentDate,AppointmentType,AppointmentStatus,EntryPoint,VisitType,DateAttended,ConsentForSMS,SMSLanguage,SMSTargetGroup,SMSPreferredSendTime,FourWeekSMSSent,FourWeekSMSSendDate,FourWeekSMSDeliveryStatus,FourWeekSMSDeliveryFailureReason,ThreeWeekSMSSent,ThreeWeekSMSSendDate,ThreeWeekSMSDeliveryStatus,ThreeWeekSMSDeliveryFailureReason,TwoWeekSMSSent,TwoWeekSMSSendDate,TwoWeekSMSDeliveryStatus,TwoWeekSMSDeliveryFailureReason,OneWeekSMSSent,OneWeekSMSSendDate,OneWeekSMSDeliveryStatus,OneWeekSMSDeliveryFailureReason,OneDaySMSSent,OneDaySMSSendDate,OneDaySMSDeliveryStatus,OneDaySMSDeliveryFailureReason,MissedAppointmentSMSSent,MissedAppointmentSMSSendDate,MissedAppointmentSMSDeliveryStatus,MissedAppointmentSMSDeliveryFailureReason,TracingOutCost,TracingOutcome,TracingOutcomeDate,DateReturnedToCare,DaysDefaulted,Getdate())

WHEN MATCHED THEN
UPDATE SET
@@ -82,9 +82,7 @@ BEGIN
a.[MissedAppointmentSMSSendDate] = b.[MissedAppointmentSMSSendDate],
a.[MissedAppointmentSMSDeliveryStatus] = b.[MissedAppointmentSMSDeliveryStatus],
a.[MissedAppointmentSMSDeliveryFailureReason] = b.[MissedAppointmentSMSDeliveryFailureReason],
a.[TracingCalls] = b.[TracingCalls],
a.[TracingSMS] = b.[TracingSMS],
a.[TracingHomeVisits] = b.[TracingHomeVisits],
a.TracingOutCost = b.TracingOutCost,
a.[TracingOutcome] = b.[TracingOutcome],
a.[TracingOutcomeDate] = b.[TracingOutcomeDate],
a.[DateReturnedToCare] = b.[DateReturnedToCare],

0 comments on commit 240512c

Please sign in to comment.