def __resolve_action_id(self, action): if isinstance(action, self.Action): if not action.is_loaded(): action.reload() avid = action.id else: avid = action return avid
def add_ehr_record(self, action, timestamp, archetype, rec): """ multi-field records will be expanded to groups of records all with the same (assumed to be unique within a KB) group id. :param action: action that generated this record :type action: ActionOnIndividual :param timestamp: when this record was collected, in millisecond since the Epoch :type timestamp: long :param archetype: a legal archetype id, e.g., ``openEHR-EHR-EVALUATION.problem-diagnosis.v1`` :type archetype: str :param rec: keys and values for this specific archetype instance, e.g., ``{'at0002.1': 'terminology://apps.who.int/classifications/apps/gE10.htm#E10'}`` :type rec: dict """ self.__check_type('action', self.ActionOnIndividual, action) self.__check_type('rec', dict, rec) action.reload() a_id = action.id target = action.target target.reload() i_id = target.id # TODO add archetype consistency checks g_id = vlu.make_vid() for k in rec: row = { 'timestamp': timestamp, 'i_vid': i_id, 'a_vid': a_id, 'valid': True, 'g_vid': g_id, 'archetype': archetype, 'field': k, 'value': rec[k], } self.eadpt.add_eav_record_row(row)