SELECT patient.Patient_Id,
patient.First_Name_M0040,
patient.Last_Name_M0040,
patient.HI_Claim_Number,
patient.DOB_M0066,
patient.Gender_M0069,
Agency.Agency_Name,
Agency.Agency_Medicare_Id,
patient.Primary_ReferringPhys_Id_M0072
FROM #Request.prefix_db_agency#.patient, #Request.prefix_db_lookup#.Agency
WHERE patient.Patient_Id = #form.txtPatientId#
AND Agency.Agency_Id = patient.Agency_Id
SELECT Employee.Last_Name,
Employee.First_Name
FROM #Request.prefix_db_lookup#.Physician, #Request.prefix_db_lookup#.Employee
WHERE Physician.Physician_Id='#PhysicianId#' AND
Employee.Employee_Id = Physician.Employee_Id
INSERT INTO #Request.prefix_db_agency#.Assessment_Forms (
Patient_Id,
Agency_Id,
Name_Item_6,
DOB_Item_8,
Gender_Item_9,
Form_Type,
HI_Claim_Item_1,
SOC_Item_2,
Provider_Num_Item_5,
Provider_name_Item_7,
Record_Creation_Date,
DME_Supplies_Item_14,
Safety_Measures_Item_15,
Nutritional_Item_16,
Func_Limits_item_18a,
Func_Limits_Item_18a_other,
Activities_Permitted_Item_18b,
Activities_Permitted_Item_18b_Other,
Mental_Status_Item_19,
Mental_Status_Item_19_Other,
Prognosis_Item_20,
Physician_ID
)
Values
(#form.txtPatientId#,
'#Session.AgencyLogin#',
'#Session.PatientName#',
#CreateODBCDate(GetP.DOB_M0066)#,
'#GetP.Gender_M0069#',
'Form 485',
'#GetP.HI_Claim_Number#',
#CreateODBCDate(form.dtSOC)#,
null
'#GetP.Agency_Medicare_Id#',
'#GetP.Agency_Name#',
#now()#,
'#form.txtDME#',
'#form.txtSafety#',
'#form.txtNutritionalReq#',
'#form.hdchklimitationValue#',
'#form.txtFunctionalother#',
'#form.Chkpermitted#',
'#form.txtOtheractivitiesPermitted#',
'#form.ChkStatus#',
'#form.txtothermental#',
'#form.hdrdPrognosisValue#',
'#PhysicianId#'
)