def test_address(self): """ Test Address Data Type """ address = {} resp = dt_address(address) # print("\nAddress:%s" % resp) self.assertEqual(resp, None) address = {} resp = dt_address(address, None, None, "123 Fourth Ave") # print("\nAddress:%s" % resp) # result = json.loads(resp) result = resp self.assertEqual(result['text'], '123 Fourth Ave') address = { "addressLine1": '123 Fourth Ave', "addressLine2": 'Apt 2B', "city": "Baltimore", "state": "MD", "zip": "21148", "period": dt_period(start_date=dt_instant()) } resp = dt_address(address, "Home", "Both", "123 Fourth Ave") # print("\nAddress:%s" % resp) # result = json.loads(resp) result = resp self.assertEqual(result['text'], '123 Fourth Ave') self.assertEqual(result['line'], ['123 Fourth Ave', 'Apt 2B']) self.assertEqual(result['city'], 'Baltimore') self.assertEqual(result['state'], 'MD') self.assertEqual(result['postalCode'], "21148") self.assertEqual(result['use'], 'home') self.assertEqual(result['type'], 'both')
def test_address(self): """ Test Address Data Type """ address = {} resp = dt_address(address) # print("\nAddress:%s" % resp) self.assertEqual(resp, None) address = {} resp = dt_address(address, None, None, "123 Fourth Ave") # print("\nAddress:%s" % resp) # result = json.loads(resp) result = resp self.assertEqual(result['text'], '123 Fourth Ave') address = {"addressLine1": '123 Fourth Ave', "addressLine2": 'Apt 2B', "city": "Baltimore", "state": "MD", "zip": "21148", "period": dt_period(start_date=dt_instant()) } resp = dt_address(address, "Home", "Both", "123 Fourth Ave") # print("\nAddress:%s" % resp) # result = json.loads(resp) result = resp self.assertEqual(result['text'], '123 Fourth Ave') self.assertEqual(result['line'], ['123 Fourth Ave', 'Apt 2B']) self.assertEqual(result['city'], 'Baltimore') self.assertEqual(result['state'], 'MD') self.assertEqual(result['postalCode'], "21148") self.assertEqual(result['use'], 'home') self.assertEqual(result['type'], 'both')
def write_consent(sender, **kwargs): # logger.debug("\n=============================================\n" # "Model post_save:%s" % sender) # logger.debug('\nSaved: {}'.format(kwargs['instance'].__dict__)) A_Tkn = kwargs['instance'].__dict__ # print("\n\nKWARGS:%s" % kwargs) # Write Consent JSON # Write fhir_Consent # print("\n\nA_Tkn:%s\n\n" % A_Tkn) A_Usr = A_Tkn['_user_cache'] A_App = A_Tkn['_application_cache'] # print("App:%s" % A_App) # print("App Name:%s" % A_App.name) friendly_language = "Beneficiary (%s) gave " \ "[%s] permission to " \ "application (%s)" % (A_Tkn['_user_cache'], A_Tkn['scope'], A_App.__str__) consent_now = timezone.now() # NOTE: dt_instant and dt_period create string representations of date instant_now = dt_instant(consent_now) instant_until = dt_instant(A_Tkn['expires']) oauth_period = dt_period(instant_now, instant_until) consent = rt_consent_directive_activate(A_Usr, A_App.name, friendly_language, oauth_period, A_Tkn['scope']) try: f_c = fhir_Consent.objects.get(user=A_Usr, application=A_App) created = False except fhir_Consent.DoesNotExist: f_c = fhir_Consent() f_c.user = A_Usr f_c.application = A_App f_c.consent = consent f_c.valid_until = A_Tkn['expires'] f_c.save() created = True if created: pass else: vid = int(f_c.consent['meta']['versionId']) vid += 1 consent['meta']['versionId'] = str(vid) f_c.consent = consent f_c.revoked = None f_c.valid_until = A_Tkn['expires'] f_c.save() return
def write_consent(sender, **kwargs): # logger.debug("\n=============================================\n" # "Model post_save:%s" % sender) # logger.debug('\nSaved: {}'.format(kwargs['instance'].__dict__)) A_Tkn = kwargs['instance'].__dict__ # print("\n\nKWARGS:%s" % kwargs) # Write Consent JSON # Write fhir_Consent # print("\n\nA_Tkn:%s\n\n" % A_Tkn) A_Usr = A_Tkn['_user_cache'] A_App = A_Tkn['_application_cache'] # print("App:%s" % A_App) # print("App Name:%s" % A_App.name) A_Appname = A_App.name friendly_language = "Beneficiary (%s) gave " \ "(%s) permission to " \ "application:%s." % (A_Tkn['_user_cache'], A_Tkn['scope'], A_Appname) consent_now = timezone.now() # NOTE: dt_instant and dt_period create string representations of date instant_now = dt_instant(consent_now) instant_until = dt_instant(A_Tkn['expires']) oauth_period = dt_period(instant_now, instant_until) consent = rt_consent_directive_activate(A_Usr, A_App.name, friendly_language, oauth_period, A_Tkn['scope']) try: f_c = fhir_Consent.objects.get(user=A_Usr, application=A_App) created = False except fhir_Consent.DoesNotExist: f_c = fhir_Consent() f_c.user = A_Usr f_c.application = A_App f_c.consent = consent f_c.valid_until = A_Tkn['expires'] f_c.save() created = True if created: pass else: vid = int(f_c.consent['meta']['versionId']) vid += 1 consent['meta']['versionId'] = str(vid) f_c.consent = consent f_c.revoked = None f_c.valid_until = A_Tkn['expires'] f_c.save() return