Exemplo n.º 1
0
 def put(self, request, identifier, format=None):
     patient = self.get_object(identifier)
     serializer = PatientSerializer(patient, data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_404_BAD_REQUEST)
Exemplo n.º 2
0
def _get_patient_data_from_alternate_facility(query):
    r = None
    obj = None
    msg = None
    fac = None
    c_msg = None
    conditions = None
    other_conditions = None
    patient_id = None
    key = query.strip()[:3].upper()
    if urls.has_key(key):
        raw_url = urls[key]
        url = raw_url + 'detail/' + query
        try:
            r = requests.get(url)
            print r
            if not r:
                msg = "Sorry the patient was not found."
        except (ConnectionError, HTTPError, Timeout), e:
            print e, "\n\n"
            msg = "Sorry there was a problem in the connection. Try Again later..."
        if r:
            stream = BytesIO(r.text)
            try:
                data = JSONParser().parse(stream)

            except Exception, e:
                raise e
            serializer = PatientSerializer(data=data, partial=True)
            if serializer.is_valid():
                obj = serializer.object
                fac = data['facility_registered_from']
                conditions = data['conditions']
                msg = "Patient information was found at  %s" % str(
                    fac.capitalize())
                patient_id = data['id']
                other_conditions_url = raw_url + 'conditions/' + str(
                    patient_id)
                other_conditions, c_msg = _get_other_conditions(
                    other_conditions_url)
Exemplo n.º 3
0
 def get(self, request, identifier, format=None):
     patient = self.get_object(identifier)
     serializer = PatientSerializer(patient)
     return Response(serializer.data)