Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMILECDR-498 & 504 #81

Merged
merged 8 commits into from
Sep 27, 2023
25 changes: 23 additions & 2 deletions hl7v2_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,13 @@
{"template": "organization_facility_resource"},
{"xpath": ".[count(PID)=1]", "template": "patient_resource"},
{"xpath": ".[count(PV1)=1]", "template": "encounter_resource"},
{"xpath": ".[EVN/message_typecode!='A40']","template": "account_resource"},
{"xpath": ".[EVN/message_typecode!='A40' and guarantor[position()>0]]","template": "account_resource"},
{"xpath": ".[PV1/point_of_care!='']","template": "organization_department_resource"},
{"xpath": ".[PV1/attending_physician_id!='']", "template": "practitioner_attending_resource"},
{"xpath": ".[PV1/referring_physician_id!='']", "template": "practitioner_referring_resource"},
{"xpath": "guarantor[position()=1]", "template": "relatedperson_guarantor_resource"},
{"xpath": "guarantor[position()=2]", "template": "relatedperson_guarantor_resource"},
{"xpath": "guarantor[position()=3]", "template": "relatedperson_guarantor_resource"},
{"xpath": "insurance[position()=1]", "template": "organization_payor_resource", "_comment": "resource for Organization of primary Payer, if found"},
{"xpath": "insurance[position()=1]", "template": "coverage_resource", "_comment": "resource for Primary Coverage 1st insurance instance found"},
{"xpath": "insurance[position()=1][//insurance[position()=1]/IN1/insured_patient_relationship[translate(text(), 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')][not(.='SELF') and not(.='01') and not(.='S') and not(.='SP') and not(.='SE')]]", "template": "relatedperson_subscriber_resource", "_comment": "relatedperson resource for subscriber will be generated IFF insured patient relationship (IN1.17) is NOT 'SELF'"},
Expand Down Expand Up @@ -699,7 +700,7 @@
},
"account": {
"array": [
{
{"xpath": "guarantor[position()=1]",
"object": {
"type": {"const": "Account"},
"reference": {"const": "urn:uuid:61ebe121-aa04-0001-0001-983a382abcd7"}
Expand Down Expand Up @@ -805,7 +806,27 @@
}
}
}
},
{"xpath": "guarantor[position()=2]",
"object": {
"party": {
"object": {
"type": {"const": "RelatedPerson"},
"reference": {"const": "urn:uuid:61ebe121-aa05-0001-0002-983a382abcd7"}
}
}
}
},
{"xpath": "guarantor[position()=3]",
"object": {
"party": {
"object": {
"type": {"const": "RelatedPerson"},
"reference": {"const": "urn:uuid:61ebe121-aa05-0001-0003-983a382abcd7"}
}
}
}
}
]
}
}
Expand Down
25 changes: 23 additions & 2 deletions hl7v2_default_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,13 @@
{"template": "organization_facility_resource"},
{"xpath": ".[count(PID)=1]", "template": "patient_resource"},
{"xpath": ".[count(PV1)=1]", "template": "encounter_resource"},
{"xpath": ".[EVN/message_typecode!='A40']","template": "account_resource"},
{"xpath": ".[EVN/message_typecode!='A40' and guarantor[position()>0]]","template": "account_resource"},
{"xpath": ".[PV1/point_of_care!='']","template": "organization_department_resource"},
{"xpath": ".[PV1/attending_physician_id!='']", "template": "practitioner_attending_resource"},
{"xpath": ".[PV1/referring_physician_id!='']", "template": "practitioner_referring_resource"},
{"xpath": "guarantor[position()=1]", "template": "relatedperson_guarantor_resource"},
{"xpath": "guarantor[position()=2]", "template": "relatedperson_guarantor_resource"},
{"xpath": "guarantor[position()=3]", "template": "relatedperson_guarantor_resource"},
{"xpath": "insurance[position()=1]", "template": "organization_payor_resource", "_comment": "resource for Organization of primary Payer, if found"},
{"xpath": "insurance[position()=1]", "template": "coverage_resource", "_comment": "resource for Primary Coverage 1st insurance instance found"},
{"xpath": "insurance[position()=1][//insurance[position()=1]/IN1/insured_patient_relationship[translate(text(), 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')][not(.='SELF') and not(.='01') and not(.='S') and not(.='SP') and not(.='SE')]]", "template": "relatedperson_subscriber_resource", "_comment": "relatedperson resource for subscriber will be generated IFF insured patient relationship (IN1.17) is NOT 'SELF'"},
Expand Down Expand Up @@ -699,7 +700,7 @@
},
"account": {
"array": [
{
{"xpath": "guarantor[position()=1]",
"object": {
"type": {"const": "Account"},
"reference": {"const": "urn:uuid:61ebe121-aa04-0001-0001-983a382abcd7"}
Expand Down Expand Up @@ -805,7 +806,27 @@
}
}
}
},
{"xpath": "guarantor[position()=2]",
"object": {
"party": {
"object": {
"type": {"const": "RelatedPerson"},
"reference": {"const": "urn:uuid:61ebe121-aa05-0001-0002-983a382abcd7"}
}
}
}
},
{"xpath": "guarantor[position()=3]",
"object": {
"party": {
"object": {
"type": {"const": "RelatedPerson"},
"reference": {"const": "urn:uuid:61ebe121-aa05-0001-0003-983a382abcd7"}
}
}
}
}
]
}
}
Expand Down
18 changes: 14 additions & 4 deletions tests/regression/account_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
COVERAGE_FULL_URL_1,
COVERAGE_FULL_URL_2,
COVERAGE_FULL_URL_3,
RELATED_PERSON_GUARANTOR_FULL_URL,
RELATED_PERSON_GUARANTOR_FULL_URL_1,
RELATED_PERSON_GUARANTOR_FULL_URL_2,
RELATED_PERSON_GUARANTOR_FULL_URL_3
)

from .reg_globals.identifier_urls import(
Expand Down Expand Up @@ -45,8 +47,12 @@ def acc_test(resource_name, testfile, identifier_url, identifier_id):
assert acc[0]["resource"]["coverage"][1]["priority"] == 2, "did not match priority"
assert acc[0]["resource"]["coverage"][2]["coverage"]["reference"] == COVERAGE_FULL_URL_3, "did not match coverage full URL"
assert acc[0]["resource"]["coverage"][2]["priority"] == 3, "did not match priority"
assert acc[0]["resource"]["guarantor"][0]["party"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL, "did not match guarantor reference"
assert acc[0]["resource"]["guarantor"][0]["party"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL_1, "did not match guarantor reference"
assert acc[0]["resource"]["guarantor"][0]["party"]["type"] == RESOURCE_NAME[7], "did not match reference type"
assert acc[0]["resource"]["guarantor"][1]["party"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL_2, "did not match guarantor reference"
assert acc[0]["resource"]["guarantor"][1]["party"]["type"] == RESOURCE_NAME[7], "did not match reference type"
assert acc[0]["resource"]["guarantor"][2]["party"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL_3, "did not match guarantor reference"
assert acc[0]["resource"]["guarantor"][2]["party"]["type"] == RESOURCE_NAME[7], "did not match reference type"
assert acc[0]["resource"]["identifier"][0]["system"] == f'{IDENTIFIER_URL}/{IDENTIFIER_ID[0]}', "did not match indentifier system"
assert acc[0]["resource"]["identifier"][0]["value"] == f'{MRN}-{FACILITY_ID}', "did not match identifier value"
assert acc[0]["resource"]["resourceType"] == RESOURCE_NAME[0], "did not match resource"
Expand All @@ -61,14 +67,18 @@ def acc_test(resource_name, testfile, identifier_url, identifier_id):
assert not acc[0]["fullUrl"] == PATIENT_FULL_URL, "negative test case failed"
assert not acc[0]["request"]["method"] == REQUEST_TYPE[1], "negative test case failed"
assert not acc[0]["request"]["url"] == {MRN}-{FACILITY_ID}, "negative test case failed"
assert not acc[0]["resource"]["coverage"][0]["coverage"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL, "negative test case failed"
assert not acc[0]["resource"]["coverage"][0]["coverage"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL_1, "negative test case failed"
assert not acc[0]["resource"]["coverage"][0]["priority"] == 3, "negative test case failed"
assert not acc[0]["resource"]["coverage"][1]["coverage"]["reference"] == ACCOUNT_FULL_URL, "negative test case failed"
assert not acc[0]["resource"]["coverage"][1]["priority"] == 1, "negative test case failed"
assert not acc[0]["resource"]["coverage"][2]["coverage"]["reference"] == PATIENT_FULL_URL, "negative test case failed"
assert not acc[0]["resource"]["coverage"][2]["priority"] == 2, "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["reference"] == ACCOUNT_FULL_URL, "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["reference"] == COVERAGE_FULL_URL_1, "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["type"] == RESOURCE_NAME[0], "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["reference"] == COVERAGE_FULL_URL_2, "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["type"] == RESOURCE_NAME[1], "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["reference"] == COVERAGE_FULL_URL_3, "negative test case failed"
assert not acc[0]["resource"]["guarantor"][0]["party"]["type"] == RESOURCE_NAME[2], "negative test case failed"
assert not acc[0]["resource"]["identifier"][0]["system"] == IDENTIFIER_URL, "negative test case failed"
assert not acc[0]["resource"]["identifier"][0]["value"] == f'{FACILITY_ID}-{MRN}', "negative test case failed"
assert not acc[0]["resource"]["resourceType"] == RESOURCE_NAME[3], "negative test case failed"
Expand Down
4 changes: 3 additions & 1 deletion tests/regression/reg_globals/reference_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
ORGANIZATION_DEPARTMENT_FULL_URL="urn:uuid:61ebe121-aa02-0003-0001-983a382abcd7"
ENCOUNTER_FULL_URL="urn:uuid:61ebe121-aa03-0001-0001-983a382abcd7"
ACCOUNT_FULL_URL="urn:uuid:61ebe121-aa04-0001-0001-983a382abcd7"
RELATED_PERSON_GUARANTOR_FULL_URL="urn:uuid:61ebe121-aa05-0001-0001-983a382abcd7"
RELATED_PERSON_GUARANTOR_FULL_URL_1="urn:uuid:61ebe121-aa05-0001-0001-983a382abcd7"
RELATED_PERSON_GUARANTOR_FULL_URL_2="urn:uuid:61ebe121-aa05-0001-0002-983a382abcd7"
RELATED_PERSON_GUARANTOR_FULL_URL_3="urn:uuid:61ebe121-aa05-0001-0003-983a382abcd7"
RELATED_PERSON_INSURANCE_FULL_URL_1="urn:uuid:61ebe121-aa05-0002-0001-983a382abcd7"
RELATED_PERSON_INSURANCE_FULL_URL_2="urn:uuid:61ebe121-aa05-0002-0002-983a382abcd7"
RELATED_PERSON_INSURANCE_FULL_URL_3="urn:uuid:61ebe121-aa05-0002-0003-983a382abcd7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MSH|^~\&|Epic|STL|Pediatrix||20230411105743145038900|TCO4A|ADT^A08|13503|T|2.3|\rEVN|A08|20230411105743145038900||A31A08A31|TCO4A^COOK^TIM^^^^^^SJMH^^^^^SJMMC|\rPID|1||TEST333345038900^^^EPI^EPI||patient1^girl1testing^sprg^^^^D||20230411|F|||111 first st^apt 1^somewhere^fl^55555-5555^US^P||(479)555-5874^CP^7^pid1@gmail.com^^479^5555874|(479)555-5875^P^7^pid12@gmail.com^^479^5555874||SINGLE||9543332222|954-331-2222|||||Y|2||||21230620|||||||||||||||20230611|20230811|\rPD1|||MERCY HOSPITAL ST LOUIS^^20101|||||||||\rNK1|1|PATIENT^TESTING^SPRG^|Mother|^^^^^US|(555)555-5551^^7^^^555^5555551||EC1||||^^||\rNK1|2|PATIENT^TESTING^SPRG^||^^^^^US|(555)555-5551^^7^^^555^5555551||MOTHER||||^^||\rNK1|3||||||EMP||||^^||NOT EMPLOYED\rPV1|1|INPATIENT|SJMNICUS^2107^^SJMMC^Dirty^^^^STLO NICU 2|NB|||15236798^SOM IP^PHYSICIAN^HOSPITALIST|15236799^SOM IP^REFERRING^HOSPITALIST||NURSERY||||BORN INSIDE |||15236798^SOM IP^PHYSICIAN^HOSPITALIST^|CONF|17723456|COMM C||||||||||||||||||||||||20230411080900|20230511080900|\rPV2||Level 2||||||||||Hospital Encounter||\rDG1|1||^Newborn|Newborn||A|\rGT1|1|100003699|patient^testing^SPRG^||1500 corporate Drive^Suite 101^SUNRISE^FL^33322^US|(555)555-5551^P^7^gt1@gmail.com^^555^5555551|(555)555-5552^P^7^gt12@gmail.com^^555^5555551|19870108|F|P/F|MOT|105-45-2154||||||||\rIN1|1|2000805^AETNA PPO|20008|AETNA|PO BOX 981106^^EL PASO^TX^79998-1106^||(800)789-9009|1234|TEST|||20230101|20250101|3456T789|130|patient^testing^L^|Child|19870108|123 main st^apt 1^anywhere^fl^55555-5555^US|||1|||YES||||||||||465|5678|||||||F||||BOTH||465\rIN2||954-333-2223|||Payer Plan|123456|||||||||||||||||||||||||||||||||||||||||||||||||||||||9876543211||(555)111-2221^^In2@gmail.com|(555)111-2222^^In212@gmail.com\rIN1|2|2007118^CIGNA HEALTHSCOPE PPO|20071|CIGNA HEALTHCARE|PO BOX 188061^^CHATTANOOGA^TN^37422-8061^||7898678090|1234||||20230202|20250202|20071PED|130|PATIENT^TESTING^K^|Child|19870108|456 main st^apt 1^anywhere^fl^55555-5555^US|||2|||YES||||||||||466|1789|||||||F||||BOTH||466\rIN2||954-333-2224|||Payer Plan||||||||||||||||||||||||||||||||||||||||||||||||||||||||987654321||5551112222^^In2sec@gmail.com|5552223333^^In2sec12@gmail.com\rIN1|3|2007119^BCBS HEALTHSCOPE PPO|20072|BCBS HEALTHCARE|PO BOX 199045^^NASHVILLE^TN^37423-8062^||7898678919|4567||||20220202|20250301|20078PED|131|PATIENT^TESTING^K^|Child|19880108|789 main st^apt 1^somewhere^fl^44444-4444^US|||2|||YES||||||||||467|1790|||||||F||||BOTH||467\rIN2||954-444-2225|||Payer Plan||||||||||||||||||||||||||||||||||||||||||||||||||||||||987654322||5551112223^^In3sec@gmail.com|5552223334^^In3sec12@gmail.com
MSH|^~\&|Epic|STL|Pediatrix||20230411105743145038900|TCO4A|ADT^A08|13503|T|2.3|\rEVN|A08|20230411105743145038900||A31A08A31|TCO4A^COOK^TIM^^^^^^SJMH^^^^^SJMMC|\rPID|1||TEST333345038900^^^EPI^EPI||patient1^girl1testing^sprg^^^^D||20230411|F|||111 first st^apt 1^somewhere^fl^55555-5555^US^P||(479)555-5874^CP^7^pid1@gmail.com^^479^5555874|(479)555-5875^P^7^pid12@gmail.com^^479^5555874||SINGLE||9543332222|954-331-2222|||||Y|2||||21230620|||||||||||||||20230611|20230811|\rPD1|||MERCY HOSPITAL ST LOUIS^^20101|||||||||\rNK1|1|PATIENT^TESTING^SPRG^|Mother|^^^^^US|(555)555-5551^^7^^^555^5555551||EC1||||^^||\rNK1|2|PATIENT^TESTING^SPRG^||^^^^^US|(555)555-5551^^7^^^555^5555551||MOTHER||||^^||\rNK1|3||||||EMP||||^^||NOT EMPLOYED\rPV1|1|INPATIENT|SJMNICUS^2107^^SJMMC^Dirty^^^^STLO NICU 2|NB|||15236798^SOM IP^PHYSICIAN^HOSPITALIST|15236799^SOM IP^REFERRING^HOSPITALIST||NURSERY||||BORN INSIDE |||15236798^SOM IP^PHYSICIAN^HOSPITALIST^|CONF|17723456|COMM C||||||||||||||||||||||||20230411080900|20230511080900|\rPV2||Level 2||||||||||Hospital Encounter||\rDG1|1||^Newborn|Newborn||A|\rGT1|1|100003699|patient^testing^SPRG^||1500 corporate Drive^Suite 101^SUNRISE^FL^33322^US|(555)555-5551^P^7^gt1@gmail.com^^555^5555551|(555)555-5552^P^7^gt12@gmail.com^^555^5555551|19870108|F|P/F|MOT|105-45-2154||||||||\rGT1|2|1000036100|patient1^testing1^SPRG1^||1501 corporate Drive^Suite 101^SUNRISE^FL^33322^US|(555)555-5551^P^7^gt2@gmail.com^^555^5555551|(555)555-5552^P^7^gt22@gmail.com^^555^5555551|19870107|F|P/F|MOT|105-45-2155||||||||\rGT1|3|1000036101|patient2^testing2^SPRG2^||1502 corporate Drive^Suite 101^SUNRISE^FL^33322^US|(555)555-5551^P^7^gt3@gmail.com^^555^5555551|(555)555-5552^P^7^gt32@gmail.com^^555^5555551|19870106|F|P/F|MOT|105-45-2156||||||||\rIN1|1|2000805^AETNA PPO|20008|AETNA|PO BOX 981106^^EL PASO^TX^79998-1106^||(800)789-9009|1234|TEST|||20230101|20250101|3456T789|130|patient^testing^L^|Child|19870108|123 main st^apt 1^anywhere^fl^55555-5555^US|||1|||YES||||||||||465|5678|||||||F||||BOTH||465\rIN2||954-333-2223|||Payer Plan|123456|||||||||||||||||||||||||||||||||||||||||||||||||||||||9876543211||(555)111-2221^^In2@gmail.com|(555)111-2222^^In212@gmail.com\rIN1|2|2007118^CIGNA HEALTHSCOPE PPO|20071|CIGNA HEALTHCARE|PO BOX 188061^^CHATTANOOGA^TN^37422-8061^||7898678090|1234||||20230202|20250202|20071PED|130|PATIENT^TESTING^K^|Child|19870108|456 main st^apt 1^anywhere^fl^55555-5555^US|||2|||YES||||||||||466|1789|||||||F||||BOTH||466\rIN2||954-333-2224|||Payer Plan||||||||||||||||||||||||||||||||||||||||||||||||||||||||987654321||5551112222^^In2sec@gmail.com|5552223333^^In2sec12@gmail.com\rIN1|3|2007119^BCBS HEALTHSCOPE PPO|20072|BCBS HEALTHCARE|PO BOX 199045^^NASHVILLE^TN^37423-8062^||7898678919|4567||||20220202|20250301|20078PED|131|PATIENT^TESTING^K^|Child|19880108|789 main st^apt 1^somewhere^fl^44444-4444^US|||2|||YES||||||||||467|1790|||||||F||||BOTH||467\rIN2||954-444-2225|||Payer Plan||||||||||||||||||||||||||||||||||||||||||||||||||||||||987654322||5551112223^^In3sec@gmail.com|5552223334^^In3sec12@gmail.com
6 changes: 3 additions & 3 deletions tests/regression/relatedperson_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)

from tests.regression.reg_globals.reference_urls import (
RELATED_PERSON_GUARANTOR_FULL_URL,
RELATED_PERSON_GUARANTOR_FULL_URL_1,
PATIENT_FULL_URL
)

Expand All @@ -53,7 +53,7 @@
def relatedperson_test(resource_name, testfile, identifier_url, identifier_id):
if(testfile == "1"):
rel = filter_resource(resource_name, testfile, identifier_url, identifier_id)
assert rel[3]["fullUrl"] == RELATED_PERSON_GUARANTOR_FULL_URL, "did not match related person resource full url"
assert rel[3]["fullUrl"] == RELATED_PERSON_GUARANTOR_FULL_URL_1, "did not match related person resource full url"
assert rel[3]["request"]["method"] == REQUEST_TYPE[0], "did not match put request type"
assert rel[3]["request"]["url"] == f'{RESOURCE_NAME[7]}?identifier={IDENTIFIER_URL}/{IDENTIFIER_ID[4]}|{MRN}-{FACILITY_ID}-{RELATED_PERSON_ID[0]}', "did not match request url"
assert rel[3]["resource"]["address"][0]["city"] == CITY, "did not match city"
Expand Down Expand Up @@ -111,7 +111,7 @@ def relatedperson_test(resource_name, testfile, identifier_url, identifier_id):
assert not rel[3]["resource"]["name"][0]["family"] == FIRSTNAME, "negative test case failed"
assert not rel[3]["resource"]["name"][0]["given"][0] == LASTNAME, "negative test case failed"
assert not rel[3]["resource"]["name"][0]["given"][1] == MIDDLENAME, "negative test case failed"
assert not rel[3]["resource"]["patient"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL, "negative test case failed"
assert not rel[3]["resource"]["patient"]["reference"] == RELATED_PERSON_GUARANTOR_FULL_URL_1, "negative test case failed"
assert not rel[3]["resource"]["patient"]["type"] == RESOURCE_NAME[1], "negative test case failed"
assert not rel[3]["resource"]["telecom"][0]["system"] == PHONETYPE, "negative test case failed"
assert not rel[3]["resource"]["telecom"][0]["use"] == ADDRESSUSE, "negative test case failed"
Expand Down