Exemple #1
0
def add_claim(request): 
    results = {'success':False, 'text': 'Claim not added'}

    if request.POST['polygon_id'] and request.POST['claim_text']:
        claim = Claim(text=request.POST['claim_text'],
                      polygon_id=request.POST['polygon_id'],
                      servant=request.POST['servant'],
                      complainer=request.user)
        claim.save()
        results = {'success':True, 'text': 'Claim added'} 


    return HttpResponse(json.dumps(results), content_type='application/json')
 def create_test_imis_instance(self):
     imis_claim = Claim()
     imis_claim.id = self._TEST_ID
     imis_claim.code = self._TEST_CODE
     imis_claim.status = self._TEST_STATUS
     imis_claim.adjustment = self._TEST_ADJUSTMENT
     imis_claim.date_processed = TimeUtils.str_to_date(
         self._TEST_DATE_PROCESSED)
     imis_claim.approved = self._TEST_APPROVED
     imis_claim.rejection_reason = self._TEST_REJECTION_REASON
     feedback = Feedback()
     feedback.id = self._TEST_FEEDBACK_ID
     imis_claim.feedback = feedback
     return imis_claim
Exemple #3
0
def add_claim(request):
    if settings.RECAPTCHA_ENABLED and not request.user.is_authenticated():
        if not request.POST.get('g-recaptcha-response', False):
            raise Exception('Google reCaptcha verification not passed')

        response = requests.post(
            "https://www.google.com/recaptcha/api/siteverify",
            {
                "secret": settings.RECAPTCHA_SECRET,
                "response": request.POST.get('g-recaptcha-response', False),
                "remoteip": get_client_ip(request)
            }
        ).json()

        if not response['success']:
            raise Exception('Google think user is not real.')

    user = None if request.POST.get(
        'anonymously',
        False) or not request.user.is_authenticated() else request.user

    code = 500

    if (
        request.POST.get('org_id', False) and
        request.POST.get('claim_text', False)
    ):
        claim = Claim(
            text=escape(request.POST.get('claim_text', False)),
            servant=escape(request.POST.get('servant', False)),
            bribe=escape(request.POST.get('bribe', 0)),
            complainer=user,
            organization=Organization.objects.get(
                id=request.POST.get('org_id', False)),
            claim_type=ClaimType.objects.get(
                id=request.POST.get('claim_type', False)),
            moderation=user and 'not_moderated' or 'anonymous',
        )
        claim.save()
        # Correct insert code
        code = 201

    return HttpResponse(status=code)
Exemple #4
0
def add_claim(request):
    if settings.RECAPTCHA_ENABLED and not request.user.is_authenticated():
        if not request.POST.get('g-recaptcha-response', False):
            raise Exception('Google reCaptcha verification not passed')

        response = requests.post(
            "https://www.google.com/recaptcha/api/siteverify", {
                "secret": settings.RECAPTCHA_SECRET,
                "response": request.POST.get('g-recaptcha-response', False),
                "remoteip": get_client_ip(request)
            }).json()

        if not response['success']:
            raise Exception('Google think user is not real.')

    user = None if request.POST.get(
        'anonymously',
        False) or not request.user.is_authenticated() else request.user

    code = 500

    if (request.POST.get('org_id', False)
            and request.POST.get('claim_text', False)):
        claim = Claim(
            text=escape(request.POST.get('claim_text', False)),
            servant=escape(request.POST.get('servant', False)),
            bribe=escape(request.POST.get('bribe', 0)),
            complainer=user,
            organization=Organization.objects.get(
                id=request.POST.get('org_id', False)),
            claim_type=ClaimType.objects.get(
                id=request.POST.get('claim_type', False)),
            moderation=user and 'not_moderated' or 'anonymous',
        )
        claim.save()
        # Correct insert code
        code = 201

    return HttpResponse(status=code)
 def to_imis_obj(cls, fhir_claim, audit_user_id):
     errors = []
     imis_claim = Claim()
     cls.build_imis_date_claimed(imis_claim, fhir_claim, errors)
     cls.build_imis_health_facility(errors, fhir_claim, imis_claim)
     cls.build_imis_identifier(imis_claim, fhir_claim, errors)
     cls.build_imis_patient(imis_claim, fhir_claim, errors)
     cls.build_imis_date_range(imis_claim, fhir_claim, errors)
     cls.build_imis_diagnoses(imis_claim, fhir_claim, errors)
     cls.build_imis_total_claimed(imis_claim, fhir_claim, errors)
     cls.build_imis_claim_admin(imis_claim, fhir_claim, errors)
     cls.build_imis_visit_type(imis_claim, fhir_claim)
     cls.build_imis_information(imis_claim, fhir_claim)
     cls.build_imis_submit_items_and_services(imis_claim, fhir_claim)
     cls.check_errors(errors)
     return imis_claim
 def create_test_imis_instance(self):
     imis_claim = Claim()
     imis_claim.id = self._TEST_ID
     imis_claim.insuree = PatientTestMixin().create_test_imis_instance()
     imis_claim.code = self._TEST_CODE
     imis_claim.date_from = TimeUtils.str_to_date(self._TEST_DATE_FROM)
     imis_claim.date_to = TimeUtils.str_to_date(self._TEST_DATE_TO)
     icd = ClaimDiagnosisCode()
     icd.code = self._TEST_MAIN_ICD_CODE
     imis_claim.icd = icd
     imis_claim.claimed = self._TEST_CLAIMED
     imis_claim.date_claimed = TimeUtils.str_to_date(
         self._TEST_DATE_CLAIMED)
     imis_claim.health_facility = LocationTestMixin(
     ).create_test_imis_instance()
     imis_claim.guarantee_id = self._TEST_GUARANTEE_ID
     imis_claim.admin = PractitionerTestMixin().create_test_imis_instance()
     imis_claim.icd_1 = self._TEST_ICD_1
     imis_claim.icd_2 = self._TEST_ICD_2
     imis_claim.icd_3 = self._TEST_ICD_3
     imis_claim.icd_4 = self._TEST_ICD_4
     imis_claim.visit_type = self._TEST_VISIT_TYPE
     return imis_claim
 def get_queryset(self):
     return Claim.get_queryset(None, self.request.user)