Esempio n. 1
0
 def __getattr__(self, name):
     matches = [
         scheme for scheme, keywords in cid_concepts[self.cid].items()
         if name in keywords
     ]
     if not matches:
         msg = "Identifier '{}' not found for cid{}".format(name, self.cid)
         raise AttributeError(msg)
     elif len(matches) > 1:
         # Should never happen, but just in case
         msg = "Multiple schemes found for '{}' in cid{}".format(name, cid)
         raise AssertionError(msg)
     else:
         scheme = matches[0]
         concept = concepts[scheme][name]
         # Almost always only one code per concepts name
         if len(concept) == 1:
             code, val = list(concept.items())[0]
         else:
             matches = [(code, val) for code, val in concept.items()
                        if self.cid in val[1]]
             if len(matches) > 1:
                 # Should never happen, but check in case
                 msg = "{} had multiple code matches for cid{}".format(
                     name, cid)
                 raise AssertionError(msg)
             code, val = matches[0]
         return Code(value=code, meaning=val[0], scheme_designator=scheme)
Esempio n. 2
0
 def test_construction_args_optional(self):
     version = 'v1.0'
     c = Code(self._value, self._scheme_designator, self._meaning, version)
     assert c.value == self._value
     assert c.scheme_designator == self._scheme_designator
     assert c.meaning == self._meaning
     assert c.scheme_version == version
Esempio n. 3
0
    def __getattr__(self, name):
        # for codes.X, X must be a CID or a scheme designator
        if name.startswith("cid"):
            if not self.scheme:
                return _CID_Dict(int(name[3:]))
            raise AttributeError("Cannot call cid selector on scheme dict")
        if name in self._dict.keys():
            # Return concepts limited only the specified scheme designator
            return _CodesDict(scheme=name)

        # If not already narrowed to a particular scheme, is an error
        if not self.scheme:
            msg = "'{}' not recognized as a CID or scheme designator"
            raise AttributeError(msg.format(name))

        # else try to find in this scheme
        scheme = self.scheme
        try:
            val = self._dict[scheme][name]
        except KeyError:
            msg = "Unknown code name '{}' for scheme '{}'"
            raise AttributeError(msg.format(name, scheme))
        # val is like {code1: (meaning, cid_list}, code2: ...}
        if len(val) > 1:  # more than one code for this name
            raise NotImplementedError("Need cid to disambiguate")
        else:
            code = list(val.keys())[0]  # get first and only
            meaning, cids = val[code]
            return Code(value=code, meaning=meaning, scheme_designator=scheme)
Esempio n. 4
0
 def test_construction_kwargs(self):
     c = Code(value=self._value,
              scheme_designator=self._scheme_designator,
              meaning=self._meaning)
     assert c.value == self._value
     assert c.scheme_designator == self._scheme_designator
     assert c.meaning == self._meaning
     assert c.scheme_version is None
Esempio n. 5
0
 def test_cid612(self):
     assert codes.cid612.MonitoredAnesthesiaCareMAC == Code(
         value='398239001',
         scheme_designator='SCT',
         meaning='Monitored Anesthesia Care (MAC)'
     )
Esempio n. 6
0
 def test_cid405(self):
     assert codes.cid405.MultiMediaCard == Code(
         value='110035',
         scheme_designator='DCM',
         meaning='Multi-media Card'
     )
Esempio n. 7
0
 def test_cid301(self):
     assert codes.cid301.mgcm3 == Code(
         value='mg/cm3',
         scheme_designator='UCUM',
         meaning='mg/cm^3'
     )
Esempio n. 8
0
 def test_cid250(self):
     assert codes.cid250.Positive == Code(
         value='10828004',
         scheme_designator='SCT',
         meaning='Positive'
     )
Esempio n. 9
0
 def test_sct_1(self):
     assert codes.SCT._1SigmaLowerValueOfPopulation == Code(
         value='371919006',
         scheme_designator='SCT',
         meaning='1 Sigma Lower Value of Populuation'
     )
Esempio n. 10
0
 def test_dcm_2(self):
     assert codes.DCM.ProcedureReported == Code(
         value='121058',
         scheme_designator='DCM',
         meaning='Procedure Reported'
     )
Esempio n. 11
0
 def test_dcm_1(self):
     assert codes.DCM.Modality == Code(
         value='121139',
         scheme_designator='DCM',
         meaning='Modality'
     )
Esempio n. 12
0
 def test_cid1003(self):
     assert codes.cid1003.LevelOfT11T12IntervertebralDisc == Code(
         value='243918001',
         scheme_designator='SCT',
         meaning='Level of T11/T12 intervertebral disc'
     )
Esempio n. 13
0
 def test_cid646(self):
     assert codes.cid646.SPECTCTOfWholeBody == Code(
         value='127902',
         scheme_designator='DCM',
         meaning='SPECT CT of Whole Body'
     )
Esempio n. 14
0
 def test_cid643(self):
     assert codes.cid643._6Hydroxydopamine == Code(
         value='4624',
         scheme_designator='PUBCHEM_CID',
         meaning='6-Hydroxydopamine'
     )
Esempio n. 15
0
 def test_cid630(self):
     assert codes.cid630.LidocainePrilocaine == Code(
         value='346553009',
         scheme_designator='SCT',
         meaning='Lidocaine + Prilocaine'
     )
Esempio n. 16
0
 def test_contained(self):
     c = Code('24028007', 'SCT', 'Right')
     assert c in codes.cid244
Esempio n. 17
0
 def test_not_contained(self):
     c = Code('130290', 'DCM', 'Median')
     assert c not in codes.cid244
Esempio n. 18
0
 def test_cid3000(self):
     assert codes.cid3000.OperatorNarrative == Code(
         value='109111',
         scheme_designator='DCM',
         meaning='Operator\'s Narrative'
     )
Esempio n. 19
0
 def test_dcm_3(self):
     assert codes.DCM.ImagingStartDatetime == Code(
         value='122712',
         scheme_designator='DCM',
         meaning='Imaging Start DateTime'
     )
Esempio n. 20
0
 def test_cid3001_1(self):
     assert codes.cid3001.Avr == Code(
         value='2:65',
         scheme_designator='MDC',
         meaning='-aVR'
     )
Esempio n. 21
0
 def test_sct_2(self):
     assert codes.SCT.FindingSite == Code(
         value='363698007',
         scheme_designator='SCT',
         meaning='Finding Site'
     )
Esempio n. 22
0
 def test_cid3001_2(self):
     assert codes.cid3001.NegativeLowRightScapulaLead == Code(
         value='2:124',
         scheme_designator='MDC',
         meaning='negativ: low right scapula Lead'
     )
Esempio n. 23
0
 def test_cid300(self):
     assert codes.cid300.NickelCobaltChromium == Code(
         value='261249004',
         scheme_designator='SCT',
         meaning='Nickel cobalt chromium'
     )
Esempio n. 24
0
 def test_cid3107(self):
     assert codes.cid3107._13Nitrogen == Code(
         value='21576001',
         scheme_designator='SCT',
         meaning='^13^Nitrogen'
     )
Esempio n. 25
0
 def test_cid402(self):
     assert codes.cid402.DestinationRoleID == Code(
         value='110152',
         scheme_designator='DCM',
         meaning='Destination Role ID'
     )
Esempio n. 26
0
 def test_cid3111(self):
     assert codes.cid3111.Tc99mTetrofosmin == Code(
         value='404707004',
         scheme_designator='SCT',
         meaning='Tc-99m tetrofosmin'
     )
Esempio n. 27
0
 def test_cid610(self):
     assert codes.cid610.ReverseOsmosisPurifiedHclAcidifiedWater == Code(
         value='127291',
         scheme_designator='DCM',
         meaning='Reverse osmosis purified, HCl acidified water'
     )
Esempio n. 28
0
 def test_cid3263(self):
     assert codes.cid3263._12LeadFromEASILeadsESASAIByDowerEASITransformation == Code(
         value='10:11284',
         scheme_designator='MDC',
         meaning='12-lead from EASI leads (ES, AS, AI) by Dower/EASI transformation'
     )
Esempio n. 29
0
 def test_cid622(self):
     assert codes.cid622.NeuromuscularBlockingNMBNonDepolarizing == Code(
         value='372790002',
         scheme_designator='SCT',
         meaning='NeuroMuscular Blocking (NMB) - non depolarizing'
     )
Esempio n. 30
0
 def test_cid3335(self):
     assert codes.cid3335.PWaveSecondDeflectionInPWave == Code(
         value='10:320',
         scheme_designator='MDC',
         meaning='P\' wave (second deflection in P wave)'
     )