def __import_from_gnu_medication(self): """Set the data from the model""" if self.medication: self.set_code( safe_attrgetter(self.medication, self.map['display']), safe_attrgetter(self.medication, self.map['code'])) self.set_kind('product')
def __set_gnu_when_given(self): """Set datetime when given""" # TODO Maybe add hours, minutes, etc. if self.medication_statement: start = safe_attrgetter(self.medication_statement, self.map['when-given']['start']) end = safe_attrgetter(self.medication_statement, self.map['when-given']['end']) if start: p = supermod.Period() p.start = supermod.dateTime(value=start.strftime('%Y/%m/%d')) if end: p.end = supermod.dateTime(value=end.strftime('%Y/%m/%d')) self.set_whenGiven(p)
def __import_from_gnu_organization(self): if self.organization: self.set_name(safe_attrgetter(self.organization, self.map_['name'])) self.set_identifier(safe_attrgetter(self.organization, self.map_['identifier'])) # Need selection text, not value t = self.map_['type'] v = safe_attrgetter(self.organization, t) d = dict(self.organization.fields_get(t)[t]['selection']) self.set_type(d.get(v)) self.set_address(safe_attrgetter(self.organization, self.map_['address'], default=[])) self.set_telecom(safe_attrgetter(self.organization, self.map_['contacts'])) self.set_active(True)
def __import_from_gnu_procedure(self): """Set the data from the model""" if self.procedure: self.set_subject( safe_attrgetter(self.procedure, self.map['subject'])) self.set_type(safe_attrgetter(self.procedure, self.map['type'])) self.set_date(safe_attrgetter(self.procedure, self.map['date']), safe_attrgetter(self.procedure, self.map['date'])) self.set_identifier( safe_attrgetter(self.procedure, self.map['subject_name']), safe_attrgetter(self.procedure, self.map['type']), safe_attrgetter(self.procedure, self.map['date']))
def __import_from_gnu_diagnostic_report(self): """Import data from the model""" if self.diagnostic_report: self.set_conclusion( safe_attrgetter(self.diagnostic_report, self.map['conclusion'])) self.set_subject( safe_attrgetter(self.diagnostic_report, self.map['subject'])) self.set_performer( safe_attrgetter(self.diagnostic_report, self.map['performer'])) self.set_issued( safe_attrgetter(self.diagnostic_report, self.map['date'])) self.set_result( safe_attrgetter(self.diagnostic_report, self.map['result'])) self.set_name( safe_attrgetter(self.diagnostic_report, self.map['test'])) self.set_identifier( safe_attrgetter(self.diagnostic_report, self.map['test']), safe_attrgetter(self.diagnostic_report, 'patient.rec_name'), safe_attrgetter(self.diagnostic_report, self.map['date']))
def __set_gnu_dosage(self): """Set dosage""" # TODO Add better dosage info # FIX On hold since many changes upcoming to the dosage if self.medication_statement: d = supermod.MedicationStatement_Dosage() d.quantity = supermod.Quantity() f = safe_attrgetter(self.medication_statement, self.map['dose']['quantity']) if f: d.quantity.value = supermod.decimal(value=f) u = safe_attrgetter(self.medication_statement, self.map['dose']['units']) if u: d.quantity.units = supermod.string(value=u) d.route = supermod.CodeableConcept() r = safe_attrgetter(self.medication_statement, self.map['dose']['route']) if r: d.route.coding = [supermod.Coding()] d.route.coding[0].code = supermod.code(value=r.code) d.route.coding[0].display = supermod.string(value=r.name) d.route.text = supermod.string(r.name) # PRN? an = safe_attrgetter(self.medication_statement, self.map['dose']['asNeededBoolean']) if an: self.set_asNeededBoolean(supermod.boolean(value=True)) d.timing = supermod.Schedule() if self.medication_statement.infusion: d.rate
def __import_from_gnu_immunization(self): """Import the data from the Health model""" if self.immunization: self.set_date(safe_attrgetter(self.immunization, self.map['date'])) self.set_expirationDate( safe_attrgetter(self.immunization, self.map['expirationDate'])) self.set_subject( safe_attrgetter(self.immunization, self.map['subject'])) self.set_performer( safe_attrgetter(self.immunization, self.map['performer'])) self.set_lotNumber( safe_attrgetter(self.immunization, self.map['lotNumber'])) self.set_doseQuantity( safe_attrgetter(self.immunization, self.map['doseQuantity'])) self.set_route( safe_attrgetter(self.immunization, self.map['route'])) self.set_site(safe_attrgetter(self.immunization, self.map['site'])) self.set_vaccineType( safe_attrgetter(self.immunization, self.map['vaccine-type'])) self.set_reported(reported=False) self.set_refusedIndicator(refusedIndicator=False)
def set_address(self, addresses): """Extend superclass Set the institution's address Keyword arguments: addresses - address models (party.address) """ ads=[] for address in addresses: ad=supermod.Address() ad.set_use(supermod.string(value='work')) line=[] street, zip_, city, state, country = safe_attrgetter( address, 'street', 'zip', 'city', 'subdivision.name', 'country.name') # Deal with number in field maybe never #if number: #line.append(str(number)) if street: line.append(street) if line: ad.add_line(supermod.string(value=' '.join(line))) if city: ad.set_city(supermod.string(value=city)) if state: ad.set_state(supermod.string(value=state)) if zip_: ad.set_zip(supermod.string(value=zip_)) if country: ad.set_country(supermod.string(value=country)) ads.append(ad) super(health_Organization, self).set_address(ads)
def __import_from_gnu_condition(self): """Sets the data from the model""" if self.condition: self.set_code(safe_attrgetter(self.condition, self.map['code'])) self.set_subject( safe_attrgetter(self.condition, self.map['subject'])) self.set_asserter( safe_attrgetter(self.condition, self.map['asserter'])) self.set_dateAsserted( safe_attrgetter(self.condition, self.map['dateAsserted'])) self.set_notes(safe_attrgetter(self.condition, self.map['notes'])) self.set_abatement( safe_attrgetter(self.condition, self.map['abatementDate'])) self.set_severity( safe_attrgetter(self.condition, self.map['severity'])) self.set_status('confirmed')
def __import_from_gnu_practitioner(self): """Set data from model""" if self.practitioner: self.set_specialty( safe_attrgetter(self.practitioner, self.map['specialty'])) self.set_role(safe_attrgetter(self.practitioner, self.map['role'])) self.set_communication( safe_attrgetter(self.practitioner, self.map['communication'])) self.set_gender( safe_attrgetter(self.practitioner, self.map['gender'])) self.set_name(safe_attrgetter(self.practitioner, self.map['name'])) self.set_identifier( safe_attrgetter(self.practitioner, self.map['identifier']))
def set_address(self, address): """Extends superclass for convenience Set patient's home address Keyword arguments: address -- domiciliary unit model """ if address: ad = supermod.Address() ad.set_use(supermod.string(value='home')) line = [] number, street, zip_, city, state, country = safe_attrgetter( address, 'address_street_number', 'address_street', 'address_zip', 'address_city', 'address_subdivision.name', 'address_country.name') if number: line.append(str(number)) if street: line.append(street) if line: ad.add_line(supermod.string(value=' '.join(line))) if city: ad.set_city(supermod.string(value=city)) if state: ad.set_state(supermod.string(value=state)) if zip_: ad.set_zip(supermod.string(value=zip_)) if country: ad.set_country(supermod.string(value=country)) super(health_Patient, self).set_address([ad])
def __import_from_gnu_patient(self): """Set data from the Patient model""" if self.patient: self.set_identifier( safe_attrgetter(self.patient, self.map_['identifier']), safe_attrgetter(self.patient, self.map_['alternative'])) self.set_name(safe_attrgetter(self.patient, 'name')) self.set_telecom( safe_attrgetter(self.patient, self.map_['contacts'])) self.set_gender(safe_attrgetter(self.patient, self.map_['gender'])) self.set_birthDate( safe_attrgetter(self.patient, self.map_['birthDate'])) self.set_deceasedBoolean( safe_attrgetter(self.patient, self.map_['deceased'])) self.set_deceasedDatetime( safe_attrgetter(self.patient, self.map_['deceasedDateTime'])) self.set_address( safe_attrgetter(self.patient, self.map_['address'])) self.set_maritalStatus( safe_attrgetter(self.patient, self.map_['maritalStatus'])) self.set_photo(safe_attrgetter(self.patient, self.map_['photo'])) self.set_communication( safe_attrgetter(self.patient, self.map_['communication'])) self.set_careProvider( safe_attrgetter(self.patient, self.map_['careProvider'])) self.set_active(safe_attrgetter(self.patient, self.map_['active']))
def __import_from_gnu_observation(self): """Set the data from the model""" if self.gnu_obs: self.set_identifier( self.gnu_obs, safe_attrgetter(self.gnu_obs, self.map_['patient']), safe_attrgetter(self.gnu_obs, self.map_['date'])) self.set_subject( safe_attrgetter(self.gnu_obs, self.map_['patient'])) self.set_comments( safe_attrgetter(self.gnu_obs, self.map_['comments'])) self.set_valueQuantity( safe_attrgetter(self.gnu_obs, self.model_field), safe_attrgetter(self.gnu_obs, 'units.name')) self.set_referenceRange( safe_attrgetter(self.gnu_obs, 'units.name', default='unknown'), safe_attrgetter(self.gnu_obs, 'lower_limit'), safe_attrgetter(self.gnu_obs, 'upper_limit')) self.set_interpretation( safe_attrgetter(self.gnu_obs, self.model_field), safe_attrgetter(self.gnu_obs, 'lower_limit'), safe_attrgetter(self.gnu_obs, 'upper_limit')) self.set_status( safe_attrgetter(self.gnu_obs, self.map_['excluded']), safe_attrgetter(self.gnu_obs, self.model_field)) self.set_reliability('ok') self.set_issued( self.gnu_obs.write_date or self.gnu_obs.create_date) self.set_performer( safe_attrgetter(self.gnu_obs, self.map_['performer'])) self.set_name( self.description)