RulesEngineService

inner class RulesEngineService

Provide access to utility functions accessible to the users defining rules in JSON format.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun computeTotalCount(relatedResourceCounts: List<RelatedResourceCount>?): Long
Link copied to clipboard
fun daysPassed(inputDate: String, pattern: String = SDF_DD_MMM_YYYY): String

This function takes inputDate and returns a difference (for examples 15, 30 etc) between inputDate and the currentDate

Link copied to clipboard
fun evaluateToBoolean(resources: List<Resource>?, conditionalFhirPathExpression: String, matchAll: Boolean = false): Boolean

This function returns a true or false value if any ( matchAll= false) or all ( matchAll= true) of the resources satisfy the conditionalFhirPathExpression provided

Link copied to clipboard
fun extractAge(resource: Resource): String

Extracts a Patient/RelatedPerson's age

Link copied to clipboard
fun extractDOB(resource: Resource, dateFormat: String): String

This function extracts a Patient/RelatedPerson's DOB from the FHIR resource

Link copied to clipboard
fun extractGender(resource: Resource): String

Extracts and returns a translated string for the gender in the resource

Link copied to clipboard

This function fetches assignment data separately that is; PractitionerId, PractitionerCareTeam, PractitionerOrganization and PractitionerLocation, using rules on the configs.

Link copied to clipboard
fun filterResources(resources: List<Resource>?, conditionalFhirPathExpression: String?): List<Resource>

This function filters resources provided the condition extracted from the conditionalFhirPathExpression is met. Returns the original source or empty resources list if FHIR path expression is null.

fun filterResources(resources: List<Resource>?, fhirPathExpression: String, dataType: String, value: Any, vararg compareToResult: Any): List<Resource>?

Filters Resource s by comparing the given value against the value obtained after extracting data on each Resource using FHIRPath with the provided fhirPathExpression. The value is cast to the DataType to facilitate comparison using the compareTo function which returns zero if this object is equal to the specified other object, a negative number if it's less than other, or a positive number if it's greater than other.

Link copied to clipboard
fun filterResourcesByJsonPath(resources: List<Resource>?, jsonPathExpression: String, dataType: String, value: Any, vararg compareToResult: Any): List<Resource>?
Link copied to clipboard
fun formatDate(date: Date, expectedFormat: String = SDF_E_MMM_DD_YYYY): String

This function is responsible for formatting a date for whatever expectedFormat we need. It takes an input a date as input and then it gives output in expected Format, expectedFormat is by default (Example: Mon, Nov 5 2021)

fun formatDate(inputDate: String, inputDateFormat: String, expectedFormat: String = SDF_E_MMM_DD_YYYY): String?

This function is responsible for formatting a date for whatever expectedFormat we need. It takes an inputDate string along with the inputDateFormat so it can convert it to the Date and then it gives output in expected Format, expectedFormat is by default (Example: Mon, Nov 5 2021)

Link copied to clipboard

This function generates a random 6-digit integer between a hard-coded range. It may generate duplicate outputs on subsequent function calls.

Link copied to clipboard
Link copied to clipboard
fun joinToString(sourceString: MutableList<String?>, regex: String = DEFAULT_REGEX, separator: String = DEFAULT_STRING_SEPARATOR): String

This function combines all string indexes to a list separated by the separator and regex defined by the content author

Link copied to clipboard
fun limitTo(source: List<Any>?, limit: Int?): List<Any>

This function returns a list of resources with a limit of limit resources

Link copied to clipboard
fun mapResourcesToExtractedValues(resources: List<Resource>?, fhirPathExpression: String): List<Any>

fun mapResourcesToExtractedValues(resources: List<Resource>?, fhirPathExpression: String, separator: String = ","): String

This function combines all the string values retrieved from the resources using the fhirPathExpression to a list separated by the separator

Link copied to clipboard
fun mapResourcesToLabeledCSV(resources: List<Resource>?, fhirPathExpression: String, label: String, matchAllExtraConditions: Boolean? = false, vararg extraConditions: Any? = emptyArray()): String

This function transform the provided resources into a list of label given that the fhirPathExpression for each of the resources is evaluated to true.

Link copied to clipboard
fun mapResourceToLabeledCSV(resource: Resource, fhirPathExpression: String, label: String): String

Transforms a resource into label if the fhirPathExpression is evaluated to true.

Link copied to clipboard
fun prettifyDate(inputDate: Date): String

This function takes inputDate and returns a difference (for examples 7 hours, 2 day, 5 months, 3 years etc)

fun prettifyDate(inputDateString: String): String

This function takes inputDateString like 2022-7-1 and returns a difference (for examples 7 hours ago, 2 days ago, 5 months ago, 3 years ago etc) inputDateString can give given as 2022-02 or 2022

Link copied to clipboard
fun retrieveCount(parentResourceId: String, relatedResourceCounts: List<RelatedResourceCount>?): Long
Link copied to clipboard
fun retrieveParentResource(childResource: Resource, parentResourceType: String, fhirPathExpression: String): Resource?

This method retrieve a parentResource for a given relatedResource from the facts map It fetches a list of facts of the given parentResourceType then iterates through this list in order to return a resource whose logical id matches the subject reference retrieved via fhirPath from the childResource

Link copied to clipboard
fun retrieveRelatedResources(resource: Resource, relatedResourceKey: String, referenceFhirPathExpression: String?, relatedResourcesMap: Map<String, List<Resource>>? = null, isRevInclude: Boolean = true): List<Resource>

This method retrieves a list of relatedResources for a given resource from the facts map It fetches a list of facts of the given relatedResourceKey then iterates through this list in order to return a list of all resources whose subject reference matches the logical Id of the resource

Link copied to clipboard
fun sortResources(resources: List<Resource>?, fhirPathExpression: String, dataType: String, order: String = Order.ASCENDING.name): List<Resource>?

This function sorts resources by comparing the values extracted by FHIRPath using the fhirPathExpression. The dataType is required for ordering of the items. You can optionally specify the Order of sorting.

Link copied to clipboard
fun taskServiceStatusExist(tasks: List<Task>, vararg serviceStatus: String): Boolean
Link copied to clipboard
fun translate(value: String): String

This function creates a property key from the string value and uses the key to retrieve the correct translation from the string.properties file.

Link copied to clipboard
fun updateResource(resource: Resource?, path: String?, value: Any?, purgeAffectedResources: Boolean = false, createLocalChangeEntitiesAfterPurge: Boolean = true)