@@ -419,62 +419,40 @@ def test_validate_category_too_many_category():
419419 }
420420
421421
422- # TODO: Parameterize this test and the one below
423- def test_validate_category_coding_display_mismatch_care_plan ():
422+ @pytest .mark .parametrize (
423+ "category_code, category_display, type_code, type_display" ,
424+ [
425+ ("734163000" , "Care plan" , None , None ),
426+ (
427+ "1102421000000108" ,
428+ "Observations" ,
429+ "1363501000000100" ,
430+ "Royal College of Physicians NEWS2 (National Early Warning Score 2) chart" ,
431+ ),
432+ ],
433+ )
434+ def test_validate_category_coding_display_mismatch (
435+ category_code , category_display , type_code , type_display
436+ ):
424437 validator = DocumentReferenceValidator ()
425438 document_ref_data = load_document_reference_json ("Y05868-736253002-Valid" )
426439
427- document_ref_data ["category" ][0 ] = {
428- "coding" : [
429- {
430- "system" : "http://snomed.info/sct" ,
431- "code" : "734163000" ,
432- "display" : "some random display name" ,
433- }
434- ]
435- }
436-
437- result = validator .validate (document_ref_data )
438-
439- assert result .is_valid is False
440- assert result .resource .id == "Y05868-99999-99999-999999"
441- assert len (result .issues ) == 1
442- assert result .issues [0 ].model_dump (exclude_none = True ) == {
443- "severity" : "error" ,
444- "code" : "value" ,
445- "details" : {
440+ if type_code and type_display :
441+ document_ref_data ["type" ] = {
446442 "coding" : [
447443 {
448- "system" : "https ://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1 " ,
449- "code" : "INVALID_RESOURCE" ,
450- "display" : "Invalid validation of resource" ,
444+ "system" : "http ://snomed.info/sct " ,
445+ "code" : type_code ,
446+ "display" : type_display ,
451447 }
452448 ]
453- },
454- "diagnostics" : "category code '734163000' must have a display value of 'Care plan'" ,
455- "expression" : ["category[0].coding[0].display" ],
456- }
457-
458-
459- def test_validate_category_coding_display_mismatch_observations ():
460- validator = DocumentReferenceValidator ()
461- document_ref_data = load_document_reference_json ("Y05868-736253002-Valid" )
462-
463- document_ref_data ["type" ] = {
464- "coding" : [
465- {
466- "system" : "http://snomed.info/sct" ,
467- "code" : "1363501000000100" ,
468- "display" : "Royal College of Physicians NEWS2 (National Early Warning Score 2) chart" ,
469- }
470- ]
471- }
449+ }
472450
473451 document_ref_data ["category" ][0 ] = {
474452 "coding" : [
475453 {
476454 "system" : "http://snomed.info/sct" ,
477- "code" : "1102421000000108" ,
455+ "code" : category_code ,
478456 "display" : "some random display name" ,
479457 }
480458 ]
@@ -497,7 +475,7 @@ def test_validate_category_coding_display_mismatch_observations():
497475 }
498476 ]
499477 },
500- "diagnostics" : "category code '1102421000000108 ' must have a display value of 'Observations '" ,
478+ "diagnostics" : f "category code '{ category_code } ' must have a display value of '{ category_display } '" ,
501479 "expression" : ["category[0].coding[0].display" ],
502480 }
503481
@@ -758,8 +736,6 @@ def test_validate_type_coding_display_mismatch(type_str: str, display: str):
758736 ]
759737 }
760738
761- # match type to category to avoid getting that error
762- # TODO: Discuss in review if I should just ignore the error that happens to simplify test
763739 category_str = TYPE_CATEGORIES [type_str ]
764740 category_parts = category_str .split ("|" )
765741 category_system = category_parts [0 ]
0 commit comments