parameters: (self, request)
return_statement: return json_response(
              subrecord.to_dict(request.user),
              status_code=status.HTTP_201_CREATED
          )
docstring: * Create a subrecord
          * Ping our integration upstream interface
          * Render the created subrecord back to the requester
  
          Raise appropriate errors for:
  
          * Nonexistant episode
          * Unexpected fields being passed in
docstring_summary: * Create a subrecord
          * Ping our integration upstream interface
          * Render the created subrecord back to the requester
docstring_tokens: * Create a subrecord * Ping our integration upstream interface * Render the created subrecord back to the requester
function: def create(self, request):
          """
          * Create a subrecord
          * Ping our integration upstream interface
          * Render the created subrecord back to the requester
  
          Raise appropriate errors for:
  
          * Nonexistant episode
          * Unexpected fields being passed in
          """
          subrecord = self.model()
          try:
              episode = Episode.objects.get(pk=request.data['episode_id'])
          except Episode.DoesNotExist:
              return json_response(
                  'Nonexistant episode', status_code=status.HTTP_400_BAD_REQUEST
              )
  
          if isinstance(subrecord, PatientSubrecord):
              del request.data['episode_id']
              patient_id = episode.patient.pk
              request.data['patient_id'] = patient_id
  
          subrecord.update_from_dict(request.data, request.user)
  
          return json_response(
              subrecord.to_dict(request.user),
              status_code=status.HTTP_201_CREATED
          )
function_tokens: def create ( self , request ) : subrecord = self . model ( ) try : episode = Episode . objects . get ( pk = request . data [ 'episode_id' ] ) except Episode . DoesNotExist : return json_response ( 'Nonexistant episode' , status_code = status . HTTP_400_BAD_REQUEST ) if isinstance ( subrecord , PatientSubrecord ) : del request . data [ 'episode_id' ] patient_id = episode . patient . pk request . data [ 'patient_id' ] = patient_id subrecord . update_from_dict ( request . data , request . user ) return json_response ( subrecord . to_dict ( request . user ) , status_code = status . HTTP_201_CREATED )