def post(self, medical_id):
        """
        复制病历
        :param medical_id:
        :return:
        """
        name = request.jsondata.get("name")
        rank = request.jsondata.get("rank")
        new_medical = MedicalTemplate()
        new_medical.set("name", name)
        new_medical.set("rank", rank)
        new_medical.set("show", False)
        new_medical.set("is_delete", False)
        new_medical.save()

        medical = Query(MedicalTemplate).get(medical_id)
        medical_processes = Query(MedicalProcess).equal_to("parent", medical).equal_to("is_delete", False).find()
        for medical_process in medical_processes:
            new_medical_process = MedicalProcess()
            new_medical_process.set("parent", new_medical)
            new_medical_process.set("is_delete", False)
            new_medical_process.set("name", medical_process.get("name"))
            new_medical_process.set("sort", medical_process.get("sort"))
            new_medical_process.set("icon_url", medical_process.get("icon_url"))
            new_medical_process.save()
            process_cards = Query(ProcessCard).equal_to("parent", medical_process).equal_to("is_delete", False).find()
            for process_card in process_cards:
                new_process_card = ProcessCard()
                new_process_card.set("parent", new_medical_process)
                new_process_card.set("is_delete", False)
                new_process_card.set("name", process_card.get("name"))
                new_process_card.set("card_can_loop", process_card.get("card_can_loop"))
                new_process_card.set("sort", process_card.get("sort"))
                new_process_card.save()
                card_items = Query(CardItem).equal_to("parent", process_card).equal_to("is_delete", False).find()
                for card_item in card_items:
                    new_card_item = CardItem()
                    new_card_item.set("parent", new_process_card)
                    new_card_item.set("is_delete", False)
                    new_card_item.set("item_before_input", card_item.get("item_before_input"))
                    new_card_item.set("item_after_input", card_item.get("item_after_input"))
                    new_card_item.set("item_choice_label", card_item.get("item_choice_label"))
                    new_card_item.set("item_is_must", card_item.get("item_is_must"))
                    new_card_item.set("item_prompt", card_item.get("item_prompt"))
                    new_card_item.set("item_title", card_item.get("item_title"))
                    new_card_item.set("item_type", card_item.get("item_type"))
                    new_card_item.set("name", card_item.get("name"))
                    new_card_item.set("sort", card_item.get("sort"))
                    new_card_item.save()
        return new_medical
 def post(self):
     name = request.jsondata.get('name')
     rank = request.jsondata.get('rank')
     category = request.jsondata.get('category')
     medical = MedicalTemplate()
     medical.set("name", name)
     medical.set("rank", rank)
     medical.set('is_delete', False)
     medical.set('show', False)
     medical.set("category", category)
     medical.save()
     return medical