diff --git a/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-coverage-read.json b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-coverage-read.json new file mode 100644 index 000000000..b859b436d --- /dev/null +++ b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-coverage-read.json @@ -0,0 +1,79 @@ +{ + "resourceType": "Coverage", + "id": "c4dic-567834", + "meta": { + "lastUpdated": "2024-06-26T15:40:21.850-07:00", + "profile": [ + "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Coverage|1.1" + ] + }, + "contained": [ + { + "resourceType": "Organization", + "id": "provider-org", + "meta": { + "profile": [ + "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Organization|1.1" + ] + } + } + ], + "identifier": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MB", + "display": "Member Number" + } + ] + }, + "system": "https://bluebutton.cms.gov/resources/variables/bene_id", + "value": "567834", + "assigner": { + "reference": "#provider-org" + } + } + ], + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", + "code": "SUBSIDIZ" + } + ] + }, + "subscriberId": "3456789", + "beneficiary": { + "reference": "Patient/567834" + }, + "relationship": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship", + "code": "self", + "display": "Self" + } + ] + }, + "payor": [ + { + "reference": "#provider-org" + } + ], + "class": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/coverage-class", + "code": "group", + "display": "Group" + } + ] + }, + "value": "Medicare" + } + ] +} diff --git a/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-coverage-search.json b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-coverage-search.json new file mode 100644 index 000000000..779092547 --- /dev/null +++ b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-coverage-search.json @@ -0,0 +1,98 @@ +{ + "resourceType": "Bundle", + "id": "0c217c0f-79aa-423f-b770-1537a957fd9f", + "meta": { + "lastUpdated": "2024-06-26T15:40:22.104-07:00" + }, + "type": "searchset", + "total": 1, + "link": [ + { + "relation": "self", + "url": "https://localhost:6500/v2/fhir/Coverage?_format=json&_profile=http%3A%2F%2Fhl7.org%2Ffhir%2Fus%2Finsurance-card%2FStructureDefinition%2FC4DIC-Coverage&beneficiary=567834" + } + ], + "entry": [ + { + "resource": { + "resourceType": "Coverage", + "id": "c4dic-567834", + "meta": { + "lastUpdated": "2024-06-26T15:40:21.850-07:00", + "profile": [ + "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Coverage|1.1" + ] + }, + "contained": [ + { + "resourceType": "Organization", + "id": "provider-org", + "meta": { + "profile": [ + "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Organization|1.1" + ] + } + } + ], + "identifier": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MB", + "display": "Member Number" + } + ] + }, + "system": "https://bluebutton.cms.gov/resources/variables/bene_id", + "value": "567834", + "assigner": { + "reference": "#provider-org" + } + } + ], + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", + "code": "SUBSIDIZ" + } + ] + }, + "subscriberId": "3456789", + "beneficiary": { + "reference": "Patient/567834" + }, + "relationship": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship", + "code": "self", + "display": "Self" + } + ] + }, + "payor": [ + { + "reference": "#provider-org" + } + ], + "class": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/coverage-class", + "code": "group", + "display": "Group" + } + ] + }, + "value": "Medicare" + } + ] + } + } + ] +} diff --git a/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-patient-read.json b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-patient-read.json new file mode 100644 index 000000000..e487a329a --- /dev/null +++ b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-patient-read.json @@ -0,0 +1,267 @@ +{ + "resourceType": "Patient", + "id": "567834", + "meta": { + "lastUpdated": "2024-06-26T15:40:21.850-07:00", + "profile": [ + "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-Patient", + "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Patient|1.1" + ] + }, + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/variables/race", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/race", + "code": "1", + "display": "White" + } + }, + { + "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", + "extension": [ + { + "url": "ombCategory", + "valueCoding": { + "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor", + "code": "UNK", + "display": "Unknown" + } + }, + { + "url": "text", + "valueString": "Unknown" + } + ] + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/rfrnc_yr", + "valueDate": "2018" + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_01", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_01", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_02", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_02", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_03", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_03", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_04", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_04", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_05", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_05", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_06", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_06", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_07", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_07", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_08", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_08", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_09", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_09", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_10", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_10", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_11", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_11", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_12", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_12", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + } + ], + "identifier": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MB", + "display": "Member Number" + } + ] + }, + "system": "https://bluebutton.cms.gov/resources/variables/bene_id", + "value": "567834" + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "current", + "display": "Current" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "3456789", + "period": { + "start": "2020-07-30" + } + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "historic", + "display": "Historic" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "9AB2WW3GR44" + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "historic", + "display": "Historic" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "543217066" + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "historic", + "display": "Historic" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "3456689" + } + ], + "name": [ + { + "use": "usual", + "family": "Doe", + "given": [ + "John", + "A" + ] + } + ], + "gender": "male", + "birthDate": "1981-03-17", + "deceasedDateTime": "1981-03-17", + "address": [ + { + "state": "MO", + "postalCode": "12345" + } + ] +} diff --git a/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-patient-search.json b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-patient-search.json new file mode 100644 index 000000000..34eac44f1 --- /dev/null +++ b/apps/fhir/bluebutton/views/fhir_resources/bfd-c4dic-patient-search.json @@ -0,0 +1,286 @@ +{ + "resourceType": "Bundle", + "id": "59876712-2dd5-41d9-bc58-3f3f00d12fee", + "meta": { + "lastUpdated": "2024-06-26T15:40:22.104-07:00" + }, + "type": "searchset", + "total": 1, + "link": [ + { + "relation": "self", + "url": "https://localhost:6500/v2/fhir/Patient?_format=json&_id=567834" + } + ], + "entry": [ + { + "resource": { + "resourceType": "Patient", + "id": "567834", + "meta": { + "lastUpdated": "2024-06-26T15:40:21.850-07:00", + "profile": [ + "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-Patient", + "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Patient|1.1" + ] + }, + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/variables/race", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/race", + "code": "1", + "display": "White" + } + }, + { + "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", + "extension": [ + { + "url": "ombCategory", + "valueCoding": { + "system": "http://terminology.hl7.org/CodeSystem/v3-NullFlavor", + "code": "UNK", + "display": "Unknown" + } + }, + { + "url": "text", + "valueString": "Unknown" + } + ] + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/rfrnc_yr", + "valueDate": "2018" + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_01", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_01", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_02", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_02", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_03", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_03", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_04", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_04", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_05", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_05", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_06", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_06", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_07", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_07", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_08", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_08", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_09", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_09", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_10", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_10", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_11", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_11", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + }, + { + "url": "https://bluebutton.cms.gov/resources/variables/dual_12", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/variables/dual_12", + "code": "**", + "display": "Enrolled in Medicare A and/or B, but no Part D enrollment data for the beneficiary. (This status was indicated as 'XX' for 2006-2009)" + } + } + ], + "identifier": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MB", + "display": "Member Number" + } + ] + }, + "system": "https://bluebutton.cms.gov/resources/variables/bene_id", + "value": "567834" + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "current", + "display": "Current" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "3456789", + "period": { + "start": "2020-07-30" + } + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "historic", + "display": "Historic" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "9AB2WW3GR44" + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "historic", + "display": "Historic" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "543217066" + }, + { + "type": { + "coding": [ + { + "extension": [ + { + "url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "valueCoding": { + "system": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency", + "code": "historic", + "display": "Historic" + } + } + ], + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MC", + "display": "Patient's Medicare number" + } + ] + }, + "system": "http://hl7.org/fhir/sid/us-mbi", + "value": "3456689" + } + ], + "name": [ + { + "use": "usual", + "family": "Doe", + "given": [ + "John", + "A" + ] + } + ], + "gender": "male", + "birthDate": "1981-03-17", + "deceasedDateTime": "1981-03-17", + "address": [ + { + "state": "MO", + "postalCode": "12345" + } + ] + } + } + ] +} diff --git a/apps/fhir/bluebutton/views/home.py b/apps/fhir/bluebutton/views/home.py index 553d3ea89..9c9733c19 100644 --- a/apps/fhir/bluebutton/views/home.py +++ b/apps/fhir/bluebutton/views/home.py @@ -111,3 +111,10 @@ def get_supported_resources(resources, resource_names): resource_list.append(item) return resource_list + + +def get_response_json(resource_file_name): + response_file = open("./apps/fhir/bluebutton/views/fhir_resources/{}.json".format(resource_file_name), 'r') + resource = json.load(response_file) + response_file.close() + return resource diff --git a/apps/fhir/bluebutton/views/read.py b/apps/fhir/bluebutton/views/read.py index 2a53206de..40d9ecac6 100644 --- a/apps/fhir/bluebutton/views/read.py +++ b/apps/fhir/bluebutton/views/read.py @@ -1,9 +1,11 @@ from rest_framework import permissions +from rest_framework.response import Response from apps.authorization.permissions import DataAccessGrantPermission from apps.capabilities.permissions import TokenHasProtectedCapability from ..permissions import (ReadCrosswalkPermission, ResourcePermission, ApplicationActivePermission) from apps.fhir.bluebutton.views.generic import FhirDataView +from apps.fhir.bluebutton.views.home import get_response_json ##################################################################### @@ -53,6 +55,13 @@ def __init__(self, version=1): super().__init__(version) self.resource_type = "Patient" + def get(self, request, *args, **kwargs): + return_c4dic = False + if return_c4dic: + return Response(get_response_json("bfd-c4dic-patient-read")) + else: + return super().get(request, *args, **kwargs) + class ReadViewCoverage(ReadView): # Class used for Patient resource @@ -60,6 +69,14 @@ def __init__(self, version=1): super().__init__(version) self.resource_type = "Coverage" + def get(self, request, *args, **kwargs): + profile = request.query_params.get('_profile', '') + return_c4dic = False + if return_c4dic and profile == "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Coverage": + return Response(get_response_json("bfd-c4dic-coverage-read")) + else: + return super().get(request, *args, **kwargs) + class ReadViewExplanationOfBenefit(ReadView): # Class used for Patient resource diff --git a/apps/fhir/bluebutton/views/search.py b/apps/fhir/bluebutton/views/search.py index 8de3df3c8..34a6a4f89 100644 --- a/apps/fhir/bluebutton/views/search.py +++ b/apps/fhir/bluebutton/views/search.py @@ -1,3 +1,5 @@ +from rest_framework import (permissions) +from rest_framework.response import Response from voluptuous import ( Required, All, @@ -7,14 +9,18 @@ Schema, REMOVE_EXTRA, ) -from rest_framework import (permissions) from apps.fhir.bluebutton.constants import DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE from apps.fhir.bluebutton.views.generic import FhirDataView +from apps.fhir.bluebutton.views.home import get_response_json from apps.authorization.permissions import DataAccessGrantPermission from apps.capabilities.permissions import TokenHasProtectedCapability from ..permissions import (SearchCrosswalkPermission, ResourcePermission, ApplicationActivePermission) +C4BB_COVERAGE_PROFILE_URL = "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-Coverage" + +C4DIC_COVERAGE_PROFILE_URL = "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Coverage" + class SearchView(FhirDataView): # Base class for FHIR resource search views @@ -39,7 +45,8 @@ class SearchView(FhirDataView): QUERY_SCHEMA = { Required('startIndex', default=0): Coerce(int), Required('_count', default=DEFAULT_PAGE_SIZE): All(Coerce(int), Range(min=0, max=MAX_PAGE_SIZE)), - '_lastUpdated': [Match(REGEX_LASTUPDATED_VALUE, msg="the _lastUpdated operator is not valid")] + '_lastUpdated': [Match(REGEX_LASTUPDATED_VALUE, msg="the _lastUpdated operator is not valid")], + '_profile': Match('.+', msg="_profile value takes a non empty url like string") } def __init__(self, version=1): @@ -74,6 +81,13 @@ def build_parameters(self, request, *args, **kwargs): '_id': request.crosswalk.fhir_id, } + def get(self, request, *args, **kwargs): + return_c4dic = False + if return_c4dic: + return Response(get_response_json("bfd-c4dic-patient-search")) + else: + return super().get(request, *args, **kwargs) + class SearchViewCoverage(SearchView): # Class used for Coverage resource search view @@ -88,28 +102,36 @@ def build_parameters(self, request, *args, **kwargs): 'beneficiary': 'Patient/' + request.crosswalk.fhir_id, } + def get(self, request, *args, **kwargs): + profile = request.query_params.get('_profile', '') + return_c4dic = False + if return_c4dic and profile == C4DIC_COVERAGE_PROFILE_URL: + return Response(get_response_json("bfd-c4dic-coverage-search")) + else: + return super().get(request, *args, **kwargs) + class SearchViewExplanationOfBenefit(SearchView): # Class used for ExplanationOfBenefit resource search view # Regex to match a valid type value REGEX_TYPE_VALUE = r"(carrier)|" + \ - r"(pde)|" + \ - r"(dme)|" + \ - r"(hha)|" + \ - r"(hospice)|" + \ - r"(inpatient)|" + \ - r"(outpatient)|" + \ - r"(snf)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|carrier)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|pde)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|dme)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|hha)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|hospice)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|inpatient)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|outpatient)|" + \ - r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|snf)" + r"(pde)|" + \ + r"(dme)|" + \ + r"(hha)|" + \ + r"(hospice)|" + \ + r"(inpatient)|" + \ + r"(outpatient)|" + \ + r"(snf)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|carrier)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|pde)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|dme)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|hha)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|hospice)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|inpatient)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|outpatient)|" + \ + r"(https://bluebutton.cms.gov/resources/codesystem/eob-type\|snf)" # Regex to match a list of comma separated type values with IGNORECASE REGEX_TYPE_VALUES_LIST = r'(?i)^((' + REGEX_TYPE_VALUE + r')\s*,*\s*)+$' diff --git a/docker-compose/source_env_secrets_from_aws.sh b/docker-compose/source_env_secrets_from_aws.sh index 0a36755cb..594dfd9da 100755 --- a/docker-compose/source_env_secrets_from_aws.sh +++ b/docker-compose/source_env_secrets_from_aws.sh @@ -76,10 +76,10 @@ SYSTEM=$(uname -s) if [[ ${SYSTEM} == "Linux" || ${SYSTEM} == "Darwin" ]] then - aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_certificate --query 'SecretString' --output text | base64 -d > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.cert.pem - aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_private_key --query 'SecretString' --output text | base64 -d > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.key.nocrypt.pem + aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_certificate_test --query 'SecretString' --output text | base64 -d > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.cert.pem + aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_private_key_test --query 'SecretString' --output text | base64 -d > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.key.nocrypt.pem else # support cygwin - aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_certificate --query 'SecretString' --output text |base64 -di > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.cert.pem - aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_private_key --query 'SecretString' --output text |base64 -di > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.key.nocrypt.pem + aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_certificate_test --query 'SecretString' --output text |base64 -di > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.cert.pem + aws secretsmanager get-secret-value --secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_private_key_test --query 'SecretString' --output text |base64 -di > ${CERTSTORE_TEMPORARY_MOUNT_PATH}/ca.key.nocrypt.pem fi diff --git a/docker-compose/web-env-vars.env b/docker-compose/web-env-vars.env index 85d11a08c..216fe8e48 100644 --- a/docker-compose/web-env-vars.env +++ b/docker-compose/web-env-vars.env @@ -14,8 +14,8 @@ AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} -# BFD credentials/settings +# BFD credentials/settings Change here DJANGO_USER_ID_SALT=${DJANGO_USER_ID_SALT} DJANGO_USER_ID_ITERATIONS=${DJANGO_USER_ID_ITERATIONS} -FHIR_URL="https://prod-sbx.bfd.cms.gov" +FHIR_URL="https://test.bfd.cms.gov" DJANGO_FHIR_CERTSTORE=/code/docker-compose/certstore/