示例#1
0
def poll_openmrs_atom_feeds(domain_name):
    for repeater in OpenmrsRepeater.by_domain(domain_name):
        if repeater.atom_feed_enabled and not repeater.paused:
            patient_uuids = get_feed_updates(repeater, ATOM_FEED_NAME_PATIENT)
            encounter_uuids = get_feed_updates(repeater, ATOM_FEED_NAME_ENCOUNTER)
            for patient_uuid in patient_uuids:
                update_patient(repeater, patient_uuid)
            for encounter_uuid in encounter_uuids:
                import_encounter(repeater, encounter_uuid)
示例#2
0
def poll_openmrs_atom_feeds(domain_name):
    for repeater in OpenmrsRepeater.by_domain(domain_name):
        if repeater.atom_feed_enabled and not repeater.paused:
            patient_uuids = get_feed_updates(repeater, ATOM_FEED_NAME_PATIENT)
            encounter_uuids = get_feed_updates(repeater,
                                               ATOM_FEED_NAME_ENCOUNTER)
            for patient_uuid in patient_uuids:
                update_patient(repeater, patient_uuid)
            for encounter_uuid in encounter_uuids:
                import_encounter(repeater, encounter_uuid)
示例#3
0
def test_get_feed_updates():
    response = SimpleNamespace(
        status_code=200,
        url='https://www.example.com/openmrs/ws/atomfeed/patient/recent',
        content='<html><body>Bad XML</html>',
    )
    requests = SimpleNamespace(
        domain_name='test_domain',
        get=lambda url: response,
        notify_exception=lambda err, msg: None,
    )
    repeater = SimpleNamespace(
        atom_feed_status={},
        requests=requests,
    )
    with patch('corehq.motech.openmrs.atom_feed.get_feed_xml') \
            as get_feed_xml_mock:
        get_feed_xml_mock.side_effect = OpenmrsFeedSyntaxError

        # Assert returns without raising
        get_feed_updates(repeater, ATOM_FEED_NAME_PATIENT)
示例#4
0
def poll_openmrs_atom_feeds(domain_name):
    for repeater in OpenmrsRepeater.by_domain(domain_name):
        errors = []
        if repeater.atom_feed_enabled and not repeater.paused:
            patient_uuids = get_feed_updates(repeater, ATOM_FEED_NAME_PATIENT)
            encounter_uuids = get_feed_updates(repeater,
                                               ATOM_FEED_NAME_ENCOUNTER)
            for patient_uuid in patient_uuids:
                try:
                    update_patient(repeater, patient_uuid)
                except (ConfigurationError, OpenmrsException) as err:
                    errors.append(str(err))
            for encounter_uuid in encounter_uuids:
                try:
                    import_encounter(repeater, encounter_uuid)
                except (ConfigurationError, OpenmrsException) as err:
                    errors.append(str(err))
        if errors:
            repeater.requests.notify_error(
                'Errors importing from Atom feed:\n' + '\n'.join(errors))
            if settings.UNIT_TESTING:
                assert False, errors