EFSPIntegration.conversions
Functions that help convert the JSON-ized XML from the proxy server into usable information.
convert_court_to_id
def convert_court_to_id(trial_court) -> str
Converts a court type to the specific id string expected by Tyler.
A fairly ad-hoc function; it will check if the object has several attributes ("tyler_court_code", "tyler_code", or "name"), or if it's already a string, it tries to just make a lower case on the string. We strongly recommend that your court object use the "tyler_court_code" attribute though.
Arguments:
trial_court
- the court object
Returns:
the string that should be the Tyler EFM court id, i.e. adams
or peoria:cr
choices_and_map
def choices_and_map(codes_list: List[Dict[str, Any]],
display: str = None,
backing: str = None) -> Tuple[List[Any], Dict]
Takes the responses from the 'codes' service and make a DA ready list of choices and a map back to the full code object
Arguments:
codes_list
- should be the direct response from a 'codes' service, i.e.proxy_conn.get_case_categories(court_id).data
display
- a python format string, where the input variables are the keys of the individual code elements. By default, it's "{name}", but could be something else like "{name} ({code})"backing
- the key to each dict element in the codes_list that you want to use as the "canonical" representation of the code, i.e. each is unique, and there aren't conflicts
Returns:
a tuple; first, a list of the codes that can be used at the choices
in a docassemble field,
second, a map of each code, from the backing key to the full code element. Useful for getting
all of the information about a code after a user has selected it.
pretty_display
def pretty_display(data, tab_depth=0, skip_xml=True, item_name=None) -> str
Given an arbitrarily nested JSON structure, print it nicely as markdown.
Recursive, for subsequent calls tab_depth
increases.
Arguments:
data
- the JSON structure (python dicts, lists, strings and ints) to printtab_depth
- how many spaces to add before each new line, to make the markdown correctskip_xml
- this function is mostly for printing responses from the EfileProxyServer, which lazily returns XML as JSON. If this is true, we won't show the useless XML cruftitem_name
- when recursing, will show the parent's name when showing elements in a list
Returns:
The string of markdown text that displays info about the given JSON structure
debug_display
def debug_display(resp: ApiResponse) -> str
Returns a string with either the error of the response, or it's data run through pretty_display
tyler_daterep_to_datetime
def tyler_daterep_to_datetime(tyler_daterep: Mapping) -> DADateTime
Takes an jsonized-XML object of "{http://niem.gov/niem/niem-core/2.0}ActivityDate, returns the datetime it repsents.
tyler_timestamp_to_datetime
def tyler_timestamp_to_datetime(timestamp_ms: int) -> DADateTime
Given a timestamp in milliseconds from epoch (in UTC), make a datetime from it
validate_tyler_regex
def validate_tyler_regex(data_field: Mapping) -> Callable[[str], Any]
Return a function that validates a given input with the provided regex,
suitable for use with Docassemble's validate:
question modifier
parse_service_contacts
def parse_service_contacts(service_list)
We'll take both Tyler service contact lists and Niem service contact lists. Tyler's are just `{"firstName": "Bob", "middleName": "P", ..., "serviceContactId": "abcrunh-13..." Niem's are more complicated
parse_case_info
def parse_case_info(proxy_conn: ProxyConnection,
new_case: DAObject,
entry: dict,
court_id: str,
*,
fetch: bool = True,
roles: dict = None)
Given sparse information about a case, gets the full details about it
Arguments:
proxy_conn
- the connection to the EFileProxyServernew_case
- the object to hold all of the information about the caseentry
- the information we have about the case, usually from a call toget_cases
court_id
- the id of the court that we searched in to get this infofetch
- if true, will fetch more detailed information about the case, include the case titleroles
- a dictionary of the party type codes to the party type name. Used so we can filter and sort participants later
fetch_case_info
def fetch_case_info(proxy_conn: ProxyConnection,
new_case: DAObject,
roles: Optional[dict] = None) -> None
Fills in these attributes with the full case details:
- attorneys
- party_to_attorneys
- case_details_worked
- case_details
- case_type
- title
- date
- participants
filter_payment_accounts
def filter_payment_accounts(account_list, allowable_card_types: List) -> List
Gets a list of all payment accounts and filters them by if the card is accepted at a particular court.
Arguments:
account_list:
allowable_card_types
- a list of the accepted card types at a court, usually from the 'allowablecardtypes' dict entry in get_full_court_info's response
Returns:
the list of payment account choices that are valid for a particular court
payment_account_labels
def payment_account_labels(resp: ApiResponse) -> Optional[List[Dict]]
Returns all payment accounts as choices, without filters.
filing_id_and_label
def filing_id_and_label(case: Mapping,
style: str = "FILING_ID") -> Dict[str, str]
Converts a raw case information from proxy_conn.get_filing_list() into a key-value pair, where the key is the filing id and the value is the user-facing label for that filing.
get_tyler_roles
def get_tyler_roles(
proxy_conn: ProxyConnection,
login_data: Optional[Mapping],
user_details: Optional[ApiResponse] = None) -> Tuple[bool, bool]
Gets whether or not the user of this interview is a Tyler Admin, and a 'global' admin. The global admin means that they are allowed to change specific Global payment methods, and can be listed under the 'global server admins' section of the 'efile proxy' settings in the DAConfig