Beispiel #1
0
        def weights():
            for property_weight in self.property_weights:
                prop = property_weight['case_property']
                jsonpath, value_source_dict = self._property_map[prop]
                weight = property_weight['weight']

                matches = jsonpath.find(patient)
                for match in matches:
                    patient_value = match.value
                    case_value = case.get_case_property(prop)
                    match_type = property_weight['match_type']
                    match_params = property_weight['match_params']
                    match_function = partial(MATCH_FUNCTIONS[match_type], *match_params)
                    is_equivalent = match_function(deserialize(value_source_dict, patient_value), case_value)
                    yield weight if is_equivalent else 0
Beispiel #2
0
def get_case_block_kwargs_for_case_property(
    mapping: ObservationMapping,
    external_data: dict,
    fallback_value: Any,
) -> dict:
    case_block_kwargs = {"update": {}}
    try:
        value = get_import_value(mapping.value, external_data)
    except (ConfigurationError, JsonpathError):
        # mapping.value isn't configured to parse external_data
        value = deserialize(mapping.value, fallback_value)
    if mapping.case_property in CASE_BLOCK_ARGS:
        case_block_kwargs[mapping.case_property] = value
    else:
        case_block_kwargs["update"][mapping.case_property] = value
    return case_block_kwargs
Beispiel #3
0
    def get_weights(self, candidate, case_trigger_info):
        for property_weight in self.property_weights:
            case_property = property_weight['case_property']
            (attr_type_id, value_source_config
             ) = self.attr_type_id_value_source_by_case_property[case_property]

            candidate_value = get_tei_attr(candidate, attr_type_id)
            case_value = case_trigger_info.extra_fields[case_property]

            weight = property_weight['weight']
            match_type = property_weight['match_type']
            match_params = property_weight['match_params']
            match_function = partial(MATCH_FUNCTIONS[match_type],
                                     *match_params)
            is_equivalent = match_function(
                deserialize(value_source_config, candidate_value), case_value)
            yield weight if is_equivalent else 0