(self)
return subtasks
Returns WorkflowTasks for creating and updating OpenMRS person attributes.
Returns WorkflowTasks for creating and updating OpenMRS person attributes.
Returns WorkflowTasks for creating and updating OpenMRS person attributes .
def run(self):
        """
        Returns WorkflowTasks for creating and updating OpenMRS person attributes.
        """
        subtasks = []
        existing_person_attributes = {
            attribute['attributeType']['uuid']: (attribute['uuid'], attribute['value'])
            for attribute in self.attributes
        }
        for person_attribute_type, value_source_dict in self.openmrs_config.case_config.person_attributes.items():
            value_source = as_value_source(value_source_dict)
            if not value_source.can_export:
                continue
            value = value_source.get_value(self.info)
            if person_attribute_type in existing_person_attributes:
                attribute_uuid, existing_value = existing_person_attributes[person_attribute_type]
                if value != existing_value:
                    if value in ("", None):
                        subtasks.append(
                            DeletePersonAttributeTask(
                                self.requests, self.person_uuid, attribute_uuid, person_attribute_type,
                                existing_value
                            )
                        )
                    else:
                        subtasks.append(
                            UpdatePersonAttributeTask(
                                self.requests, self.person_uuid, attribute_uuid, person_attribute_type, value,
                                existing_value
                            )
                        )
            else:
                subtasks.append(
                    CreatePersonAttributeTask(self.requests, self.person_uuid, person_attribute_type, value)
                )
        return subtasks
def run ( self ) : subtasks = [ ] existing_person_attributes = { attribute [ 'attributeType' ] [ 'uuid' ] : ( attribute [ 'uuid' ] , attribute [ 'value' ] ) for attribute in self . attributes } for person_attribute_type , value_source_dict in self . openmrs_config . case_config . person_attributes . items ( ) : value_source = as_value_source ( value_source_dict ) if not value_source . can_export : continue value = value_source . get_value ( self . info ) if person_attribute_type in existing_person_attributes : attribute_uuid , existing_value = existing_person_attributes [ person_attribute_type ] if value != existing_value : if value in ( "" , None ) : subtasks . append ( DeletePersonAttributeTask ( self . requests , self . person_uuid , attribute_uuid , person_attribute_type , existing_value ) ) else : subtasks . append ( UpdatePersonAttributeTask ( self . requests , self . person_uuid , attribute_uuid , person_attribute_type , value , existing_value ) ) else : subtasks . append ( CreatePersonAttributeTask ( self . requests , self . person_uuid , person_attribute_type , value ) ) return subtasks