(self)
return subtasks
Returns WorkflowTasks for creating and updating OpenMRS patient identifiers.
Returns WorkflowTasks for creating and updating OpenMRS patient identifiers.
Returns WorkflowTasks for creating and updating OpenMRS patient identifiers .
def run(self):
        """
        Returns WorkflowTasks for creating and updating OpenMRS patient identifiers.
        """
        subtasks = []
        existing_patient_identifiers = {
            identifier['identifierType']['uuid']: (identifier['uuid'], identifier['identifier'])
            for identifier in self.patient['identifiers']
        }
        for patient_identifier_type, dict_ in self.openmrs_config.case_config.patient_identifiers.items():
            value_source = as_value_source(dict_)
            if not value_source.can_export:
                continue
            if patient_identifier_type == PERSON_UUID_IDENTIFIER_TYPE_ID:
                # Don't try to sync the OpenMRS person UUID; It's not a
                # user-defined identifier and it can't be changed.
                continue
            identifier = value_source.get_value(self.info)
            # If the patient is new, and its case property that
            # corresponds to the identifier is blank, then the
            # patient's identifier will have been generated by
            # repeater_helpers.generate_identifier(). The case will have
            # been updated by repeater_helpers.save_match_ids() but
            # self.info will not contain the newly-generated identifier.
            # `identifier` will be None. Don't try to update the
            # patient's identifier to None; it's already set correctly.
            if not identifier:
                continue
            if patient_identifier_type in existing_patient_identifiers:
                identifier_uuid, existing_identifier = existing_patient_identifiers[patient_identifier_type]
                if identifier != existing_identifier:
                    subtasks.append(
                        UpdatePatientIdentifierTask(
                            self.requests, self.patient['uuid'], identifier_uuid, patient_identifier_type,
                            identifier, existing_identifier
                        )
                    )
            else:
                subtasks.append(
                    CreatePatientIdentifierTask(
                        self.requests, self.patient['uuid'], patient_identifier_type, identifier
                    )
                )
        return subtasks
def run ( self ) : subtasks = [ ] existing_patient_identifiers = { identifier [ 'identifierType' ] [ 'uuid' ] : ( identifier [ 'uuid' ] , identifier [ 'identifier' ] ) for identifier in self . patient [ 'identifiers' ] } for patient_identifier_type , dict_ in self . openmrs_config . case_config . patient_identifiers . items ( ) : value_source = as_value_source ( dict_ ) if not value_source . can_export : continue if patient_identifier_type == PERSON_UUID_IDENTIFIER_TYPE_ID : # Don't try to sync the OpenMRS person UUID; It's not a # user-defined identifier and it can't be changed. continue identifier = value_source . get_value ( self . info ) # If the patient is new, and its case property that # corresponds to the identifier is blank, then the # patient's identifier will have been generated by # repeater_helpers.generate_identifier(). The case will have # been updated by repeater_helpers.save_match_ids() but # self.info will not contain the newly-generated identifier. # `identifier` will be None. Don't try to update the # patient's identifier to None; it's already set correctly. if not identifier : continue if patient_identifier_type in existing_patient_identifiers : identifier_uuid , existing_identifier = existing_patient_identifiers [ patient_identifier_type ] if identifier != existing_identifier : subtasks . append ( UpdatePatientIdentifierTask ( self . requests , self . patient [ 'uuid' ] , identifier_uuid , patient_identifier_type , identifier , existing_identifier ) ) else : subtasks . append ( CreatePatientIdentifierTask ( self . requests , self . patient [ 'uuid' ] , patient_identifier_type , identifier ) ) return subtasks