File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55from pydantic import BaseModel
66
7- from app .db .codes .model import CodedConcept
87from app .services .ecr .specification .constants import OID_TO_SYSTEM_KEY_MAP
98
109from ..db .conditions .model import DbCondition , DbConditionCoding
@@ -37,7 +36,7 @@ def index_condition_code_list_by_system(
3736
3837
3938@dataclass (frozen = True )
40- class Coding ( CodedConcept ) :
39+ class Coding :
4140 """
4241 A code + display + system triple, representing a single coded concept.
4342
@@ -47,7 +46,9 @@ class Coding(CodedConcept):
4746 and a human label for custom codes with "Other".
4847 """
4948
50- system_oid : str = ""
49+ code : str
50+ display : str
51+ system_oid : str
5152
5253
5354type Code = str
@@ -213,7 +214,7 @@ def _deserialize_system(
213214 item ["code" ]: Coding (
214215 code = item ["code" ],
215216 display = item .get ("display" , "" ),
216- system_oid = item .get ("system " , "" ),
217+ system_oid = item .get ("system_oid " , "" ),
217218 )
218219 for item in codings
219220 }
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from app .db .configurations .db import get_configuration_by_id_db
4+ from app .services .configurations import convert_config_to_storage_payload
5+ from app .services .ecr .specification .constants import OID_TO_SYSTEM_KEY_MAP
6+
7+
8+ @pytest .mark .integration
9+ @pytest .mark .asyncio
10+ class TestSerialization :
11+ async def test_successful_serialization (
12+ self ,
13+ create_config ,
14+ activate_config ,
15+ get_condition_id ,
16+ test_user_jurisdiction_id ,
17+ db_pool ,
18+ ):
19+ condition_name = "Ophthalmia Neonatorum"
20+ condition_id = await get_condition_id (condition_name )
21+
22+ config_metadata = await create_config (condition_id )
23+ config_id = config_metadata ["id" ]
24+ await activate_config (config_id )
25+ ophtalmia_config = await get_configuration_by_id_db (
26+ id = config_id , jurisdiction_id = test_user_jurisdiction_id , db = db_pool
27+ )
28+ assert ophtalmia_config
29+
30+ payload = await convert_config_to_storage_payload (
31+ configuration = ophtalmia_config , db = db_pool
32+ )
33+
34+ assert payload
35+
36+ for k , coding in payload .code_system_sets .items ():
37+ assert k in OID_TO_SYSTEM_KEY_MAP .values ()
38+
39+ for c in coding :
40+ assert c ["code" ] and c ["code" ] != ""
41+ assert c ["display" ] and c ["display" ] != ""
42+ assert c ["system" ] in OID_TO_SYSTEM_KEY_MAP .keys ()
You can’t perform that action at this time.
0 commit comments