예제 #1
0
    def __set_gnu_identifier(self):
        if self.related_person:
            puid=safe_attrgetter(self.related_person, self.map['identifier'])
            if puid:
                ident = supermod.Identifier(
                            use=supermod.IdentifierUse(value='usual'),
                            label=supermod.string(value='PUID'),
                            value=supermod.string(value=puid))

                self.add_identifier(value=ident)
예제 #2
0
 def __set_gnu_patient(self):
     if self.related_patient:
         if RUN_FLASK:
             uri = url_for('pat_record', log_id=self.related_patient.id)
         else:
             uri = dumb_url_generate(['Patient', self.related_patient.id])
         display = self.related_patient.rec_name
         ref=supermod.ResourceReference()
         ref.display = supermod.string(value=display)
         ref.reference = supermod.string(value=uri)
         self.set_subject(ref)
예제 #3
0
    def __set_gnu_name(self):
        family=[]
        given=[supermod.string(value=x) for x in safe_attrgetter(
                        self.related_person, self.map['given'], '').split()]
        after_names=[supermod.string(value=x) for x in safe_attrgetter(
                        self.related_person, self.map['family'], '').split()]
        if len(after_names) > 1:
            family=after_names[-1:]
            given.extend(after_names[:-1])
        else:
            family=after_names
        name=supermod.HumanName(
                    use=supermod.NameUse(value='usual'),
                    family=family,
                    given=given)


        self.set_name(name)
예제 #4
0
 def __set_gnu_gender(self):
     try:
         gender = attrgetter(self.map['gender'])(self.related_person)
         coding = supermod.Coding(
                     system=supermod.uri(value='http://hl7.org/fhir/v3/AdministrativeGender'),
                     code=supermod.code(value=gender.upper()),
                     display=supermod.string(value='Male' if gender == 'm' else 'Female')
                     )
         gender=supermod.CodeableConcept(coding=[coding])
         self.set_gender(gender)
     except:
         raise ValueError('No gender')
예제 #5
0
 def __set_gnu_telecom(self):
     telecom = []
     phone=safe_attrgetter(self.related_person, self.map['phone'])
     if phone:
         telecom.append(supermod.Contact(
                 system=supermod.ContactSystem(value='phone'),
                 value=supermod.string(value=phone),
                 use=supermod.ContactUse(value='home')))
     mobile=safe_attrgetter(self.related_person, self.map['mobile'])
     if mobile:
         telecom.append(supermod.Contact(
                 system=supermod.ContactSystem(value='phone'),
                 value=supermod.string(value=mobile),
                 use=supermod.ContactUse(value='mobile')))
     email=safe_attrgetter(self.related_person, self.map['email'])
     if email:
         telecom.append(supermod.Contact(
                 system=supermod.ContactSystem(value='email'),
                 value=supermod.string(value=email),
                 use=supermod.ContactUse(value='email')))
     for x in telecom:
         self.add_telecom(x)
예제 #6
0
    def set_gender(self, gender):
        """Extends superclass for convenience

        Keyword arguments:
        gender -- practitioner's gender
        """

        if gender:
            from server.fhir.value_sets import administrativeGender as codes
            us = gender.upper()
            sd = [x for x in codes.contents if x['code'] == us][0]
            coding = supermod.Coding(
                system=supermod.uri(value=sd['system']),
                code=supermod.code(value=sd['code']),
                display=supermod.string(value=sd['display']))
            g = supermod.CodeableConcept(coding=[coding])
            super(health_Practitioner, self).set_gender(g)
예제 #7
0
    def set_code(self, name, code):
        """Extends superclass for convenience

        Keyword arguments:
        code -- code value
        name -- name of the medication
        """

        #TODO Better info, use recognized codes
        if name:
            c = supermod.Coding()
            c.display = supermod.string(value=str(name))
            if code:
                c.code = supermod.code(value=code)
            cc = supermod.CodeableConcept()
            cc.coding = [c]
            super(health_Medication, self).set_code(cc)
예제 #8
0
    def set_name(self, name):
        """Extends superclass for convenience

        Keyword arguments:
        name -- the test (Health model)
        """

        if name:
            conc = supermod.CodeableConcept()
            conc.coding = [supermod.Coding()]
            conc.coding[0].display = supermod.string(value=name.name)
            conc.coding[0].code = supermod.code(value=name.code)
            super(health_DiagnosticReport, self).set_name(conc)

        else:
            # If you don't know what is being tested,
            #   the data is useless
            raise ValueError('No test coding info')
예제 #9
0
    def __set_gnu_address(self):
        #FIX Ugly, but clear
        if self.related_person:
            try:
                address=supermod.Address()
                address.set_use(supermod.string(value='home'))
                line=[]
                try:
                    line.append(str(attrgetter(self.map['addressNumber'](self.related_person))))
                except:
                    pass

                try:
                    line.append(attrgetter(self.map['addressStreet'])(self.related_person))
                except:
                    pass

                try:
                    city = attrgetter(self.map['addressCity'])(self.related_person)
                    if city:
                        address.set_city(supermod.string(value=city))
                except:
                    pass

                try:
                    state = attrgetter(self.map['addressState'])(self.related_person)
                    if state:
                        address.set_state(supermod.string(value=state))
                except:
                    pass

                try:
                    z = attrgetter(self.map['addressZip'])(self.related_person)
                    if z:
                        address.set_zip(supermod.string(value=z))
                except:
                    pass

                try:
                    country = attrgetter(self.map['addressCountry'])(self.related_person)
                    if country:
                        address.set_country(supermod.string(value=value))
                except:
                    pass

                if line:
                    address.add_line(supermod.string(value=' '.join(line)))
                self.add_address(address)
            except:
                pass
    def set_site(self, site):
        """Extends superclass for convenience

        Keyword arguments:
        site -- site code where the vaccine was administered
        """

        from server.fhir.value_sets import immunizationSite
        if site:
            m = [
                i for i in immunizationSite.contents
                if i['code'] == site.upper()
            ]
            if m:
                cc = supermod.CodeableConcept()
                c = supermod.Coding()
                c.display = cc.text = supermod.string(value=m[0]['display'])
                c.code = supermod.code(value=m[0]['code'])
                cc.coding = [c]
                super(health_Immunization, self).set_site(cc)
    def set_route(self, route):
        """Extends superclass for convenience

        Keyword argument:
        route -- how vaccine entered body
        """

        from server.fhir.value_sets import immunizationRoute
        if route:
            ir = [
                i for i in immunizationRoute.contents
                if i['code'] == route.upper()
            ]
            if ir:
                cc = supermod.CodeableConcept()
                c = supermod.Coding()
                c.display = cc.text = supermod.string(value=ir[0]['display'])
                c.code = supermod.code(value=ir[0]['code'])
                cc.coding = [c]
                super(health_Immunization, self).set_route(cc)
    def set_gender(self, gender):
        """Extends superclass for convenience

        Set patient gender

        Keyword arguments:
        gender -- gender code
        """

        from server.fhir.value_sets import administrativeGender as gender_codes
        if gender:
            us = gender.upper()  #Standard requires uppercase
            try:
                sd = [x for x in gender_codes.contents if x['code'] == us][0]
            except:
                return None
            coding = supermod.Coding(
                system=supermod.uri(value=sd['system']),
                code=supermod.code(value=sd['code']),
                display=supermod.string(value=sd['display']))
            g = supermod.CodeableConcept(coding=[coding])
            super(health_Patient, self).set_gender(g)
예제 #13
0
    def set_valueQuantity(self, value, units=None, code=None, system=None):
        """Extends superclass for convenience

        Set actual value of observation

        Keyword arguments:
        value -- the actual value
        units -- units (e.g., g/dL)
        code -- the code (e.g., 'XHEHA1')
        system -- the code system (e.g., 'http://code.system')
        """

        if value:

            # This is to handle multi-field
            #if self.field == 'temp':
                #units = "degrees C"
                #code = "258710007"
                #system = "http://snomed.info/sct"
            #elif self.field == 'press_d':
                #units = "mm[Hg]"
            #elif self.field == 'press_s':
                #units = "mm[Hg]"
            #elif self.field == 'pulse':
                #units = "beats/min"
            #elif self.field == 'rate':
                #units= "breaths/min"


            q = supermod.Quantity()
            q.value = supermod.decimal(value=value)

            if units:
                q.units = supermod.string(value=str(units))
            if code:
                q.code = supermod.code(value=str(code))
            if system:
                q.system = supermod.uri(value=str(system))
            super(health_Observation, self).set_valueQuantity(q)
    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 set_telecom(self, contacts):
        """Extends superclass for convenience

        Set telecom information

        Keyword arguments:
        contacts -- contacts info (Party model)
        """

        telecom = []
        for contact in contacts:
            c=supermod.Contact()
            c.value = supermod.string(value=contact.value)
            if contact.type == 'phone':
                system='phone'
                use='work'
            else:
                use = system = contact.type
            c.system=supermod.ContactSystem(value=system)
            c.use=supermod.ContactUse(value=use)
            telecom.append(c)

        if telecom:
            super(health_Organization, self).set_telecom(telecom)
    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])
예제 #17
0
 def add_location(self, location):
     if location:
         st = supermod.string(value=location)
         super(health_OperationOutcome_Issue, self).add_location(st)
예제 #18
0
 def set_details(self, details):
     if details:
         st = supermod.string(value=details)
         super(health_OperationOutcome_Issue, self).set_details(st)