def getrawrequestforid(self, requestid):
        request = FOIRawRequest.get_request(requestid)
        request = self.__attachministriesinfo(request)
        if request != {} and request[
                'version'] == 1 and request['sourceofsubmission'] != "intake":
            requestrawdata = request['requestrawdata']
            requesttype = requestrawdata['requestType']['requestType']
            baserequestinfo = self.__preparebaserequestinfo(
                requestid, request, requesttype, requestrawdata)
            if self.__ispersonalrequest(requesttype):
                baserequestinfo[
                    'additionalPersonalInfo'] = self.__prepareadditionalpersonalinfo(
                        requestrawdata)
            return baserequestinfo
        elif request != {} and request['version'] != 1 and request[
                'sourceofsubmission'] != "intake":
            request['requestrawdata']['currentState'] = request['status']
            requeststatus = FOIRequestStatus().getrequeststatusid(
                request['status'])
            request['requestrawdata']['requeststatusid'] = requeststatus[
                'requeststatusid']
            request['requestrawdata'][
                'lastStatusUpdateDate'] = FOIRawRequest.getLastStatusUpdateDate(
                    requestid,
                    request['status']).strftime(self.__generaldateformat())
            if request['status'] == 'Closed':
                request['requestrawdata'][
                    'stateTransition'] = FOIRawRequest.getstatesummary(
                        requestid)
            return request['requestrawdata']
        elif request != {} and request['sourceofsubmission'] == "intake":
            requestrawdata = request['requestrawdata']
            requesttype = requestrawdata['requestType']
            additionalpersonalinfo = None
            if self.__ispersonalrequest(requesttype) and requestrawdata.get(
                    'additionalPersonalInfo') is not None:
                additionalpersonalinfo = self.__prepareadditionalpersonalinfoforintakesubmission(
                    requestrawdata)

            request['requestrawdata'][
                'additionalPersonalInfo'] = additionalpersonalinfo

            request['requestrawdata']['wfinstanceid'] = request['wfinstanceid']
            request['requestrawdata']['currentState'] = request['status']
            requeststatus = FOIRequestStatus().getrequeststatusid(
                request['status'])
            request['requestrawdata']['requeststatusid'] = requeststatus[
                'requeststatusid']
            request['requestrawdata'][
                'lastStatusUpdateDate'] = FOIRawRequest.getLastStatusUpdateDate(
                    requestid,
                    request['status']).strftime(self.__generaldateformat())
            request['requestrawdata'][
                'stateTransition'] = FOIRawRequest.getstatesummary(requestid)
            return request['requestrawdata']
        else:
            return None
 def __preparebaserequestinfo(self, requestid, request, requesttype,
                              requestrawdata):
     contactinfo = requestrawdata.get('contactInfo')
     dt = maya.parse(request['created_at']).datetime(
         to_timezone='America/Vancouver', naive=False)
     _createddate = dt
     decriptiontimeframe = requestrawdata.get('descriptionTimeframe')
     contactinfooptions = requestrawdata.get('contactInfoOptions')
     _fromdate = parse(decriptiontimeframe['fromDate'])
     _todate = parse(decriptiontimeframe['toDate'])
     return {
         'id':
         request['requestid'],
         'wfinstanceid':
         request['wfinstanceid'],
         'ispiiredacted':
         request['ispiiredacted'],
         'sourceOfSubmission':
         request['sourceofsubmission'],
         'requestType':
         requesttype,
         'firstName':
         contactinfo['firstName'],
         'middleName':
         requestrawdata['contactInfo']['middleName'],
         'lastName':
         contactinfo['lastName'],
         'businessName':
         contactinfo['businessName'],
         'currentState':
         request['status'],
         'receivedDate':
         _createddate.strftime('%Y %b, %d'),
         'receivedDateUF':
         _createddate.strftime('%Y-%m-%d %H:%M:%S.%f'),
         'assignedGroup':
         "Unassigned",
         'assignedTo':
         "Unassigned",
         'xgov':
         'No',
         'idNumber':
         'U-00' + str(request['requestid']),
         'email':
         contactinfooptions['email'],
         'phonePrimary':
         contactinfooptions['phonePrimary'],
         'phoneSecondary':
         contactinfooptions['phoneSecondary'],
         'address':
         contactinfooptions['address'],
         'city':
         contactinfooptions['city'],
         'postal':
         contactinfooptions['postal'],
         'province':
         contactinfooptions['province'],
         'country':
         contactinfooptions['country'],
         'description':
         decriptiontimeframe['description'],
         'fromDate':
         _fromdate.strftime(self.__generaldateformat()),
         'toDate':
         _todate.strftime(self.__generaldateformat()),
         'correctionalServiceNumber':
         decriptiontimeframe['correctionalServiceNumber'],
         'publicServiceEmployeeNumber':
         decriptiontimeframe['publicServiceEmployeeNumber'],
         'topic':
         decriptiontimeframe['topic'],
         'selectedMinistries':
         requestrawdata['ministry']['selectedMinistry'],
         'lastStatusUpdateDate':
         FOIRawRequest.getLastStatusUpdateDate(
             requestid,
             request['status']).strftime(self.__generaldateformat()),
         'stateTransition':
         FOIRawRequest.getstatesummary(requestid)
     }