def store_record(self, record): station_id = record.get('station_id') wave_height = record.get('wave_height_meters') if wave_height is not None : observation = Observation( station_id = station_id, wave_height_meters = float(wave_height), ) observation.put()
def testMostRecentObservation(self): instance = Station(station_id = "abcdefg") instance.put() observation = Observation( station_id = instance.station_id, wave_height_meters = 10, ) observation.put() instance.most_recent_observation = observation instance.put()
class Parser: __msg = None pid = Patient() obx = Observation() sch = Appointment() def parse(self, hl7_message): self.__msg = hl7.parse(hl7_message) self.parsePatient() self.parseObservation() self.parseAppointment() def getMessageType(self): return str(self.__msg.segment('MSH')[9]) def parsePatient(self): self.pid.ip = self.__msg.segment('PID')[3][0] self.pid.nom = self.__msg.segment('PID')[5][0] self.pid.date_naissance = self.__msg.segment('PID')[7][0] self.pid.sexe = self.__msg.segment('PID')[8][0] self.pid.adresse = self.__msg.segment('PID')[11][0] def parseObservation(self): self.obx.set_id = self.__msg.segment('OBX')[1][0] self.obx.value = self.__msg.segment('OBX')[5][0] self.obx.units = self.__msg.segment('OBX')[6][0] self.obx.references_range = self.__msg.segment('OBX')[7][0] self.obx.result = self.__msg.segment('OBX')[11][0] def parseAppointment(self): self.sch.id = self.__msg.segment('SCH')[1][0]