Esempio n. 1
0
 def new():
     enc_type = gmCfgDB.get4user(
         option='encounter.default_type',
         workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace)
     if enc_type is None:
         enc_type = gmEMRStructItems.get_most_commonly_used_encounter_type()
     if enc_type is None:
         enc_type = 'in surgery'
     enc = gmEMRStructItems.create_encounter(fk_patient=patient.ID,
                                             enc_type=enc_type)
     saved = edit_encounter(parent=parent, encounter=enc)
     if saved:
         return True
     gmEMRStructItems.delete_encounter(pk_encounter=enc['pk_encounter'])
     return False
Esempio n. 2
0
	def delete(enc=None):
		if enc is None:
			return False
		question = _(
			'Really delete encounter [%s] ?\n'
			'\n'
			'Once deletion succeeds it cannot be undone.\n'
			'\n'
			'Note that it will only succeed if there\n'
			'is no data attached to the encounter.'
		) % enc['pk_encounter']
		delete_it = gmGuiHelpers.gm_show_question (
			question = question,
			title = _('Deleting encounter'),
			cancel_button = False
		)
		if not delete_it:
			return False
		if gmEMRStructItems.delete_encounter(pk_encounter = enc['pk_encounter']):
			return True
		gmDispatcher.send (
			signal = u'statustext',
			msg = _('Cannot delete encounter [%s]. It is probably in use.') % enc['pk_encounter'],
			beep = True
		)
		return False
Esempio n. 3
0
	def delete(enc=None):
		if enc is None:
			return False
		question = _(
			'Really delete encounter [%s] ?\n'
			'\n'
			'Once deletion succeeds it cannot be undone.\n'
			'\n'
			'Note that it will only succeed if there\n'
			'is no data attached to the encounter.'
		) % enc['pk_encounter']
		delete_it = gmGuiHelpers.gm_show_question (
			question = question,
			title = _('Deleting encounter'),
			cancel_button = False
		)
		if not delete_it:
			return False
		if gmEMRStructItems.delete_encounter(pk_encounter = enc['pk_encounter']):
			return True
		gmDispatcher.send (
			signal = 'statustext',
			msg = _('Cannot delete encounter [%s]. It is probably in use.') % enc['pk_encounter'],
			beep = True
		)
		return False
Esempio n. 4
0
	def new():
		cfg_db = gmCfg.cCfgSQL()
		enc_type = cfg_db.get2 (
			option = u'encounter.default_type',
			workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace,
			bias = u'user'
		)
		if enc_type is None:
			enc_type = gmEMRStructItems.get_most_commonly_used_encounter_type()
		if enc_type is None:
			enc_type = u'in surgery'
		enc = gmEMRStructItems.create_encounter(fk_patient = patient.ID, enc_type = enc_type)
		saved = edit_encounter(parent = parent, encounter = enc)
		if saved:
			return True
		gmEMRStructItems.delete_encounter(pk_encounter = enc['pk_encounter'])
		return False
Esempio n. 5
0
def _ask_for_encounter_continuation(new_encounter=None,
                                    fairly_recent_encounter=None):
    """This is used as the callback when the EMR detects that the
	   patient was here rather recently and wants to ask the
	   provider whether to continue the recent encounter.
	"""
    # better safe than sorry
    if new_encounter['pk_patient'] != fairly_recent_encounter['pk_patient']:
        raise ValueError(
            'pk_patient values on new (enc=%s pat=%s) and fairly-recent (enc=%s pat=%s) encounter do not match'
            % (new_encounter['pk_encounter'], new_encounter['pk_patient'],
               fairly_recent_encounter['pk_encounter'],
               fairly_recent_encounter['pk_patient']))

    # only pester user if current patient is concerned
    curr_pat = gmPerson.gmCurrentPatient()
    if new_encounter['pk_patient'] != curr_pat.ID:
        return

    # ask user
    msg = _('%s, %s  [#%s]\n'
            '\n'
            "This patient's chart was worked on only recently:\n"
            '\n'
            ' %s'
            '\n'
            'Do you want to continue that consultation ?\n'
            ' (If not a new one will be used.)\n') % (
                curr_pat.get_description_gender(with_nickname=False),
                gmDateTime.pydt_strftime(curr_pat['dob'],
                                         '%Y %b %d'), curr_pat.ID,
                fairly_recent_encounter.format(episodes=None,
                                               with_soap=False,
                                               left_margin=1,
                                               patient=None,
                                               issues=None,
                                               with_docs=False,
                                               with_tests=False,
                                               fancy_header=False,
                                               with_vaccinations=False,
                                               with_rfe_aoe=True,
                                               with_family_history=False,
                                               with_co_encountlet_hints=False,
                                               by_episode=False))
    dlg = gmGuiHelpers.c2ButtonQuestionDlg(
        parent=None,
        id=-1,
        caption=_('Pulling chart'),
        question=msg,
        button_defs=[{
            'label': _('Continue recent'),
            'tooltip': _('Continue the existing recent encounter.'),
            'default': False
        }, {
            'label':
            _('Start new'),
            'tooltip':
            _('Start a new encounter. The existing one will be closed.'),
            'default':
            True
        }],
        show_checkbox=False)
    result = dlg.ShowModal()
    dlg.DestroyLater()

    # switch encounters
    if result == wx.ID_YES:
        _log.info('user wants to continue fairly-recent encounter')
        curr_pat.emr.active_encounter = fairly_recent_encounter
        if new_encounter.transfer_all_data_to_another_encounter(
                pk_target_encounter=fairly_recent_encounter['pk_encounter']):
            if not gmEMRStructItems.delete_encounter(
                    pk_encounter=new_encounter['pk_encounter']):
                gmGuiHelpers.gm_show_info(
                    _('Properly switched to fairly recent encounter but unable to delete newly-created encounter.'
                      ), _('Pulling chart'))
        else:
            gmGuiHelpers.gm_show_info(
                _('Unable to transfer the data from newly-created to fairly recent encounter.'
                  ), _('Pulling chart'))
        return

    _log.debug('stayed with newly created encounter')