Skip to content

Commit

Permalink
Adds support for phone number in HCX Create Patient Profile (#2319)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jul 23, 2024
1 parent d085c2a commit d42e769
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 38 deletions.
62 changes: 39 additions & 23 deletions care/hcx/api/viewsets/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ def check_eligibility(self, request):
"7894561232",
policy["patient_object"]["id"],
policy["patient_object"]["name"],
"male"
if policy["patient_object"]["gender"] == 1
else "female"
if policy["patient_object"]["gender"] == 2
else "other",
(
"male"
if policy["patient_object"]["gender"] == 1
else (
"female" if policy["patient_object"]["gender"] == 2 else "other"
)
),
policy["subscriber_id"],
policy["policy_id"],
policy["id"],
policy["id"],
policy["id"],
policy["patient_object"]["phone_number"],
REVERSE_STATUS_CHOICES[policy["status"]],
REVERSE_PRIORITY_CHOICES[policy["priority"]],
REVERSE_PURPOSE_CHOICES[policy["purpose"]],
Expand Down Expand Up @@ -125,17 +128,23 @@ def make_claim(self, request):
lambda procedure: {
"id": str(uuid()),
"name": procedure["procedure"],
"performed": procedure["time"]
if "time" in procedure
else procedure["frequency"],
"performed": (
procedure["time"]
if "time" in procedure
else procedure["frequency"]
),
"status": (
"completed"
if datetime.strptime(procedure["time"], "%Y-%m-%dT%H:%M")
< datetime.now()
else "preparation"
)
if "time" in procedure
else "in-progress",
(
"completed"
if datetime.strptime(
procedure["time"], "%Y-%m-%dT%H:%M"
)
< datetime.now()
else "preparation"
)
if "time" in procedure
else "in-progress"
),
},
consultation.procedure,
)
Expand Down Expand Up @@ -208,17 +217,22 @@ def make_claim(self, request):
"GICOFINDIA",
claim["policy_object"]["patient_object"]["id"],
claim["policy_object"]["patient_object"]["name"],
"male"
if claim["policy_object"]["patient_object"]["gender"] == 1
else "female"
if claim["policy_object"]["patient_object"]["gender"] == 2
else "other",
(
"male"
if claim["policy_object"]["patient_object"]["gender"] == 1
else (
"female"
if claim["policy_object"]["patient_object"]["gender"] == 2
else "other"
)
),
claim["policy_object"]["subscriber_id"],
claim["policy_object"]["policy_id"],
claim["policy_object"]["id"],
claim["id"],
claim["id"],
claim["items"],
claim["policy_object"]["patient_object"]["phone_number"],
REVERSE_USE_CHOICES[claim["use"]],
REVERSE_STATUS_CHOICES[claim["status"]],
REVERSE_CLAIM_TYPE_CHOICES[claim["type"]],
Expand All @@ -237,9 +251,11 @@ def make_claim(self, request):

response = Hcx().generateOutgoingHcxCall(
fhirPayload=json.loads(claim_fhir_bundle.json()),
operation=HcxOperations.CLAIM_SUBMIT
if REVERSE_USE_CHOICES[claim["use"]] == "claim"
else HcxOperations.PRE_AUTH_SUBMIT,
operation=(
HcxOperations.CLAIM_SUBMIT
if REVERSE_USE_CHOICES[claim["use"]] == "claim"
else HcxOperations.PRE_AUTH_SUBMIT
),
recipientCode=claim["policy_object"]["insurer_id"],
)

Expand Down
37 changes: 22 additions & 15 deletions care/hcx/utils/fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def get_reference_url(self, resource: domainresource.DomainResource):
return f"{resource.resource_type}/{resource.id}"

def create_patient_profile(
self, id: str, name: str, gender: str, identifier_value: str
self, id: str, name: str, gender: str, phone: str, identifier_value: str
):
return patient.Patient(
id=id,
Expand All @@ -280,6 +280,7 @@ def create_patient_profile(
],
name=[{"text": name}],
gender=gender,
telecom=[{"system": "phone", "value": phone}],
)

def create_provider_profile(self, id: str, name: str, identifier_value: str):
Expand Down Expand Up @@ -558,9 +559,11 @@ def create_claim_profile(
category=codeableconcept.CodeableConcept(
coding=[
coding.Coding(
system=SYSTEM.claim_item_category_pmjy
if item["category"] == "HBP"
else SYSTEM.claim_item_category,
system=(
SYSTEM.claim_item_category_pmjy
if item["category"] == "HBP"
else SYSTEM.claim_item_category
),
code=item["category"],
)
]
Expand Down Expand Up @@ -695,6 +698,7 @@ def create_coverage_eligibility_request_bundle(
coverage_id: str,
eligibility_request_id: str,
eligibility_request_identifier_value: str,
patient_phone: str,
status="active",
priority="normal",
purpose="validation",
Expand All @@ -709,7 +713,7 @@ def create_coverage_eligibility_request_bundle(
insurer_id, insurer_name, insurer_identifier_value
)
patient = self.create_patient_profile(
patient_id, pateint_name, patient_gender, subscriber_id
patient_id, pateint_name, patient_gender, patient_phone, subscriber_id
)
enterer = self.create_practitioner_role_profile(
enterer_id, enterer_identifier_value, enterer_speciality, enterer_phone
Expand Down Expand Up @@ -792,6 +796,7 @@ def create_claim_bundle(
claim_id: str,
claim_identifier_value: str,
items: list[IClaimItem],
patient_phone: str,
use="claim",
status="active",
type="institutional",
Expand All @@ -810,7 +815,7 @@ def create_claim_bundle(
insurer_id, insurer_name, insurer_identifier_value
)
patient = self.create_patient_profile(
patient_id, pateint_name, patient_gender, subscriber_id
patient_id, pateint_name, patient_gender, patient_phone, subscriber_id
)
coverage = self.create_coverage_profile(
coverage_id,
Expand Down Expand Up @@ -947,15 +952,17 @@ def create_communication_profile(
map(
lambda content: (
communication.CommunicationPayload(
contentString=content["data"]
if content["type"] == "text"
else None,
contentAttachment=attachment.Attachment(
url=content["data"],
title=content["name"] if content["name"] else None,
)
if content["type"] == "url"
else None,
contentString=(
content["data"] if content["type"] == "text" else None
),
contentAttachment=(
attachment.Attachment(
url=content["data"],
title=content["name"] if content["name"] else None,
)
if content["type"] == "url"
else None
),
)
),
payload,
Expand Down

0 comments on commit d42e769

Please sign in to comment.